LparData.c
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:8k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  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 <asm/types.h>
  10. #include <asm/page.h>
  11. #include <stddef.h>
  12. #include <linux/threads.h>
  13. #include <asm/processor.h>
  14. #include <asm/ptrace.h>
  15. #include <asm/naca.h>
  16. #include <asm/abs_addr.h>
  17. #include <asm/bitops.h>
  18. #include <asm/iSeries/ItLpNaca.h>
  19. #include <asm/iSeries/ItLpPaca.h>
  20. #include <asm/iSeries/ItLpRegSave.h>
  21. #include <asm/paca.h>
  22. #include <asm/iSeries/HvReleaseData.h>
  23. #include <asm/iSeries/LparMap.h>
  24. #include <asm/iSeries/ItVpdAreas.h>
  25. #include <asm/iSeries/ItIplParmsReal.h>
  26. #include <asm/iSeries/ItExtVpdPanel.h>
  27. #include <asm/iSeries/ItLpQueue.h>
  28. #include <asm/iSeries/IoHriProcessorVpd.h>
  29. #include <asm/iSeries/ItSpCommArea.h>
  30. extern char _start_boltedStacks[];
  31. /* The LparMap data is now located at offset 0x6000 in head.S
  32.  * It was put there so that the HvReleaseData could address it
  33.  * with a 32-bit offset as required by the iSeries hypervisor
  34.  *
  35.  * The Naca has a pointer to the ItVpdAreas.  The hypervisor finds
  36.  * the Naca via the HvReleaseData area.  The HvReleaseData has the
  37.  * offset into the Naca of the pointer to the ItVpdAreas.
  38.  */
  39. extern struct ItVpdAreas itVpdAreas;
  40. /* The LpQueue is used to pass event data from the hypervisor to
  41.  * the partition.  This is where I/O interrupt events are communicated.
  42.  * The ItLpQueue must be initialized (even though only to all zeros)
  43.  * If it were uninitialized (in .bss) it would get zeroed after the
  44.  * kernel gets control.  The hypervisor will have filled in some fields
  45.  * before the kernel gets control.  By initializing it we keep it out
  46.  * of the .bss
  47.  */
  48. struct ItLpQueue xItLpQueue = {};
  49. /* The HvReleaseData is the root of the information shared between 
  50.  * the hypervisor and Linux.  
  51.  */
  52. struct HvReleaseData hvReleaseData = {
  53. 0xc8a5d9c4, /* desc = "HvRD" ebcdic */
  54. sizeof(struct HvReleaseData),
  55. offsetof(struct naca_struct, xItVpdAreas),
  56. (struct naca_struct *)(KERNELBASE+0x4000), /* 64-bit Naca address */
  57. 0x6000, /* offset of LparMap within loadarea (see head.S) */
  58. 0,
  59. 1, /* tags inactive       */
  60. 0, /* 64 bit              */
  61. 0, /* shared processors   */
  62. 0, /* HMT allowed         */
  63. 6, /* TEMP: This allows non-GA driver */
  64. 4, /* We are v5r2m0               */
  65. 3, /* Min supported PLIC = v5r1m0 */
  66. 3, /* Min usuable PLIC   = v5r1m0 */
  67. { 0xd3, 0x89, 0x95, 0xa4, /* "Linux 2.4   "*/
  68.   0xa7, 0x40, 0xf2, 0x4b,
  69.   0xf4, 0x4b, 0xf6, 0xf4 },
  70. {0}  
  71. };
  72. extern void SystemReset_Iseries(void);
  73. extern void MachineCheck_Iseries(void);
  74. extern void DataAccess_Iseries(void);
  75. extern void InstructionAccess_Iseries(void);
  76. extern void HardwareInterrupt_Iseries(void);
  77. extern void Alignment_Iseries(void);
  78. extern void ProgramCheck_Iseries(void);
  79. extern void FPUnavailable_Iseries(void);
  80. extern void Decrementer_Iseries(void);
  81. extern void Trap_0a_Iseries(void);
  82. extern void Trap_0b_Iseries(void);
  83. extern void SystemCall_Iseries(void);
  84. extern void SingleStep_Iseries(void);
  85. extern void Trap_0e_Iseries(void);
  86. extern void PerformanceMonitor_Iseries(void);
  87. extern void DataAccessSLB_Iseries(void);
  88. extern void InstructionAccessSLB_Iseries(void);
  89. struct ItLpNaca itLpNaca = {
  90. 0xd397d581, /* desc = "LpNa" ebcdic */
  91. 0x0400, /* size of ItLpNaca     */
  92. 0x0300, 19, /* offset to int array, # ents */
  93. 0, 0, 0, /* Part # of primary, serv, me */
  94. 0, 0x100, /* # of LP queues, offset */
  95. 0, 0, 0, /* Piranha stuff */
  96. { 0,0,0,0,0 }, /* reserved */
  97. 0,0,0,0,0,0,0, /* stuff    */
  98. { 0,0,0,0,0 }, /* reserved */
  99. 0, /* reserved */
  100. 0, /* VRM index of PLIC */
  101. 0, 0, /* min supported, compat SLIC */
  102. 0, /* 64-bit addr of load area   */
  103. 0, /* chunks for load area  */
  104. 0, 0, /* PASE mask, seg table  */
  105. { 0 }, /* 64 reserved bytes  */
  106. { 0 },  /* 128 reserved bytes */
  107. { 0 },  /* Old LP Queue       */
  108. { 0 },  /* 384 reserved bytes */
  109. {
  110. (u64)SystemReset_Iseries, /* 0x100 System Reset */
  111. (u64)MachineCheck_Iseries, /* 0x200 Machine Check */
  112. (u64)DataAccess_Iseries, /* 0x300 Data Access */
  113. (u64)InstructionAccess_Iseries, /* 0x400 Instruction Access */
  114. (u64)HardwareInterrupt_Iseries, /* 0x500 External */
  115. (u64)Alignment_Iseries, /* 0x600 Alignment */
  116. (u64)ProgramCheck_Iseries, /* 0x700 Program Check */
  117. (u64)FPUnavailable_Iseries, /* 0x800 FP Unavailable */
  118. (u64)Decrementer_Iseries, /* 0x900 Decrementer */
  119. (u64)Trap_0a_Iseries, /* 0xa00 Trap 0A */
  120. (u64)Trap_0b_Iseries, /* 0xb00 Trap 0B */
  121. (u64)SystemCall_Iseries, /* 0xc00 System Call */
  122. (u64)SingleStep_Iseries, /* 0xd00 Single Step */
  123. (u64)Trap_0e_Iseries, /* 0xe00 Trap 0E */
  124. (u64)PerformanceMonitor_Iseries,/* 0xf00 Performance Monitor */
  125. 0, /* int 0x1000 */
  126. 0, /* int 0x1010 */
  127. 0, /* int 0x1020 CPU ctls */
  128. (u64)HardwareInterrupt_Iseries, /* SC Ret Hdlr */
  129. (u64)DataAccessSLB_Iseries, /* 0x380 D-SLB */
  130. (u64)InstructionAccessSLB_Iseries /* 0x480 I-SLB */
  131. }
  132. };
  133. struct ItIplParmsReal xItIplParmsReal = {};
  134. struct ItExtVpdPanel xItExtVpdPanel = {};
  135. #define maxPhysicalProcessors 32
  136. struct IoHriProcessorVpd xIoHriProcessorVpd[maxPhysicalProcessors] = {
  137. {
  138. xInstCacheOperandSize: 32,
  139. xDataCacheOperandSize: 32,
  140. xProcFreq:     50000000,
  141. xTimeBaseFreq: 50000000,
  142. xPVR: 0x3600
  143. }
  144. };
  145. u64    xMsVpd[3400] = {}; /* Space for Main Store Vpd 27,200 bytes */
  146. u64    xRecoveryLogBuffer[32] = {}; /* Space for Recovery Log Buffer */
  147. struct SpCommArea xSpCommArea = {
  148. 0xE2D7C3C2,
  149. 1,
  150. {0},
  151. 0, 0, 0, 0, {0}
  152. };
  153. struct ItVpdAreas itVpdAreas = {
  154. 0xc9a3e5c1, /* "ItVA" */
  155. sizeof( struct ItVpdAreas ),
  156. 0, 0,
  157. 26, /* # VPD array entries */
  158. 10, /* # DMA array entries */
  159. MAX_PROCESSORS*2, maxPhysicalProcessors, /* Max logical, physical procs */
  160. offsetof(struct ItVpdAreas,xPlicDmaToks),/* offset to DMA toks */
  161. offsetof(struct ItVpdAreas,xSlicVpdAdrs),/* offset to VPD addrs */
  162. offsetof(struct ItVpdAreas,xPlicDmaLens),/* offset to DMA lens */
  163. offsetof(struct ItVpdAreas,xSlicVpdLens),/* offset to VPD lens */
  164. 0, /* max slot labels */
  165. 1, /* max LP queues */
  166. {0}, {0}, /* reserved */
  167. {0}, /* DMA lengths */
  168. {0}, /* DMA tokens */
  169. { /* VPD lengths */
  170.         0,0,0,         /*  0 - 2 */
  171. sizeof(xItExtVpdPanel), /*       3 Extended VPD   */
  172. sizeof(struct paca_struct), /*       4 length of Paca  */
  173. 0, /*       5 */
  174. sizeof(struct ItIplParmsReal),/* 6 length of IPL parms */
  175. 26992, /*  7 length of MS VPD */
  176. 0, /*       8 */
  177. sizeof(struct ItLpNaca),/*       9 length of LP Naca */
  178. 0,  /* 10 */
  179. 256, /* 11 length of Recovery Log Buf */
  180. sizeof(struct SpCommArea), /*   12 length of SP Comm Area */
  181. 0,0,0, /* 13 - 15 */
  182. sizeof(struct IoHriProcessorVpd),/* 16 length of Proc Vpd */
  183. 0,0,0,0,0,0, /* 17 - 22  */
  184. sizeof(struct ItLpQueue),/*     23 length of Lp Queue */
  185. 0,0 /* 24 - 25 */
  186. },
  187. { /* VPD addresses */
  188. 0,0,0,   /*  0 -  2 */
  189. &xItExtVpdPanel,        /*       3 Extended VPD */
  190. &paca[0], /*       4 first Paca */
  191. 0, /*       5 */
  192. &xItIplParmsReal, /*  6 IPL parms */
  193. &xMsVpd, /*  7 MS Vpd */
  194. 0, /*       8 */
  195. &itLpNaca, /*       9 LpNaca */
  196. 0, /* 10 */
  197. &xRecoveryLogBuffer, /* 11 Recovery Log Buffer */
  198. &xSpCommArea, /* 12 SP Comm Area */
  199. 0,0,0, /* 13 - 15 */
  200. &xIoHriProcessorVpd, /*      16 Proc Vpd */
  201. 0,0,0,0,0,0, /* 17 - 22 */
  202. &xItLpQueue, /*      23 Lp Queue */
  203. 0,0
  204. }
  205. };
  206. struct msChunks msChunks = {0, 0, 0, 0, NULL};
  207. /* Depending on whether this is called from iSeries or pSeries setup
  208.  * code, the location of the msChunks struct may or may not have
  209.  * to be reloc'd, so we force the caller to do that for us by passing
  210.  * in a pointer to the structure.
  211.  */
  212. unsigned long
  213. msChunks_alloc(unsigned long mem, unsigned long num_chunks, unsigned long chunk_size)
  214. {
  215. unsigned long offset = reloc_offset();
  216. struct msChunks *_msChunks = PTRRELOC(&msChunks);
  217. _msChunks->num_chunks  = num_chunks;
  218. _msChunks->chunk_size  = chunk_size;
  219. _msChunks->chunk_shift = __ilog2(chunk_size);
  220. _msChunks->chunk_mask  = (1UL<<_msChunks->chunk_shift)-1;
  221. mem = _ALIGN(mem, sizeof(msChunks_entry));
  222. _msChunks->abs = (msChunks_entry *)(mem + offset);
  223. mem += num_chunks * sizeof(msChunks_entry);
  224. return mem;
  225. }