lpardata.c 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  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/iseries/it_lp_reg_save.h>
  18. #include <asm/paca.h>
  19. #include <asm/iseries/lpar_map.h>
  20. #include <asm/iseries/it_lp_queue.h>
  21. #include <asm/iseries/alpaca.h>
  22. #include "naca.h"
  23. #include "vpd_areas.h"
  24. #include "spcomm_area.h"
  25. #include "ipl_parms.h"
  26. #include "processor_vpd.h"
  27. #include "release_data.h"
  28. #include "it_exp_vpd_panel.h"
  29. #include "it_lp_naca.h"
  30. /* The HvReleaseData is the root of the information shared between
  31. * the hypervisor and Linux.
  32. */
  33. struct HvReleaseData hvReleaseData = {
  34. .xDesc = 0xc8a5d9c4, /* "HvRD" ebcdic */
  35. .xSize = sizeof(struct HvReleaseData),
  36. .xVpdAreasPtrOffset = offsetof(struct naca_struct, xItVpdAreas),
  37. .xSlicNacaAddr = &naca, /* 64-bit Naca address */
  38. .xMsNucDataOffset = LPARMAP_PHYS,
  39. .xFlags = HVREL_TAGSINACTIVE /* tags inactive */
  40. /* 64 bit */
  41. /* shared processors */
  42. /* HMT allowed */
  43. | 6, /* TEMP: This allows non-GA driver */
  44. .xVrmIndex = 4, /* We are v5r2m0 */
  45. .xMinSupportedPlicVrmIndex = 3, /* v5r1m0 */
  46. .xMinCompatablePlicVrmIndex = 3, /* v5r1m0 */
  47. .xVrmName = { 0xd3, 0x89, 0x95, 0xa4, /* "Linux 2.4.64" ebcdic */
  48. 0xa7, 0x40, 0xf2, 0x4b,
  49. 0xf4, 0x4b, 0xf6, 0xf4 },
  50. };
  51. /*
  52. * The NACA. The first dword of the naca is required by the iSeries
  53. * hypervisor to point to itVpdAreas. The hypervisor finds the NACA
  54. * through the pointer in hvReleaseData.
  55. */
  56. struct naca_struct naca = {
  57. .xItVpdAreas = &itVpdAreas,
  58. .xRamDisk = 0,
  59. .xRamDiskSize = 0,
  60. };
  61. extern void system_reset_iSeries(void);
  62. extern void machine_check_iSeries(void);
  63. extern void data_access_iSeries(void);
  64. extern void instruction_access_iSeries(void);
  65. extern void hardware_interrupt_iSeries(void);
  66. extern void alignment_iSeries(void);
  67. extern void program_check_iSeries(void);
  68. extern void fp_unavailable_iSeries(void);
  69. extern void decrementer_iSeries(void);
  70. extern void trap_0a_iSeries(void);
  71. extern void trap_0b_iSeries(void);
  72. extern void system_call_iSeries(void);
  73. extern void single_step_iSeries(void);
  74. extern void trap_0e_iSeries(void);
  75. extern void performance_monitor_iSeries(void);
  76. extern void data_access_slb_iSeries(void);
  77. extern void instruction_access_slb_iSeries(void);
  78. struct ItLpNaca itLpNaca = {
  79. .xDesc = 0xd397d581, /* "LpNa" ebcdic */
  80. .xSize = 0x0400, /* size of ItLpNaca */
  81. .xIntHdlrOffset = 0x0300, /* offset to int array */
  82. .xMaxIntHdlrEntries = 19, /* # ents */
  83. .xPrimaryLpIndex = 0, /* Part # of primary */
  84. .xServiceLpIndex = 0, /* Part # of serv */
  85. .xLpIndex = 0, /* Part # of me */
  86. .xMaxLpQueues = 0, /* # of LP queues */
  87. .xLpQueueOffset = 0x100, /* offset of start of LP queues */
  88. .xPirEnvironMode = 0, /* Piranha stuff */
  89. .xPirConsoleMode = 0,
  90. .xPirDasdMode = 0,
  91. .flags = 0,
  92. .xSpVpdFormat = 0,
  93. .xIntProcRatio = 0,
  94. .xPlicVrmIndex = 0, /* VRM index of PLIC */
  95. .xMinSupportedSlicVrmInd = 0, /* min supported SLIC */
  96. .xMinCompatableSlicVrmInd = 0, /* min compat SLIC */
  97. .xLoadAreaAddr = 0, /* 64-bit addr of load area */
  98. .xLoadAreaChunks = 0, /* chunks for load area */
  99. .xPaseSysCallCRMask = 0, /* PASE mask */
  100. .xSlicSegmentTablePtr = 0, /* seg table */
  101. .xOldLpQueue = { 0 }, /* Old LP Queue */
  102. .xInterruptHdlr = {
  103. (u64)system_reset_iSeries, /* 0x100 System Reset */
  104. (u64)machine_check_iSeries, /* 0x200 Machine Check */
  105. (u64)data_access_iSeries, /* 0x300 Data Access */
  106. (u64)instruction_access_iSeries, /* 0x400 Instruction Access */
  107. (u64)hardware_interrupt_iSeries, /* 0x500 External */
  108. (u64)alignment_iSeries, /* 0x600 Alignment */
  109. (u64)program_check_iSeries, /* 0x700 Program Check */
  110. (u64)fp_unavailable_iSeries, /* 0x800 FP Unavailable */
  111. (u64)decrementer_iSeries, /* 0x900 Decrementer */
  112. (u64)trap_0a_iSeries, /* 0xa00 Trap 0A */
  113. (u64)trap_0b_iSeries, /* 0xb00 Trap 0B */
  114. (u64)system_call_iSeries, /* 0xc00 System Call */
  115. (u64)single_step_iSeries, /* 0xd00 Single Step */
  116. (u64)trap_0e_iSeries, /* 0xe00 Trap 0E */
  117. (u64)performance_monitor_iSeries,/* 0xf00 Performance Monitor */
  118. 0, /* int 0x1000 */
  119. 0, /* int 0x1010 */
  120. 0, /* int 0x1020 CPU ctls */
  121. (u64)hardware_interrupt_iSeries, /* SC Ret Hdlr */
  122. (u64)data_access_slb_iSeries, /* 0x380 D-SLB */
  123. (u64)instruction_access_slb_iSeries /* 0x480 I-SLB */
  124. }
  125. };
  126. /* May be filled in by the hypervisor so cannot end up in the BSS */
  127. struct ItIplParmsReal xItIplParmsReal __attribute__((__section__(".data")));
  128. /* May be filled in by the hypervisor so cannot end up in the BSS */
  129. struct ItExtVpdPanel xItExtVpdPanel __attribute__((__section__(".data")));
  130. #define maxPhysicalProcessors 32
  131. struct IoHriProcessorVpd xIoHriProcessorVpd[maxPhysicalProcessors] = {
  132. {
  133. .xInstCacheOperandSize = 32,
  134. .xDataCacheOperandSize = 32,
  135. .xProcFreq = 50000000,
  136. .xTimeBaseFreq = 50000000,
  137. .xPVR = 0x3600
  138. }
  139. };
  140. /* Space for Main Store Vpd 27,200 bytes */
  141. /* May be filled in by the hypervisor so cannot end up in the BSS */
  142. u64 xMsVpd[3400] __attribute__((__section__(".data")));
  143. /* Space for Recovery Log Buffer */
  144. /* May be filled in by the hypervisor so cannot end up in the BSS */
  145. u64 xRecoveryLogBuffer[32] __attribute__((__section__(".data")));
  146. struct SpCommArea xSpCommArea = {
  147. .xDesc = 0xE2D7C3C2,
  148. .xFormat = 1,
  149. };
  150. #define ALPACA_INIT(number) \
  151. { \
  152. .lppaca_ptr = &lppaca[number], \
  153. .reg_save_ptr = &iseries_reg_save[number], \
  154. }
  155. struct alpaca alpaca[] = {
  156. ALPACA_INIT( 0),
  157. #if NR_CPUS > 1
  158. ALPACA_INIT( 1), ALPACA_INIT( 2), ALPACA_INIT( 3),
  159. #if NR_CPUS > 4
  160. ALPACA_INIT( 4), ALPACA_INIT( 5), ALPACA_INIT( 6), ALPACA_INIT( 7),
  161. #if NR_CPUS > 8
  162. ALPACA_INIT( 8), ALPACA_INIT( 9), ALPACA_INIT(10), ALPACA_INIT(11),
  163. ALPACA_INIT(12), ALPACA_INIT(13), ALPACA_INIT(14), ALPACA_INIT(15),
  164. ALPACA_INIT(16), ALPACA_INIT(17), ALPACA_INIT(18), ALPACA_INIT(19),
  165. ALPACA_INIT(20), ALPACA_INIT(21), ALPACA_INIT(22), ALPACA_INIT(23),
  166. ALPACA_INIT(24), ALPACA_INIT(25), ALPACA_INIT(26), ALPACA_INIT(27),
  167. ALPACA_INIT(28), ALPACA_INIT(29), ALPACA_INIT(30), ALPACA_INIT(31),
  168. #if NR_CPUS > 32
  169. ALPACA_INIT(32), ALPACA_INIT(33), ALPACA_INIT(34), ALPACA_INIT(35),
  170. ALPACA_INIT(36), ALPACA_INIT(37), ALPACA_INIT(38), ALPACA_INIT(39),
  171. ALPACA_INIT(40), ALPACA_INIT(41), ALPACA_INIT(42), ALPACA_INIT(43),
  172. ALPACA_INIT(44), ALPACA_INIT(45), ALPACA_INIT(46), ALPACA_INIT(47),
  173. ALPACA_INIT(48), ALPACA_INIT(49), ALPACA_INIT(50), ALPACA_INIT(51),
  174. ALPACA_INIT(52), ALPACA_INIT(53), ALPACA_INIT(54), ALPACA_INIT(55),
  175. ALPACA_INIT(56), ALPACA_INIT(57), ALPACA_INIT(58), ALPACA_INIT(59),
  176. ALPACA_INIT(60), ALPACA_INIT(61), ALPACA_INIT(62), ALPACA_INIT(63),
  177. #endif
  178. #endif
  179. #endif
  180. #endif
  181. };
  182. /* The LparMap data is now located at offset 0x6000 in head.S
  183. * It was put there so that the HvReleaseData could address it
  184. * with a 32-bit offset as required by the iSeries hypervisor
  185. *
  186. * The Naca has a pointer to the ItVpdAreas. The hypervisor finds
  187. * the Naca via the HvReleaseData area. The HvReleaseData has the
  188. * offset into the Naca of the pointer to the ItVpdAreas.
  189. */
  190. struct ItVpdAreas itVpdAreas = {
  191. .xSlicDesc = 0xc9a3e5c1, /* "ItVA" */
  192. .xSlicSize = sizeof(struct ItVpdAreas),
  193. .xSlicVpdEntries = ItVpdMaxEntries, /* # VPD array entries */
  194. .xSlicDmaEntries = ItDmaMaxEntries, /* # DMA array entries */
  195. .xSlicMaxLogicalProcs = NR_CPUS * 2, /* Max logical procs */
  196. .xSlicMaxPhysicalProcs = maxPhysicalProcessors, /* Max physical procs */
  197. .xSlicDmaToksOffset = offsetof(struct ItVpdAreas, xPlicDmaToks),
  198. .xSlicVpdAdrsOffset = offsetof(struct ItVpdAreas, xSlicVpdAdrs),
  199. .xSlicDmaLensOffset = offsetof(struct ItVpdAreas, xPlicDmaLens),
  200. .xSlicVpdLensOffset = offsetof(struct ItVpdAreas, xSlicVpdLens),
  201. .xSlicMaxSlotLabels = 0, /* max slot labels */
  202. .xSlicMaxLpQueues = 1, /* max LP queues */
  203. .xPlicDmaLens = { 0 }, /* DMA lengths */
  204. .xPlicDmaToks = { 0 }, /* DMA tokens */
  205. .xSlicVpdLens = { /* VPD lengths */
  206. 0,0,0, /* 0 - 2 */
  207. sizeof(xItExtVpdPanel), /* 3 Extended VPD */
  208. sizeof(struct alpaca), /* 4 length of (fake) Paca */
  209. 0, /* 5 */
  210. sizeof(struct ItIplParmsReal),/* 6 length of IPL parms */
  211. 26992, /* 7 length of MS VPD */
  212. 0, /* 8 */
  213. sizeof(struct ItLpNaca),/* 9 length of LP Naca */
  214. 0, /* 10 */
  215. 256, /* 11 length of Recovery Log Buf */
  216. sizeof(struct SpCommArea), /* 12 length of SP Comm Area */
  217. 0,0,0, /* 13 - 15 */
  218. sizeof(struct IoHriProcessorVpd),/* 16 length of Proc Vpd */
  219. 0,0,0,0,0,0, /* 17 - 22 */
  220. sizeof(struct hvlpevent_queue), /* 23 length of Lp Queue */
  221. 0,0 /* 24 - 25 */
  222. },
  223. .xSlicVpdAdrs = { /* VPD addresses */
  224. 0,0,0, /* 0 - 2 */
  225. &xItExtVpdPanel, /* 3 Extended VPD */
  226. &alpaca[0], /* 4 first (fake) Paca */
  227. 0, /* 5 */
  228. &xItIplParmsReal, /* 6 IPL parms */
  229. &xMsVpd, /* 7 MS Vpd */
  230. 0, /* 8 */
  231. &itLpNaca, /* 9 LpNaca */
  232. 0, /* 10 */
  233. &xRecoveryLogBuffer, /* 11 Recovery Log Buffer */
  234. &xSpCommArea, /* 12 SP Comm Area */
  235. 0,0,0, /* 13 - 15 */
  236. &xIoHriProcessorVpd, /* 16 Proc Vpd */
  237. 0,0,0,0,0,0, /* 17 - 22 */
  238. &hvlpevent_queue, /* 23 Lp Queue */
  239. 0,0
  240. }
  241. };
  242. struct ItLpRegSave iseries_reg_save[] = {
  243. [0 ... (NR_CPUS-1)] = {
  244. .xDesc = 0xd397d9e2, /* "LpRS" */
  245. .xSize = sizeof(struct ItLpRegSave),
  246. },
  247. };