efiapi.h 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038
  1. #ifndef _EFI_API_H
  2. #define _EFI_API_H
  3. #include <efidevp.h>
  4. #include <efiprot.h>
  5. #include <eficon.h>
  6. /*++
  7. Copyright (c) 1998 Intel Corporation
  8. Module Name:
  9. efiapi.h
  10. Abstract:
  11. Global EFI runtime & boot service interfaces
  12. Revision History
  13. --*/
  14. //
  15. // EFI Specification Revision
  16. //
  17. #define EFI_SPECIFICATION_REVISION_MAJORMINOR(major, minor) ((major<<16) | (minor))
  18. #define EFI_SPECIFICATION_MAJOR_REVISION 1
  19. #define EFI_SPECIFICATION_MINOR_REVISION 02
  20. #define EFI_SPECIFICATION_VERSION EFI_SPECIFICATION_REVISION_MAJORMINOR(EFI_SPECIFICATION_MAJOR_REVISION, EFI_SPECIFICATION_MINOR_REVISION)
  21. //
  22. // Declare forward referenced data structures
  23. //
  24. INTERFACE_DECL(_EFI_SYSTEM_TABLE);
  25. //
  26. // EFI Memory
  27. //
  28. typedef
  29. EFI_STATUS
  30. (EFIAPI *EFI_ALLOCATE_PAGES) (
  31. IN EFI_ALLOCATE_TYPE Type,
  32. IN EFI_MEMORY_TYPE MemoryType,
  33. IN UINTN NoPages,
  34. OUT EFI_PHYSICAL_ADDRESS *Memory
  35. );
  36. typedef
  37. EFI_STATUS
  38. (EFIAPI *EFI_FREE_PAGES) (
  39. IN EFI_PHYSICAL_ADDRESS Memory,
  40. IN UINTN NoPages
  41. );
  42. typedef
  43. EFI_STATUS
  44. (EFIAPI *EFI_GET_MEMORY_MAP) (
  45. IN OUT UINTN *MemoryMapSize,
  46. IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap,
  47. OUT UINTN *MapKey,
  48. OUT UINTN *DescriptorSize,
  49. OUT UINT32 *DescriptorVersion
  50. );
  51. #define NextMemoryDescriptor(Ptr,Size) ((EFI_MEMORY_DESCRIPTOR *) (((UINT8 *) Ptr) + Size))
  52. typedef
  53. EFI_STATUS
  54. (EFIAPI *EFI_ALLOCATE_POOL) (
  55. IN EFI_MEMORY_TYPE PoolType,
  56. IN UINTN Size,
  57. OUT VOID **Buffer
  58. );
  59. typedef
  60. EFI_STATUS
  61. (EFIAPI *EFI_FREE_POOL) (
  62. IN VOID *Buffer
  63. );
  64. typedef
  65. EFI_STATUS
  66. (EFIAPI *EFI_SET_VIRTUAL_ADDRESS_MAP) (
  67. IN UINTN MemoryMapSize,
  68. IN UINTN DescriptorSize,
  69. IN UINT32 DescriptorVersion,
  70. IN EFI_MEMORY_DESCRIPTOR *VirtualMap
  71. );
  72. #define EFI_OPTIONAL_PTR 0x00000001
  73. #define EFI_INTERNAL_FNC 0x00000002 // Pointer to internal runtime fnc
  74. #define EFI_INTERNAL_PTR 0x00000004 // Pointer to internal runtime data
  75. typedef
  76. EFI_STATUS
  77. (EFIAPI *EFI_CONVERT_POINTER) (
  78. IN UINTN DebugDisposition,
  79. IN OUT VOID **Address
  80. );
  81. //
  82. // EFI Events
  83. //
  84. #define EVT_TIMER 0x80000000
  85. #define EVT_RUNTIME 0x40000000
  86. #define EVT_RUNTIME_CONTEXT 0x20000000
  87. #define EVT_NOTIFY_WAIT 0x00000100
  88. #define EVT_NOTIFY_SIGNAL 0x00000200
  89. #define EVT_SIGNAL_EXIT_BOOT_SERVICES 0x00000201
  90. #define EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE 0x60000202
  91. #define EVT_EFI_SIGNAL_MASK 0x000000FF
  92. #define EVT_EFI_SIGNAL_MAX 4
  93. #define EFI_EVENT_TIMER EVT_TIMER
  94. #define EFI_EVENT_RUNTIME EVT_RUNTIME
  95. #define EFI_EVENT_RUNTIME_CONTEXT EVT_RUNTIME_CONTEXT
  96. #define EFI_EVENT_NOTIFY_WAIT EVT_NOTIFY_WAIT
  97. #define EFI_EVENT_NOTIFY_SIGNAL EVT_NOTIFY_SIGNAL
  98. #define EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES EVT_SIGNAL_EXIT_BOOT_SERVICES
  99. #define EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE
  100. #define EFI_EVENT_EFI_SIGNAL_MASK EVT_EFI_SIGNAL_MASK
  101. #define EFI_EVENT_EFI_SIGNAL_MAX EVT_EFI_SIGNAL_MAX
  102. typedef
  103. VOID
  104. (EFIAPI *EFI_EVENT_NOTIFY) (
  105. IN EFI_EVENT Event,
  106. IN VOID *Context
  107. );
  108. typedef
  109. EFI_STATUS
  110. (EFIAPI *EFI_CREATE_EVENT) (
  111. IN UINT32 Type,
  112. IN EFI_TPL NotifyTpl,
  113. IN EFI_EVENT_NOTIFY NotifyFunction,
  114. IN VOID *NotifyContext,
  115. OUT EFI_EVENT *Event
  116. );
  117. typedef enum {
  118. TimerCancel,
  119. TimerPeriodic,
  120. TimerRelative,
  121. TimerTypeMax
  122. } EFI_TIMER_DELAY;
  123. typedef
  124. EFI_STATUS
  125. (EFIAPI *EFI_SET_TIMER) (
  126. IN EFI_EVENT Event,
  127. IN EFI_TIMER_DELAY Type,
  128. IN UINT64 TriggerTime
  129. );
  130. typedef
  131. EFI_STATUS
  132. (EFIAPI *EFI_SIGNAL_EVENT) (
  133. IN EFI_EVENT Event
  134. );
  135. typedef
  136. EFI_STATUS
  137. (EFIAPI *EFI_WAIT_FOR_EVENT) (
  138. IN UINTN NumberOfEvents,
  139. IN EFI_EVENT *Event,
  140. OUT UINTN *Index
  141. );
  142. typedef
  143. EFI_STATUS
  144. (EFIAPI *EFI_CLOSE_EVENT) (
  145. IN EFI_EVENT Event
  146. );
  147. typedef
  148. EFI_STATUS
  149. (EFIAPI *EFI_CHECK_EVENT) (
  150. IN EFI_EVENT Event
  151. );
  152. //
  153. // Task priority level
  154. //
  155. #define TPL_APPLICATION 4
  156. #define TPL_CALLBACK 8
  157. #define TPL_NOTIFY 16
  158. #define TPL_HIGH_LEVEL 31
  159. #define EFI_TPL_APPLICATION TPL_APPLICATION
  160. #define EFI_TPL_CALLBACK TPL_CALLBACK
  161. #define EFI_TPL_NOTIFY TPL_NOTIFY
  162. #define EFI_TPL_HIGH_LEVEL TPL_HIGH_LEVEL
  163. typedef
  164. EFI_TPL
  165. (EFIAPI *EFI_RAISE_TPL) (
  166. IN EFI_TPL NewTpl
  167. );
  168. typedef
  169. VOID
  170. (EFIAPI *EFI_RESTORE_TPL) (
  171. IN EFI_TPL OldTpl
  172. );
  173. //
  174. // EFI platform varibles
  175. //
  176. #define EFI_GLOBAL_VARIABLE \
  177. { 0x8BE4DF61, 0x93CA, 0x11d2, {0xAA, 0x0D, 0x00, 0xE0, 0x98, 0x03, 0x2B, 0x8C} }
  178. // Variable attributes
  179. #define EFI_VARIABLE_NON_VOLATILE 0x00000001
  180. #define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002
  181. #define EFI_VARIABLE_RUNTIME_ACCESS 0x00000004
  182. #define EFI_VARIABLE_HARDWARE_ERROR_RECORD 0x00000008
  183. #define EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS 0x00000010
  184. #define EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS 0x00000020
  185. #define EFI_VARIABLE_APPEND_WRITE 0x00000040
  186. #define EFI_VARIABLE_ENHANCED_AUTHENTICATED_ACCESS 0x00000080
  187. // Variable size limitation
  188. #define EFI_MAXIMUM_VARIABLE_SIZE 1024
  189. typedef
  190. EFI_STATUS
  191. (EFIAPI *EFI_GET_VARIABLE) (
  192. IN CHAR16 *VariableName,
  193. IN EFI_GUID *VendorGuid,
  194. OUT UINT32 *Attributes OPTIONAL,
  195. IN OUT UINTN *DataSize,
  196. OUT VOID *Data
  197. );
  198. typedef
  199. EFI_STATUS
  200. (EFIAPI *EFI_GET_NEXT_VARIABLE_NAME) (
  201. IN OUT UINTN *VariableNameSize,
  202. IN OUT CHAR16 *VariableName,
  203. IN OUT EFI_GUID *VendorGuid
  204. );
  205. typedef
  206. EFI_STATUS
  207. (EFIAPI *EFI_SET_VARIABLE) (
  208. IN CHAR16 *VariableName,
  209. IN EFI_GUID *VendorGuid,
  210. IN UINT32 Attributes,
  211. IN UINTN DataSize,
  212. IN VOID *Data
  213. );
  214. //
  215. // EFI Time
  216. //
  217. typedef struct {
  218. UINT32 Resolution; // 1e-6 parts per million
  219. UINT32 Accuracy; // hertz
  220. BOOLEAN SetsToZero; // Set clears sub-second time
  221. } EFI_TIME_CAPABILITIES;
  222. typedef
  223. EFI_STATUS
  224. (EFIAPI *EFI_GET_TIME) (
  225. OUT EFI_TIME *Time,
  226. OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL
  227. );
  228. typedef
  229. EFI_STATUS
  230. (EFIAPI *EFI_SET_TIME) (
  231. IN EFI_TIME *Time
  232. );
  233. typedef
  234. EFI_STATUS
  235. (EFIAPI *EFI_GET_WAKEUP_TIME) (
  236. OUT BOOLEAN *Enabled,
  237. OUT BOOLEAN *Pending,
  238. OUT EFI_TIME *Time
  239. );
  240. typedef
  241. EFI_STATUS
  242. (EFIAPI *EFI_SET_WAKEUP_TIME) (
  243. IN BOOLEAN Enable,
  244. IN EFI_TIME *Time OPTIONAL
  245. );
  246. //
  247. // Image functions
  248. //
  249. // PE32+ Subsystem type for EFI images
  250. #if !defined(IMAGE_SUBSYSTEM_EFI_APPLICATION)
  251. #define IMAGE_SUBSYSTEM_EFI_APPLICATION 10
  252. #define IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER 11
  253. #define IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER 12
  254. #endif
  255. // PE32+ Machine type for EFI images
  256. #if !defined(EFI_IMAGE_MACHINE_IA32)
  257. #define EFI_IMAGE_MACHINE_IA32 0x014c
  258. #endif
  259. #if !defined(EFI_IMAGE_MACHINE_IA64)
  260. #define EFI_IMAGE_MACHINE_IA64 0x0200
  261. #endif
  262. #if !defined(EFI_IMAGE_MACHINE_EBC)
  263. #define EFI_IMAGE_MACHINE_EBC 0x0EBC
  264. #endif
  265. #if !defined(EFI_IMAGE_MACHINE_X64)
  266. #define EFI_IMAGE_MACHINE_X64 0x8664
  267. #endif
  268. #if !defined(EFI_IMAGE_MACHINE_ARMTHUMB_MIXED)
  269. #define EFI_IMAGE_MACHINE_ARMTHUMB_MIXED 0x01C2
  270. #endif
  271. #if !defined(EFI_IMAGE_MACHINE_AARCH64)
  272. #define EFI_IMAGE_MACHINE_AARCH64 0xAA64
  273. #endif
  274. #if !defined(EFI_IMAGE_MACHINE_RISCV32)
  275. #define EFI_IMAGE_MACHINE_RISCV32 0x5032
  276. #endif
  277. #if !defined(EFI_IMAGE_MACHINE_RISCV64)
  278. #define EFI_IMAGE_MACHINE_RISCV64 0x5064
  279. #endif
  280. #if !defined(EFI_IMAGE_MACHINE_RISCV128)
  281. #define EFI_IMAGE_MACHINE_RISCV128 0x5128
  282. #endif
  283. #if !defined(EFI_IMAGE_MACHINE_LOONGARCH32)
  284. #define EFI_IMAGE_MACHINE_LOONGARCH32 0x6232
  285. #endif
  286. #if !defined(EFI_IMAGE_MACHINE_LOONGARCH64)
  287. #define EFI_IMAGE_MACHINE_LOONGARCH64 0x6264
  288. #endif
  289. // Image Entry prototype
  290. typedef
  291. EFI_STATUS
  292. (EFIAPI *EFI_IMAGE_ENTRY_POINT) (
  293. IN EFI_HANDLE ImageHandle,
  294. IN struct _EFI_SYSTEM_TABLE *SystemTable
  295. );
  296. typedef
  297. EFI_STATUS
  298. (EFIAPI *EFI_IMAGE_LOAD) (
  299. IN BOOLEAN BootPolicy,
  300. IN EFI_HANDLE ParentImageHandle,
  301. IN EFI_DEVICE_PATH *FilePath,
  302. IN VOID *SourceBuffer OPTIONAL,
  303. IN UINTN SourceSize,
  304. OUT EFI_HANDLE *ImageHandle
  305. );
  306. typedef
  307. EFI_STATUS
  308. (EFIAPI *EFI_IMAGE_START) (
  309. IN EFI_HANDLE ImageHandle,
  310. OUT UINTN *ExitDataSize,
  311. OUT CHAR16 **ExitData OPTIONAL
  312. );
  313. typedef
  314. EFI_STATUS
  315. (EFIAPI *EFI_EXIT) (
  316. IN EFI_HANDLE ImageHandle,
  317. IN EFI_STATUS ExitStatus,
  318. IN UINTN ExitDataSize,
  319. IN CHAR16 *ExitData OPTIONAL
  320. );
  321. // Image handle
  322. /*#define LOADED_IMAGE_PROTOCOL \
  323. { 0x5B1B31A1, 0x9562, 0x11d2, {0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B} }
  324. #define EFI_IMAGE_INFORMATION_REVISION 0x1000
  325. typedef struct {
  326. UINT32 Revision;
  327. EFI_HANDLE ParentHandle;
  328. struct _EFI_SYSTEM_TABLE *SystemTable;
  329. // Source location of image
  330. EFI_HANDLE DeviceHandle;
  331. EFI_DEVICE_PATH *FilePath;
  332. VOID *Reserved;
  333. // Images load options
  334. UINT32 LoadOptionsSize;
  335. VOID *LoadOptions;
  336. // Location of where image was loaded
  337. VOID *ImageBase;
  338. UINT64 ImageSize;
  339. EFI_MEMORY_TYPE ImageCodeType;
  340. EFI_MEMORY_TYPE ImageDataType;
  341. // If the driver image supports a dynamic unload request
  342. EFI_IMAGE_UNLOAD Unload;
  343. } EFI_LOADED_IMAGE;*/
  344. typedef
  345. EFI_STATUS
  346. (EFIAPI *EFI_EXIT_BOOT_SERVICES) (
  347. IN EFI_HANDLE ImageHandle,
  348. IN UINTN MapKey
  349. );
  350. //
  351. // Misc
  352. //
  353. typedef
  354. EFI_STATUS
  355. (EFIAPI *EFI_STALL) (
  356. IN UINTN Microseconds
  357. );
  358. typedef
  359. EFI_STATUS
  360. (EFIAPI *EFI_SET_WATCHDOG_TIMER) (
  361. IN UINTN Timeout,
  362. IN UINT64 WatchdogCode,
  363. IN UINTN DataSize,
  364. IN CHAR16 *WatchdogData OPTIONAL
  365. );
  366. typedef
  367. EFI_STATUS
  368. (EFIAPI *EFI_CONNECT_CONTROLLER) (
  369. IN EFI_HANDLE ControllerHandle,
  370. IN EFI_HANDLE *DriverImageHandle OPTIONAL,
  371. IN EFI_DEVICE_PATH *RemainingDevicePath OPTIONAL,
  372. IN BOOLEAN Recursive
  373. );
  374. typedef
  375. EFI_STATUS
  376. (EFIAPI *EFI_DISCONNECT_CONTROLLER) (
  377. IN EFI_HANDLE ControllerHandle,
  378. IN EFI_HANDLE DriverImageHandle OPTIONAL,
  379. IN EFI_HANDLE ChildHandle OPTIONAL
  380. );
  381. #define EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL 0x00000001
  382. #define EFI_OPEN_PROTOCOL_GET_PROTOCOL 0x00000002
  383. #define EFI_OPEN_PROTOCOL_TEST_PROTOCOL 0x00000004
  384. #define EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 0x00000008
  385. #define EFI_OPEN_PROTOCOL_BY_DRIVER 0x00000010
  386. #define EFI_OPEN_PROTOCOL_EXCLUSIVE 0x00000020
  387. typedef
  388. EFI_STATUS
  389. (EFIAPI *EFI_OPEN_PROTOCOL) (
  390. IN EFI_HANDLE Handle,
  391. IN EFI_GUID *Protocol,
  392. OUT VOID **Interface OPTIONAL,
  393. IN EFI_HANDLE AgentHandle,
  394. IN EFI_HANDLE ControllerHandle,
  395. IN UINT32 Attributes
  396. );
  397. typedef
  398. EFI_STATUS
  399. (EFIAPI *EFI_CLOSE_PROTOCOL) (
  400. IN EFI_HANDLE Handle,
  401. IN EFI_GUID *Protocol,
  402. IN EFI_HANDLE AgentHandle,
  403. IN EFI_HANDLE ControllerHandle
  404. );
  405. typedef struct {
  406. EFI_HANDLE AgentHandle;
  407. EFI_HANDLE ControllerHandle;
  408. UINT32 Attributes;
  409. UINT32 OpenCount;
  410. } EFI_OPEN_PROTOCOL_INFORMATION_ENTRY;
  411. typedef
  412. EFI_STATUS
  413. (EFIAPI *EFI_OPEN_PROTOCOL_INFORMATION) (
  414. IN EFI_HANDLE Handle,
  415. IN EFI_GUID *Protocol,
  416. OUT EFI_OPEN_PROTOCOL_INFORMATION_ENTRY **EntryBuffer,
  417. OUT UINTN *EntryCount
  418. );
  419. typedef
  420. EFI_STATUS
  421. (EFIAPI *EFI_PROTOCOLS_PER_HANDLE) (
  422. IN EFI_HANDLE Handle,
  423. OUT EFI_GUID ***ProtocolBuffer,
  424. OUT UINTN *ProtocolBufferCount
  425. );
  426. typedef enum {
  427. AllHandles,
  428. ByRegisterNotify,
  429. ByProtocol
  430. } EFI_LOCATE_SEARCH_TYPE;
  431. typedef
  432. EFI_STATUS
  433. (EFIAPI *EFI_LOCATE_HANDLE_BUFFER) (
  434. IN EFI_LOCATE_SEARCH_TYPE SearchType,
  435. IN EFI_GUID *Protocol OPTIONAL,
  436. IN VOID *SearchKey OPTIONAL,
  437. IN OUT UINTN *NoHandles,
  438. OUT EFI_HANDLE **Buffer
  439. );
  440. typedef
  441. EFI_STATUS
  442. (EFIAPI *EFI_LOCATE_PROTOCOL) (
  443. IN EFI_GUID *Protocol,
  444. IN VOID *Registration OPTIONAL,
  445. OUT VOID **Interface
  446. );
  447. typedef
  448. EFI_STATUS
  449. (EFIAPI *EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES) (
  450. IN OUT EFI_HANDLE *Handle,
  451. ...
  452. );
  453. typedef
  454. EFI_STATUS
  455. (EFIAPI *EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES) (
  456. IN OUT EFI_HANDLE Handle,
  457. ...
  458. );
  459. typedef
  460. EFI_STATUS
  461. (EFIAPI *EFI_CALCULATE_CRC32) (
  462. IN VOID *Data,
  463. IN UINTN DataSize,
  464. OUT UINT32 *Crc32
  465. );
  466. typedef
  467. VOID
  468. (EFIAPI *EFI_COPY_MEM) (
  469. IN VOID *Destination,
  470. IN VOID *Source,
  471. IN UINTN Length
  472. );
  473. typedef
  474. VOID
  475. (EFIAPI *EFI_SET_MEM) (
  476. IN VOID *Buffer,
  477. IN UINTN Size,
  478. IN UINT8 Value
  479. );
  480. typedef
  481. EFI_STATUS
  482. (EFIAPI *EFI_CREATE_EVENT_EX) (
  483. IN UINT32 Type,
  484. IN EFI_TPL NotifyTpl,
  485. IN EFI_EVENT_NOTIFY NotifyFunction OPTIONAL,
  486. IN const VOID *NotifyContext OPTIONAL,
  487. IN const EFI_GUID *EventGroup OPTIONAL,
  488. OUT EFI_EVENT *Event
  489. );
  490. typedef enum {
  491. EfiResetCold,
  492. EfiResetWarm,
  493. EfiResetShutdown
  494. } EFI_RESET_TYPE;
  495. typedef
  496. EFI_STATUS
  497. (EFIAPI *EFI_RESET_SYSTEM) (
  498. IN EFI_RESET_TYPE ResetType,
  499. IN EFI_STATUS ResetStatus,
  500. IN UINTN DataSize,
  501. IN CHAR16 *ResetData OPTIONAL
  502. );
  503. typedef
  504. EFI_STATUS
  505. (EFIAPI *EFI_GET_NEXT_MONOTONIC_COUNT) (
  506. OUT UINT64 *Count
  507. );
  508. typedef
  509. EFI_STATUS
  510. (EFIAPI *EFI_GET_NEXT_HIGH_MONO_COUNT) (
  511. OUT UINT32 *HighCount
  512. );
  513. typedef struct {
  514. UINT64 Length;
  515. union {
  516. EFI_PHYSICAL_ADDRESS DataBlock;
  517. EFI_PHYSICAL_ADDRESS ContinuationPointer;
  518. } Union;
  519. } EFI_CAPSULE_BLOCK_DESCRIPTOR;
  520. typedef struct {
  521. EFI_GUID CapsuleGuid;
  522. UINT32 HeaderSize;
  523. UINT32 Flags;
  524. UINT32 CapsuleImageSize;
  525. } EFI_CAPSULE_HEADER;
  526. #define CAPSULE_FLAGS_PERSIST_ACROSS_RESET 0x00010000
  527. #define CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE 0x00020000
  528. #define CAPSULE_FLAGS_INITIATE_RESET 0x00040000
  529. typedef
  530. EFI_STATUS
  531. (EFIAPI *EFI_UPDATE_CAPSULE) (
  532. IN EFI_CAPSULE_HEADER **CapsuleHeaderArray,
  533. IN UINTN CapsuleCount,
  534. IN EFI_PHYSICAL_ADDRESS ScatterGatherList OPTIONAL
  535. );
  536. typedef
  537. EFI_STATUS
  538. (EFIAPI *EFI_QUERY_CAPSULE_CAPABILITIES) (
  539. IN EFI_CAPSULE_HEADER **CapsuleHeaderArray,
  540. IN UINTN CapsuleCount,
  541. OUT UINT64 *MaximumCapsuleSize,
  542. OUT EFI_RESET_TYPE *ResetType
  543. );
  544. typedef
  545. EFI_STATUS
  546. (EFIAPI *EFI_QUERY_VARIABLE_INFO) (
  547. IN UINT32 Attributes,
  548. OUT UINT64 *MaximumVariableStorageSize,
  549. OUT UINT64 *RemainingVariableStorageSize,
  550. OUT UINT64 *MaximumVariableSize
  551. );
  552. //
  553. // Protocol handler functions
  554. //
  555. typedef enum {
  556. EFI_NATIVE_INTERFACE,
  557. EFI_PCODE_INTERFACE
  558. } EFI_INTERFACE_TYPE;
  559. typedef
  560. EFI_STATUS
  561. (EFIAPI *EFI_INSTALL_PROTOCOL_INTERFACE) (
  562. IN OUT EFI_HANDLE *Handle,
  563. IN EFI_GUID *Protocol,
  564. IN EFI_INTERFACE_TYPE InterfaceType,
  565. IN VOID *Interface
  566. );
  567. typedef
  568. EFI_STATUS
  569. (EFIAPI *EFI_REINSTALL_PROTOCOL_INTERFACE) (
  570. IN EFI_HANDLE Handle,
  571. IN EFI_GUID *Protocol,
  572. IN VOID *OldInterface,
  573. IN VOID *NewInterface
  574. );
  575. typedef
  576. EFI_STATUS
  577. (EFIAPI *EFI_UNINSTALL_PROTOCOL_INTERFACE) (
  578. IN EFI_HANDLE Handle,
  579. IN EFI_GUID *Protocol,
  580. IN VOID *Interface
  581. );
  582. typedef
  583. EFI_STATUS
  584. (EFIAPI *EFI_HANDLE_PROTOCOL) (
  585. IN EFI_HANDLE Handle,
  586. IN EFI_GUID *Protocol,
  587. OUT VOID **Interface
  588. );
  589. typedef
  590. EFI_STATUS
  591. (EFIAPI *EFI_REGISTER_PROTOCOL_NOTIFY) (
  592. IN EFI_GUID *Protocol,
  593. IN EFI_EVENT Event,
  594. OUT VOID **Registration
  595. );
  596. typedef
  597. EFI_STATUS
  598. (EFIAPI *EFI_LOCATE_HANDLE) (
  599. IN EFI_LOCATE_SEARCH_TYPE SearchType,
  600. IN EFI_GUID *Protocol OPTIONAL,
  601. IN VOID *SearchKey OPTIONAL,
  602. IN OUT UINTN *BufferSize,
  603. OUT EFI_HANDLE *Buffer
  604. );
  605. typedef
  606. EFI_STATUS
  607. (EFIAPI *EFI_LOCATE_DEVICE_PATH) (
  608. IN EFI_GUID *Protocol,
  609. IN OUT EFI_DEVICE_PATH **DevicePath,
  610. OUT EFI_HANDLE *Device
  611. );
  612. typedef
  613. EFI_STATUS
  614. (EFIAPI *EFI_INSTALL_CONFIGURATION_TABLE) (
  615. IN EFI_GUID *Guid,
  616. IN VOID *Table
  617. );
  618. typedef
  619. EFI_STATUS
  620. (EFIAPI *EFI_RESERVED_SERVICE) (
  621. );
  622. //
  623. // Standard EFI table header
  624. //
  625. typedef struct _EFI_TABLE_HEADER {
  626. UINT64 Signature;
  627. UINT32 Revision;
  628. UINT32 HeaderSize;
  629. UINT32 CRC32;
  630. UINT32 Reserved;
  631. } EFI_TABLE_HEADER;
  632. //
  633. // EFI Runtime Serivces Table
  634. //
  635. #define EFI_RUNTIME_SERVICES_SIGNATURE 0x56524553544e5552
  636. #define EFI_1_02_RUNTIME_SERVICES_REVISION EFI_SPECIFICATION_REVISION_MAJORMINOR(1, 02)
  637. #define EFI_1_10_RUNTIME_SERVICES_REVISION EFI_SPECIFICATION_REVISION_MAJORMINOR(1, 10)
  638. #define EFI_2_00_RUNTIME_SERVICES_REVISION EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 00)
  639. #define EFI_2_10_RUNTIME_SERVICES_REVISION EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 10)
  640. #define EFI_2_20_RUNTIME_SERVICES_REVISION EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 20)
  641. #define EFI_2_30_RUNTIME_SERVICES_REVISION EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 30)
  642. #define EFI_2_31_RUNTIME_SERVICES_REVISION EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 31)
  643. #define EFI_2_40_RUNTIME_SERVICES_REVISION EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 40)
  644. #define EFI_2_50_RUNTIME_SERVICES_REVISION EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 50)
  645. #define EFI_2_60_RUNTIME_SERVICES_REVISION EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 60)
  646. #define EFI_2_70_RUNTIME_SERVICES_REVISION EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 70)
  647. #define EFI_2_80_RUNTIME_SERVICES_REVISION EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 80)
  648. #define EFI_2_90_RUNTIME_SERVICES_REVISION EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 90)
  649. #define EFI_2_100_RUNTIME_SERVICES_REVISION EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 100)
  650. #define EFI_RUNTIME_SERVICES_REVISION EFI_SPECIFICATION_VERSION
  651. typedef struct {
  652. EFI_TABLE_HEADER Hdr;
  653. //
  654. // Time services
  655. //
  656. EFI_GET_TIME GetTime;
  657. EFI_SET_TIME SetTime;
  658. EFI_GET_WAKEUP_TIME GetWakeupTime;
  659. EFI_SET_WAKEUP_TIME SetWakeupTime;
  660. //
  661. // Virtual memory services
  662. //
  663. EFI_SET_VIRTUAL_ADDRESS_MAP SetVirtualAddressMap;
  664. EFI_CONVERT_POINTER ConvertPointer;
  665. //
  666. // Variable serviers
  667. //
  668. EFI_GET_VARIABLE GetVariable;
  669. EFI_GET_NEXT_VARIABLE_NAME GetNextVariableName;
  670. EFI_SET_VARIABLE SetVariable;
  671. //
  672. // Misc
  673. //
  674. EFI_GET_NEXT_HIGH_MONO_COUNT GetNextHighMonotonicCount;
  675. EFI_RESET_SYSTEM ResetSystem;
  676. EFI_UPDATE_CAPSULE UpdateCapsule;
  677. EFI_QUERY_CAPSULE_CAPABILITIES QueryCapsuleCapabilities;
  678. EFI_QUERY_VARIABLE_INFO QueryVariableInfo;
  679. } EFI_RUNTIME_SERVICES;
  680. //
  681. // EFI Boot Services Table
  682. //
  683. #define EFI_BOOT_SERVICES_SIGNATURE 0x56524553544f4f42
  684. #define EFI_1_02_BOOT_SERVICES_REVISION EFI_SPECIFICATION_REVISION_MAJORMINOR(1, 02)
  685. #define EFI_1_10_BOOT_SERVICES_REVISION EFI_SPECIFICATION_REVISION_MAJORMINOR(1, 10)
  686. #define EFI_2_00_BOOT_SERVICES_REVISION EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 00)
  687. #define EFI_2_10_BOOT_SERVICES_REVISION EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 10)
  688. #define EFI_2_20_BOOT_SERVICES_REVISION EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 20)
  689. #define EFI_2_30_BOOT_SERVICES_REVISION EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 30)
  690. #define EFI_2_31_BOOT_SERVICES_REVISION EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 31)
  691. #define EFI_2_40_BOOT_SERVICES_REVISION EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 40)
  692. #define EFI_2_50_BOOT_SERVICES_REVISION EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 50)
  693. #define EFI_2_60_BOOT_SERVICES_REVISION EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 60)
  694. #define EFI_2_70_BOOT_SERVICES_REVISION EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 70)
  695. #define EFI_2_80_BOOT_SERVICES_REVISION EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 80)
  696. #define EFI_2_90_BOOT_SERVICES_REVISION EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 90)
  697. #define EFI_2_100_BOOT_SERVICES_REVISION EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 100)
  698. #define EFI_BOOT_SERVICES_REVISION EFI_SPECIFICATION_VERSION
  699. typedef struct _EFI_BOOT_SERVICES {
  700. EFI_TABLE_HEADER Hdr;
  701. //
  702. // Task priority functions
  703. //
  704. EFI_RAISE_TPL RaiseTPL;
  705. EFI_RESTORE_TPL RestoreTPL;
  706. //
  707. // Memory functions
  708. //
  709. EFI_ALLOCATE_PAGES AllocatePages;
  710. EFI_FREE_PAGES FreePages;
  711. EFI_GET_MEMORY_MAP GetMemoryMap;
  712. EFI_ALLOCATE_POOL AllocatePool;
  713. EFI_FREE_POOL FreePool;
  714. //
  715. // Event & timer functions
  716. //
  717. EFI_CREATE_EVENT CreateEvent;
  718. EFI_SET_TIMER SetTimer;
  719. EFI_WAIT_FOR_EVENT WaitForEvent;
  720. EFI_SIGNAL_EVENT SignalEvent;
  721. EFI_CLOSE_EVENT CloseEvent;
  722. EFI_CHECK_EVENT CheckEvent;
  723. //
  724. // Protocol handler functions
  725. //
  726. EFI_INSTALL_PROTOCOL_INTERFACE InstallProtocolInterface;
  727. EFI_REINSTALL_PROTOCOL_INTERFACE ReinstallProtocolInterface;
  728. EFI_UNINSTALL_PROTOCOL_INTERFACE UninstallProtocolInterface;
  729. EFI_HANDLE_PROTOCOL HandleProtocol;
  730. EFI_HANDLE_PROTOCOL PCHandleProtocol;
  731. EFI_REGISTER_PROTOCOL_NOTIFY RegisterProtocolNotify;
  732. EFI_LOCATE_HANDLE LocateHandle;
  733. EFI_LOCATE_DEVICE_PATH LocateDevicePath;
  734. EFI_INSTALL_CONFIGURATION_TABLE InstallConfigurationTable;
  735. //
  736. // Image functions
  737. //
  738. EFI_IMAGE_LOAD LoadImage;
  739. EFI_IMAGE_START StartImage;
  740. EFI_EXIT Exit;
  741. EFI_IMAGE_UNLOAD UnloadImage;
  742. EFI_EXIT_BOOT_SERVICES ExitBootServices;
  743. //
  744. // Misc functions
  745. //
  746. EFI_GET_NEXT_MONOTONIC_COUNT GetNextMonotonicCount;
  747. EFI_STALL Stall;
  748. EFI_SET_WATCHDOG_TIMER SetWatchdogTimer;
  749. //
  750. // DriverSupport Services
  751. //
  752. EFI_CONNECT_CONTROLLER ConnectController;
  753. EFI_DISCONNECT_CONTROLLER DisconnectController;
  754. //
  755. // Open and Close Protocol Services
  756. //
  757. EFI_OPEN_PROTOCOL OpenProtocol;
  758. EFI_CLOSE_PROTOCOL CloseProtocol;
  759. EFI_OPEN_PROTOCOL_INFORMATION OpenProtocolInformation;
  760. //
  761. // Library Services
  762. //
  763. EFI_PROTOCOLS_PER_HANDLE ProtocolsPerHandle;
  764. EFI_LOCATE_HANDLE_BUFFER LocateHandleBuffer;
  765. EFI_LOCATE_PROTOCOL LocateProtocol;
  766. EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES InstallMultipleProtocolInterfaces;
  767. EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES UninstallMultipleProtocolInterfaces;
  768. //
  769. // 32-bit CRC Services
  770. //
  771. EFI_CALCULATE_CRC32 CalculateCrc32;
  772. //
  773. // Misc Services
  774. //
  775. EFI_COPY_MEM CopyMem;
  776. EFI_SET_MEM SetMem;
  777. EFI_CREATE_EVENT_EX CreateEventEx;
  778. } EFI_BOOT_SERVICES;
  779. //
  780. // EFI Configuration Table and GUID definitions
  781. //
  782. #define MPS_TABLE_GUID \
  783. { 0xeb9d2d2f, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} }
  784. #define ACPI_TABLE_GUID \
  785. { 0xeb9d2d30, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} }
  786. #define ACPI_20_TABLE_GUID \
  787. { 0x8868e871, 0xe4f1, 0x11d3, {0xbc, 0x22, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81} }
  788. #define SMBIOS_TABLE_GUID \
  789. { 0xeb9d2d31, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} }
  790. #define SMBIOS3_TABLE_GUID \
  791. { 0xf2fd1544, 0x9794, 0x4a2c, {0x99, 0x2e, 0xe5, 0xbb, 0xcf, 0x20, 0xe3, 0x94} }
  792. #define SAL_SYSTEM_TABLE_GUID \
  793. { 0xeb9d2d32, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} }
  794. #define EFI_DTB_TABLE_GUID \
  795. { 0xb1b621d5, 0xf19c, 0x41a5, {0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0} }
  796. typedef struct _EFI_CONFIGURATION_TABLE {
  797. EFI_GUID VendorGuid;
  798. VOID *VendorTable;
  799. } EFI_CONFIGURATION_TABLE;
  800. //
  801. // EFI System Table
  802. //
  803. #define EFI_SYSTEM_TABLE_SIGNATURE 0x5453595320494249
  804. #define EFI_1_02_SYSTEM_TABLE_REVISION EFI_SPECIFICATION_REVISION_MAJORMINOR(1, 02)
  805. #define EFI_1_10_SYSTEM_TABLE_REVISION EFI_SPECIFICATION_REVISION_MAJORMINOR(1, 10)
  806. #define EFI_2_00_SYSTEM_TABLE_REVISION EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 00)
  807. #define EFI_2_10_SYSTEM_TABLE_REVISION EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 10)
  808. #define EFI_2_20_SYSTEM_TABLE_REVISION EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 20)
  809. #define EFI_2_30_SYSTEM_TABLE_REVISION EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 30)
  810. #define EFI_2_31_SYSTEM_TABLE_REVISION EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 31)
  811. #define EFI_2_40_SYSTEM_TABLE_REVISION EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 40)
  812. #define EFI_2_50_SYSTEM_TABLE_REVISION EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 50)
  813. #define EFI_2_60_SYSTEM_TABLE_REVISION EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 60)
  814. #define EFI_2_70_SYSTEM_TABLE_REVISION EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 70)
  815. #define EFI_2_80_SYSTEM_TABLE_REVISION EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 80)
  816. #define EFI_2_90_SYSTEM_TABLE_REVISION EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 90)
  817. #define EFI_2_100_SYSTEM_TABLE_REVISION EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 100)
  818. #define EFI_SYSTEM_TABLE_REVISION EFI_SPECIFICATION_VERSION
  819. typedef struct _EFI_SYSTEM_TABLE {
  820. EFI_TABLE_HEADER Hdr;
  821. CHAR16 *FirmwareVendor;
  822. UINT32 FirmwareRevision;
  823. EFI_HANDLE ConsoleInHandle;
  824. SIMPLE_INPUT_INTERFACE *ConIn;
  825. EFI_HANDLE ConsoleOutHandle;
  826. SIMPLE_TEXT_OUTPUT_INTERFACE *ConOut;
  827. EFI_HANDLE StandardErrorHandle;
  828. SIMPLE_TEXT_OUTPUT_INTERFACE *StdErr;
  829. EFI_RUNTIME_SERVICES *RuntimeServices;
  830. EFI_BOOT_SERVICES *BootServices;
  831. UINTN NumberOfTableEntries;
  832. EFI_CONFIGURATION_TABLE *ConfigurationTable;
  833. } EFI_SYSTEM_TABLE;
  834. #endif