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.

714 lines
17 KiB

  1. #ifndef _EFI_API_H
  2. #define _EFI_API_H
  3. /*++
  4. Copyright (c) 1998 Intel Corporation
  5. Module Name:
  6. efiapi.h
  7. Abstract:
  8. Global EFI runtime & boot service interfaces
  9. Revision History
  10. --*/
  11. /*
  12. * EFI Specification Revision
  13. */
  14. #define EFI_SPECIFICATION_MAJOR_REVISION 0
  15. #define EFI_SPECIFICATION_MINOR_REVISION 99
  16. /*
  17. * Declare forward referenced data structures
  18. */
  19. INTERFACE_DECL(_EFI_SYSTEM_TABLE);
  20. /*
  21. * EFI Memory
  22. */
  23. typedef
  24. EFI_STATUS
  25. (EFIAPI *EFI_ALLOCATE_PAGES) (
  26. IN EFI_ALLOCATE_TYPE Type,
  27. IN EFI_MEMORY_TYPE MemoryType,
  28. IN UINTN NoPages,
  29. OUT EFI_PHYSICAL_ADDRESS *Memory
  30. );
  31. typedef
  32. EFI_STATUS
  33. (EFIAPI *EFI_FREE_PAGES) (
  34. IN EFI_PHYSICAL_ADDRESS Memory,
  35. IN UINTN NoPages
  36. );
  37. typedef
  38. EFI_STATUS
  39. (EFIAPI *EFI_GET_MEMORY_MAP) (
  40. IN OUT UINTN *MemoryMapSize,
  41. IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap,
  42. OUT UINTN *MapKey,
  43. OUT UINTN *DescriptorSize,
  44. OUT UINT32 *DescriptorVersion
  45. );
  46. #define NextMemoryDescriptor(Ptr,Size) ((EFI_MEMORY_DESCRIPTOR *) (((UINT8 *) Ptr) + Size))
  47. typedef
  48. EFI_STATUS
  49. (EFIAPI *EFI_ALLOCATE_POOL) (
  50. IN EFI_MEMORY_TYPE PoolType,
  51. IN UINTN Size,
  52. OUT VOID **Buffer
  53. );
  54. typedef
  55. EFI_STATUS
  56. (EFIAPI *EFI_FREE_POOL) (
  57. IN VOID *Buffer
  58. );
  59. typedef
  60. EFI_STATUS
  61. (EFIAPI *EFI_SET_VIRTUAL_ADDRESS_MAP) (
  62. IN UINTN MemoryMapSize,
  63. IN UINTN DescriptorSize,
  64. IN UINT32 DescriptorVersion,
  65. IN EFI_MEMORY_DESCRIPTOR *VirtualMap
  66. );
  67. #define EFI_OPTIONAL_PTR 0x00000001
  68. #define EFI_INTERNAL_FNC 0x00000002 /* Pointer to internal runtime fnc */
  69. #define EFI_INTERNAL_PTR 0x00000004 /* Pointer to internal runtime data */
  70. typedef
  71. EFI_STATUS
  72. (EFIAPI *EFI_CONVERT_POINTER) (
  73. IN UINTN DebugDisposition,
  74. IN OUT VOID **Address
  75. );
  76. /*
  77. * EFI Events
  78. */
  79. #define EVT_TIMER 0x80000000
  80. #define EVT_RUNTIME 0x40000000
  81. #define EVT_RUNTIME_CONTEXT 0x20000000
  82. #define EVT_NOTIFY_WAIT 0x00000100
  83. #define EVT_NOTIFY_SIGNAL 0x00000200
  84. #define EVT_SIGNAL_EXIT_BOOT_SERVICES 0x00000201
  85. #define EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE 0x60000202
  86. #define EVT_EFI_SIGNAL_MASK 0x000000FF
  87. #define EVT_EFI_SIGNAL_MAX 2
  88. typedef
  89. VOID
  90. (EFIAPI *EFI_EVENT_NOTIFY) (
  91. IN EFI_EVENT Event,
  92. IN VOID *Context
  93. );
  94. typedef
  95. EFI_STATUS
  96. (EFIAPI *EFI_CREATE_EVENT) (
  97. IN UINT32 Type,
  98. IN EFI_TPL NotifyTpl,
  99. IN EFI_EVENT_NOTIFY NotifyFunction,
  100. IN VOID *NotifyContext,
  101. OUT EFI_EVENT *Event
  102. );
  103. typedef enum {
  104. TimerCancel,
  105. TimerPeriodic,
  106. TimerRelative,
  107. TimerTypeMax
  108. } EFI_TIMER_DELAY;
  109. typedef
  110. EFI_STATUS
  111. (EFIAPI *EFI_SET_TIMER) (
  112. IN EFI_EVENT Event,
  113. IN EFI_TIMER_DELAY Type,
  114. IN UINT64 TriggerTime
  115. );
  116. typedef
  117. EFI_STATUS
  118. (EFIAPI *EFI_SIGNAL_EVENT) (
  119. IN EFI_EVENT Event
  120. );
  121. typedef
  122. EFI_STATUS
  123. (EFIAPI *EFI_WAIT_FOR_EVENT) (
  124. IN UINTN NumberOfEvents,
  125. IN EFI_EVENT *Event,
  126. OUT UINTN *Index
  127. );
  128. typedef
  129. EFI_STATUS
  130. (EFIAPI *EFI_CLOSE_EVENT) (
  131. IN EFI_EVENT Event
  132. );
  133. typedef
  134. EFI_STATUS
  135. (EFIAPI *EFI_CHECK_EVENT) (
  136. IN EFI_EVENT Event
  137. );
  138. /*
  139. * Task priority level
  140. */
  141. #define TPL_APPLICATION 4
  142. #define TPL_CALLBACK 8
  143. #define TPL_NOTIFY 16
  144. #define TPL_HIGH_LEVEL 31
  145. typedef
  146. EFI_TPL
  147. (EFIAPI *EFI_RAISE_TPL) (
  148. IN EFI_TPL NewTpl
  149. );
  150. typedef
  151. VOID
  152. (EFIAPI *EFI_RESTORE_TPL) (
  153. IN EFI_TPL OldTpl
  154. );
  155. /*
  156. * EFI platform varibles
  157. */
  158. #define EFI_GLOBAL_VARIABLE \
  159. { 0x8BE4DF61, 0x93CA, 0x11d2, 0xAA, 0x0D, 0x00, 0xE0, 0x98, 0x03, 0x2B, 0x8C }
  160. /* Variable attributes */
  161. #define EFI_VARIABLE_NON_VOLATILE 0x00000001
  162. #define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002
  163. #define EFI_VARIABLE_RUNTIME_ACCESS 0x00000004
  164. typedef
  165. EFI_STATUS
  166. (EFIAPI *EFI_GET_VARIABLE) (
  167. IN CHAR16 *VariableName,
  168. IN EFI_GUID *VendorGuid,
  169. OUT UINT32 *Attributes OPTIONAL,
  170. IN OUT UINTN *DataSize,
  171. OUT VOID *Data
  172. );
  173. typedef
  174. EFI_STATUS
  175. (EFIAPI *EFI_GET_NEXT_VARIABLE_NAME) (
  176. IN OUT UINTN *VariableNameSize,
  177. IN OUT CHAR16 *VariableName,
  178. IN OUT EFI_GUID *VendorGuid
  179. );
  180. typedef
  181. EFI_STATUS
  182. (EFIAPI *EFI_SET_VARIABLE) (
  183. IN CHAR16 *VariableName,
  184. IN EFI_GUID *VendorGuid,
  185. IN UINT32 Attributes,
  186. IN UINTN DataSize,
  187. IN VOID *Data
  188. );
  189. /*
  190. * EFI Time
  191. */
  192. typedef struct {
  193. UINT32 Resolution; /* 1e-6 parts per million */
  194. UINT32 Accuracy; /* hertz */
  195. BOOLEAN SetsToZero; /* Set clears sub-second time */
  196. } EFI_TIME_CAPABILITIES;
  197. typedef
  198. EFI_STATUS
  199. (EFIAPI *EFI_GET_TIME) (
  200. OUT EFI_TIME *Time,
  201. OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL
  202. );
  203. typedef
  204. EFI_STATUS
  205. (EFIAPI *EFI_SET_TIME) (
  206. IN EFI_TIME *Time
  207. );
  208. typedef
  209. EFI_STATUS
  210. (EFIAPI *EFI_GET_WAKEUP_TIME) (
  211. OUT BOOLEAN *Enabled,
  212. OUT BOOLEAN *Pending,
  213. OUT EFI_TIME *Time
  214. );
  215. typedef
  216. EFI_STATUS
  217. (EFIAPI *EFI_SET_WAKEUP_TIME) (
  218. IN BOOLEAN Enable,
  219. IN EFI_TIME *Time OPTIONAL
  220. );
  221. /*
  222. * Image functions
  223. */
  224. /* PE32+ Subsystem type for EFI images */
  225. #if !defined(IMAGE_SUBSYSTEM_EFI_APPLICATION)
  226. #define IMAGE_SUBSYSTEM_EFI_APPLICATION 10
  227. #define IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER 11
  228. #define IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER 12
  229. #endif
  230. /* PE32+ Machine type for EFI images */
  231. #if !defined(EFI_IMAGE_MACHINE_IA32)
  232. #define EFI_IMAGE_MACHINE_IA32 0x014c
  233. #endif
  234. #if !defined(EFI_IMAGE_MACHINE_IA64)
  235. #define EFI_IMAGE_MACHINE_IA64 0x0200
  236. #endif
  237. /* Image Entry prototype */
  238. typedef
  239. EFI_STATUS
  240. (EFIAPI *EFI_IMAGE_ENTRY_POINT) (
  241. IN EFI_HANDLE ImageHandle,
  242. IN struct _EFI_SYSTEM_TABLE *SystemTable
  243. );
  244. typedef
  245. EFI_STATUS
  246. (EFIAPI *EFI_IMAGE_LOAD) (
  247. IN BOOLEAN BootPolicy,
  248. IN EFI_HANDLE ParentImageHandle,
  249. IN EFI_DEVICE_PATH *FilePath,
  250. IN VOID *SourceBuffer OPTIONAL,
  251. IN UINTN SourceSize,
  252. OUT EFI_HANDLE *ImageHandle
  253. );
  254. typedef
  255. EFI_STATUS
  256. (EFIAPI *EFI_IMAGE_START) (
  257. IN EFI_HANDLE ImageHandle,
  258. OUT UINTN *ExitDataSize,
  259. OUT CHAR16 **ExitData OPTIONAL
  260. );
  261. typedef
  262. EFI_STATUS
  263. (EFIAPI *EFI_EXIT) (
  264. IN EFI_HANDLE ImageHandle,
  265. IN EFI_STATUS ExitStatus,
  266. IN UINTN ExitDataSize,
  267. IN CHAR16 *ExitData OPTIONAL
  268. );
  269. typedef
  270. EFI_STATUS
  271. (EFIAPI *EFI_IMAGE_UNLOAD) (
  272. IN EFI_HANDLE ImageHandle
  273. );
  274. /* Image handle */
  275. #define LOADED_IMAGE_PROTOCOL \
  276. { 0x5B1B31A1, 0x9562, 0x11d2, 0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B }
  277. #define EFI_IMAGE_INFORMATION_REVISION 0x1000
  278. typedef struct {
  279. UINT32 Revision;
  280. EFI_HANDLE ParentHandle;
  281. struct _EFI_SYSTEM_TABLE *SystemTable;
  282. /* Source location of image */
  283. EFI_HANDLE DeviceHandle;
  284. EFI_DEVICE_PATH *FilePath;
  285. VOID *Reserved;
  286. /* Images load options */
  287. UINT32 LoadOptionsSize;
  288. VOID *LoadOptions;
  289. /* Location of where image was loaded */
  290. VOID *ImageBase;
  291. UINT64 ImageSize;
  292. EFI_MEMORY_TYPE ImageCodeType;
  293. EFI_MEMORY_TYPE ImageDataType;
  294. /* If the driver image supports a dynamic unload request */
  295. EFI_IMAGE_UNLOAD Unload;
  296. } EFI_LOADED_IMAGE;
  297. typedef
  298. EFI_STATUS
  299. (EFIAPI *EFI_EXIT_BOOT_SERVICES) (
  300. IN EFI_HANDLE ImageHandle,
  301. IN UINTN MapKey
  302. );
  303. /*
  304. * Misc
  305. */
  306. typedef
  307. EFI_STATUS
  308. (EFIAPI *EFI_STALL) (
  309. IN UINTN Microseconds
  310. );
  311. typedef
  312. EFI_STATUS
  313. (EFIAPI *EFI_SET_WATCHDOG_TIMER) (
  314. IN UINTN Timeout,
  315. IN UINT64 WatchdogCode,
  316. IN UINTN DataSize,
  317. IN CHAR16 *WatchdogData OPTIONAL
  318. );
  319. typedef enum {
  320. EfiResetCold,
  321. EfiResetWarm
  322. } EFI_RESET_TYPE;
  323. typedef
  324. EFI_STATUS
  325. (EFIAPI *EFI_RESET_SYSTEM) (
  326. IN EFI_RESET_TYPE ResetType,
  327. IN EFI_STATUS ResetStatus,
  328. IN UINTN DataSize,
  329. IN CHAR16 *ResetData OPTIONAL
  330. );
  331. typedef
  332. EFI_STATUS
  333. (EFIAPI *EFI_GET_NEXT_MONOTONIC_COUNT) (
  334. OUT UINT64 *Count
  335. );
  336. typedef
  337. EFI_STATUS
  338. (EFIAPI *EFI_GET_NEXT_HIGH_MONO_COUNT) (
  339. OUT UINT32 *HighCount
  340. );
  341. /*
  342. * Protocol handler functions
  343. */
  344. typedef enum {
  345. EFI_NATIVE_INTERFACE,
  346. EFI_PCODE_INTERFACE
  347. } EFI_INTERFACE_TYPE;
  348. typedef
  349. EFI_STATUS
  350. (EFIAPI *EFI_INSTALL_PROTOCOL_INTERFACE) (
  351. IN OUT EFI_HANDLE *Handle,
  352. IN EFI_GUID *Protocol,
  353. IN EFI_INTERFACE_TYPE InterfaceType,
  354. IN VOID *Interface
  355. );
  356. typedef
  357. EFI_STATUS
  358. (EFIAPI *EFI_REINSTALL_PROTOCOL_INTERFACE) (
  359. IN EFI_HANDLE Handle,
  360. IN EFI_GUID *Protocol,
  361. IN VOID *OldInterface,
  362. IN VOID *NewInterface
  363. );
  364. typedef
  365. EFI_STATUS
  366. (EFIAPI *EFI_UNINSTALL_PROTOCOL_INTERFACE) (
  367. IN EFI_HANDLE Handle,
  368. IN EFI_GUID *Protocol,
  369. IN VOID *Interface
  370. );
  371. typedef
  372. EFI_STATUS
  373. (EFIAPI *EFI_HANDLE_PROTOCOL) (
  374. IN EFI_HANDLE Handle,
  375. IN EFI_GUID *Protocol,
  376. OUT VOID **Interface
  377. );
  378. typedef
  379. EFI_STATUS
  380. (EFIAPI *EFI_REGISTER_PROTOCOL_NOTIFY) (
  381. IN EFI_GUID *Protocol,
  382. IN EFI_EVENT Event,
  383. OUT VOID **Registration
  384. );
  385. typedef enum {
  386. AllHandles,
  387. ByRegisterNotify,
  388. ByProtocol
  389. } EFI_LOCATE_SEARCH_TYPE;
  390. typedef
  391. EFI_STATUS
  392. (EFIAPI *EFI_LOCATE_HANDLE) (
  393. IN EFI_LOCATE_SEARCH_TYPE SearchType,
  394. IN EFI_GUID *Protocol OPTIONAL,
  395. IN VOID *SearchKey OPTIONAL,
  396. IN OUT UINTN *BufferSize,
  397. OUT EFI_HANDLE *Buffer
  398. );
  399. typedef
  400. EFI_STATUS
  401. (EFIAPI *EFI_LOCATE_DEVICE_PATH) (
  402. IN EFI_GUID *Protocol,
  403. IN OUT EFI_DEVICE_PATH **DevicePath,
  404. OUT EFI_HANDLE *Device
  405. );
  406. typedef
  407. EFI_STATUS
  408. (EFIAPI *EFI_INSTALL_CONFIGURATION_TABLE) (
  409. IN EFI_GUID *Guid,
  410. IN VOID *Table
  411. );
  412. typedef
  413. EFI_STATUS
  414. (EFIAPI *EFI_RESERVED_SERVICE) (
  415. );
  416. /*
  417. * Standard EFI table header
  418. */
  419. typedef struct _EFI_TABLE_HEARDER {
  420. UINT64 Signature;
  421. UINT32 Revision;
  422. UINT32 HeaderSize;
  423. UINT32 CRC32;
  424. UINT32 Reserved;
  425. } EFI_TABLE_HEADER;
  426. /*
  427. * EFI Runtime Serivces Table
  428. */
  429. #define EFI_RUNTIME_SERVICES_SIGNATURE 0x56524553544e5552
  430. #define EFI_RUNTIME_SERVICES_REVISION (EFI_SPECIFICATION_MAJOR_REVISION<<16) | (EFI_SPECIFICATION_MINOR_REVISION)
  431. typedef struct {
  432. EFI_TABLE_HEADER Hdr;
  433. /*
  434. * Time services
  435. */
  436. EFI_GET_TIME GetTime;
  437. EFI_SET_TIME SetTime;
  438. EFI_GET_WAKEUP_TIME GetWakeupTime;
  439. EFI_SET_WAKEUP_TIME SetWakeupTime;
  440. /*
  441. * Virtual memory services
  442. */
  443. EFI_SET_VIRTUAL_ADDRESS_MAP SetVirtualAddressMap;
  444. EFI_CONVERT_POINTER ConvertPointer;
  445. /*
  446. * Variable serviers
  447. */
  448. EFI_GET_VARIABLE GetVariable;
  449. EFI_GET_NEXT_VARIABLE_NAME GetNextVariableName;
  450. EFI_SET_VARIABLE SetVariable;
  451. /*
  452. * Misc
  453. */
  454. EFI_GET_NEXT_HIGH_MONO_COUNT GetNextHighMonotonicCount;
  455. EFI_RESET_SYSTEM ResetSystem;
  456. } EFI_RUNTIME_SERVICES;
  457. /*
  458. * EFI Boot Services Table
  459. */
  460. #define EFI_BOOT_SERVICES_SIGNATURE 0x56524553544f4f42
  461. #define EFI_BOOT_SERVICES_REVISION (EFI_SPECIFICATION_MAJOR_REVISION<<16) | (EFI_SPECIFICATION_MINOR_REVISION)
  462. typedef struct _EFI_BOOT_SERVICES {
  463. EFI_TABLE_HEADER Hdr;
  464. /*
  465. * Task priority functions
  466. */
  467. EFI_RAISE_TPL RaiseTPL;
  468. EFI_RESTORE_TPL RestoreTPL;
  469. /*
  470. * Memory functions
  471. */
  472. EFI_ALLOCATE_PAGES AllocatePages;
  473. EFI_FREE_PAGES FreePages;
  474. EFI_GET_MEMORY_MAP GetMemoryMap;
  475. EFI_ALLOCATE_POOL AllocatePool;
  476. EFI_FREE_POOL FreePool;
  477. /*
  478. * Event & timer functions
  479. */
  480. EFI_CREATE_EVENT CreateEvent;
  481. EFI_SET_TIMER SetTimer;
  482. EFI_WAIT_FOR_EVENT WaitForEvent;
  483. EFI_SIGNAL_EVENT SignalEvent;
  484. EFI_CLOSE_EVENT CloseEvent;
  485. EFI_CHECK_EVENT CheckEvent;
  486. /*
  487. * Protocol handler functions
  488. */
  489. EFI_INSTALL_PROTOCOL_INTERFACE InstallProtocolInterface;
  490. EFI_REINSTALL_PROTOCOL_INTERFACE ReinstallProtocolInterface;
  491. EFI_UNINSTALL_PROTOCOL_INTERFACE UninstallProtocolInterface;
  492. EFI_HANDLE_PROTOCOL HandleProtocol;
  493. EFI_HANDLE_PROTOCOL PCHandleProtocol;
  494. EFI_REGISTER_PROTOCOL_NOTIFY RegisterProtocolNotify;
  495. EFI_LOCATE_HANDLE LocateHandle;
  496. EFI_LOCATE_DEVICE_PATH LocateDevicePath;
  497. EFI_INSTALL_CONFIGURATION_TABLE InstallConfigurationTable;
  498. /*
  499. * Image functions
  500. */
  501. EFI_IMAGE_LOAD LoadImage;
  502. EFI_IMAGE_START StartImage;
  503. EFI_EXIT Exit;
  504. EFI_IMAGE_UNLOAD UnloadImage;
  505. EFI_EXIT_BOOT_SERVICES ExitBootServices;
  506. /*
  507. * Misc functions
  508. */
  509. EFI_GET_NEXT_MONOTONIC_COUNT GetNextMonotonicCount;
  510. EFI_STALL Stall;
  511. EFI_SET_WATCHDOG_TIMER SetWatchdogTimer;
  512. } EFI_BOOT_SERVICES;
  513. /*
  514. * EFI Configuration Table and GUID definitions
  515. */
  516. #define MPS_TABLE_GUID \
  517. { 0xeb9d2d2f, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d }
  518. #define ACPI_TABLE_GUID \
  519. { 0x8868e871, 0xe4f1, 0x11d3, 0xbc, 0x22, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 }
  520. #define SMBIOS_TABLE_GUID \
  521. { 0xeb9d2d31, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d }
  522. #define SAL_SYSTEM_TABLE_GUID \
  523. { 0xeb9d2d32, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d }
  524. typedef struct _EFI_CONFIGURATION_TABLE {
  525. EFI_GUID VendorGuid;
  526. VOID *VendorTable;
  527. } EFI_CONFIGURATION_TABLE;
  528. /*
  529. * EFI System Table
  530. */
  531. #define EFI_SYSTEM_TABLE_SIGNATURE 0x5453595320494249
  532. #define EFI_SYSTEM_TABLE_REVISION (EFI_SPECIFICATION_MAJOR_REVISION<<16) | (EFI_SPECIFICATION_MINOR_REVISION)
  533. typedef struct _EFI_SYSTEM_TABLE {
  534. EFI_TABLE_HEADER Hdr;
  535. CHAR16 *FirmwareVendor;
  536. UINT32 FirmwareRevision;
  537. EFI_HANDLE ConsoleInHandle;
  538. SIMPLE_INPUT_INTERFACE *ConIn;
  539. EFI_HANDLE ConsoleOutHandle;
  540. SIMPLE_TEXT_OUTPUT_INTERFACE *ConOut;
  541. EFI_HANDLE StandardErrorHandle;
  542. SIMPLE_TEXT_OUTPUT_INTERFACE *StdErr;
  543. EFI_RUNTIME_SERVICES *RuntimeServices;
  544. EFI_BOOT_SERVICES *BootServices;
  545. UINTN NumberOfTableEntries;
  546. EFI_CONFIGURATION_TABLE *ConfigurationTable;
  547. } EFI_SYSTEM_TABLE;
  548. #endif