processor.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  20. * MA 02111-1307 USA
  21. *
  22. */
  23. #ifndef __ASM_SPARC_PROCESSOR_H
  24. #define __ASM_SPARC_PROCESSOR_H
  25. #include <asm/arch/asi.h>
  26. #ifdef CONFIG_LEON
  27. /* All LEON processors supported */
  28. #include <asm/leon.h>
  29. #else
  30. /* other processors */
  31. #error Unknown SPARC Processor
  32. #endif
  33. #ifndef __ASSEMBLY__
  34. /* flush data cache */
  35. static __inline__ void sparc_dcache_flush_all(void)
  36. {
  37. __asm__ __volatile__("sta %%g0, [%%g0] %0\n\t"::"i"(ASI_DFLUSH):"memory");
  38. }
  39. /* flush instruction cache */
  40. static __inline__ void sparc_icache_flush_all(void)
  41. {
  42. __asm__ __volatile__("sta %%g0, [%%g0] %0\n\t"::"i"(ASI_IFLUSH):"memory");
  43. }
  44. /* do a cache miss load */
  45. static __inline__ unsigned long long sparc_load_reg_cachemiss_qword(unsigned
  46. long paddr)
  47. {
  48. unsigned long long retval;
  49. __asm__ __volatile__("ldda [%1] %2, %0\n\t":
  50. "=r"(retval):"r"(paddr), "i"(ASI_CACHEMISS));
  51. return retval;
  52. }
  53. static __inline__ unsigned long sparc_load_reg_cachemiss(unsigned long paddr)
  54. {
  55. unsigned long retval;
  56. __asm__ __volatile__("lda [%1] %2, %0\n\t":
  57. "=r"(retval):"r"(paddr), "i"(ASI_CACHEMISS));
  58. return retval;
  59. }
  60. static __inline__ unsigned short sparc_load_reg_cachemiss_word(unsigned long
  61. paddr)
  62. {
  63. unsigned short retval;
  64. __asm__ __volatile__("lduha [%1] %2, %0\n\t":
  65. "=r"(retval):"r"(paddr), "i"(ASI_CACHEMISS));
  66. return retval;
  67. }
  68. static __inline__ unsigned char sparc_load_reg_cachemiss_byte(unsigned long
  69. paddr)
  70. {
  71. unsigned char retval;
  72. __asm__ __volatile__("lduba [%1] %2, %0\n\t":
  73. "=r"(retval):"r"(paddr), "i"(ASI_CACHEMISS));
  74. return retval;
  75. }
  76. /* do a physical address bypass write, i.e. for 0x80000000 */
  77. static __inline__ void sparc_store_reg_bypass(unsigned long paddr,
  78. unsigned long value)
  79. {
  80. __asm__ __volatile__("sta %0, [%1] %2\n\t"::"r"(value), "r"(paddr),
  81. "i"(ASI_BYPASS):"memory");
  82. }
  83. static __inline__ unsigned long sparc_load_reg_bypass(unsigned long paddr)
  84. {
  85. unsigned long retval;
  86. __asm__ __volatile__("lda [%1] %2, %0\n\t":
  87. "=r"(retval):"r"(paddr), "i"(ASI_BYPASS));
  88. return retval;
  89. }
  90. /* Macros for bypassing cache when reading */
  91. #define SPARC_NOCACHE_READ_DWORD(address) sparc_load_reg_cachemiss_qword((unsigned int)(address))
  92. #define SPARC_NOCACHE_READ(address) sparc_load_reg_cachemiss((unsigned int)(address))
  93. #define SPARC_NOCACHE_READ_HWORD(address) sparc_load_reg_cachemiss_word((unsigned int)(address))
  94. #define SPARC_NOCACHE_READ_BYTE(address) sparc_load_reg_cachemiss_byte((unsigned int)(address))
  95. #define SPARC_BYPASS_READ(address) sparc_load_reg_bypass((unsigned int)(address))
  96. #define SPARC_BYPASS_WRITE(address,value) sparc_store_reg_bypass((unsigned int)(address),(unsigned int)(value))
  97. #endif
  98. #endif /* __ASM_SPARC_PROCESSOR_H */