lpardata.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. /*
  2. * Copyright 2001 Mike Corrigan, IBM Corp
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version
  7. * 2 of the License, or (at your option) any later version.
  8. */
  9. #include <linux/types.h>
  10. #include <linux/threads.h>
  11. #include <linux/module.h>
  12. #include <linux/bitops.h>
  13. #include <asm/processor.h>
  14. #include <asm/ptrace.h>
  15. #include <asm/abs_addr.h>
  16. #include <asm/lppaca.h>
  17. #include <asm/paca.h>
  18. #include <asm/iseries/lpar_map.h>
  19. #include <asm/iseries/it_lp_queue.h>
  20. #include <asm/iseries/alpaca.h>
  21. #include "naca.h"
  22. #include "vpd_areas.h"
  23. #include "spcomm_area.h"
  24. #include "ipl_parms.h"
  25. #include "processor_vpd.h"
  26. #include "release_data.h"
  27. #include "it_exp_vpd_panel.h"
  28. #include "it_lp_naca.h"
  29. /* The HvReleaseData is the root of the information shared between
  30. * the hypervisor and Linux.
  31. */
  32. const struct HvReleaseData hvReleaseData = {
  33. .xDesc = 0xc8a5d9c4, /* "HvRD" ebcdic */
  34. .xSize = sizeof(struct HvReleaseData),
  35. .xVpdAreasPtrOffset = offsetof(struct naca_struct, xItVpdAreas),
  36. .xSlicNacaAddr = &naca, /* 64-bit Naca address */
  37. .xMsNucDataOffset = LPARMAP_PHYS,
  38. .xFlags = HVREL_TAGSINACTIVE /* tags inactive */
  39. /* 64 bit */
  40. /* shared processors */
  41. /* HMT allowed */
  42. | 6, /* TEMP: This allows non-GA driver */
  43. .xVrmIndex = 4, /* We are v5r2m0 */
  44. .xMinSupportedPlicVrmIndex = 3, /* v5r1m0 */
  45. .xMinCompatablePlicVrmIndex = 3, /* v5r1m0 */
  46. .xVrmName = { 0xd3, 0x89, 0x95, 0xa4, /* "Linux 2.4.64" ebcdic */
  47. 0xa7, 0x40, 0xf2, 0x4b,
  48. 0xf4, 0x4b, 0xf6, 0xf4 },
  49. };
  50. /*
  51. * The NACA. The first dword of the naca is required by the iSeries
  52. * hypervisor to point to itVpdAreas. The hypervisor finds the NACA
  53. * through the pointer in hvReleaseData.
  54. */
  55. struct naca_struct naca = {
  56. .xItVpdAreas = &itVpdAreas,
  57. .xRamDisk = 0,
  58. .xRamDiskSize = 0,
  59. };
  60. struct ItLpRegSave {
  61. u32 xDesc; // Eye catcher "LpRS" ebcdic 000-003
  62. u16 xSize; // Size of this class 004-005
  63. u8 xInUse; // Area is live 006-007
  64. u8 xRsvd1[9]; // Reserved 007-00F
  65. u8 xFixedRegSave[352]; // Fixed Register Save Area 010-16F
  66. u32 xCTRL; // Control Register 170-173
  67. u32 xDEC; // Decrementer 174-177
  68. u32 xFPSCR; // FP Status and Control Reg 178-17B
  69. u32 xPVR; // Processor Version Number 17C-17F
  70. u64 xMMCR0; // Monitor Mode Control Reg 0 180-187
  71. u32 xPMC1; // Perf Monitor Counter 1 188-18B
  72. u32 xPMC2; // Perf Monitor Counter 2 18C-18F
  73. u32 xPMC3; // Perf Monitor Counter 3 190-193
  74. u32 xPMC4; // Perf Monitor Counter 4 194-197
  75. u32 xPIR; // Processor ID Reg 198-19B
  76. u32 xMMCR1; // Monitor Mode Control Reg 1 19C-19F
  77. u32 xMMCRA; // Monitor Mode Control Reg A 1A0-1A3
  78. u32 xPMC5; // Perf Monitor Counter 5 1A4-1A7
  79. u32 xPMC6; // Perf Monitor Counter 6 1A8-1AB
  80. u32 xPMC7; // Perf Monitor Counter 7 1AC-1AF
  81. u32 xPMC8; // Perf Monitor Counter 8 1B0-1B3
  82. u32 xTSC; // Thread Switch Control 1B4-1B7
  83. u32 xTST; // Thread Switch Timeout 1B8-1BB
  84. u32 xRsvd; // Reserved 1BC-1BF
  85. u64 xACCR; // Address Compare Control Reg 1C0-1C7
  86. u64 xIMR; // Instruction Match Register 1C8-1CF
  87. u64 xSDR1; // Storage Description Reg 1 1D0-1D7
  88. u64 xSPRG0; // Special Purpose Reg General0 1D8-1DF
  89. u64 xSPRG1; // Special Purpose Reg General1 1E0-1E7
  90. u64 xSPRG2; // Special Purpose Reg General2 1E8-1EF
  91. u64 xSPRG3; // Special Purpose Reg General3 1F0-1F7
  92. u64 xTB; // Time Base Register 1F8-1FF
  93. u64 xFPR[32]; // Floating Point Registers 200-2FF
  94. u64 xMSR; // Machine State Register 300-307
  95. u64 xNIA; // Next Instruction Address 308-30F
  96. u64 xDABR; // Data Address Breakpoint Reg 310-317
  97. u64 xIABR; // Inst Address Breakpoint Reg 318-31F
  98. u64 xHID0; // HW Implementation Dependent0 320-327
  99. u64 xHID4; // HW Implementation Dependent4 328-32F
  100. u64 xSCOMd; // SCON Data Reg (SPRG4) 330-337
  101. u64 xSCOMc; // SCON Command Reg (SPRG5) 338-33F
  102. u64 xSDAR; // Sample Data Address Register 340-347
  103. u64 xSIAR; // Sample Inst Address Register 348-34F
  104. u8 xRsvd3[176]; // Reserved 350-3FF
  105. };
  106. extern void system_reset_iSeries(void);
  107. extern void machine_check_iSeries(void);
  108. extern void data_access_iSeries(void);
  109. extern void instruction_access_iSeries(void);
  110. extern void hardware_interrupt_iSeries(void);
  111. extern void alignment_iSeries(void);
  112. extern void program_check_iSeries(void);
  113. extern void fp_unavailable_iSeries(void);
  114. extern void decrementer_iSeries(void);
  115. extern void trap_0a_iSeries(void);
  116. extern void trap_0b_iSeries(void);
  117. extern void system_call_iSeries(void);
  118. extern void single_step_iSeries(void);
  119. extern void trap_0e_iSeries(void);
  120. extern void performance_monitor_iSeries(void);
  121. extern void data_access_slb_iSeries(void);
  122. extern void instruction_access_slb_iSeries(void);
  123. struct ItLpNaca itLpNaca = {
  124. .xDesc = 0xd397d581, /* "LpNa" ebcdic */
  125. .xSize = 0x0400, /* size of ItLpNaca */
  126. .xIntHdlrOffset = 0x0300, /* offset to int array */
  127. .xMaxIntHdlrEntries = 19, /* # ents */
  128. .xPrimaryLpIndex = 0, /* Part # of primary */
  129. .xServiceLpIndex = 0, /* Part # of serv */
  130. .xLpIndex = 0, /* Part # of me */
  131. .xMaxLpQueues = 0, /* # of LP queues */
  132. .xLpQueueOffset = 0x100, /* offset of start of LP queues */
  133. .xPirEnvironMode = 0, /* Piranha stuff */
  134. .xPirConsoleMode = 0,
  135. .xPirDasdMode = 0,
  136. .flags = 0,
  137. .xSpVpdFormat = 0,
  138. .xIntProcRatio = 0,
  139. .xPlicVrmIndex = 0, /* VRM index of PLIC */
  140. .xMinSupportedSlicVrmInd = 0, /* min supported SLIC */
  141. .xMinCompatableSlicVrmInd = 0, /* min compat SLIC */
  142. .xLoadAreaAddr = 0, /* 64-bit addr of load area */
  143. .xLoadAreaChunks = 0, /* chunks for load area */
  144. .xPaseSysCallCRMask = 0, /* PASE mask */
  145. .xSlicSegmentTablePtr = 0, /* seg table */
  146. .xOldLpQueue = { 0 }, /* Old LP Queue */
  147. .xInterruptHdlr = {
  148. (u64)system_reset_iSeries, /* 0x100 System Reset */
  149. (u64)machine_check_iSeries, /* 0x200 Machine Check */
  150. (u64)data_access_iSeries, /* 0x300 Data Access */
  151. (u64)instruction_access_iSeries, /* 0x400 Instruction Access */
  152. (u64)hardware_interrupt_iSeries, /* 0x500 External */
  153. (u64)alignment_iSeries, /* 0x600 Alignment */
  154. (u64)program_check_iSeries, /* 0x700 Program Check */
  155. (u64)fp_unavailable_iSeries, /* 0x800 FP Unavailable */
  156. (u64)decrementer_iSeries, /* 0x900 Decrementer */
  157. (u64)trap_0a_iSeries, /* 0xa00 Trap 0A */
  158. (u64)trap_0b_iSeries, /* 0xb00 Trap 0B */
  159. (u64)system_call_iSeries, /* 0xc00 System Call */
  160. (u64)single_step_iSeries, /* 0xd00 Single Step */
  161. (u64)trap_0e_iSeries, /* 0xe00 Trap 0E */
  162. (u64)performance_monitor_iSeries,/* 0xf00 Performance Monitor */
  163. 0, /* int 0x1000 */
  164. 0, /* int 0x1010 */
  165. 0, /* int 0x1020 CPU ctls */
  166. (u64)hardware_interrupt_iSeries, /* SC Ret Hdlr */
  167. (u64)data_access_slb_iSeries, /* 0x380 D-SLB */
  168. (u64)instruction_access_slb_iSeries /* 0x480 I-SLB */
  169. }
  170. };
  171. /* May be filled in by the hypervisor so cannot end up in the BSS */
  172. static struct ItIplParmsReal xItIplParmsReal __attribute__((__section__(".data")));
  173. /* May be filled in by the hypervisor so cannot end up in the BSS */
  174. struct ItExtVpdPanel xItExtVpdPanel __attribute__((__section__(".data")));
  175. #define maxPhysicalProcessors 32
  176. struct IoHriProcessorVpd xIoHriProcessorVpd[maxPhysicalProcessors] = {
  177. {
  178. .xInstCacheOperandSize = 32,
  179. .xDataCacheOperandSize = 32,
  180. .xProcFreq = 50000000,
  181. .xTimeBaseFreq = 50000000,
  182. .xPVR = 0x3600
  183. }
  184. };
  185. /* Space for Main Store Vpd 27,200 bytes */
  186. /* May be filled in by the hypervisor so cannot end up in the BSS */
  187. u64 xMsVpd[3400] __attribute__((__section__(".data")));
  188. /* Space for Recovery Log Buffer */
  189. /* May be filled in by the hypervisor so cannot end up in the BSS */
  190. static u64 xRecoveryLogBuffer[32] __attribute__((__section__(".data")));
  191. static const struct SpCommArea xSpCommArea = {
  192. .xDesc = 0xE2D7C3C2,
  193. .xFormat = 1,
  194. };
  195. static const struct ItLpRegSave iseries_reg_save[] = {
  196. [0 ... (NR_CPUS-1)] = {
  197. .xDesc = 0xd397d9e2, /* "LpRS" */
  198. .xSize = sizeof(struct ItLpRegSave),
  199. },
  200. };
  201. #define ALPACA_INIT(number) \
  202. { \
  203. .lppaca_ptr = &lppaca[number], \
  204. .reg_save_ptr = &iseries_reg_save[number], \
  205. }
  206. const struct alpaca alpaca[] = {
  207. ALPACA_INIT( 0),
  208. #if NR_CPUS > 1
  209. ALPACA_INIT( 1), ALPACA_INIT( 2), ALPACA_INIT( 3),
  210. #if NR_CPUS > 4
  211. ALPACA_INIT( 4), ALPACA_INIT( 5), ALPACA_INIT( 6), ALPACA_INIT( 7),
  212. #if NR_CPUS > 8
  213. ALPACA_INIT( 8), ALPACA_INIT( 9), ALPACA_INIT(10), ALPACA_INIT(11),
  214. ALPACA_INIT(12), ALPACA_INIT(13), ALPACA_INIT(14), ALPACA_INIT(15),
  215. ALPACA_INIT(16), ALPACA_INIT(17), ALPACA_INIT(18), ALPACA_INIT(19),
  216. ALPACA_INIT(20), ALPACA_INIT(21), ALPACA_INIT(22), ALPACA_INIT(23),
  217. ALPACA_INIT(24), ALPACA_INIT(25), ALPACA_INIT(26), ALPACA_INIT(27),
  218. ALPACA_INIT(28), ALPACA_INIT(29), ALPACA_INIT(30), ALPACA_INIT(31),
  219. #if NR_CPUS > 32
  220. ALPACA_INIT(32), ALPACA_INIT(33), ALPACA_INIT(34), ALPACA_INIT(35),
  221. ALPACA_INIT(36), ALPACA_INIT(37), ALPACA_INIT(38), ALPACA_INIT(39),
  222. ALPACA_INIT(40), ALPACA_INIT(41), ALPACA_INIT(42), ALPACA_INIT(43),
  223. ALPACA_INIT(44), ALPACA_INIT(45), ALPACA_INIT(46), ALPACA_INIT(47),
  224. ALPACA_INIT(48), ALPACA_INIT(49), ALPACA_INIT(50), ALPACA_INIT(51),
  225. ALPACA_INIT(52), ALPACA_INIT(53), ALPACA_INIT(54), ALPACA_INIT(55),
  226. ALPACA_INIT(56), ALPACA_INIT(57), ALPACA_INIT(58), ALPACA_INIT(59),
  227. ALPACA_INIT(60), ALPACA_INIT(61), ALPACA_INIT(62), ALPACA_INIT(63),
  228. #endif
  229. #endif
  230. #endif
  231. #endif
  232. };
  233. /* The LparMap data is now located at offset 0x6000 in head.S
  234. * It was put there so that the HvReleaseData could address it
  235. * with a 32-bit offset as required by the iSeries hypervisor
  236. *
  237. * The Naca has a pointer to the ItVpdAreas. The hypervisor finds
  238. * the Naca via the HvReleaseData area. The HvReleaseData has the
  239. * offset into the Naca of the pointer to the ItVpdAreas.
  240. */
  241. const struct ItVpdAreas itVpdAreas = {
  242. .xSlicDesc = 0xc9a3e5c1, /* "ItVA" */
  243. .xSlicSize = sizeof(struct ItVpdAreas),
  244. .xSlicVpdEntries = ItVpdMaxEntries, /* # VPD array entries */
  245. .xSlicDmaEntries = ItDmaMaxEntries, /* # DMA array entries */
  246. .xSlicMaxLogicalProcs = NR_CPUS * 2, /* Max logical procs */
  247. .xSlicMaxPhysicalProcs = maxPhysicalProcessors, /* Max physical procs */
  248. .xSlicDmaToksOffset = offsetof(struct ItVpdAreas, xPlicDmaToks),
  249. .xSlicVpdAdrsOffset = offsetof(struct ItVpdAreas, xSlicVpdAdrs),
  250. .xSlicDmaLensOffset = offsetof(struct ItVpdAreas, xPlicDmaLens),
  251. .xSlicVpdLensOffset = offsetof(struct ItVpdAreas, xSlicVpdLens),
  252. .xSlicMaxSlotLabels = 0, /* max slot labels */
  253. .xSlicMaxLpQueues = 1, /* max LP queues */
  254. .xPlicDmaLens = { 0 }, /* DMA lengths */
  255. .xPlicDmaToks = { 0 }, /* DMA tokens */
  256. .xSlicVpdLens = { /* VPD lengths */
  257. 0,0,0, /* 0 - 2 */
  258. sizeof(xItExtVpdPanel), /* 3 Extended VPD */
  259. sizeof(struct alpaca), /* 4 length of (fake) Paca */
  260. 0, /* 5 */
  261. sizeof(struct ItIplParmsReal),/* 6 length of IPL parms */
  262. 26992, /* 7 length of MS VPD */
  263. 0, /* 8 */
  264. sizeof(struct ItLpNaca),/* 9 length of LP Naca */
  265. 0, /* 10 */
  266. 256, /* 11 length of Recovery Log Buf */
  267. sizeof(struct SpCommArea), /* 12 length of SP Comm Area */
  268. 0,0,0, /* 13 - 15 */
  269. sizeof(struct IoHriProcessorVpd),/* 16 length of Proc Vpd */
  270. 0,0,0,0,0,0, /* 17 - 22 */
  271. sizeof(struct hvlpevent_queue), /* 23 length of Lp Queue */
  272. 0,0 /* 24 - 25 */
  273. },
  274. .xSlicVpdAdrs = { /* VPD addresses */
  275. 0,0,0, /* 0 - 2 */
  276. &xItExtVpdPanel, /* 3 Extended VPD */
  277. &alpaca[0], /* 4 first (fake) Paca */
  278. 0, /* 5 */
  279. &xItIplParmsReal, /* 6 IPL parms */
  280. &xMsVpd, /* 7 MS Vpd */
  281. 0, /* 8 */
  282. &itLpNaca, /* 9 LpNaca */
  283. 0, /* 10 */
  284. &xRecoveryLogBuffer, /* 11 Recovery Log Buffer */
  285. &xSpCommArea, /* 12 SP Comm Area */
  286. 0,0,0, /* 13 - 15 */
  287. &xIoHriProcessorVpd, /* 16 Proc Vpd */
  288. 0,0,0,0,0,0, /* 17 - 22 */
  289. &hvlpevent_queue, /* 23 Lp Queue */
  290. 0,0
  291. }
  292. };