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.

453 lines
13 KiB

  1. //
  2. //
  3. // Module name
  4. // i64fw.h
  5. // Author
  6. // Arad Rostampour ([email protected]) Mar-22-99
  7. // Description
  8. // Defines SAL/PAL data structures and prototypes
  9. //
  10. #ifndef _I64FW_H_
  11. #define _I64FW_H_
  12. #define SET_ITR_AND_DTR 3
  13. #define SET_DTR_ONLY 2
  14. #define SET_ITR_ONLY 1
  15. // TR for PAL is:
  16. // ed=1, PPN=0 (to be ORed in), RWX privledge only for ring 0, dirty/accessed bit set,
  17. // cacheable memory, present bit set.
  18. #define HAL_SAL_PAL_TR_ATTRIB TR_VALUE(1,0,3,0,1,1,0,1)
  19. #define HAL_TR_ATTRIBUTE_PPN_MASK 0x0000FFFFFFFFF000I64
  20. #define HAL_RID_MASK 0x00000000FFFFFF00I64
  21. #define HAL_RR_PS_VE 0x69
  22. #define HAL_ITIR_PPN_MASK 0x7FFF000000000000I64
  23. #define PAL_HIGHEST_STATIC_FUNCTION_ID 255
  24. #define REGULAR_MEMORY 0
  25. #define PAL_CODE_MEM 1
  26. #define SAL_CODE_MEM 4
  27. #define SAL_DATA_MEM 5
  28. #define FW_RESERVED 12
  29. #define FIRMWARE_CODE 4
  30. #define FW_SAL_PAL 0
  31. #define OEM_ID_LENGTH RTL_NUMBER_OF_FIELD( SST_HEADER, OemId )
  32. #define OEM_PRODUCT_ID_LENGTH RTL_NUMBER_OF_FIELD( SST_HEADER, ProductId )
  33. #define MASK_16KB 0xffffffffffffc000I64
  34. #define MASK_16MB 0xffffffffff000000I64
  35. #define SIZE_IN_BYTES_16KB 16384
  36. //
  37. // Define the size of the stack and backing store needed by calls to the
  38. // PAL and SAL. PAL needs 8KB of each and SAL needs 16KB of each so we'll
  39. // set this value to the larger of the two. The EFI specification defers
  40. // to the SAL specification when discussing stack and backing store needs
  41. // for its runtime services so these stack sizes should accomodate EFI calls
  42. // as well.
  43. //
  44. #define HALP_FW_MEMORY_STACK_SIZE 16384
  45. #define HALP_FW_BACKING_STORE_SIZE 16384
  46. //
  47. // The stack and backing store for physical mode firmware calls are allocated
  48. // in one large block. These macros extract the top of the stack and the
  49. // bottom of the backing store, respectively, given the base of the combined
  50. // block.
  51. //
  52. #define GET_FW_STACK_POINTER(StackBase) \
  53. ((StackBase) + HALP_FW_MEMORY_STACK_SIZE - 16)
  54. #define GET_FW_BACKING_STORE_POINTER(StackBase) \
  55. ((StackBase) + HALP_FW_MEMORY_STACK_SIZE)
  56. // SAL_STATUS and PAL_STATUS is a 64-bit copy of the value in ReturnValues[0]
  57. typedef LONGLONG SAL_STATUS;
  58. typedef LONGLONG PAL_STATUS;
  59. // SAL and PAL return up to 4 64-bit return values; HalpSalCall() and
  60. // HalpPalCall() will return a pointer to this structure
  61. typedef struct _SAL_PAL_RETURN_VALUES {
  62. LONGLONG ReturnValues[4];
  63. } SAL_PAL_RETURN_VALUES, *PSAL_PAL_RETURN_VALUES;
  64. typedef struct _HAL_PLATFORM_ID {
  65. ANSI_STRING VendorId;
  66. ANSI_STRING DeviceId;
  67. } HAL_PLATFORM_ID, *PHAL_PLATFORM_ID;
  68. typedef struct _SST_MEMORY_LIST {
  69. ULONGLONG PhysicalAddress;
  70. ULONGLONG VirtualAddress;
  71. ULONGLONG Length;
  72. UCHAR NeedVaReg;
  73. struct _SST_MEMORY_LIST *Next;
  74. } SST_MEMORY_LIST, *PSST_MEMORY_LIST;
  75. // Function Prototypes: SAL takes 8 arguments, PAL takes 4
  76. VOID
  77. HalpSetupTranslationRegisters(
  78. ULONGLONG VAddr,
  79. ULONGLONG PAddr,
  80. ULONG PageSize,
  81. ULONG TrNumber,
  82. ULONG RidValue,
  83. ULONG Mode
  84. );
  85. SAL_STATUS
  86. HalpSalCall(
  87. IN LONGLONG FunctionId,
  88. IN LONGLONG Arg1,
  89. IN LONGLONG Arg2,
  90. IN LONGLONG Arg3,
  91. IN LONGLONG Arg4,
  92. IN LONGLONG Arg5,
  93. IN LONGLONG Arg6,
  94. IN LONGLONG Arg7,
  95. OUT PSAL_PAL_RETURN_VALUES ReturnValues
  96. );
  97. PAL_STATUS
  98. HalpPalCall(
  99. IN LONGLONG FunctionId,
  100. IN LONGLONG Arg1,
  101. IN LONGLONG Arg2,
  102. IN LONGLONG Arg3,
  103. OUT PSAL_PAL_RETURN_VALUES ReturnValues
  104. );
  105. //
  106. // Define a function prototype for the virtual and physical mode SAL call
  107. // dispatchers.
  108. //
  109. typedef
  110. SAL_PAL_RETURN_VALUES
  111. (*HALP_SAL_PROC) (
  112. LONGLONG FunctionId,
  113. LONGLONG Arg1,
  114. LONGLONG Arg2,
  115. LONGLONG Arg3,
  116. LONGLONG Arg4,
  117. LONGLONG Arg5,
  118. LONGLONG Arg6,
  119. LONGLONG Arg7
  120. );
  121. SAL_PAL_RETURN_VALUES
  122. HalpSalProc(
  123. LONGLONG FunctionId,
  124. LONGLONG Arg1,
  125. LONGLONG Arg2,
  126. LONGLONG Arg3,
  127. LONGLONG Arg4,
  128. LONGLONG Arg5,
  129. LONGLONG Arg6,
  130. LONGLONG Arg7
  131. );
  132. SAL_PAL_RETURN_VALUES
  133. HalpSalProcPhysical(
  134. LONGLONG FunctionId,
  135. LONGLONG Arg1,
  136. LONGLONG Arg2,
  137. LONGLONG Arg3,
  138. LONGLONG Arg4,
  139. LONGLONG Arg5,
  140. LONGLONG Arg6,
  141. LONGLONG Arg7
  142. );
  143. SAL_PAL_RETURN_VALUES
  144. HalpSalProcPhysicalEx(
  145. LONGLONG FunctionId,
  146. LONGLONG Arg1,
  147. LONGLONG Arg2,
  148. LONGLONG Arg3,
  149. LONGLONG Arg4,
  150. LONGLONG Arg5,
  151. LONGLONG Arg6,
  152. LONGLONG Arg7,
  153. LONGLONG StackPointer,
  154. LONGLONG BackingStorePointer
  155. );
  156. SAL_PAL_RETURN_VALUES
  157. HalpPalProc(
  158. LONGLONG FunctionId,
  159. LONGLONG Arg1,
  160. LONGLONG Arg2,
  161. LONGLONG Arg3
  162. );
  163. SAL_PAL_RETURN_VALUES
  164. HalpPalProcPhysicalStatic(
  165. LONGLONG FunctionId,
  166. LONGLONG Arg1,
  167. LONGLONG Arg2,
  168. LONGLONG Arg3
  169. );
  170. SAL_PAL_RETURN_VALUES
  171. HalpPalProcPhysicalStacked(
  172. LONGLONG FunctionId,
  173. LONGLONG Arg1,
  174. LONGLONG Arg2,
  175. LONGLONG Arg3,
  176. LONGLONG StackPointer,
  177. LONGLONG BackingStorePointer
  178. );
  179. NTSTATUS
  180. HalpGetPlatformId(
  181. OUT PHAL_PLATFORM_ID PlatformId
  182. );
  183. VOID
  184. InternalTestSal(
  185. IN LONGLONG FunctionId,
  186. IN LONGLONG Arg1,
  187. IN LONGLONG Arg2,
  188. IN LONGLONG Arg3,
  189. IN LONGLONG Arg4,
  190. IN LONGLONG Arg5,
  191. IN LONGLONG Arg6,
  192. IN LONGLONG Arg7,
  193. OUT PSAL_PAL_RETURN_VALUES ReturnValues
  194. );
  195. VOID
  196. InternalTestPal(
  197. IN LONGLONG FunctionId,
  198. IN LONGLONG Arg1,
  199. IN LONGLONG Arg2,
  200. IN LONGLONG Arg3,
  201. OUT PSAL_PAL_RETURN_VALUES ReturnValues
  202. );
  203. // For SAL cache flush
  204. #define FLUSH_INSTRUCTION_CACHE 1
  205. #define FLUSH_DATA_CACHE 2
  206. #define FLUSH_INSTRUCTION_AND_DATA_CACHE 3
  207. #define FLUSH_COHERENT 4
  208. // iA-64 defined SAL function IDs in hex format as in the SAL spec
  209. #define SAL_SET_VECTORS 0x01000000I64
  210. #define SAL_GET_STATE_INFO 0x01000001I64
  211. #define SAL_GET_STATE_INFO_SIZE 0x01000002I64
  212. #define SAL_CLEAR_STATE_INFO 0x01000003I64
  213. #define SAL_MC_RENDEZ 0x01000004I64
  214. #define SAL_MC_SET_PARAMS 0x01000005I64
  215. #define SAL_REGISTER_VIRTUAL_ADDR 0x01000050I64
  216. #define SAL_REGISTER_PHYSICAL_ADDR 0x01000006I64
  217. #define SAL_CACHE_FLUSH 0x01000008I64
  218. #define SAL_CACHE_INIT 0x01000009I64
  219. #define SAL_PCI_CONFIG_READ 0x01000010I64
  220. #define SAL_PCI_CONFIG_WRITE 0x01000011I64
  221. #define SAL_FREQ_BASE 0x01000012I64
  222. #define SAL_UPDATE_PAL 0x01000020I64
  223. // iA-64 defined SAL return values
  224. #define SAL_STATUS_SUCCESS 0I64
  225. #define SAL_STATUS_SUCCESS_WITH_OVERFLOW 1I64
  226. #define SAL_STATUS_SUCCESS_MORE_RECORDS 3I64
  227. #define SAL_STATUS_NOT_IMPLEMENTED -1I64
  228. #define SAL_STATUS_INVALID_ARGUMENT -2I64
  229. #define SAL_STATUS_ERROR -3I64
  230. #define SAL_STATUS_VA_NOT_REGISTERED -4I64
  231. #define SAL_STATUS_NO_INFORMATION_AVAILABLE -5I64
  232. #define SAL_STATUS_INSUFFICIENT_NVM_MEMORY -6I64
  233. #define SAL_STATUS_INSUFFICIENT_SCRATCH_BUFFER -7I64
  234. #define SAL_STATUS_INVALID_INTERRUPT_VECTOR -8I64
  235. #define SAL_STATUS_PARTITION_TYPE_EXISTS -9I64
  236. #define SAL_STATUS_REQUESTED_MEMORY_UNAVAILABLE -9I64
  237. #define SAL_STATUS_UNABLE_TO_WRITE_NVM -10I64
  238. #define SAL_STATUS_INVALID_PARTITION_TYPE -11I64
  239. #define SAL_STATUS_INVALID_NVM_OBJECT_ID -12I64
  240. #define SAL_STATUS_NVM_OBJECT_MAXIMUM_PARITIONS -13I64
  241. #define SAL_STATUS_INSUFFICIENT_SPACE_FOR_WRITE -14I64
  242. #define SAL_STATUS_INSUFFICIENT_SPACE_FOR_READ -15I64
  243. #define SAL_STATUS_SCRATCH_BUFFER_REQUIRED -16I64
  244. #define SAL_STATUS_INSUFFICIENT_NVM_SPACE_FOR_SUBFUNCTION -17I64
  245. #define SAL_STATUS_INVALID_PARTITION_VALUE -18I64
  246. #define SAL_STATUS_RECORD_ORIENTED_IO_NOT_SUPPORTED -19I64
  247. #define SAL_STATUS_BAD_RECORD_FORMAT_OR_KEYWORD_VARIABLE -20I64
  248. #define SAL_SUCCESSFUL( /* SAL_PAL_RETURN_VALUE */ _rv ) (((_rv).ReturnValues[0]) >= (LONGLONG)0)
  249. //
  250. // SAL descriptor types
  251. //
  252. typedef enum {
  253. SAL_PAL_ENTRY_POINT_TYPE = 0,
  254. SST_MEMORY_DESCRIPTOR_TYPE,
  255. PLATFORM_FEATURES_TYPE,
  256. TRANSLATION_REGISTER_TYPE,
  257. PTC_COHERENCE_DOMAIN_TYPE,
  258. AP_WAKEUP_DESCRIPTOR_TYPE
  259. };
  260. //
  261. // IA64 PAL: PAL_VERSION
  262. //
  263. typedef union _PAL_VERSION_STRUCT {
  264. struct {
  265. UCHAR PAL_B_Revision;
  266. UCHAR PAL_B_Model;
  267. UCHAR PAL_Reserved1;
  268. UCHAR PAL_Vendor;
  269. UCHAR PAL_A_Revision;
  270. UCHAR PAL_A_Model;
  271. UCHAR PAL_Reserved2[2];
  272. };
  273. ULONGLONG ReturnValue;
  274. }PAL_VERSION_STRUCT, *PPAL_VERSION_STRUCT;
  275. //
  276. // IA64 SAL: SAL_REVISION definitions
  277. //
  278. typedef union _SAL_REVISION {
  279. USHORT Revision; // Major and Minor revision:
  280. struct {
  281. UCHAR Minor; // Byte0: Minor.
  282. UCHAR Major; // Byte1: Major.
  283. };
  284. } SAL_REVISION, *PSAL_REVISION;
  285. #define HALP_SAL_REVISION_2_90 0x0290 /* v2.9 */
  286. #define HALP_SAL_REVISION_MAX 0xffff
  287. //
  288. // Format of the SAL System Table (SST) Header. SAL Specs July 2000, Revision: 2.9.
  289. // The SST is followed by a variable number of entries with varying length.
  290. //
  291. typedef struct _SST_HEADER {
  292. ULONG Signature;
  293. ULONG Length;
  294. USHORT SalRev;
  295. USHORT EntryCount;
  296. UCHAR CheckSum;
  297. UCHAR Reserved1[7];
  298. USHORT Sal_A_Version;
  299. USHORT Sal_B_Version;
  300. UCHAR OemId[32];
  301. UCHAR ProductId[32];
  302. UCHAR Reserved2[8];
  303. } SST_HEADER, *PSST_HEADER;
  304. //
  305. // Global Data used by the SAL/PAL support routines
  306. //
  307. // _HALP_SAL_PAL_DATA.Flags:
  308. #define HALP_SALPAL_FIX_MCE_LOG_ID 0x0001
  309. #define HALP_SALPAL_FIX_MP_SAFE 0x0002
  310. #define HALP_SALPAL_CMC_BROKEN 0x0004
  311. #define HALP_SALPAL_CPE_BROKEN 0x0008
  312. typedef struct _HALP_SAL_PAL_DATA {
  313. PSST_HEADER SalSystemTable;
  314. ULONGLONG PalTrBase;
  315. ULONGLONG PalTrSize;
  316. NTSTATUS Status;
  317. SAL_REVISION SalRevision; // Copy of SalSystemTable.SalRev in case we unmap SST.
  318. USHORT Flags;
  319. PAL_VERSION_STRUCT PalVersion;
  320. PUCHAR SmBiosVersion;
  321. ULONGLONG Reserved[4];
  322. } HALP_SAL_PAL_DATA, *PHALP_SAL_PAL_DATA;
  323. #define SMBIOS_STRUCT_HEADER_TYPE_FIELD 0
  324. #define SMBIOS_STRUCT_HEADER_LENGTH_FIELD 1
  325. #define SMBIOS_STRUCT_HEADER_HANDLE_FIELD 2
  326. #define SMBIOS_TYPE0_STRUCT_BIOSVER_FIELD 5
  327. //
  328. // Listing of Descriptors in the SAL System Table and their formats
  329. //
  330. typedef struct _SAL_PAL_ENTRY_POINT {
  331. UCHAR EntryType;
  332. UCHAR Reserved0[7];
  333. ULONGLONG PalEntryPoint;
  334. ULONGLONG SalEntryPoint;
  335. ULONGLONG GlobalPointer;
  336. UCHAR Reserved1[16];
  337. } SAL_PAL_ENTRY_POINT, *PSAL_PAL_ENTRY_POINT;
  338. typedef struct _SST_MEMORY_DESCRIPTOR {
  339. UCHAR EntryType;
  340. UCHAR NeedVaReg;
  341. UCHAR CurrentAttribute;
  342. UCHAR PageAccessRights;
  343. UCHAR SupportedAttribute;
  344. UCHAR Reserved1[1];
  345. UCHAR MemoryType;
  346. UCHAR MemoryUsage;
  347. ULONGLONG MemoryAddress;
  348. ULONG Length;
  349. UCHAR Reserved[4];
  350. UCHAR OemReserved[8];
  351. } SST_MEMORY_DESCRIPTOR, *PSST_MEMORY_DESCRIPTOR;
  352. typedef struct _PLATFORM_FEATURES {
  353. UCHAR EntryType;
  354. UCHAR FeatureList;
  355. UCHAR Reserved[14];
  356. } PLATFORM_FEATURES, *PPLATFORM_FEATURES;
  357. typedef struct _PTC_COHERENCE_DOMAIN {
  358. UCHAR EntryType;
  359. UCHAR Reserved[3];
  360. ULONG NumberOfDomains;
  361. ULONGLONG CoherenceDomainInfo;
  362. } PTC_COHERENCE_DOMAIN, *PPTC_COHERENCE_DOMAIN;
  363. typedef struct _COHERENCE_DOMAIN_INFO {
  364. ULONGLONG NumberOfProcessors;
  365. ULONGLONG LocalIdRegisters;
  366. } COHERENCE_DOMAIN_INFO, *PCOHERENCE_DOMAIN_INFO;
  367. typedef struct _AP_WAKEUP_DESCRIPTOR {
  368. UCHAR EntryType;
  369. UCHAR WakeupMechanism;
  370. UCHAR Reserved[6];
  371. ULONGLONG WakeupVector;
  372. } AP_WAKEUP_DESCRIPTOR, *PAP_WAKEUP_DESCRIPTOR;
  373. typedef struct _TRANSLATION_REGISTER {
  374. UCHAR EntryType;
  375. UCHAR TRType;
  376. UCHAR TRNumber;
  377. UCHAR Reserved1[5];
  378. ULONGLONG VirtualAddress;
  379. ULONGLONG PageSize;
  380. UCHAR Reserved2[8];
  381. } TRANSLATION_REGISTER, *PTRANSLATION_REGISTER;
  382. #endif // _I64FW_H_