Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

594 lines
25 KiB

  1. //###########################################################################
  2. //**
  3. //** Copyright (C) 1996-99 Intel Corporation. All rights reserved.
  4. //**
  5. //** The information and source code contained herein is the exclusive
  6. //** property of Intel Corporation and may not be disclosed, examined
  7. //** or reproduced in whole or in part without explicit written authorization
  8. //** from the company.
  9. //**
  10. //###########################################################################
  11. ;//-----------------------------------------------------------------------------
  12. ;// Version control information follows.
  13. ;//
  14. ;// $Header: I:/DEVPVCS/sal/INCLUDE/FWGLOBAL.H 6.6 07 May 1999 10:52:24 smariset $
  15. ;// $Log: I:/DEVPVCS/sal/INCLUDE/FWGLOBAL.H $
  16. ;//
  17. ;// Rev 6.6 07 May 1999 10:52:24 smariset
  18. ;//Copyright year update
  19. ;//
  20. ;// Rev 6.5 05 May 1999 14:13:30 smariset
  21. ;//Pre Fresh Build
  22. ;//
  23. ;// Rev 6.4 16 Apr 1999 13:45:34 smariset
  24. ;//MinState Size Change, Procs Clean Up
  25. ;//
  26. ;// Rev 6.2 04 Mar 1999 13:36:06 smariset
  27. ;//Pre 0.6 release symbol globalization
  28. ;//
  29. ;// Rev 6.1 10 Feb 1999 15:58:38 smariset
  30. ;//Boot Mgr Updates
  31. ;//
  32. ;// Rev 6.0 Dec 11 1998 10:23:08 khaw
  33. ;//Post FW 0.5 release sync-up
  34. ;//
  35. ;// Rev 5.0 27 Aug 1998 11:52:28 khaw
  36. ;//FW merged for EAS 2.4 SDK tools
  37. ;//
  38. ;// Rev 4.1 20 Aug 1998 16:53:30 smariset
  39. ;//EAS 2.4 Changes
  40. ;//
  41. ;// Rev 4.0 06 May 1998 22:22:50 khaw
  42. ;//Major update for MP SAL, tools and build.
  43. ;//SAL A/B common source. .s extension.
  44. ;//
  45. ;// Rev 3.3 17 Feb 1998 08:37:24 khaw
  46. ;//SAL buid/code update for SDK0.3
  47. ;//
  48. ;// Rev 3.2 06 Jan 1998 12:52:48 smariset
  49. ;//One more flag: OStoPalRtn
  50. ;//
  51. ;// Rev 3.1 06 Jan 1998 09:16:50 smariset
  52. ;//Hazard Checked
  53. ;//
  54. ;// Rev 3.0 17 Dec 1997 12:42:54 khaw
  55. ;// Merced Firmware Development Kit Rev 0.2
  56. ;//
  57. ;// Rev 2.8 Apr 02 1997 14:18:40 smariset
  58. ;//Post release clean up
  59. ;//
  60. ;// Rev 2.7 Mar 31 1997 12:28:48 smariset
  61. ;//Indent tabs replaced by spaces
  62. ;//
  63. ;// Rev 2.0 Feb 04 1997 07:29:54 khaw
  64. ;//PAL_A/B, SAL_A/B updates
  65. ;//
  66. ;//*****************************************************************************//
  67. #define xs0 s0
  68. #define xs1 s1
  69. #define xs2 s2
  70. #define xs3 s3
  71. // constants
  72. #define Sz64b 64
  73. #define Sz128b 128
  74. #define Sz256b 0x00100
  75. #define Sz512b 0x00200
  76. #define Sz1kb 0x00400
  77. #define Sz2kb 0x00800
  78. #define Sz4kb 0x01000
  79. #define Sz6kb 0x01800
  80. #define Sz8kb 0x02000
  81. #define Sz16kb 0x04000
  82. #define Sz20kb 0x05000
  83. #define Sz32kb 0x08000
  84. #define SzSALGlobal Sz16kb // 16K size
  85. #define SzSALData Sz20kb // size MCA/INIT/CMC areas
  86. #define SzPMIData Sz4kb
  87. #define SzBkpStore Sz512b
  88. #define SzStackFrame Sz256b+Sz128b
  89. #define SALGpOff 0x08
  90. #define PMIGpOff 0x0f
  91. #define SzProcMinState 0x1000 // Architected MinState+ScratchMinState Size
  92. #define aSzProcMinState 0x400 // architected MinState Size
  93. #define PSI_hLogSz 8*3 // PSI log header size
  94. #define PSI_procLogSz (8*4+16*2+48*2+64*2+128+2*1024+aSzProcMinState) // size of processor PSI log size
  95. #define PSI_platLogSz Sz4kb // size of platform log
  96. // primary and secondary debug port numbers
  97. // #define pDbgPort 0x080 // used for release code
  98. #define sDbgPort 0x0a0 // used for non-release code only
  99. // increment contstans
  100. #define Inc4 4
  101. #define Dec4 (-4)
  102. #define Inc8 8
  103. #define Dec8 (-8)
  104. #define Inc16 16
  105. #define Dec16 (-16)
  106. #define Inc32 32
  107. #define Dec32 (-32)
  108. #define Inc48 48
  109. #define Dec48 (-48)
  110. #define Inc64 64
  111. #define Dec64 (-64)
  112. // defines
  113. #define PMITimeOutValue 0x0f // PMI Time Out Value
  114. #define DestIDMask 0x0ff000000 // LID info.
  115. #define DestEIDMask 0x000ff0000
  116. #define DestIDMaskPos 24 // LID.id position
  117. #define DestEIDMaskPos 16 // LID.eid position
  118. #define IntStoreAddrMsk 0x0fee00000000 // SAPIC store address message mask
  119. #define InitDelvModeMsk 0x0500 // SAPIC INIT del. message mask
  120. #define PmiDelvModeMsk 0x0200 // SAPIC PMI del. message mask
  121. #define FixedDelvModeMsk 0x0000 // SAPIC Fixed Del Mode mask
  122. #define MCAFlagMsk 0x01 // bit1 of SalFlags, indicating that a CPU is in MCA
  123. #define OSFlagEMMsk 0x01 // bit2 of SalFlags=1/0
  124. #define PDSSize 0x02000 // Processor Data Structure memory size 8Kb
  125. #define GDataSize 0x01000 // Global Data Area Memory Size 4Kb
  126. #define FlushPMI 0x0 // PMI Flush Bit mask
  127. #define MsgPMI 0x01 // PMI due to SAPIC Msg
  128. #define PSIvLog 0x01 // PSI Structure Log Valid Bit Position
  129. #define IntrPMI 0x02 // vector for Rendez. PMI interrupt
  130. #define RendzNotRequired 0x00
  131. #define RendezOk 0x01
  132. #define RendezThruInitCombo 0x02
  133. #define MulProcInMca 0x02
  134. #define RendezFailed (-0x01)
  135. // Processor State Register Bit position value for PSR bits.
  136. #define PSRor 0
  137. #define PSRbe 1
  138. #define PSRup 2
  139. #define PSRac 3
  140. #define PSRic 13
  141. #define PSRi 14
  142. #define PSRpk 15
  143. #define PSRrv 16
  144. #define PSRdt 17
  145. #define PSRdfl 18
  146. #define PSRdfh 19
  147. #define PSRsp 20
  148. #define PSRpp 21
  149. #define PSRdi 22
  150. #define PSRsi 23
  151. #define PSRdb 24
  152. #define PSRlp 25
  153. #define PSRtb 26
  154. #define PSRrt 27
  155. // since PSR.um only starts from bit 32 and up and gets loaded that way
  156. #define PSRcpl0 32
  157. #define PSRcpl1 33
  158. #define PSRis 34
  159. #define PSRmc 35
  160. #define PSRit 36
  161. #define PSRid 37
  162. #define PSRda 38
  163. #define PSRdd 39
  164. #define PSRss 40
  165. #define PSRri0 41
  166. #define PSRri1 42
  167. #define PSRed 43
  168. #define PSRbn 44
  169. #define RSCmode 0x0003
  170. #define PSRmcMask 0x0800000000
  171. #define PSRicMask 0x02000
  172. #define PSRiMask 0x04000
  173. // RSE management registers offset
  174. #define rRSCOff 0
  175. #define rPFSOff (rRSCOff+0x08)
  176. #define rIFSOff (rPFSOff+0x08)
  177. #define rBSPStOff (rIFSOff+0x08)
  178. #define rRNATOff (rBSPStOff+0x08)
  179. #define rBSPDiffOff (rRNATOff+0x08)
  180. //********************* start of First 4K Shared Data ***************************
  181. // variable offsets used by SAL Set MC Interrupt call
  182. #define IPIVectorOff 0x00 // fix this later to 0, data area bug
  183. // MP synch. semaphores
  184. #define InMCAOff (IPIVectorOff+0x08) // byte flags per processor to indicate that it is in MC
  185. #define InRendzOff (InMCAOff+0x08)
  186. #define RendzCheckInOff (InRendzOff+0x08) // indicates that processor checkin status
  187. #define RendzResultOff (RendzCheckInOff+0x08)
  188. #define PMICheckInOff (RendzResultOff+0x08)
  189. // Platform Log valid flag bits
  190. #define PSI_vPlatLogOff (PMICheckInOff+0x08) // platform non-CMC state log flag
  191. #define PSI_cvPlatLogOff (PSI_vPlatLogOff+0x01) // platform CMC state log flag
  192. #define PSI_ivPlatLogOff (PSI_cvPlatLogOff+0x01) // platform INIT state log flag
  193. //********************* start of Next 4K block of Shared Data Area ******************
  194. // each platform log is 4kb in size (three logs here for MCA, CMC, INIT each 4x3=12Kbytes total
  195. // PSI MCA generic header field offsets from BOM; applies to PSI MemInfo and IOInfo
  196. // PSI MCA Platform Info. data area
  197. #define PSI_PlatInfoOff PSI_platLogSz
  198. #define PSI_gLogNext PSI_platLogSz // platform area starts at 4K from BOM
  199. #define PSI_gLength (PSI_gLogNext+0x08)
  200. #define PSI_gType (PSI_gLength+0x04)
  201. #define PSI_gTimeStamp (PSI_gType+0x04)
  202. // PSI INIT generic header field offsets from BOM; applies to PSI MemInfo and IOInfo
  203. // PSI INIT Platform Info. data area
  204. #define PSI_iPlatInfoOff (PSI_PlatInfoOff+PSI_platLogSz)
  205. #define PSI_igLogNext (PSI_cgLogNext+PSI_platLogSz)
  206. #define PSI_igLength (PSI_igLogNext+0x08)
  207. #define PSI_igType (PSI_igLength+0x04)
  208. #define PSI_igTimeStamp (PSI_igType+0x04)
  209. // PSI CMC generic header field offsets from BOM; applies to PSI MemInfo and IOInfo)
  210. // PSI CMC Platform Info. data area
  211. #define PSI_cPlatInfoOff (PSI_iPlatInfoOff+PSI_platLogSz)
  212. #define PSI_cgLogNext (PSI_gLogNext+PSI_platLogSz)
  213. #define PSI_cgLength (PSI_cgLogNext+0x08)
  214. #define PSI_cgType (PSI_cgLength+0x04)
  215. #define PSI_cgTimeStamp (PSI_cgType+0x04)
  216. //1******************* start of First Proc. Specific 4K block *****************
  217. // Offsets from start of MinState Area *** Start of Min State Area ***
  218. #define Min_ProcStateOff 0 // 512byte aligned always
  219. //2******************* start of First Proc. 2nd 4K block *****************
  220. // pointer to TOM is registered here by SAL malloc/init. code
  221. #define TOMPtrOff SzProcMinState // offset from min state ptr.
  222. // Mail box for software SAPIC PMI type message
  223. #define PMIMailBoxOff (TOMPtrOff+0x08) // software PMI request mailbox
  224. #define OStoPalRtnFlagOff (PMIMailBoxOff+0x01) // set by OS_MCA Call processing
  225. // processor state log valid word MCA, INIT, CMC log areas
  226. #define PSI_vProcLogOff (PMIMailBoxOff+0x10) // log valid flag for non-CMC log area
  227. #define PSI_cvProcLogOff (PSI_vProcLogOff+0x01) // log valid flag for CMC log area
  228. #define PSI_ivProcLogOff (PSI_cvProcLogOff+0x01) // log valid flag for INIT log area
  229. // processor stack frame
  230. #define StackFrameOff (PSI_vProcLogOff+0x08) //PSI_vProcLogOff+0x08
  231. // bspstore
  232. #define BL_SP_BASEOff (StackFrameOff+SzStackFrame) // stack frame size of 256 bytes
  233. #define BL_R12_BASEOff (BL_SP_BASEOff+Sz1kb+Sz512b) // assuming 1.5Kb size for BspMemory
  234. //3**************** start of First Proc. Specific PSI 4K block ****************
  235. // data structure SAL Processor-0 State Info (PSI) Structure
  236. // push header data structure above the second 4k boundary, or below the first 4k
  237. #define PSI_LogNextOff (TOMPtrOff+Sz4kb)-(PSI_hLogSz+24*8) // offset from beginning of MinState
  238. #define PSI_LengthOff (PSI_LogNextOff+0x08)
  239. #define PSI_LogTypeOff (PSI_LengthOff+0x04)
  240. #define PSI_TimeStampOff (PSI_LogTypeOff+0x04)
  241. // PSI Processor Specific Info Header
  242. #define PSI_pValidOff (PSI_TimeStampOff+0x08)
  243. // PSI Proc. State, Cache, TLB & Bus Check info.
  244. #define PSI_StatusCmdOff (PSI_pValidOff+0x08)
  245. #define PSI_CacheCheckOff (PSI_StatusCmdOff+0x08)
  246. #define PSI_CacheTarAdrOff (PSI_CacheCheckOff+0x008)
  247. #define PSI_CacheCheck1Off (PSI_CacheTarAdrOff+0x08)
  248. #define PSI_CacheTarAd1rOff (PSI_CacheCheck1Off+0x008)
  249. #define PSI_CacheCheck2Off (PSI_CacheTarAd1rOff+0x08)
  250. #define PSI_CacheTarAdr2Off (PSI_CacheCheck2Off+0x008)
  251. #define PSI_CacheCheck3Off (PSI_CacheTarAdr2Off+0x08)
  252. #define PSI_CacheTarAdr3Off (PSI_CacheCheck3Off+0x008)
  253. #define PSI_CacheCheck4Off (PSI_CacheTarAdr3Off+0x08)
  254. #define PSI_CacheTarAdr4Off (PSI_CacheCheck4Off+0x008)
  255. #define PSI_CacheCheck5Off (PSI_CacheTarAdr4Off+0x08)
  256. #define PSI_CacheTarAdr5Off (PSI_CacheCheck5Off+0x008)
  257. #define PSI_TLBCheckOff (PSI_CacheTarAdr5Off+0x008)
  258. #define PSI_BusCheckOff (PSI_TLBCheckOff+0x030)
  259. #define PSI_BusReqAdrOff (PSI_BusCheckOff+0x008)
  260. #define PSI_BusResAdrOff (PSI_BusReqAdrOff+0x008)
  261. #define PSI_BusTarAdrOff (PSI_BusResAdrOff+0x008)
  262. // PSI Static Info - 512 bytes aligned starting at 4K boundary
  263. #define PSI_MinStateOff (PSI_BusTarAdrOff+0x08)
  264. #define PSI_BankGRsOff (PSI_MinStateOff+aSzProcMinState)
  265. #define PSI_GRNaTOff (PSI_BankGRsOff+Sz128b)
  266. #define PSI_BRsOff (PSI_GRNaTOff+0x08)
  267. #define PSI_CRsOff (PSI_BRsOff+Sz64b)
  268. #define PSI_ARsOff (PSI_CRsOff+Sz1kb)
  269. #define PSI_RRsOff (PSI_ARsOff+Sz1kb)
  270. //4************ start of First Proc. Specific INIT PSI 4K block ************
  271. // data structure SAL INIT Processor-0 State Info (PSI) Structure
  272. // offset from beginning of MinState
  273. #define PSI_iLogNextOff (PSI_LogNextOff+Sz4kb)
  274. #define PSI_iLengthOff (PSI_iLogNextOff+0x08)
  275. #define PSI_iLogTypeOff (PSI_iLengthOff+0x04)
  276. #define PSI_iTimeStampOff (PSI_iLogTypeOff+0x04)
  277. // PSI Processor Specific Info Header
  278. #define PSI_ipValidOff (PSI_iTimeStampOff+0x08)
  279. // PSI Proc. State, Cache, TLB & Bus Check info.
  280. //#define PSI_iStatusCmdOff (PSI_ipValidOff+0x04)
  281. #define PSI_iStaticSizeOff (PSI_ipValidOff+0x04)
  282. // PSI Proc. State, Cache, TLB & Bus Check info.
  283. #define PSI_iStatusCmdOff (PSI_ipValidOff+0x08)
  284. #define PSI_iCacheCheckOff (PSI_iStatusCmdOff+0x08)
  285. #define PSI_iCacheTarAdrOff (PSI_iCacheCheckOff+0x008)
  286. #define PSI_iCacheCheck1Off (PSI_iCacheTarAdrOff+0x08)
  287. #define PSI_iCacheTarAd1rOff (PSI_iCacheCheck1Off+0x008)
  288. #define PSI_iCacheCheck2Off (PSI_iCacheTarAd1rOff+0x08)
  289. #define PSI_iCacheTarAdr2Off (PSI_iCacheCheck2Off+0x008)
  290. #define PSI_iCacheCheck3Off (PSI_iCacheTarAdr2Off+0x08)
  291. #define PSI_iCacheTarAdr3Off (PSI_iCacheCheck3Off+0x008)
  292. #define PSI_iCacheCheck4Off (PSI_iCacheTarAdr3Off+0x08)
  293. #define PSI_iCacheTarAdr4Off (PSI_iCacheCheck4Off+0x008)
  294. #define PSI_iCacheCheck5Off (PSI_iCacheTarAdr4Off+0x08)
  295. #define PSI_iCacheTarAdr5Off (PSI_iCacheCheck5Off+0x008)
  296. #define PSI_iTLBCheckOff (PSI_iCacheTarAdr5Off+0x008)
  297. #define PSI_iBusCheckOff (PSI_iTLBCheckOff+0x030)
  298. #define PSI_iBusReqAdrOff (PSI_iBusCheckOff+0x008)
  299. #define PSI_iBusResAdrOff (PSI_iBusReqAdrOff+0x008)
  300. #define PSI_iBusTarAdrOff (PSI_iBusResAdrOff+0x008)
  301. // PSI Static Info - 512 bytes aligned starting at 4K boundary
  302. #define PSI_iMinStateOff (PSI_iBusTarAdrOff+0x08)
  303. #define PSI_iBankGRsOff (PSI_iMinStateOff+aSzProcMinState)
  304. #define PSI_iGRNaTOff (PSI_iBankGRsOff+Sz128b)
  305. #define PSI_iBRsOff (PSI_iGRNaTOff+0x08)
  306. #define PSI_iCRsOff (PSI_iBRsOff+Sz64b)
  307. #define PSI_iARsOff (PSI_iCRsOff+Sz1kb)
  308. #define PSI_iRRsOff (PSI_iARsOff+Sz1kb)
  309. //5************ start of First Proc. Specific CMC PSI 4K block *************
  310. // data structure SAL CMC Processor State Info (PSI) Structure
  311. // offset from beginning of MinState
  312. #define PSI_cLogNextOff (PSI_iLogNextOff+Sz4kb)
  313. #define PSI_cLengthOff (PSI_cLogNextOff+0x08)
  314. #define PSI_cLogTypeOff (PSI_cLengthOff+0x04)
  315. #define PSI_cTimeStampOff (PSI_cLogTypeOff+0x04)
  316. // PSI Processor Specific Info Header
  317. #define PSI_cpValidOff (PSI_cTimeStampOff+0x08)
  318. // PSI Proc. State, Cache, TLB & Bus Check info.
  319. #define PSI_cStatusCmdOff (PSI_cpValidOff+0x08)
  320. #define PSI_cCacheCheckOff (PSI_cStatusCmdOff+0x08)
  321. #define PSI_cCacheTarAdrOff (PSI_cCacheCheckOff+0x008)
  322. #define PSI_cCacheCheck1Off (PSI_cCacheTarAdrOff+0x08)
  323. #define PSI_cCacheTarAd1rOff (PSI_cCacheCheck1Off+0x008)
  324. #define PSI_cCacheCheck2Off (PSI_cCacheTarAd1rOff+0x08)
  325. #define PSI_cCacheTarAdr2Off (PSI_cCacheCheck2Off+0x008)
  326. #define PSI_cCacheCheck3Off (PSI_cCacheTarAdr2Off+0x08)
  327. #define PSI_cCacheTarAdr3Off (PSI_cCacheCheck3Off+0x008)
  328. #define PSI_cCacheCheck4Off (PSI_cCacheTarAdr3Off+0x08)
  329. #define PSI_cCacheTarAdr4Off (PSI_cCacheCheck4Off+0x008)
  330. #define PSI_cCacheCheck5Off (PSI_cCacheTarAdr4Off+0x08)
  331. #define PSI_cCacheTarAdr5Off (PSI_cCacheCheck5Off+0x008)
  332. #define PSI_cTLBCheckOff (PSI_cCacheTarAdr5Off+0x008)
  333. #define PSI_cBusCheckOff (PSI_cTLBCheckOff+0x030)
  334. #define PSI_cBusReqAdrOff (PSI_cBusCheckOff+0x008)
  335. #define PSI_cBusResAdrOff (PSI_cBusReqAdrOff+0x008)
  336. #define PSI_cBusTarAdrOff (PSI_cBusResAdrOff+0x008)
  337. // PSI Static Info - 512 bytes aligned starting at 4K boundary
  338. #define PSI_cMinStateOff (PSI_cBusTarAdrOff+0x08)
  339. #define PSI_cBankGRsOff (PSI_cMinStateOff+aSzProcMinState)
  340. #define PSI_cGRNaTOff (PSI_cBankGRsOff+Sz128b)
  341. #define PSI_cBRsOff (PSI_cGRNaTOff+0x08)
  342. #define PSI_cCRsOff (PSI_cBRsOff+Sz64b)
  343. #define PSI_cARsOff (PSI_cCRsOff+Sz1kb)
  344. #define PSI_cRRsOff (PSI_cARsOff+Sz1kb)
  345. //6************ start of First Proc. Specific PMI 4K block *************
  346. //PMI Data Area 4 Kbytes, offsets from MinState Ptr.
  347. #define PMI_BL_SP_BASEOff SzSALData
  348. #define PmiStackFrameOff (PMI_BL_SP_BASEOff+SzBkpStore)
  349. #define PMIGlobalDataOff (PmiStackFrameOff+SzStackFrame)
  350. #define TOM TOMPtrOff
  351. // returns Entry Points in regX for whatever SAL/PAL procs, ProcNum value etc.
  352. #define GetEPs(NameOff,regX,regY) \
  353. add regX= TOMPtrOff,regX;;\
  354. ld8 regY = [regX];;\
  355. movl regX=NameOff;;\
  356. add regY = regX,regY;;\
  357. ld8 regX = [regY];;
  358. #define GetEPsRAM(NameOff,regX,rBOM) \
  359. movl regX= SALDataBlockLength;;\
  360. add regX = regX,rBOM;\
  361. movl rBOM=NameOff;; \
  362. add regX = regX,rBOM;;\
  363. ld8 regX = [regX];;
  364. // calculates absolute physical ptr to variable from offset and base
  365. #define GetAbsPtr(Var,RegX,BASE) \
  366. movl RegX=Var##Off##;;\
  367. add RegX=RegX, BASE;;
  368. // input regX=XR0, returns Bottom of Memory (BOM) TOM-256k in regX
  369. #define GetBOM(regX,regY) \
  370. add regX= TOM,regX;;\
  371. ld8 regX=[regX];; \
  372. movl regY=SALDataBlockLength;; \
  373. sub regX=regX,regY;;
  374. // input regX=XR0, returns Top of Memory (TOM) in regX
  375. #define GetTOM(regX) \
  376. add regX= TOM,regX;;\
  377. ld8 regX=[regX];;
  378. // returns the pointer to "this" processor MinState Area beginning in regX
  379. // bom is preserved
  380. #define GetMinStateHead(regX,regY,bom,ProcX) \
  381. movl regX=SzPMIData+SzSALData;; \
  382. shl regX=regX, ProcX;; \
  383. movl ProcX=SzPMIData+SzSALData;; \
  384. sub regX=regX,ProcX;; \
  385. movl regY=SzSALGlobal;; \
  386. add regX=regY,regX;; \
  387. add regX=regX,bom;;
  388. // the save and restore macros saves R17-R19 during MCA and INIT before any
  389. // external PAL and SAL calls
  390. #define SaveRs(regX,regY,regZ) \
  391. mov xs0=regX;\
  392. mov xs1=regY; \
  393. mov xs2=regZ
  394. #define ResRs(regX,regY,regZ) \
  395. mov regX=xs0;\
  396. mov regY=xs1; \
  397. mov regZ=xs2;;
  398. //this macro manages the stack frame for the new context, by saving the previous one
  399. #define SwIntCxt(regX,pStkFrm,pBspStore) \
  400. ;; \
  401. mov regX=ar##.##rsc;; \
  402. st8 [pStkFrm]=regX,Inc8;; \
  403. mov regX=ar##.##pfs;; \
  404. st8 [pStkFrm]=regX,Inc8; \
  405. cover ;;\
  406. mov regX=cr##.##ifs;; \
  407. st8 [pStkFrm]=regX,Inc8;; \
  408. mov regX=ar##.##bspstore;; \
  409. st8 [pStkFrm]=regX,Inc8;; \
  410. mov regX=ar##.##rnat;; \
  411. st8 [pStkFrm]=regX,Inc8; \
  412. mov ar##.##bspstore=pBspStore;; \
  413. mov regX=ar##.##bsp;; \
  414. sub regX=regX,pBspStore;;\
  415. st8 [pStkFrm]=regX,Inc8
  416. //this macro restores the stack frame of the previous context
  417. #define RtnIntCxt(PSRMaskReg,regX,pStkFrm) \
  418. ;; \
  419. alloc regX=ar.pfs,0,0,0,0;\
  420. add pStkFrm=rBSPDiffOff,pStkFrm;;\
  421. ld8 regX=[pStkFrm];; \
  422. shl regX=regX,16;;\
  423. mov ar##.##rsc=regX;; \
  424. loadrs;;\
  425. add pStkFrm=-rBSPDiffOff+rBSPStOff,pStkFrm;;\
  426. ld8 regX=[pStkFrm];; \
  427. mov ar##.##bspstore=regX;; \
  428. add pStkFrm=-rBSPStOff+rRNATOff,pStkFrm;;\
  429. ld8 regX=[pStkFrm];; \
  430. mov ar##.##rnat=regX;;\
  431. add pStkFrm=-rRNATOff+rPFSOff,pStkFrm;;\
  432. ld8 regX=[pStkFrm];; \
  433. mov ar##.##pfs=regX;\
  434. add pStkFrm=-rPFSOff+rIFSOff,pStkFrm;;\
  435. ld8 regX=[pStkFrm];; \
  436. mov cr##.##ifs=regX;\
  437. add pStkFrm=-rIFSOff+rRSCOff,pStkFrm;;\
  438. ld8 regX=[pStkFrm];; \
  439. mov ar##.##rsc=regX ;\
  440. add pStkFrm=-rRSCOff,pStkFrm;\
  441. mov regX=cr.ipsr;;\
  442. st8 [pStkFrm]=regX,Inc8;\
  443. mov regX=cr.iip;;\
  444. st8 [pStkFrm]=regX,-Inc8;\
  445. mov regX=psr;;\
  446. or regX=regX,PSRMaskReg;;\
  447. mov cr.ipsr=regX;;\
  448. mov regX=ip;;\
  449. add regX=0x30,regX;;\
  450. mov cr.iip=regX;;\
  451. rfi;;\
  452. ld8 regX=[pStkFrm],Inc8;;\
  453. mov cr.ipsr=regX;;\
  454. ld8 regX=[pStkFrm];;\
  455. mov cr.iip=regX
  456. //these macros do left and right rotate respectively.
  457. #define lRotate(regX, regCnt,nLabel) \
  458. mov ar##.##lc=regCnt;\
  459. nLabel:;\
  460. shrp regX=regX,regX,63;\
  461. br##.##cloop##.##dpnt nLabel
  462. #define rRotate(regX, regCnt,nLabel) \
  463. mov ar##.##lc=regCnt;\
  464. nLabel:;\
  465. shrp regX=regX,regX,1;\
  466. br##.##cloop##.##dpnt nLabel
  467. // macro increments pointer in regX by (4Kbytes x regCnt)
  468. #define Mul(regX, regCnt,regI) \
  469. cmp.eq.unc pt0,p0=0x02, regCnt;\
  470. movl regI=Sz4kb;;\
  471. shl regI=regI,regCnt;;\
  472. adds regI=-Sz4kb,regI;;\
  473. (pt0) adds regI=-Sz4kb,regI;;\
  474. add regX=regX,regI
  475. // this macro loads the return pointer in b0 during static procedure calls
  476. // rLabel=label after macro, pLabel=label prior to this macro
  477. #define SetupBrFrame(regX, regY, regZ, pLabel,rLabel) \
  478. mov regX=ip;\
  479. movl regY=pLabel;\
  480. movl regZ=rLabel;;\
  481. sub regZ=regZ,regY;;\
  482. add regX=regX,regZ;;\
  483. mov b0=regX
  484. //this macro manages the stack frame for the new context, by saving the previous one
  485. #define nSwIntCxt(regX,pStkFrm,pBspStore) \
  486. mov regX=ar##.##rsc; \
  487. st8 [pStkFrm]=regX,Inc8; \
  488. mov regX=ar##.##pfs; \
  489. st8 [pStkFrm]=regX,Inc8; \
  490. cover;;\
  491. mov regX=ar##.##ifs; \
  492. st8 [pStkFrm]=regX,Inc8; \
  493. mov regX=ar##.##bspstore; \
  494. st8 [pStkFrm]=regX,Inc8; \
  495. mov regX=ar##.##rnat; \
  496. st8 [pStkFrm]=regX,Inc8; \
  497. mov ar##.##bspstore=pBspStore; \
  498. mov regX=ar##.##bsp; \
  499. st8 [pStkFrm]=regX,Inc8;\
  500. mov regX=b0;\
  501. st8 [pStkFrm]=regX,Inc8
  502. //this macro restores the stack frame of the previous context
  503. #define nRtnIntCxt(regX,pStkFrm) \
  504. alloc regX=ar.pfs,0,0,0,0;\
  505. ld8 regX=[pStkFrm],Inc8; \
  506. mov ar##.##bspstore=regX; \
  507. ld8 regX=[pStkFrm],Inc8; \
  508. mov ar##.##rnat=regX
  509. #define GLOBAL_FUNCTION(Function) \
  510. .##type Function, @function; \
  511. .##global Function
  512. #define WRITE_MASK (0x8000000000000000) // RTC IO port write mask
  513. //
  514. // GetProcessorLidBasedEntry()
  515. // - macro to setup register regX with arrary entry, indexed with LID.ID field.
  516. //
  517. #define GetProcessorLidBasedEntry(regX,regY,szOffset,VarName,lpName) \
  518. mov regY=ar##.##lc;\
  519. mov regX=cr##.##lid;;\
  520. extr##.##u regX=regX,DestIDMaskPos,8;;\
  521. mov ar##.##lc=regX;;\
  522. movl regX=VarName;;\
  523. lpName##:##;\
  524. addl regX=szOffset,regX;\
  525. br##.##cloop##.##dpnt lpName;;\
  526. mov ar##.##lc=regY;\
  527. addl regX=-szOffset, regX;;