processor.h 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747
  1. #ifndef __ASM_PPC_PROCESSOR_H
  2. #define __ASM_PPC_PROCESSOR_H
  3. /*
  4. * Default implementation of macro that returns current
  5. * instruction pointer ("program counter").
  6. */
  7. #define current_text_addr() ({ __label__ _l; _l: &&_l;})
  8. #include <linux/config.h>
  9. #include <asm/ptrace.h>
  10. #include <asm/types.h>
  11. /* Machine State Register (MSR) Fields */
  12. #ifdef CONFIG_PPC64BRIDGE
  13. #define MSR_SF (1<<63)
  14. #define MSR_ISF (1<<61)
  15. #endif /* CONFIG_PPC64BRIDGE */
  16. #define MSR_VEC (1<<25) /* Enable AltiVec */
  17. #define MSR_POW (1<<18) /* Enable Power Management */
  18. #define MSR_WE (1<<18) /* Wait State Enable */
  19. #define MSR_TGPR (1<<17) /* TLB Update registers in use */
  20. #define MSR_CE (1<<17) /* Critical Interrupt Enable */
  21. #define MSR_ILE (1<<16) /* Interrupt Little Endian */
  22. #define MSR_EE (1<<15) /* External Interrupt Enable */
  23. #define MSR_PR (1<<14) /* Problem State / Privilege Level */
  24. #define MSR_FP (1<<13) /* Floating Point enable */
  25. #define MSR_ME (1<<12) /* Machine Check Enable */
  26. #define MSR_FE0 (1<<11) /* Floating Exception mode 0 */
  27. #define MSR_SE (1<<10) /* Single Step */
  28. #define MSR_BE (1<<9) /* Branch Trace */
  29. #define MSR_DE (1<<9) /* Debug Exception Enable */
  30. #define MSR_FE1 (1<<8) /* Floating Exception mode 1 */
  31. #define MSR_IP (1<<6) /* Exception prefix 0x000/0xFFF */
  32. #define MSR_IR (1<<5) /* Instruction Relocate */
  33. #define MSR_DR (1<<4) /* Data Relocate */
  34. #define MSR_PE (1<<3) /* Protection Enable */
  35. #define MSR_PX (1<<2) /* Protection Exclusive Mode */
  36. #define MSR_RI (1<<1) /* Recoverable Exception */
  37. #define MSR_LE (1<<0) /* Little Endian */
  38. #ifdef CONFIG_APUS_FAST_EXCEPT
  39. #define MSR_ MSR_ME|MSR_IP|MSR_RI
  40. #else
  41. #define MSR_ MSR_ME|MSR_RI
  42. #endif
  43. #define MSR_KERNEL MSR_|MSR_IR|MSR_DR
  44. #define MSR_USER MSR_KERNEL|MSR_PR|MSR_EE
  45. /* Floating Point Status and Control Register (FPSCR) Fields */
  46. #define FPSCR_FX 0x80000000 /* FPU exception summary */
  47. #define FPSCR_FEX 0x40000000 /* FPU enabled exception summary */
  48. #define FPSCR_VX 0x20000000 /* Invalid operation summary */
  49. #define FPSCR_OX 0x10000000 /* Overflow exception summary */
  50. #define FPSCR_UX 0x08000000 /* Underflow exception summary */
  51. #define FPSCR_ZX 0x04000000 /* Zero-devide exception summary */
  52. #define FPSCR_XX 0x02000000 /* Inexact exception summary */
  53. #define FPSCR_VXSNAN 0x01000000 /* Invalid op for SNaN */
  54. #define FPSCR_VXISI 0x00800000 /* Invalid op for Inv - Inv */
  55. #define FPSCR_VXIDI 0x00400000 /* Invalid op for Inv / Inv */
  56. #define FPSCR_VXZDZ 0x00200000 /* Invalid op for Zero / Zero */
  57. #define FPSCR_VXIMZ 0x00100000 /* Invalid op for Inv * Zero */
  58. #define FPSCR_VXVC 0x00080000 /* Invalid op for Compare */
  59. #define FPSCR_FR 0x00040000 /* Fraction rounded */
  60. #define FPSCR_FI 0x00020000 /* Fraction inexact */
  61. #define FPSCR_FPRF 0x0001f000 /* FPU Result Flags */
  62. #define FPSCR_FPCC 0x0000f000 /* FPU Condition Codes */
  63. #define FPSCR_VXSOFT 0x00000400 /* Invalid op for software request */
  64. #define FPSCR_VXSQRT 0x00000200 /* Invalid op for square root */
  65. #define FPSCR_VXCVI 0x00000100 /* Invalid op for integer convert */
  66. #define FPSCR_VE 0x00000080 /* Invalid op exception enable */
  67. #define FPSCR_OE 0x00000040 /* IEEE overflow exception enable */
  68. #define FPSCR_UE 0x00000020 /* IEEE underflow exception enable */
  69. #define FPSCR_ZE 0x00000010 /* IEEE zero divide exception enable */
  70. #define FPSCR_XE 0x00000008 /* FP inexact exception enable */
  71. #define FPSCR_NI 0x00000004 /* FPU non IEEE-Mode */
  72. #define FPSCR_RN 0x00000003 /* FPU rounding control */
  73. /* Special Purpose Registers (SPRNs)*/
  74. #define SPRN_CDBCR 0x3D7 /* Cache Debug Control Register */
  75. #define SPRN_CTR 0x009 /* Count Register */
  76. #define SPRN_DABR 0x3F5 /* Data Address Breakpoint Register */
  77. #define SPRN_DAC1 0x3F6 /* Data Address Compare 1 */
  78. #define SPRN_DAC2 0x3F7 /* Data Address Compare 2 */
  79. #define SPRN_DAR 0x013 /* Data Address Register */
  80. #define SPRN_DBAT0L 0x219 /* Data BAT 0 Lower Register */
  81. #define SPRN_DBAT0U 0x218 /* Data BAT 0 Upper Register */
  82. #define SPRN_DBAT1L 0x21B /* Data BAT 1 Lower Register */
  83. #define SPRN_DBAT1U 0x21A /* Data BAT 1 Upper Register */
  84. #define SPRN_DBAT2L 0x21D /* Data BAT 2 Lower Register */
  85. #define SPRN_DBAT2U 0x21C /* Data BAT 2 Upper Register */
  86. #define SPRN_DBAT3L 0x21F /* Data BAT 3 Lower Register */
  87. #define SPRN_DBAT3U 0x21E /* Data BAT 3 Upper Register */
  88. #define SPRN_DBCR 0x3F2 /* Debug Control Regsiter */
  89. #define DBCR_EDM 0x80000000
  90. #define DBCR_IDM 0x40000000
  91. #define DBCR_RST(x) (((x) & 0x3) << 28)
  92. #define DBCR_RST_NONE 0
  93. #define DBCR_RST_CORE 1
  94. #define DBCR_RST_CHIP 2
  95. #define DBCR_RST_SYSTEM 3
  96. #define DBCR_IC 0x08000000 /* Instruction Completion Debug Evnt */
  97. #define DBCR_BT 0x04000000 /* Branch Taken Debug Event */
  98. #define DBCR_EDE 0x02000000 /* Exception Debug Event */
  99. #define DBCR_TDE 0x01000000 /* TRAP Debug Event */
  100. #define DBCR_FER 0x00F80000 /* First Events Remaining Mask */
  101. #define DBCR_FT 0x00040000 /* Freeze Timers on Debug Event */
  102. #define DBCR_IA1 0x00020000 /* Instr. Addr. Compare 1 Enable */
  103. #define DBCR_IA2 0x00010000 /* Instr. Addr. Compare 2 Enable */
  104. #define DBCR_D1R 0x00008000 /* Data Addr. Compare 1 Read Enable */
  105. #define DBCR_D1W 0x00004000 /* Data Addr. Compare 1 Write Enable */
  106. #define DBCR_D1S(x) (((x) & 0x3) << 12) /* Data Adrr. Compare 1 Size */
  107. #define DAC_BYTE 0
  108. #define DAC_HALF 1
  109. #define DAC_WORD 2
  110. #define DAC_QUAD 3
  111. #define DBCR_D2R 0x00000800 /* Data Addr. Compare 2 Read Enable */
  112. #define DBCR_D2W 0x00000400 /* Data Addr. Compare 2 Write Enable */
  113. #define DBCR_D2S(x) (((x) & 0x3) << 8) /* Data Addr. Compare 2 Size */
  114. #define DBCR_SBT 0x00000040 /* Second Branch Taken Debug Event */
  115. #define DBCR_SED 0x00000020 /* Second Exception Debug Event */
  116. #define DBCR_STD 0x00000010 /* Second Trap Debug Event */
  117. #define DBCR_SIA 0x00000008 /* Second IAC Enable */
  118. #define DBCR_SDA 0x00000004 /* Second DAC Enable */
  119. #define DBCR_JOI 0x00000002 /* JTAG Serial Outbound Int. Enable */
  120. #define DBCR_JII 0x00000001 /* JTAG Serial Inbound Int. Enable */
  121. #define SPRN_DBCR0 0x3F2 /* Debug Control Register 0 */
  122. #define SPRN_DBCR1 0x3BD /* Debug Control Register 1 */
  123. #define SPRN_DBSR 0x3F0 /* Debug Status Register */
  124. #define SPRN_DCCR 0x3FA /* Data Cache Cacheability Register */
  125. #define DCCR_NOCACHE 0 /* Noncacheable */
  126. #define DCCR_CACHE 1 /* Cacheable */
  127. #define SPRN_DCMP 0x3D1 /* Data TLB Compare Register */
  128. #define SPRN_DCWR 0x3BA /* Data Cache Write-thru Register */
  129. #define DCWR_COPY 0 /* Copy-back */
  130. #define DCWR_WRITE 1 /* Write-through */
  131. #define SPRN_DEAR 0x3D5 /* Data Error Address Register */
  132. #define SPRN_DEC 0x016 /* Decrement Register */
  133. #define SPRN_DMISS 0x3D0 /* Data TLB Miss Register */
  134. #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
  135. #define SPRN_EAR 0x11A /* External Address Register */
  136. #define SPRN_ESR 0x3D4 /* Exception Syndrome Register */
  137. #define ESR_IMCP 0x80000000 /* Instr. Machine Check - Protection */
  138. #define ESR_IMCN 0x40000000 /* Instr. Machine Check - Non-config */
  139. #define ESR_IMCB 0x20000000 /* Instr. Machine Check - Bus error */
  140. #define ESR_IMCT 0x10000000 /* Instr. Machine Check - Timeout */
  141. #define ESR_PIL 0x08000000 /* Program Exception - Illegal */
  142. #define ESR_PPR 0x04000000 /* Program Exception - Priveleged */
  143. #define ESR_PTR 0x02000000 /* Program Exception - Trap */
  144. #define ESR_DST 0x00800000 /* Storage Exception - Data miss */
  145. #define ESR_DIZ 0x00400000 /* Storage Exception - Zone fault */
  146. #define SPRN_EVPR 0x3D6 /* Exception Vector Prefix Register */
  147. #define SPRN_HASH1 0x3D2 /* Primary Hash Address Register */
  148. #define SPRN_HASH2 0x3D3 /* Secondary Hash Address Resgister */
  149. #define SPRN_HID0 0x3F0 /* Hardware Implementation Register 0 */
  150. #define HID0_EMCP (1<<31) /* Enable Machine Check pin */
  151. #define HID0_EBA (1<<29) /* Enable Bus Address Parity */
  152. #define HID0_EBD (1<<28) /* Enable Bus Data Parity */
  153. #define HID0_SBCLK (1<<27)
  154. #define HID0_EICE (1<<26)
  155. #define HID0_ECLK (1<<25)
  156. #define HID0_PAR (1<<24)
  157. #define HID0_DOZE (1<<23)
  158. #define HID0_NAP (1<<22)
  159. #define HID0_SLEEP (1<<21)
  160. #define HID0_DPM (1<<20)
  161. #define HID0_ICE (1<<15) /* Instruction Cache Enable */
  162. #define HID0_DCE (1<<14) /* Data Cache Enable */
  163. #define HID0_ILOCK (1<<13) /* Instruction Cache Lock */
  164. #define HID0_DLOCK (1<<12) /* Data Cache Lock */
  165. #define HID0_ICFI (1<<11) /* Instr. Cache Flash Invalidate */
  166. #define HID0_DCFI (1<<10) /* Data Cache Flash Invalidate */
  167. #define HID0_DCI HID0_DCFI
  168. #define HID0_SPD (1<<9) /* Speculative disable */
  169. #define HID0_SGE (1<<7) /* Store Gathering Enable */
  170. #define HID0_SIED HID_SGE /* Serial Instr. Execution [Disable] */
  171. #define HID0_DCFA (1<<6) /* Data Cache Flush Assist */
  172. #define HID0_BTIC (1<<5) /* Branch Target Instruction Cache Enable */
  173. #define HID0_ABE (1<<3) /* Address Broadcast Enable */
  174. #define HID0_BHTE (1<<2) /* Branch History Table Enable */
  175. #define HID0_BTCD (1<<1) /* Branch target cache disable */
  176. #define SPRN_HID1 0x3F1 /* Hardware Implementation Register 1 */
  177. #define SPRN_IABR 0x3F2 /* Instruction Address Breakpoint Register */
  178. #define SPRN_IAC1 0x3F4 /* Instruction Address Compare 1 */
  179. #define SPRN_IAC2 0x3F5 /* Instruction Address Compare 2 */
  180. #define SPRN_IBAT0L 0x211 /* Instruction BAT 0 Lower Register */
  181. #define SPRN_IBAT0U 0x210 /* Instruction BAT 0 Upper Register */
  182. #define SPRN_IBAT1L 0x213 /* Instruction BAT 1 Lower Register */
  183. #define SPRN_IBAT1U 0x212 /* Instruction BAT 1 Upper Register */
  184. #define SPRN_IBAT2L 0x215 /* Instruction BAT 2 Lower Register */
  185. #define SPRN_IBAT2U 0x214 /* Instruction BAT 2 Upper Register */
  186. #define SPRN_IBAT3L 0x217 /* Instruction BAT 3 Lower Register */
  187. #define SPRN_IBAT3U 0x216 /* Instruction BAT 3 Upper Register */
  188. #define SPRN_ICCR 0x3FB /* Instruction Cache Cacheability Register */
  189. #define ICCR_NOCACHE 0 /* Noncacheable */
  190. #define ICCR_CACHE 1 /* Cacheable */
  191. #define SPRN_ICDBDR 0x3D3 /* Instruction Cache Debug Data Register */
  192. #define SPRN_ICMP 0x3D5 /* Instruction TLB Compare Register */
  193. #define SPRN_ICTC 0x3FB /* Instruction Cache Throttling Control Reg */
  194. #define SPRN_IMISS 0x3D4 /* Instruction TLB Miss Register */
  195. #define SPRN_IMMR 0x27E /* Internal Memory Map Register */
  196. #define SPRN_L2CR 0x3F9 /* Level 2 Cache Control Regsiter */
  197. #define SPRN_LR 0x008 /* Link Register */
  198. #define SPRN_MMCR0 0x3B8 /* Monitor Mode Control Register 0 */
  199. #define SPRN_MMCR1 0x3BC /* Monitor Mode Control Register 1 */
  200. #define SPRN_PBL1 0x3FC /* Protection Bound Lower 1 */
  201. #define SPRN_PBL2 0x3FE /* Protection Bound Lower 2 */
  202. #define SPRN_PBU1 0x3FD /* Protection Bound Upper 1 */
  203. #define SPRN_PBU2 0x3FF /* Protection Bound Upper 2 */
  204. #define SPRN_PID 0x3B1 /* Process ID */
  205. #define SPRN_PIR 0x3FF /* Processor Identification Register */
  206. #define SPRN_PIT 0x3DB /* Programmable Interval Timer */
  207. #define SPRN_PMC1 0x3B9 /* Performance Counter Register 1 */
  208. #define SPRN_PMC2 0x3BA /* Performance Counter Register 2 */
  209. #define SPRN_PMC3 0x3BD /* Performance Counter Register 3 */
  210. #define SPRN_PMC4 0x3BE /* Performance Counter Register 4 */
  211. #define SPRN_PVR 0x11F /* Processor Version Register */
  212. #define SPRN_RPA 0x3D6 /* Required Physical Address Register */
  213. #define SPRN_SDA 0x3BF /* Sampled Data Address Register */
  214. #define SPRN_SDR1 0x019 /* MMU Hash Base Register */
  215. #define SPRN_SGR 0x3B9 /* Storage Guarded Register */
  216. #define SGR_NORMAL 0
  217. #define SGR_GUARDED 1
  218. #define SPRN_SIA 0x3BB /* Sampled Instruction Address Register */
  219. #define SPRN_SPRG0 0x110 /* Special Purpose Register General 0 */
  220. #define SPRN_SPRG1 0x111 /* Special Purpose Register General 1 */
  221. #define SPRN_SPRG2 0x112 /* Special Purpose Register General 2 */
  222. #define SPRN_SPRG3 0x113 /* Special Purpose Register General 3 */
  223. #define SPRN_SRR0 0x01A /* Save/Restore Register 0 */
  224. #define SPRN_SRR1 0x01B /* Save/Restore Register 1 */
  225. #define SPRN_SRR2 0x3DE /* Save/Restore Register 2 */
  226. #define SPRN_SRR3 0x3DF /* Save/Restore Register 3 */
  227. #define SPRN_TBHI 0x3DC /* Time Base High */
  228. #define SPRN_TBHU 0x3CC /* Time Base High User-mode */
  229. #define SPRN_TBLO 0x3DD /* Time Base Low */
  230. #define SPRN_TBLU 0x3CD /* Time Base Low User-mode */
  231. #define SPRN_TBRL 0x10D /* Time Base Read Lower Register */
  232. #define SPRN_TBRU 0x10C /* Time Base Read Upper Register */
  233. #define SPRN_TBWL 0x11D /* Time Base Write Lower Register */
  234. #define SPRN_TBWU 0x11C /* Time Base Write Upper Register */
  235. #define SPRN_TCR 0x3DA /* Timer Control Register */
  236. #define TCR_WP(x) (((x)&0x3)<<30) /* WDT Period */
  237. #define WP_2_17 0 /* 2^17 clocks */
  238. #define WP_2_21 1 /* 2^21 clocks */
  239. #define WP_2_25 2 /* 2^25 clocks */
  240. #define WP_2_29 3 /* 2^29 clocks */
  241. #define TCR_WRC(x) (((x)&0x3)<<28) /* WDT Reset Control */
  242. #define WRC_NONE 0 /* No reset will occur */
  243. #define WRC_CORE 1 /* Core reset will occur */
  244. #define WRC_CHIP 2 /* Chip reset will occur */
  245. #define WRC_SYSTEM 3 /* System reset will occur */
  246. #define TCR_WIE 0x08000000 /* WDT Interrupt Enable */
  247. #define TCR_PIE 0x04000000 /* PIT Interrupt Enable */
  248. #define TCR_FP(x) (((x)&0x3)<<24) /* FIT Period */
  249. #define FP_2_9 0 /* 2^9 clocks */
  250. #define FP_2_13 1 /* 2^13 clocks */
  251. #define FP_2_17 2 /* 2^17 clocks */
  252. #define FP_2_21 3 /* 2^21 clocks */
  253. #define TCR_FIE 0x00800000 /* FIT Interrupt Enable */
  254. #define TCR_ARE 0x00400000 /* Auto Reload Enable */
  255. #define SPRN_THRM1 0x3FC /* Thermal Management Register 1 */
  256. #define THRM1_TIN (1<<0)
  257. #define THRM1_TIV (1<<1)
  258. #define THRM1_THRES (0x7f<<2)
  259. #define THRM1_TID (1<<29)
  260. #define THRM1_TIE (1<<30)
  261. #define THRM1_V (1<<31)
  262. #define SPRN_THRM2 0x3FD /* Thermal Management Register 2 */
  263. #define SPRN_THRM3 0x3FE /* Thermal Management Register 3 */
  264. #define THRM3_E (1<<31)
  265. #define SPRN_TSR 0x3D8 /* Timer Status Register */
  266. #define TSR_ENW 0x80000000 /* Enable Next Watchdog */
  267. #define TSR_WIS 0x40000000 /* WDT Interrupt Status */
  268. #define TSR_WRS(x) (((x)&0x3)<<28) /* WDT Reset Status */
  269. #define WRS_NONE 0 /* No WDT reset occurred */
  270. #define WRS_CORE 1 /* WDT forced core reset */
  271. #define WRS_CHIP 2 /* WDT forced chip reset */
  272. #define WRS_SYSTEM 3 /* WDT forced system reset */
  273. #define TSR_PIS 0x08000000 /* PIT Interrupt Status */
  274. #define TSR_FIS 0x04000000 /* FIT Interrupt Status */
  275. #define SPRN_UMMCR0 0x3A8 /* User Monitor Mode Control Register 0 */
  276. #define SPRN_UMMCR1 0x3AC /* User Monitor Mode Control Register 0 */
  277. #define SPRN_UPMC1 0x3A9 /* User Performance Counter Register 1 */
  278. #define SPRN_UPMC2 0x3AA /* User Performance Counter Register 2 */
  279. #define SPRN_UPMC3 0x3AD /* User Performance Counter Register 3 */
  280. #define SPRN_UPMC4 0x3AE /* User Performance Counter Register 4 */
  281. #define SPRN_USIA 0x3AB /* User Sampled Instruction Address Register */
  282. #define SPRN_XER 0x001 /* Fixed Point Exception Register */
  283. #define SPRN_ZPR 0x3B0 /* Zone Protection Register */
  284. /* Short-hand versions for a number of the above SPRNs */
  285. #define CTR SPRN_CTR /* Counter Register */
  286. #define DAR SPRN_DAR /* Data Address Register */
  287. #define DABR SPRN_DABR /* Data Address Breakpoint Register */
  288. #define DBAT0L SPRN_DBAT0L /* Data BAT 0 Lower Register */
  289. #define DBAT0U SPRN_DBAT0U /* Data BAT 0 Upper Register */
  290. #define DBAT1L SPRN_DBAT1L /* Data BAT 1 Lower Register */
  291. #define DBAT1U SPRN_DBAT1U /* Data BAT 1 Upper Register */
  292. #define DBAT2L SPRN_DBAT2L /* Data BAT 2 Lower Register */
  293. #define DBAT2U SPRN_DBAT2U /* Data BAT 2 Upper Register */
  294. #define DBAT3L SPRN_DBAT3L /* Data BAT 3 Lower Register */
  295. #define DBAT3U SPRN_DBAT3U /* Data BAT 3 Upper Register */
  296. #define DCMP SPRN_DCMP /* Data TLB Compare Register */
  297. #define DEC SPRN_DEC /* Decrement Register */
  298. #define DMISS SPRN_DMISS /* Data TLB Miss Register */
  299. #define DSISR SPRN_DSISR /* Data Storage Interrupt Status Register */
  300. #define EAR SPRN_EAR /* External Address Register */
  301. #define HASH1 SPRN_HASH1 /* Primary Hash Address Register */
  302. #define HASH2 SPRN_HASH2 /* Secondary Hash Address Register */
  303. #define HID0 SPRN_HID0 /* Hardware Implementation Register 0 */
  304. #define HID1 SPRN_HID1 /* Hardware Implementation Register 1 */
  305. #define IABR SPRN_IABR /* Instruction Address Breakpoint Register */
  306. #define IBAT0L SPRN_IBAT0L /* Instruction BAT 0 Lower Register */
  307. #define IBAT0U SPRN_IBAT0U /* Instruction BAT 0 Upper Register */
  308. #define IBAT1L SPRN_IBAT1L /* Instruction BAT 1 Lower Register */
  309. #define IBAT1U SPRN_IBAT1U /* Instruction BAT 1 Upper Register */
  310. #define IBAT2L SPRN_IBAT2L /* Instruction BAT 2 Lower Register */
  311. #define IBAT2U SPRN_IBAT2U /* Instruction BAT 2 Upper Register */
  312. #define IBAT3L SPRN_IBAT3L /* Instruction BAT 3 Lower Register */
  313. #define IBAT3U SPRN_IBAT3U /* Instruction BAT 3 Upper Register */
  314. #define ICMP SPRN_ICMP /* Instruction TLB Compare Register */
  315. #define IMISS SPRN_IMISS /* Instruction TLB Miss Register */
  316. #define IMMR SPRN_IMMR /* PPC 860/821 Internal Memory Map Register */
  317. #define L2CR SPRN_L2CR /* PPC 750 L2 control register */
  318. #define LR SPRN_LR
  319. #define PVR SPRN_PVR /* Processor Version */
  320. #define RPA SPRN_RPA /* Required Physical Address Register */
  321. #define SDR1 SPRN_SDR1 /* MMU hash base register */
  322. #define SPR0 SPRN_SPRG0 /* Supervisor Private Registers */
  323. #define SPR1 SPRN_SPRG1
  324. #define SPR2 SPRN_SPRG2
  325. #define SPR3 SPRN_SPRG3
  326. #define SPRG0 SPRN_SPRG0
  327. #define SPRG1 SPRN_SPRG1
  328. #define SPRG2 SPRN_SPRG2
  329. #define SPRG3 SPRN_SPRG3
  330. #define SRR0 SPRN_SRR0 /* Save and Restore Register 0 */
  331. #define SRR1 SPRN_SRR1 /* Save and Restore Register 1 */
  332. #define TBRL SPRN_TBRL /* Time Base Read Lower Register */
  333. #define TBRU SPRN_TBRU /* Time Base Read Upper Register */
  334. #define TBWL SPRN_TBWL /* Time Base Write Lower Register */
  335. #define TBWU SPRN_TBWU /* Time Base Write Upper Register */
  336. #define ICTC 1019
  337. #define THRM1 SPRN_THRM1 /* Thermal Management Register 1 */
  338. #define THRM2 SPRN_THRM2 /* Thermal Management Register 2 */
  339. #define THRM3 SPRN_THRM3 /* Thermal Management Register 3 */
  340. #define XER SPRN_XER
  341. /* Device Control Registers */
  342. #define DCRN_BEAR 0x090 /* Bus Error Address Register */
  343. #define DCRN_BESR 0x091 /* Bus Error Syndrome Register */
  344. #define BESR_DSES 0x80000000 /* Data-Side Error Status */
  345. #define BESR_DMES 0x40000000 /* DMA Error Status */
  346. #define BESR_RWS 0x20000000 /* Read/Write Status */
  347. #define BESR_ETMASK 0x1C000000 /* Error Type */
  348. #define ET_PROT 0
  349. #define ET_PARITY 1
  350. #define ET_NCFG 2
  351. #define ET_BUSERR 4
  352. #define ET_BUSTO 6
  353. #define DCRN_DMACC0 0x0C4 /* DMA Chained Count Register 0 */
  354. #define DCRN_DMACC1 0x0CC /* DMA Chained Count Register 1 */
  355. #define DCRN_DMACC2 0x0D4 /* DMA Chained Count Register 2 */
  356. #define DCRN_DMACC3 0x0DC /* DMA Chained Count Register 3 */
  357. #define DCRN_DMACR0 0x0C0 /* DMA Channel Control Register 0 */
  358. #define DCRN_DMACR1 0x0C8 /* DMA Channel Control Register 1 */
  359. #define DCRN_DMACR2 0x0D0 /* DMA Channel Control Register 2 */
  360. #define DCRN_DMACR3 0x0D8 /* DMA Channel Control Register 3 */
  361. #define DCRN_DMACT0 0x0C1 /* DMA Count Register 0 */
  362. #define DCRN_DMACT1 0x0C9 /* DMA Count Register 1 */
  363. #define DCRN_DMACT2 0x0D1 /* DMA Count Register 2 */
  364. #define DCRN_DMACT3 0x0D9 /* DMA Count Register 3 */
  365. #define DCRN_DMADA0 0x0C2 /* DMA Destination Address Register 0 */
  366. #define DCRN_DMADA1 0x0CA /* DMA Destination Address Register 1 */
  367. #define DCRN_DMADA2 0x0D2 /* DMA Destination Address Register 2 */
  368. #define DCRN_DMADA3 0x0DA /* DMA Destination Address Register 3 */
  369. #define DCRN_DMASA0 0x0C3 /* DMA Source Address Register 0 */
  370. #define DCRN_DMASA1 0x0CB /* DMA Source Address Register 1 */
  371. #define DCRN_DMASA2 0x0D3 /* DMA Source Address Register 2 */
  372. #define DCRN_DMASA3 0x0DB /* DMA Source Address Register 3 */
  373. #define DCRN_DMASR 0x0E0 /* DMA Status Register */
  374. #define DCRN_EXIER 0x042 /* External Interrupt Enable Register */
  375. #define EXIER_CIE 0x80000000 /* Critical Interrupt Enable */
  376. #define EXIER_SRIE 0x08000000 /* Serial Port Rx Int. Enable */
  377. #define EXIER_STIE 0x04000000 /* Serial Port Tx Int. Enable */
  378. #define EXIER_JRIE 0x02000000 /* JTAG Serial Port Rx Int. Enable */
  379. #define EXIER_JTIE 0x01000000 /* JTAG Serial Port Tx Int. Enable */
  380. #define EXIER_D0IE 0x00800000 /* DMA Channel 0 Interrupt Enable */
  381. #define EXIER_D1IE 0x00400000 /* DMA Channel 1 Interrupt Enable */
  382. #define EXIER_D2IE 0x00200000 /* DMA Channel 2 Interrupt Enable */
  383. #define EXIER_D3IE 0x00100000 /* DMA Channel 3 Interrupt Enable */
  384. #define EXIER_E0IE 0x00000010 /* External Interrupt 0 Enable */
  385. #define EXIER_E1IE 0x00000008 /* External Interrupt 1 Enable */
  386. #define EXIER_E2IE 0x00000004 /* External Interrupt 2 Enable */
  387. #define EXIER_E3IE 0x00000002 /* External Interrupt 3 Enable */
  388. #define EXIER_E4IE 0x00000001 /* External Interrupt 4 Enable */
  389. #define DCRN_EXISR 0x040 /* External Interrupt Status Register */
  390. #define DCRN_IOCR 0x0A0 /* Input/Output Configuration Register */
  391. #define IOCR_E0TE 0x80000000
  392. #define IOCR_E0LP 0x40000000
  393. #define IOCR_E1TE 0x20000000
  394. #define IOCR_E1LP 0x10000000
  395. #define IOCR_E2TE 0x08000000
  396. #define IOCR_E2LP 0x04000000
  397. #define IOCR_E3TE 0x02000000
  398. #define IOCR_E3LP 0x01000000
  399. #define IOCR_E4TE 0x00800000
  400. #define IOCR_E4LP 0x00400000
  401. #define IOCR_EDT 0x00080000
  402. #define IOCR_SOR 0x00040000
  403. #define IOCR_EDO 0x00008000
  404. #define IOCR_2XC 0x00004000
  405. #define IOCR_ATC 0x00002000
  406. #define IOCR_SPD 0x00001000
  407. #define IOCR_BEM 0x00000800
  408. #define IOCR_PTD 0x00000400
  409. #define IOCR_ARE 0x00000080
  410. #define IOCR_DRC 0x00000020
  411. #define IOCR_RDM(x) (((x) & 0x3) << 3)
  412. #define IOCR_TCS 0x00000004
  413. #define IOCR_SCS 0x00000002
  414. #define IOCR_SPC 0x00000001
  415. /* Processor Version Register */
  416. /* Processor Version Register (PVR) field extraction */
  417. #define PVR_VER(pvr) (((pvr) >> 16) & 0xFFFF) /* Version field */
  418. #define PVR_REV(pvr) (((pvr) >> 0) & 0xFFFF) /* Revison field */
  419. /*
  420. * IBM has further subdivided the standard PowerPC 16-bit version and
  421. * revision subfields of the PVR for the PowerPC 403s into the following:
  422. */
  423. #define PVR_FAM(pvr) (((pvr) >> 20) & 0xFFF) /* Family field */
  424. #define PVR_MEM(pvr) (((pvr) >> 16) & 0xF) /* Member field */
  425. #define PVR_CORE(pvr) (((pvr) >> 12) & 0xF) /* Core field */
  426. #define PVR_CFG(pvr) (((pvr) >> 8) & 0xF) /* Configuration field */
  427. #define PVR_MAJ(pvr) (((pvr) >> 4) & 0xF) /* Major revision field */
  428. #define PVR_MIN(pvr) (((pvr) >> 0) & 0xF) /* Minor revision field */
  429. /* Processor Version Numbers */
  430. #define PVR_403GA 0x00200000
  431. #define PVR_403GB 0x00200100
  432. #define PVR_403GC 0x00200200
  433. #define PVR_403GCX 0x00201400
  434. #define PVR_405GP 0x40110000
  435. #define PVR_405GP_RB 0x40110040
  436. #define PVR_405GP_RC 0x40110082
  437. #define PVR_405GP_RD 0x401100C4
  438. #define PVR_405GP_RE 0x40110145 /* same as pc405cr rev c */
  439. #define PVR_405CR_RA 0x40110041
  440. #define PVR_405CR_RB 0x401100C5
  441. #define PVR_405CR_RC 0x40110145 /* same as pc405gp rev e */
  442. #define PVR_405GPR_RB 0x50910951
  443. #define PVR_440GP_RB 0x40120440
  444. #define PVR_440GP_RC 0x40120481
  445. #define PVR_405EP_RB 0x51210950
  446. #define PVR_601 0x00010000
  447. #define PVR_602 0x00050000
  448. #define PVR_603 0x00030000
  449. #define PVR_603e 0x00060000
  450. #define PVR_603ev 0x00070000
  451. #define PVR_603r 0x00071000
  452. #define PVR_604 0x00040000
  453. #define PVR_604e 0x00090000
  454. #define PVR_604r 0x000A0000
  455. #define PVR_620 0x00140000
  456. #define PVR_740 0x00080000
  457. #define PVR_750 PVR_740
  458. #define PVR_740P 0x10080000
  459. #define PVR_750P PVR_740P
  460. /*
  461. * For the 8xx processors, all of them report the same PVR family for
  462. * the PowerPC core. The various versions of these processors must be
  463. * differentiated by the version number in the Communication Processor
  464. * Module (CPM).
  465. */
  466. #define PVR_821 0x00500000
  467. #define PVR_823 PVR_821
  468. #define PVR_850 PVR_821
  469. #define PVR_860 PVR_821
  470. #define PVR_7400 0x000C0000
  471. #define PVR_8240 0x00810100
  472. #define PVR_8260 PVR_8240
  473. /* I am just adding a single entry for 8260 boards. I think we may be
  474. * able to combine mbx, fads, rpxlite, bseip, and classic into a single
  475. * generic 8xx as well. The boards containing these processors are either
  476. * identical at the processor level (due to the high integration) or so
  477. * wildly different that testing _machine at run time is best replaced by
  478. * conditional compilation by board type (found in their respective .h file).
  479. * -- Dan
  480. */
  481. #define _MACH_prep 0x00000001
  482. #define _MACH_Pmac 0x00000002 /* pmac or pmac clone (non-chrp) */
  483. #define _MACH_chrp 0x00000004 /* chrp machine */
  484. #define _MACH_mbx 0x00000008 /* Motorola MBX board */
  485. #define _MACH_apus 0x00000010 /* amiga with phase5 powerup */
  486. #define _MACH_fads 0x00000020 /* Motorola FADS board */
  487. #define _MACH_rpxlite 0x00000040 /* RPCG RPX-Lite 8xx board */
  488. #define _MACH_bseip 0x00000080 /* Bright Star Engineering ip-Engine */
  489. #define _MACH_yk 0x00000100 /* Motorola Yellowknife */
  490. #define _MACH_gemini 0x00000200 /* Synergy Microsystems gemini board */
  491. #define _MACH_classic 0x00000400 /* RPCG RPX-Classic 8xx board */
  492. #define _MACH_oak 0x00000800 /* IBM "Oak" 403 eval. board */
  493. #define _MACH_walnut 0x00001000 /* IBM "Walnut" 405GP eval. board */
  494. #define _MACH_8260 0x00002000 /* Generic 8260 */
  495. #define _MACH_sandpoint 0x00004000 /* Motorola SPS Processor eval board */
  496. #define _MACH_tqm860 0x00008000 /* TQM860/L */
  497. #define _MACH_tqm8xxL 0x00010000 /* TQM8xxL */
  498. /* see residual.h for these */
  499. #define _PREP_Motorola 0x01 /* motorola prep */
  500. #define _PREP_Firm 0x02 /* firmworks prep */
  501. #define _PREP_IBM 0x00 /* ibm prep */
  502. #define _PREP_Bull 0x03 /* bull prep */
  503. #define _PREP_Radstone 0x04 /* Radstone Technology PLC prep */
  504. /*
  505. * Radstone board types
  506. */
  507. #define RS_SYS_TYPE_PPC1 0
  508. #define RS_SYS_TYPE_PPC2 1
  509. #define RS_SYS_TYPE_PPC1a 2
  510. #define RS_SYS_TYPE_PPC2a 3
  511. #define RS_SYS_TYPE_PPC4 4
  512. #define RS_SYS_TYPE_PPC4a 5
  513. #define RS_SYS_TYPE_PPC2ep 6
  514. /* these are arbitrary */
  515. #define _CHRP_Motorola 0x04 /* motorola chrp, the cobra */
  516. #define _CHRP_IBM 0x05 /* IBM chrp, the longtrail and longtrail 2 */
  517. #define _GLOBAL(n)\
  518. .globl n;\
  519. n:
  520. /* Macros for setting and retrieving special purpose registers */
  521. #define stringify(s) tostring(s)
  522. #define tostring(s) #s
  523. #define mfdcr(rn) ({unsigned int rval; \
  524. asm volatile("mfdcr %0," stringify(rn) \
  525. : "=r" (rval)); rval;})
  526. #define mtdcr(rn, v) asm volatile("mtdcr " stringify(rn) ",%0" : : "r" (v))
  527. #define mfmsr() ({unsigned int rval; \
  528. asm volatile("mfmsr %0" : "=r" (rval)); rval;})
  529. #define mtmsr(v) asm volatile("mtmsr %0" : : "r" (v))
  530. #define mfspr(rn) ({unsigned int rval; \
  531. asm volatile("mfspr %0," stringify(rn) \
  532. : "=r" (rval)); rval;})
  533. #define mtspr(rn, v) asm volatile("mtspr " stringify(rn) ",%0" : : "r" (v))
  534. #define tlbie(v) asm volatile("tlbie %0 \n sync" : : "r" (v))
  535. /* Segment Registers */
  536. #define SR0 0
  537. #define SR1 1
  538. #define SR2 2
  539. #define SR3 3
  540. #define SR4 4
  541. #define SR5 5
  542. #define SR6 6
  543. #define SR7 7
  544. #define SR8 8
  545. #define SR9 9
  546. #define SR10 10
  547. #define SR11 11
  548. #define SR12 12
  549. #define SR13 13
  550. #define SR14 14
  551. #define SR15 15
  552. #ifndef __ASSEMBLY__
  553. #ifndef CONFIG_MACH_SPECIFIC
  554. extern int _machine;
  555. extern int have_of;
  556. #endif /* CONFIG_MACH_SPECIFIC */
  557. /* what kind of prep workstation we are */
  558. extern int _prep_type;
  559. /*
  560. * This is used to identify the board type from a given PReP board
  561. * vendor. Board revision is also made available.
  562. */
  563. extern unsigned char ucSystemType;
  564. extern unsigned char ucBoardRev;
  565. extern unsigned char ucBoardRevMaj, ucBoardRevMin;
  566. struct task_struct;
  567. void start_thread(struct pt_regs *regs, unsigned long nip, unsigned long sp);
  568. void release_thread(struct task_struct *);
  569. /*
  570. * Create a new kernel thread.
  571. */
  572. extern long kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
  573. /*
  574. * Bus types
  575. */
  576. #define EISA_bus 0
  577. #define EISA_bus__is_a_macro /* for versions in ksyms.c */
  578. #define MCA_bus 0
  579. #define MCA_bus__is_a_macro /* for versions in ksyms.c */
  580. /* Lazy FPU handling on uni-processor */
  581. extern struct task_struct *last_task_used_math;
  582. extern struct task_struct *last_task_used_altivec;
  583. /*
  584. * this is the minimum allowable io space due to the location
  585. * of the io areas on prep (first one at 0x80000000) but
  586. * as soon as I get around to remapping the io areas with the BATs
  587. * to match the mac we can raise this. -- Cort
  588. */
  589. #define TASK_SIZE (0x80000000UL)
  590. /* This decides where the kernel will search for a free chunk of vm
  591. * space during mmap's.
  592. */
  593. #define TASK_UNMAPPED_BASE (TASK_SIZE / 8 * 3)
  594. typedef struct {
  595. unsigned long seg;
  596. } mm_segment_t;
  597. struct thread_struct {
  598. unsigned long ksp; /* Kernel stack pointer */
  599. unsigned long wchan; /* Event task is sleeping on */
  600. struct pt_regs *regs; /* Pointer to saved register state */
  601. mm_segment_t fs; /* for get_fs() validation */
  602. void *pgdir; /* root of page-table tree */
  603. signed long last_syscall;
  604. double fpr[32]; /* Complete floating point set */
  605. unsigned long fpscr_pad; /* fpr ... fpscr must be contiguous */
  606. unsigned long fpscr; /* Floating point status */
  607. #ifdef CONFIG_ALTIVEC
  608. vector128 vr[32]; /* Complete AltiVec set */
  609. vector128 vscr; /* AltiVec status */
  610. unsigned long vrsave;
  611. #endif /* CONFIG_ALTIVEC */
  612. };
  613. #define INIT_SP (sizeof(init_stack) + (unsigned long) &init_stack)
  614. #define INIT_THREAD { \
  615. INIT_SP, /* ksp */ \
  616. 0, /* wchan */ \
  617. (struct pt_regs *)INIT_SP - 1, /* regs */ \
  618. KERNEL_DS, /*fs*/ \
  619. swapper_pg_dir, /* pgdir */ \
  620. 0, /* last_syscall */ \
  621. {0}, 0, 0 \
  622. }
  623. /*
  624. * Note: the vm_start and vm_end fields here should *not*
  625. * be in kernel space. (Could vm_end == vm_start perhaps?)
  626. */
  627. #define INIT_MMAP { &init_mm, 0, 0x1000, NULL, \
  628. PAGE_SHARED, VM_READ | VM_WRITE | VM_EXEC, \
  629. 1, NULL, NULL }
  630. /*
  631. * Return saved PC of a blocked thread. For now, this is the "user" PC
  632. */
  633. static inline unsigned long thread_saved_pc(struct thread_struct *t)
  634. {
  635. return (t->regs) ? t->regs->nip : 0;
  636. }
  637. #define copy_segments(tsk, mm) do { } while (0)
  638. #define release_segments(mm) do { } while (0)
  639. #define forget_segments() do { } while (0)
  640. unsigned long get_wchan(struct task_struct *p);
  641. #define KSTK_EIP(tsk) ((tsk)->thread.regs->nip)
  642. #define KSTK_ESP(tsk) ((tsk)->thread.regs->gpr[1])
  643. /*
  644. * NOTE! The task struct and the stack go together
  645. */
  646. #define THREAD_SIZE (2*PAGE_SIZE)
  647. #define alloc_task_struct() \
  648. ((struct task_struct *) __get_free_pages(GFP_KERNEL,1))
  649. #define free_task_struct(p) free_pages((unsigned long)(p),1)
  650. #define get_task_struct(tsk) atomic_inc(&mem_map[MAP_NR(tsk)].count)
  651. /* in process.c - for early bootup debug -- Cort */
  652. int ll_printk(const char *, ...);
  653. void ll_puts(const char *);
  654. #define init_task (init_task_union.task)
  655. #define init_stack (init_task_union.stack)
  656. /* In misc.c */
  657. void _nmask_and_or_msr(unsigned long nmask, unsigned long or_val);
  658. #endif /* ndef ASSEMBLY*/
  659. #ifdef CONFIG_MACH_SPECIFIC
  660. #if defined(CONFIG_8xx)
  661. #define _machine _MACH_8xx
  662. #define have_of 0
  663. #elif defined(CONFIG_OAK)
  664. #define _machine _MACH_oak
  665. #define have_of 0
  666. #elif defined(CONFIG_WALNUT)
  667. #define _machine _MACH_walnut
  668. #define have_of 0
  669. #elif defined(CONFIG_APUS)
  670. #define _machine _MACH_apus
  671. #define have_of 0
  672. #elif defined(CONFIG_GEMINI)
  673. #define _machine _MACH_gemini
  674. #define have_of 0
  675. #elif defined(CONFIG_8260)
  676. #define _machine _MACH_8260
  677. #define have_of 0
  678. #elif defined(CONFIG_SANDPOINT)
  679. #define _machine _MACH_sandpoint
  680. #define have_of 0
  681. #else
  682. #error "Machine not defined correctly"
  683. #endif
  684. #endif /* CONFIG_MACH_SPECIFIC */
  685. #endif /* __ASM_PPC_PROCESSOR_H */