uefifw.h 31 KB

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