processor.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /* SPARC Processor specifics
  2. * taken from the SPARC port of Linux (ptrace.h).
  3. *
  4. * (C) Copyright 2007
  5. * Daniel Hellstrom, Gaisler Research, daniel@gaisler.com.
  6. *
  7. * SPDX-License-Identifier: GPL-2.0+
  8. */
  9. #ifndef __ASM_SPARC_PROCESSOR_H
  10. #define __ASM_SPARC_PROCESSOR_H
  11. #include <asm/arch/asi.h>
  12. #ifdef CONFIG_LEON
  13. /* All LEON processors supported */
  14. #include <asm/leon.h>
  15. #else
  16. /* other processors */
  17. #error Unknown SPARC Processor
  18. #endif
  19. #ifndef __ASSEMBLY__
  20. /* flush data cache */
  21. static __inline__ void sparc_dcache_flush_all(void)
  22. {
  23. __asm__ __volatile__("sta %%g0, [%%g0] %0\n\t"::"i"(ASI_DFLUSH):"memory");
  24. }
  25. /* flush instruction cache */
  26. static __inline__ void sparc_icache_flush_all(void)
  27. {
  28. __asm__ __volatile__("sta %%g0, [%%g0] %0\n\t"::"i"(ASI_IFLUSH):"memory");
  29. }
  30. /* do a cache miss load */
  31. static __inline__ unsigned long long sparc_load_reg_cachemiss_qword(unsigned
  32. long paddr)
  33. {
  34. unsigned long long retval;
  35. __asm__ __volatile__("ldda [%1] %2, %0\n\t":
  36. "=r"(retval):"r"(paddr), "i"(ASI_CACHEMISS));
  37. return retval;
  38. }
  39. static __inline__ unsigned long sparc_load_reg_cachemiss(unsigned long paddr)
  40. {
  41. unsigned long retval;
  42. __asm__ __volatile__("lda [%1] %2, %0\n\t":
  43. "=r"(retval):"r"(paddr), "i"(ASI_CACHEMISS));
  44. return retval;
  45. }
  46. static __inline__ unsigned short sparc_load_reg_cachemiss_word(unsigned long
  47. paddr)
  48. {
  49. unsigned short retval;
  50. __asm__ __volatile__("lduha [%1] %2, %0\n\t":
  51. "=r"(retval):"r"(paddr), "i"(ASI_CACHEMISS));
  52. return retval;
  53. }
  54. static __inline__ unsigned char sparc_load_reg_cachemiss_byte(unsigned long
  55. paddr)
  56. {
  57. unsigned char retval;
  58. __asm__ __volatile__("lduba [%1] %2, %0\n\t":
  59. "=r"(retval):"r"(paddr), "i"(ASI_CACHEMISS));
  60. return retval;
  61. }
  62. /* do a physical address bypass write, i.e. for 0x80000000 */
  63. static __inline__ void sparc_store_reg_bypass(unsigned long paddr,
  64. unsigned long value)
  65. {
  66. __asm__ __volatile__("sta %0, [%1] %2\n\t"::"r"(value), "r"(paddr),
  67. "i"(ASI_BYPASS):"memory");
  68. }
  69. static __inline__ unsigned long sparc_load_reg_bypass(unsigned long paddr)
  70. {
  71. unsigned long retval;
  72. __asm__ __volatile__("lda [%1] %2, %0\n\t":
  73. "=r"(retval):"r"(paddr), "i"(ASI_BYPASS));
  74. return retval;
  75. }
  76. /* Macros for bypassing cache when reading */
  77. #define SPARC_NOCACHE_READ_DWORD(address) sparc_load_reg_cachemiss_qword((unsigned int)(address))
  78. #define SPARC_NOCACHE_READ(address) sparc_load_reg_cachemiss((unsigned int)(address))
  79. #define SPARC_NOCACHE_READ_HWORD(address) sparc_load_reg_cachemiss_word((unsigned int)(address))
  80. #define SPARC_NOCACHE_READ_BYTE(address) sparc_load_reg_cachemiss_byte((unsigned int)(address))
  81. #define SPARC_BYPASS_READ(address) sparc_load_reg_bypass((unsigned int)(address))
  82. #define SPARC_BYPASS_WRITE(address,value) sparc_store_reg_bypass((unsigned int)(address),(unsigned int)(value))
  83. #endif
  84. #endif /* __ASM_SPARC_PROCESSOR_H */