dcc.h 981 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /* Copyright (c) 2014-2015 The Linux Foundation. All rights reserved.
  3. *
  4. * A call to __dcc_getchar() or __dcc_putchar() is typically followed by
  5. * a call to __dcc_getstatus(). We want to make sure that the CPU does
  6. * not speculative read the DCC status before executing the read or write
  7. * instruction. That's what the ISBs are for.
  8. *
  9. * The 'volatile' ensures that the compiler does not cache the status bits,
  10. * and instead reads the DCC register every time.
  11. */
  12. #ifndef __ASM_DCC_H
  13. #define __ASM_DCC_H
  14. #include <asm/barrier.h>
  15. #include <asm/sysreg.h>
  16. static inline u32 __dcc_getstatus(void)
  17. {
  18. return read_sysreg(mdccsr_el0);
  19. }
  20. static inline char __dcc_getchar(void)
  21. {
  22. char c = read_sysreg(dbgdtrrx_el0);
  23. isb();
  24. return c;
  25. }
  26. static inline void __dcc_putchar(char c)
  27. {
  28. /*
  29. * The typecast is to make absolutely certain that 'c' is
  30. * zero-extended.
  31. */
  32. write_sysreg((unsigned char)c, dbgdtrtx_el0);
  33. isb();
  34. }
  35. #endif