uefifw.h 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653
  1. /*++
  2. Copyright (c) 2013 Minoca Corp.
  3. This file is licensed under the terms of the GNU General Public License
  4. version 3. Alternative licensing terms are available. Contact
  5. info@minocacorp.com for details. See the LICENSE file at the root of this
  6. project for complete licensing information.
  7. Module Name:
  8. uefifw.h
  9. Abstract:
  10. This header contains base definitions for the UEFI firmware implementations.
  11. This header is internal to the firmware implementation and is not exposed
  12. to UEFI applications or drivers.
  13. Author:
  14. Evan Green 26-Feb-2014
  15. --*/
  16. //
  17. // ------------------------------------------------------------------- Includes
  18. //
  19. #include <minoca/uefi/uefi.h>
  20. #include "shortcut.h"
  21. //
  22. // --------------------------------------------------------------------- Macros
  23. //
  24. //
  25. // These macros convert to and from Binary Coded Decimal values.
  26. //
  27. #define EFI_BCD_TO_BINARY(_BcdValue) \
  28. ((((_BcdValue) >> 4) * 10) + ((_BcdValue) & 0x0F))
  29. #define EFI_BINARY_TO_BCD(_BinaryValue) \
  30. ((((_BinaryValue) / 10) << 4) | ((_BinaryValue) % 10))
  31. //
  32. // ---------------------------------------------------------------- Definitions
  33. //
  34. #ifndef NOTHING
  35. #define NOTHING
  36. #endif
  37. #define EFI_IDLE_LOOP_EVENT_GUID \
  38. { \
  39. 0x3C8D294C, 0x5FC3, 0x4451, \
  40. {0xBB, 0x31, 0xC4, 0xC0, 0x32, 0x29, 0x5E, 0x6C} \
  41. }
  42. #define EFI_DEFAULT_SHELL_FILE_GUID \
  43. { \
  44. 0x7C04A583, 0x9E3E, 0x4F1C, \
  45. {0xAD, 0x65, 0xE0, 0x52, 0x68, 0xD0, 0xB4, 0xD1} \
  46. }
  47. //
  48. // Define the default watchdog timer duration that gets set when handing
  49. // control to drivers and boot entries.
  50. //
  51. #define EFI_DEFAULT_WATCHDOG_DURATION (5 * 60)
  52. //
  53. // ------------------------------------------------------ Data Type Definitions
  54. //
  55. typedef
  56. VOID
  57. (*EFI_PLATFORM_BEGIN_INTERRUPT) (
  58. UINT32 *InterruptNumber,
  59. VOID **InterruptContext
  60. );
  61. /*++
  62. Routine Description:
  63. This routine is called when an interrupts comes in. The platform code is
  64. responsible for reporting the interrupt number. Interrupts are disabled at
  65. the processor core at this point.
  66. Arguments:
  67. InterruptNumber - Supplies a pointer where interrupt line number will be
  68. returned.
  69. InterruptContext - Supplies a pointer where the platform can store a
  70. pointer's worth of context that will be passed back when ending the
  71. interrupt.
  72. Return Value:
  73. None.
  74. --*/
  75. typedef
  76. VOID
  77. (*EFI_PLATFORM_HANDLE_INTERRUPT) (
  78. UINT32 InterruptNumber,
  79. VOID *InterruptContext
  80. );
  81. /*++
  82. Routine Description:
  83. This routine is called to handle a platform interrupt.
  84. Arguments:
  85. InterruptNumber - Supplies the interrupt number that occurred.
  86. InterruptContext - Supplies the context returned by the interrupt
  87. controller when the interrupt began.
  88. Return Value:
  89. None.
  90. --*/
  91. typedef
  92. VOID
  93. (*EFI_PLATFORM_END_INTERRUPT) (
  94. UINT32 InterruptNumber,
  95. VOID *InterruptContext
  96. );
  97. /*++
  98. Routine Description:
  99. This routine is called to finish handling of a platform interrupt. This is
  100. where the End-Of-Interrupt would get sent to the interrupt controller.
  101. Arguments:
  102. InterruptNumber - Supplies the interrupt number that occurred.
  103. InterruptContext - Supplies the context returned by the interrupt
  104. controller when the interrupt began.
  105. Return Value:
  106. None.
  107. --*/
  108. typedef
  109. VOID
  110. (*EFI_PLATFORM_SERVICE_TIMER_INTERRUPT) (
  111. UINT32 InterruptNumber
  112. );
  113. /*++
  114. Routine Description:
  115. This routine is called to acknowledge a platform timer interrupt. This
  116. routine is responsible for quiescing the interrupt.
  117. Arguments:
  118. InterruptNumber - Supplies the interrupt number that occurred.
  119. Return Value:
  120. None.
  121. --*/
  122. typedef
  123. UINT64
  124. (*EFI_PLATFORM_READ_TIMER) (
  125. VOID
  126. );
  127. /*++
  128. Routine Description:
  129. This routine is called to read the current platform time value. The timer
  130. is assumed to be free running at a constant frequency, and should have a
  131. bit width as reported in the initialize function. The UEFI core will
  132. manage software bit extension out to 64 bits, this routine should just
  133. reporte the hardware timer value.
  134. Arguments:
  135. None.
  136. Return Value:
  137. Returns the hardware timer value.
  138. --*/
  139. //
  140. // -------------------------------------------------------------------- Globals
  141. //
  142. //
  143. // Store the firmware version information.
  144. //
  145. extern UINT16 EfiVersionMajor;
  146. extern UINT16 EfiVersionMinor;
  147. extern UINT16 EfiVersionRevision;
  148. extern UINT8 EfiVersionRelease;
  149. extern UINT32 EfiEncodedVersion;
  150. extern UINT32 EfiVersionSerial;
  151. extern UINT32 EfiBuildTime;
  152. extern CHAR8 *EfiBuildString;
  153. extern CHAR8 *EfiProductName;
  154. extern CHAR8 *EfiBuildTimeString;
  155. //
  156. // Define some well known GUIDs.
  157. //
  158. extern EFI_GUID EfiAcpiTableGuid;
  159. extern EFI_GUID EfiAcpiTable1Guid;
  160. extern EFI_GUID EfiBlockIoProtocolGuid;
  161. extern EFI_GUID EfiDevicePathProtocolGuid;
  162. extern EFI_GUID EfiDiskIoProtocolGuid;
  163. extern EFI_GUID EfiDriverBindingProtocolGuid;
  164. extern EFI_GUID EfiEventExitBootServicesGuid;
  165. extern EFI_GUID EfiEventVirtualAddressChangeGuid;
  166. extern EFI_GUID EfiEventMemoryMapChangeGuid;
  167. extern EFI_GUID EfiEventReadyToBootGuid;
  168. extern EFI_GUID EfiFileInformationGuid;
  169. extern EFI_GUID EfiFirmwareVolume2ProtocolGuid;
  170. extern EFI_GUID EfiGlobalVariableGuid;
  171. extern EFI_GUID EfiGraphicsOutputProtocolGuid;
  172. extern EFI_GUID EfiLoadedImageProtocolGuid;
  173. extern EFI_GUID EfiLoadFileProtocolGuid;
  174. extern EFI_GUID EfiLoadFile2ProtocolGuid;
  175. extern EFI_GUID EfiPartitionTypeSystemPartitionGuid;
  176. extern EFI_GUID EfiSimpleFileSystemProtocolGuid;
  177. extern EFI_GUID EfiSimpleTextInputProtocolGuid;
  178. extern EFI_GUID EfiSimpleTextOutputProtocolGuid;
  179. //
  180. // -------------------------------------------------------- Function Prototypes
  181. //
  182. //
  183. // Define functions implemented by the platform-specific firmware, called by
  184. // the firmware core.
  185. //
  186. //
  187. // Debug transport routines
  188. //
  189. EFI_STATUS
  190. EfiPlatformDebugDeviceReset (
  191. UINT32 BaudRate
  192. );
  193. /*++
  194. Routine Description:
  195. This routine attempts to initialize the serial UART used for debugging.
  196. Arguments:
  197. BaudRate - Supplies the desired baud rate.
  198. Return Value:
  199. EFI_SUCCESS on success.
  200. EFI_DEVICE_ERROR if a device error occurred while resetting the device.
  201. EFI_UNSUPPORTED if the given baud rate cannot be achieved.
  202. --*/
  203. EFI_STATUS
  204. EfiPlatformDebugDeviceTransmit (
  205. VOID *Data,
  206. UINTN Size
  207. );
  208. /*++
  209. Routine Description:
  210. This routine transmits data from the host out through the debug device.
  211. Arguments:
  212. Data - Supplies a pointer to the data to write.
  213. Size - Supplies the size to write, in bytes.
  214. Return Value:
  215. EFI_SUCCESS on success.
  216. EFI_DEVICE_ERROR if a device error occurred.
  217. --*/
  218. EFI_STATUS
  219. EfiPlatformDebugDeviceReceive (
  220. VOID *Data,
  221. UINTN *Size
  222. );
  223. /*++
  224. Routine Description:
  225. This routine receives incoming data from the debug device.
  226. Arguments:
  227. Data - Supplies a pointer where the read data will be returned on success.
  228. Size - Supplies a pointer that on input contains the size of the receive
  229. buffer. On output, returns the number of bytes read.
  230. Return Value:
  231. EFI_SUCCESS on success.
  232. EFI_NOT_READY if there was no data to be read at the current time.
  233. EFI_DEVICE_ERROR if a device error occurred.
  234. --*/
  235. EFI_STATUS
  236. EfiPlatformDebugDeviceGetStatus (
  237. BOOLEAN *ReceiveDataAvailable
  238. );
  239. /*++
  240. Routine Description:
  241. This routine returns the current device status.
  242. Arguments:
  243. ReceiveDataAvailable - Supplies a pointer where a boolean will be returned
  244. indicating whether or not receive data is available.
  245. Return Value:
  246. EFI_SUCCESS on success.
  247. EFI_DEVICE_ERROR if a device error occurred.
  248. --*/
  249. VOID
  250. EfiPlatformDebugDeviceDisconnect (
  251. VOID
  252. );
  253. /*++
  254. Routine Description:
  255. This routine disconnects a device, taking it offline.
  256. Arguments:
  257. None.
  258. Return Value:
  259. None.
  260. --*/
  261. //
  262. // Initialization routines
  263. //
  264. EFI_STATUS
  265. EfiPlatformInitialize (
  266. UINT32 Phase
  267. );
  268. /*++
  269. Routine Description:
  270. This routine performs platform-specific firmware initialization.
  271. Arguments:
  272. Phase - Supplies the iteration number this routine is being called on.
  273. Phase zero occurs very early, just after the debugger comes up.
  274. Phase one occurs a bit later, after timer and interrupt services are
  275. initialized. Phase two happens right before boot, after all platform
  276. devices have been enumerated.
  277. Return Value:
  278. EFI status code.
  279. --*/
  280. EFI_STATUS
  281. EfiPlatformGetInitialMemoryMap (
  282. EFI_MEMORY_DESCRIPTOR **Map,
  283. UINTN *MapSize
  284. );
  285. /*++
  286. Routine Description:
  287. This routine returns the initial platform memory map to the EFI core. The
  288. core maintains this memory map. The memory map returned does not need to
  289. take into account the firmware image itself or stack, the EFI core will
  290. reserve those regions automatically.
  291. Arguments:
  292. Map - Supplies a pointer where the array of memory descriptors constituting
  293. the initial memory map is returned on success. The EFI core will make
  294. a copy of these descriptors, so they can be in read-only or
  295. temporary memory.
  296. MapSize - Supplies a pointer where the number of elements in the initial
  297. memory map will be returned on success.
  298. Return Value:
  299. EFI status code.
  300. --*/
  301. EFI_STATUS
  302. EfiPlatformInitializeInterrupts (
  303. EFI_PLATFORM_BEGIN_INTERRUPT *BeginInterruptFunction,
  304. EFI_PLATFORM_HANDLE_INTERRUPT *HandleInterruptFunction,
  305. EFI_PLATFORM_END_INTERRUPT *EndInterruptFunction
  306. );
  307. /*++
  308. Routine Description:
  309. This routine initializes support for platform interrupts. Interrupts are
  310. assumed to be disabled at the processor now. This routine should enable
  311. interrupts at the procesor core.
  312. Arguments:
  313. BeginInterruptFunction - Supplies a pointer where a pointer to a function
  314. will be returned that is called when an interrupt occurs.
  315. HandleInterruptFunction - Supplies a pointer where a pointer to a function
  316. will be returned that is called to handle a platform-specific interurpt.
  317. NULL may be returned here.
  318. EndInterruptFunction - Supplies a pointer where a pointer to a function
  319. will be returned that is called to complete an interrupt.
  320. Return Value:
  321. EFI Status code.
  322. --*/
  323. VOID
  324. EfiPlatformTerminateInterrupts (
  325. VOID
  326. );
  327. /*++
  328. Routine Description:
  329. This routine terminates interrupt services in preparation for transitioning
  330. out of boot services.
  331. Arguments:
  332. None.
  333. Return Value:
  334. None.
  335. --*/
  336. EFIAPI
  337. EFI_STATUS
  338. EfiPlatformSetWatchdogTimer (
  339. UINTN Timeout,
  340. UINT64 WatchdogCode,
  341. UINTN DataSize,
  342. CHAR16 *WatchdogData
  343. );
  344. /*++
  345. Routine Description:
  346. This routine sets the system's watchdog timer.
  347. Arguments:
  348. Timeout - Supplies the number of seconds to set the timer for.
  349. WatchdogCode - Supplies a numeric code to log on a watchdog timeout event.
  350. DataSize - Supplies the size of the watchdog data.
  351. WatchdogData - Supplies an optional buffer that includes a null-terminated
  352. string, optionally followed by additional binary data.
  353. Return Value:
  354. EFI_SUCCESS on success.
  355. EFI_INVALID_PARAMETER if the supplied watchdog code is invalid.
  356. EFI_UNSUPPORTED if there is no watchdog timer.
  357. EFI_DEVICE_ERROR if an error occurred accessing the device hardware.
  358. --*/
  359. EFI_STATUS
  360. EfiPlatformInitializeTimers (
  361. UINT32 *ClockTimerInterruptNumber,
  362. EFI_PLATFORM_SERVICE_TIMER_INTERRUPT *ClockTimerServiceRoutine,
  363. EFI_PLATFORM_READ_TIMER *ReadTimerRoutine,
  364. UINT64 *ReadTimerFrequency,
  365. UINT32 *ReadTimerWidth
  366. );
  367. /*++
  368. Routine Description:
  369. This routine initializes platform timer services. There are actually two
  370. different timer services returned in this routine. The periodic timer tick
  371. provides a periodic interrupt. The read timer provides a free running
  372. counter value. These are likely serviced by different timers. For the
  373. periodic timer tick, this routine should start the periodic interrupts
  374. coming in. The periodic rate of the timer can be anything reasonable, as
  375. the time counter will be used to count actual duration. The rate should be
  376. greater than twice the rollover rate of the time counter to ensure proper
  377. time accounting. Interrupts are disabled at the processor core for the
  378. duration of this routine.
  379. Arguments:
  380. ClockTimerInterruptNumber - Supplies a pointer where the interrupt line
  381. number of the periodic timer tick will be returned.
  382. ClockTimerServiceRoutine - Supplies a pointer where a pointer to a routine
  383. called when the periodic timer tick interrupt occurs will be returned.
  384. ReadTimerRoutine - Supplies a pointer where a pointer to a routine
  385. called to read the current timer value will be returned.
  386. ReadTimerFrequency - Supplies the frequency of the counter.
  387. ReadTimerWidth - Supplies a pointer where the read timer bit width will be
  388. returned.
  389. Return Value:
  390. EFI Status code.
  391. --*/
  392. VOID
  393. EfiPlatformTerminateTimers (
  394. VOID
  395. );
  396. /*++
  397. Routine Description:
  398. This routine terminates timer services in preparation for the termination
  399. of boot services.
  400. Arguments:
  401. None.
  402. Return Value:
  403. None.
  404. --*/
  405. EFI_STATUS
  406. EfiPlatformEnumerateFirmwareVolumes (
  407. VOID
  408. );
  409. /*++
  410. Routine Description:
  411. This routine enumerates any firmware volumes the platform may have
  412. tucked away. The platform should load them into memory and call
  413. EfiCreateFirmwareVolume for each one.
  414. Arguments:
  415. None.
  416. Return Value:
  417. EFI Status code.
  418. --*/
  419. EFI_STATUS
  420. EfiPlatformEnumerateDevices (
  421. VOID
  422. );
  423. /*++
  424. Routine Description:
  425. This routine enumerates and connects any builtin devices the platform
  426. contains.
  427. Arguments:
  428. None.
  429. Return Value:
  430. EFI status code.
  431. --*/
  432. EFI_STATUS
  433. EfiPlatformRuntimeInitialize (
  434. VOID
  435. );
  436. /*++
  437. Routine Description:
  438. This routine performs platform-specific firmware initialization in the
  439. runtime core driver. The runtime routines are in a separate binary from the
  440. firmware core routines as they need to be relocated for runtime. This
  441. routine should perform platform-specific initialization needed to provide
  442. the core runtime services.
  443. Arguments:
  444. None.
  445. Return Value:
  446. EFI status code.
  447. --*/
  448. //
  449. // Variable services, implemented in the runtime core.
  450. //
  451. EFI_STATUS
  452. EfiPlatformReadNonVolatileData (
  453. VOID *Data,
  454. UINTN DataSize
  455. );
  456. /*++
  457. Routine Description:
  458. This routine reads the EFI variable data from non-volatile storage.
  459. Arguments:
  460. Data - Supplies a pointer where the platform returns the non-volatile
  461. data.
  462. DataSize - Supplies the size of the data to return.
  463. Return Value:
  464. EFI_SUCCESS if some data was successfully loaded.
  465. EFI_UNSUPPORTED if the platform does not have non-volatile storage. In this
  466. case the firmware core saves the non-volatile variables to a file on the
  467. EFI system partition, and the variable library hopes to catch the same
  468. variable buffer on reboots to see variable writes that happened at
  469. runtime.
  470. EFI_DEVICE_IO_ERROR if a device error occurred during the operation.
  471. Other error codes on other failures.
  472. --*/
  473. EFI_STATUS
  474. EfiPlatformWriteNonVolatileData (
  475. VOID *Data,
  476. UINTN DataSize
  477. );
  478. /*++
  479. Routine Description:
  480. This routine writes the EFI variable data to non-volatile storage.
  481. Arguments:
  482. Data - Supplies a pointer to the data to write.
  483. DataSize - Supplies the size of the data to write, in bytes.
  484. Return Value:
  485. EFI_SUCCESS if some data was successfully loaded.
  486. EFI_UNSUPPORTED if the platform does not have non-volatile storage. In this
  487. case the firmware core saves the non-volatile variables to a file on the
  488. EFI system partition, and the variable library hopes to catch the same
  489. variable buffer on reboots to see variable writes that happened at
  490. runtime.
  491. EFI_DEVICE_IO_ERROR if a device error occurred during the operation.
  492. Other error codes on other failures.
  493. --*/
  494. VOID
  495. EfiPlatformRuntimeExitBootServices (
  496. VOID
  497. );
  498. /*++
  499. Routine Description:
  500. This routine is called in the runtime core driver when the firmware is in
  501. the process of terminating boot services. The platform can do any work it
  502. needs to prepare for the imminent termination of boot services.
  503. Arguments:
  504. None.
  505. Return Value:
  506. None.
  507. --*/
  508. VOID
  509. EfiPlatformRuntimeVirtualAddressChange (
  510. VOID
  511. );
  512. /*++
  513. Routine Description:
  514. This routine is called in the runtime core driver when the firmware is
  515. converting to virtual address mode. It should convert any pointers it's
  516. got. This routine is called after ExitBootServices, so no EFI boot services
  517. are available.
  518. Arguments:
  519. None.
  520. Return Value:
  521. None.
  522. --*/
  523. //
  524. // Define functions implemented by the UEFI core that platform functions can
  525. // call.
  526. //
  527. VOID
  528. EfiCoreMain (
  529. VOID *FirmwareBaseAddress,
  530. VOID *FirmwareLowestAddress,
  531. UINTN FirmwareSize,
  532. CHAR8 *FirmwareBinaryName,
  533. VOID *StackBase,
  534. UINTN StackSize
  535. );
  536. /*++
  537. Routine Description:
  538. This routine implements the entry point into the UEFI firmware. This
  539. routine is called by the platform firmware, and should be called as early
  540. as possible. It will perform callouts to allow the platform to initialize
  541. further.
  542. Arguments:
  543. FirmwareBaseAddress - Supplies the base address where the firmware was
  544. loaded into memory. Supply -1 to indicate that the image is loaded at
  545. its preferred base address and was not relocated.
  546. FirmwareLowestAddress - Supplies the lowest address where the firmware was
  547. loaded into memory.
  548. FirmwareSize - Supplies the size of the firmware image in memory, in bytes.
  549. FirmwareBinaryName - Supplies the name of the binary that's loaded, which
  550. is reported to the debugger for symbol loading.
  551. StackBase - Supplies the base (lowest) address of the stack.
  552. StackSize - Supplies the size in bytes of the stack. This should be at
  553. least 0x4000 bytes (16kB).
  554. Return Value:
  555. This routine does not return.
  556. --*/
  557. EFI_STATUS
  558. EfiCreateFirmwareVolume (
  559. EFI_PHYSICAL_ADDRESS BaseAddress,
  560. UINT64 Length,
  561. EFI_HANDLE ParentHandle,
  562. UINT32 AuthenticationStatus,
  563. EFI_HANDLE *BlockIoProtocol
  564. );
  565. /*++
  566. Routine Description:
  567. This routine creates a firmware volume out of the given memory buffer.
  568. Specifically, this function creates a handle and adds the Firmware Block
  569. I/O protocol and the Device Path protocol to it. The firmware volume
  570. protocol will then attach after noticing the block I/O protocol instance.
  571. Arguments:
  572. BaseAddress - Supplies the physical address of the firmware volume buffer.
  573. Length - Supplies the length of the firmware volume buffer in bytes.
  574. ParentHandle - Supplies an optional handle to a parent firmware volume this
  575. volume is being enumerated from.
  576. AuthenticationStatus - Supplies the authentication status of this volume if
  577. this volume came from another file and volume.
  578. BlockIoProtocol - Supplies an optional pointer where the created handle
  579. will be returned on success.
  580. Return Value:
  581. EFI_SUCCESS on success.
  582. EFI_VOLUME_CORRUPTED if the volume was not valid.
  583. EFI_OUT_OF_RESOURCES on allocation failure.
  584. --*/
  585. EFI_STATUS
  586. EfiCoreEnumerateRamDisk (
  587. EFI_PHYSICAL_ADDRESS Base,
  588. UINT64 Size
  589. );
  590. /*++
  591. Routine Description:
  592. This routine enumerates a RAM disk at the given address.
  593. Arguments:
  594. Base - Supplies the base physical address of the RAM disk.
  595. Size - Supplies the size of the RAM disk.
  596. Return Value:
  597. EFI Status code.
  598. --*/
  599. EFIAPI
  600. EFI_STATUS
  601. EfiCoreFlushVariableData (
  602. VOID
  603. );
  604. /*++
  605. Routine Description:
  606. This routine attempts to write variable data out to non-volatile storage.
  607. Arguments:
  608. None.
  609. Return Value:
  610. EFI status code.
  611. --*/
  612. EFIAPI
  613. EFI_STATUS
  614. EfiAcpiInstallTable (
  615. VOID *AcpiTableBuffer,
  616. UINTN AcpiTableBufferSize,
  617. UINTN *TableKey
  618. );
  619. /*++
  620. Routine Description:
  621. This routine installs an ACPI table into the RSDT/XSDT.
  622. Arguments:
  623. AcpiTableBuffer - Supplies a pointer to the buffer containing the ACPI
  624. table to insert.
  625. AcpiTableBufferSize - Supplies the size in bytes of the ACPI table buffer.
  626. TableKey - Supplies a pointer where a key will be returned that refers
  627. to the table.
  628. Return Value:
  629. EFI status code.
  630. --*/
  631. EFIAPI
  632. EFI_STATUS
  633. EfiAcpiUninstallTable (
  634. UINTN TableKey
  635. );
  636. /*++
  637. Routine Description:
  638. This routine uninstalls a previously install ACPI table.
  639. Arguments:
  640. TableKey - Supplies the key returned when the table was installed.
  641. Return Value:
  642. EFI status code.
  643. --*/
  644. EFIAPI
  645. VOID
  646. EfiAcpiChecksumTable (
  647. VOID *Buffer,
  648. UINTN Size,
  649. UINTN ChecksumOffset
  650. );
  651. /*++
  652. Routine Description:
  653. This routine checksums an ACPI table.
  654. Arguments:
  655. Buffer - Supplies a pointer to the table to checksum.
  656. Size - Supplies the size of the table in bytes.
  657. ChecksumOffset - Supplies the offset of the 8 bit checksum field.
  658. Return Value:
  659. None.
  660. --*/
  661. EFIAPI
  662. VOID *
  663. EfiGetAcpiTable (
  664. UINT32 Signature,
  665. VOID *PreviousTable
  666. );
  667. /*++
  668. Routine Description:
  669. This routine attempts to find an ACPI description table with the given
  670. signature. This routine does not validate the checksum of the table.
  671. Arguments:
  672. Signature - Supplies the signature of the desired table.
  673. PreviousTable - Supplies an optional pointer to the table to start the
  674. search from.
  675. Return Value:
  676. Returns a pointer to the beginning of the header to the table if the table
  677. was found, or NULL if the table could not be located.
  678. --*/
  679. EFIAPI
  680. EFI_STATUS
  681. EfiSmbiosAddStructure (
  682. VOID *Table,
  683. ...
  684. );
  685. /*++
  686. Routine Description:
  687. This routine adds an SMBIOS structure to the SMBIOS table.
  688. Arguments:
  689. Table - Supplies a pointer to the table to add. A copy of this data will be
  690. made. The length of the table must be correctly filled in.
  691. ... - Supplies an array of pointers to strings to add to the end of the
  692. table. This list must be terminated with a NULL.
  693. Return Value:
  694. EFI_SUCCESS on success.
  695. EFI_INSUFFICIENT_RESOURCES if a memory allocation failed.
  696. --*/
  697. EFI_STATUS
  698. EfiConvertCounterToEfiTime (
  699. INT64 Counter,
  700. EFI_TIME *EfiTime
  701. );
  702. /*++
  703. Routine Description:
  704. This routine converts from a second-based counter value to an EFI time
  705. structure.
  706. Arguments:
  707. Counter - Supplies the count of seconds since January 1, 2001 GMT.
  708. EfiTime - Supplies a pointer where the EFI time fields will be returned.
  709. Return Value:
  710. EFI_SUCCESS on success.
  711. EFI_INVALID_PARAMETER if the counter could not be converted.
  712. --*/
  713. EFI_STATUS
  714. EfiConvertEfiTimeToCounter (
  715. EFI_TIME *EfiTime,
  716. INT64 *Counter
  717. );
  718. /*++
  719. Routine Description:
  720. This routine converts from an EFI time structure into the number of seconds
  721. since January 1, 2001 GMT.
  722. Arguments:
  723. EfiTime - Supplies a pointer to the EFI time to convert.
  724. Counter - Supplies a pointer where the count of seconds will be returned
  725. on success.
  726. Return Value:
  727. EFI_SUCCESS on success.
  728. EFI_INVALID_PARAMETER if the counter could not be converted.
  729. --*/
  730. BOOLEAN
  731. EfiDivideUnsigned64 (
  732. UINT64 Dividend,
  733. UINT64 Divisor,
  734. UINT64 *QuotientOut,
  735. UINT64 *RemainderOut
  736. );
  737. /*++
  738. Routine Description:
  739. This routine performs a 64-bit divide of two unsigned numbers.
  740. Arguments:
  741. Dividend - Supplies the number that is going to be divided (the numerator).
  742. Divisor - Supplies the number to divide into (the denominator).
  743. QuotientOut - Supplies a pointer that receives the result of the divide.
  744. This parameter may be NULL.
  745. RemainderOut - Supplies a pointer that receives the remainder of the
  746. divide. This parameter may be NULL.
  747. Return Value:
  748. Returns TRUE if the operation was successful, or FALSE if there was an
  749. error (like divide by 0).
  750. --*/
  751. BOOLEAN
  752. EfiDivide64 (
  753. INT64 Dividend,
  754. INT64 Divisor,
  755. INT64 *QuotientOut,
  756. INT64 *RemainderOut
  757. );
  758. /*++
  759. Routine Description:
  760. This routine performs a 64-bit divide of two signed numbers.
  761. Arguments:
  762. Dividend - Supplies the number that is going to be divided (the numerator).
  763. Divisor - Supplies the number to divide into (the denominator).
  764. QuotientOut - Supplies a pointer that receives the result of the divide.
  765. This parameter may be NULL.
  766. RemainderOut - Supplies a pointer that receives the remainder of the
  767. divide. This parameter may be NULL.
  768. Return Value:
  769. Returns TRUE if the operation was successful, or FALSE if there was an
  770. error (like divide by 0).
  771. --*/
  772. //
  773. // Interrupt functions
  774. //
  775. BOOLEAN
  776. EfiDisableInterrupts (
  777. VOID
  778. );
  779. /*++
  780. Routine Description:
  781. This routine disables all interrupts on the current processor.
  782. Arguments:
  783. None.
  784. Return Value:
  785. TRUE if interrupts were previously enabled on the processor.
  786. FALSE if interrupts were not previously enabled on the processor.
  787. --*/
  788. VOID
  789. EfiEnableInterrupts (
  790. VOID
  791. );
  792. /*++
  793. Routine Description:
  794. This routine enables interrupts on the current processor.
  795. Arguments:
  796. None.
  797. Return Value:
  798. None.
  799. --*/
  800. BOOLEAN
  801. EfiAreInterruptsEnabled (
  802. VOID
  803. );
  804. /*++
  805. Routine Description:
  806. This routine determines whether or not interrupts are currently enabled
  807. on the processor.
  808. Arguments:
  809. None.
  810. Return Value:
  811. TRUE if interrupts are enabled in the processor.
  812. FALSE if interrupts are globally disabled.
  813. --*/
  814. VOID
  815. EfiCoreInvalidateInstructionCacheRange (
  816. VOID *Address,
  817. UINTN Length
  818. );
  819. /*++
  820. Routine Description:
  821. This routine invalidates a region of memory in the instruction cache.
  822. Arguments:
  823. Address - Supplies the address to invalidate. If translation is enabled,
  824. this is a virtual address.
  825. Length - Supplies the number of bytes in the region to invalidate.
  826. Return Value:
  827. None.
  828. --*/
  829. BOOLEAN
  830. EfiIsAtRuntime (
  831. VOID
  832. );
  833. /*++
  834. Routine Description:
  835. This routine determines whether or not the system has gone through
  836. ExitBootServices.
  837. Arguments:
  838. None.
  839. Return Value:
  840. TRUE if the system has gone past ExitBootServices and is now in the
  841. Runtime phase.
  842. FALSE if the system is currently in the Boot phase.
  843. --*/
  844. //
  845. // I/O port functions (only applicable to PC platforms).
  846. //
  847. UINT8
  848. EfiIoPortIn8 (
  849. UINT16 Address
  850. );
  851. /*++
  852. Routine Description:
  853. This routine performs an 8-bit read from the given I/O port.
  854. Arguments:
  855. Address - Supplies the address to read from.
  856. Return Value:
  857. Returns the value at that address.
  858. --*/
  859. UINT16
  860. EfiIoPortIn16 (
  861. UINT16 Address
  862. );
  863. /*++
  864. Routine Description:
  865. This routine performs a 16-bit read from the given I/O port.
  866. Arguments:
  867. Address - Supplies the address to read from.
  868. Return Value:
  869. Returns the value at that address.
  870. --*/
  871. UINT32
  872. EfiIoPortIn32 (
  873. UINT16 Address
  874. );
  875. /*++
  876. Routine Description:
  877. This routine performs a 32-bit read from the given I/O port.
  878. Arguments:
  879. Address - Supplies the address to read from.
  880. Return Value:
  881. Returns the value at that address.
  882. --*/
  883. VOID
  884. EfiIoPortOut8 (
  885. UINT16 Address,
  886. UINT8 Value
  887. );
  888. /*++
  889. Routine Description:
  890. This routine performs an 8-bit write to the given I/O port.
  891. Arguments:
  892. Address - Supplies the address to write to.
  893. Value - Supplies the value to write.
  894. Return Value:
  895. None.
  896. --*/
  897. VOID
  898. EfiIoPortOut16 (
  899. UINT16 Address,
  900. UINT16 Value
  901. );
  902. /*++
  903. Routine Description:
  904. This routine performs a 16-bit write to the given I/O port.
  905. Arguments:
  906. Address - Supplies the address to write to.
  907. Value - Supplies the value to write.
  908. Return Value:
  909. None.
  910. --*/
  911. VOID
  912. EfiIoPortOut32 (
  913. UINT16 Address,
  914. UINT32 Value
  915. );
  916. /*++
  917. Routine Description:
  918. This routine performs a 32-bit write to the given I/O port.
  919. Arguments:
  920. Address - Supplies the address to write to.
  921. Value - Supplies the value to write.
  922. Return Value:
  923. None.
  924. --*/
  925. //
  926. // Safe memory-mapped hardware register access functions
  927. //
  928. UINT32
  929. EfiReadRegister32 (
  930. VOID *RegisterAddress
  931. );
  932. /*++
  933. Routine Description:
  934. This routine performs a 32-bit memory register read. The given address
  935. is assumed to be mapped with an uncached attribute.
  936. Arguments:
  937. RegisterAddress - Supplies the virtual address of the register to read.
  938. Return Value:
  939. Returns the value at the given register.
  940. --*/
  941. VOID
  942. EfiWriteRegister32 (
  943. VOID *RegisterAddress,
  944. UINT32 Value
  945. );
  946. /*++
  947. Routine Description:
  948. This routine performs a 32-bit memory register write. The given address
  949. is assumed to be mapped with an uncached attribute.
  950. Arguments:
  951. RegisterAddress - Supplies the virtual address of the register to write to.
  952. Value - Supplies the value to write.
  953. Return Value:
  954. None.
  955. --*/
  956. UINT16
  957. EfiReadRegister16 (
  958. VOID *RegisterAddress
  959. );
  960. /*++
  961. Routine Description:
  962. This routine performs a 16-bit memory register read. The given address
  963. is assumed to be mapped with an uncached attribute.
  964. Arguments:
  965. RegisterAddress - Supplies the virtual address of the register to read.
  966. Return Value:
  967. Returns the value at the given register.
  968. --*/
  969. VOID
  970. EfiWriteRegister16 (
  971. VOID *RegisterAddress,
  972. UINT16 Value
  973. );
  974. /*++
  975. Routine Description:
  976. This routine performs a 16-bit memory register write. The given address
  977. is assumed to be mapped with an uncached attribute.
  978. Arguments:
  979. RegisterAddress - Supplies the virtual address of the register to write to.
  980. Value - Supplies the value to write.
  981. Return Value:
  982. None.
  983. --*/
  984. UINT8
  985. EfiReadRegister8 (
  986. VOID *RegisterAddress
  987. );
  988. /*++
  989. Routine Description:
  990. This routine performs an 8-bit memory register read. The given address
  991. is assumed to be mapped with an uncached attribute.
  992. Arguments:
  993. RegisterAddress - Supplies the virtual address of the register to read.
  994. Return Value:
  995. Returns the value at the given register.
  996. --*/
  997. VOID
  998. EfiWriteRegister8 (
  999. VOID *RegisterAddress,
  1000. UINT8 Value
  1001. );
  1002. /*++
  1003. Routine Description:
  1004. This routine performs an 8-bit memory register write. The given address
  1005. is assumed to be mapped with an uncached attribute.
  1006. Arguments:
  1007. RegisterAddress - Supplies the virtual address of the register to write to.
  1008. Value - Supplies the value to write.
  1009. Return Value:
  1010. None.
  1011. --*/
  1012. VOID
  1013. EfiMemoryBarrier (
  1014. VOID
  1015. );
  1016. /*++
  1017. Routine Description:
  1018. This routine provides a full memory barrier, ensuring that all memory
  1019. accesses occurring before this function complete before any memory accesses
  1020. after this function start.
  1021. Arguments:
  1022. None.
  1023. Return Value:
  1024. None.
  1025. --*/
  1026. VOID
  1027. EfiDebugPrint (
  1028. CHAR8 *Format,
  1029. ...
  1030. );
  1031. /*++
  1032. Routine Description:
  1033. This routine prints to the debugger and console.
  1034. Arguments:
  1035. Format - Supplies a pointer to the format string.
  1036. ... - Supplies the remaining arguments to the format string.
  1037. Return Value:
  1038. None.
  1039. --*/