efilib.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089
  1. #ifndef _EFILIB_INCLUDE_
  2. #define _EFILIB_INCLUDE_
  3. /*++
  4. Copyright (c) 2000 Intel Corporation
  5. Module Name:
  6. efilib.h
  7. Abstract:
  8. EFI library functions
  9. Revision History
  10. --*/
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14. #include "efidebug.h"
  15. #include "efipart.h"
  16. #if defined(_M_X64) || defined(__x86_64__) || defined(__amd64__)
  17. #include "x86_64/efilibplat.h"
  18. #elif defined(_M_IX86) || defined(__i386__)
  19. #include "ia32/efilibplat.h"
  20. #elif defined(_M_IA64) || defined(__ia64__)
  21. #include "ia64/efilibplat.h"
  22. #elif defined (_M_ARM64) || defined(__aarch64__)
  23. #include "aarch64/efilibplat.h"
  24. #elif defined (_M_ARM) || defined(__arm__)
  25. #include "arm/efilibplat.h"
  26. #elif defined (_M_MIPS64) || defined(__mips64__) || defined(__mips64)
  27. #include "mips64el/efilibplat.h"
  28. #elif defined (__riscv) && __riscv_xlen == 64
  29. #include "riscv64/efilibplat.h"
  30. #elif defined (__loongarch64)
  31. #include "loongarch64/efilibplat.h"
  32. #endif
  33. #include "efilink.h"
  34. #include "efirtlib.h"
  35. #include "efistdarg.h"
  36. #include "pci22.h"
  37. #include "libsmbios.h"
  38. //
  39. // Public read-only data in the EFI library
  40. //
  41. extern EFI_SYSTEM_TABLE *ST;
  42. #define gST ST
  43. extern EFI_BOOT_SERVICES *BS;
  44. #define gBS BS
  45. extern EFI_RUNTIME_SERVICES *RT;
  46. #define gRT RT
  47. extern EFI_GUID gEfiDevicePathProtocolGuid;
  48. #define DevicePathProtocol gEfiDevicePathProtocolGuid
  49. extern EFI_GUID gEfiDevicePathToTextProtocolGuid;
  50. #define DevicePathToTextProtocol gEfiDevicePathToTextProtocolGuid
  51. extern EFI_GUID gEfiDevicePathFromTextProtocolGuid;
  52. #define DevicePathFromTextProtocol gEfiDevicePathFromTextProtocolGuid
  53. extern EFI_GUID gEfiDevicePathUtilitiesProtocolGuid;
  54. #define DevicePathUtilitiesProtocol gEfiDevicePathUtilitiesProtocolGuid
  55. extern EFI_GUID gEfiLoadedImageProtocolGuid;
  56. #define LoadedImageProtocol gEfiLoadedImageProtocolGuid
  57. extern EFI_GUID gEfiSimpleTextInProtocolGuid;
  58. #define TextInProtocol gEfiSimpleTextInProtocolGuid
  59. extern EFI_GUID gEfiSimpleTextOutProtocolGuid;
  60. #define TextOutProtocol gEfiSimpleTextOutProtocolGuid
  61. extern EFI_GUID gEfiGraphicsOutputProtocolGuid;
  62. #define GraphicsOutputProtocol gEfiGraphicsOutputProtocolGuid
  63. extern EFI_GUID gEfiEdidDiscoveredProtocolGuid;
  64. #define EdidDiscoveredProtocol gEfiEdidDiscoveredProtocolGuid
  65. extern EFI_GUID gEfiEdidActiveProtocolGuid;
  66. #define EdidActiveProtocol gEfiEdidActiveProtocolGuid
  67. extern EFI_GUID gEfiEdidOverrideProtocolGuid;
  68. #define EdidOverrideProtocol gEfiEdidOverrideProtocolGuid
  69. extern EFI_GUID gEfiBlockIoProtocolGuid;
  70. #define BlockIoProtocol gEfiBlockIoProtocolGuid
  71. extern EFI_GUID gEfiBlockIo2ProtocolGuid;
  72. #define BlockIo2Protocol gEfiBlockIo2ProtocolGuid
  73. extern EFI_GUID gEfiDiskIoProtocolGuid;
  74. #define DiskIoProtocol gEfiDiskIoProtocolGuid
  75. extern EFI_GUID gEfiDiskIo2ProtocolGuid;
  76. #define DiskIo2Protocol gEfiDiskIo2ProtocolGuid
  77. extern EFI_GUID gEfiSimpleFileSystemProtocolGuid;
  78. #define FileSystemProtocol gEfiSimpleFileSystemProtocolGuid
  79. extern EFI_GUID gEfiLoadFileProtocolGuid;
  80. #define LoadFileProtocol gEfiLoadFileProtocolGuid
  81. extern EFI_GUID gEfiDeviceIoProtocolGuid;
  82. #define DeviceIoProtocol gEfiDeviceIoProtocolGuid
  83. extern EFI_GUID VariableStoreProtocol;
  84. extern EFI_GUID LegacyBootProtocol;
  85. extern EFI_GUID gEfiUnicodeCollationProtocolGuid;
  86. #define UnicodeCollationProtocol gEfiUnicodeCollationProtocolGuid
  87. extern EFI_GUID gEfiSerialIoProtocolGuid;
  88. #define SerialIoProtocol gEfiSerialIoProtocolGuid
  89. extern EFI_GUID VgaClassProtocol;
  90. extern EFI_GUID TextOutSpliterProtocol;
  91. extern EFI_GUID ErrorOutSpliterProtocol;
  92. extern EFI_GUID TextInSpliterProtocol;
  93. extern EFI_GUID gEfiSimpleNetworkProtocolGuid;
  94. #define SimpleNetworkProtocol gEfiSimpleNetworkProtocolGuid
  95. extern EFI_GUID gEfiPxeBaseCodeProtocolGuid;
  96. #define PxeBaseCodeProtocol gEfiPxeBaseCodeProtocolGuid
  97. extern EFI_GUID gEfiPxeBaseCodeCallbackProtocolGuid;
  98. #define PxeCallbackProtocol gEfiPxeBaseCodeCallbackProtocolGuid
  99. extern EFI_GUID gEfiNetworkInterfaceIdentifierProtocolGuid;
  100. #define NetworkInterfaceIdentifierProtocol gEfiNetworkInterfaceIdentifierProtocolGuid
  101. extern EFI_GUID gEFiUiInterfaceProtocolGuid;
  102. #define UiProtocol gEFiUiInterfaceProtocolGuid
  103. extern EFI_GUID InternalShellProtocol;
  104. extern EFI_GUID gEfiPciIoProtocolGuid;
  105. #define PciIoProtocol gEfiPciIoProtocolGuid
  106. extern EFI_GUID gEfiPciRootBridgeIoProtocolGuid;
  107. extern EFI_GUID gEfiDriverBindingProtocolGuid;
  108. #define DriverBindingProtocol gEfiDriverBindingProtocolGuid
  109. extern EFI_GUID gEfiComponentNameProtocolGuid;
  110. #define ComponentNameProtocol gEfiComponentNameProtocolGuid
  111. extern EFI_GUID gEfiComponentName2ProtocolGuid;
  112. #define ComponentName2Protocol gEfiComponentName2ProtocolGuid
  113. extern EFI_GUID gEfiHashProtocolGuid;
  114. #define HashProtocol gEfiHashProtocolGuid
  115. extern EFI_GUID gEfiPlatformDriverOverrideProtocolGuid;
  116. #define PlatformDriverOverrideProtocol gEfiPlatformDriverOverrideProtocolGuid
  117. extern EFI_GUID gEfiBusSpecificDriverOverrideProtocolGuid;
  118. #define BusSpecificDriverOverrideProtocol gEfiBusSpecificDriverOverrideProtocolGuid
  119. extern EFI_GUID gEfiDriverFamilyOverrideProtocolGuid;
  120. #define DriverFamilyOverrideProtocol gEfiDriverFamilyOverrideProtocolGuid
  121. extern EFI_GUID gEfiEbcProtocolGuid;
  122. extern EFI_GUID gEfiGlobalVariableGuid;
  123. #define EfiGlobalVariable gEfiGlobalVariableGuid
  124. extern EFI_GUID gEfiFileInfoGuid;
  125. #define GenericFileInfo gEfiFileInfoGuid
  126. extern EFI_GUID gEfiFileSystemInfoGuid;
  127. #define FileSystemInfo gEfiFileSystemInfoGuid
  128. extern EFI_GUID gEfiFileSystemVolumeLabelInfoIdGuid;
  129. #define FileSystemVolumeLabelInfo gEfiFileSystemVolumeLabelInfoIdGuid
  130. extern EFI_GUID gEfiPcAnsiGuid;
  131. #define PcAnsiProtocol gEfiPcAnsiGuid
  132. extern EFI_GUID gEfiVT100Guid;
  133. #define Vt100Protocol gEfiVT100Guid
  134. extern EFI_GUID gEfiVT100PlusGuid;
  135. extern EFI_GUID gEfiVTUTF8Guid;
  136. extern EFI_GUID NullGuid;
  137. extern EFI_GUID UnknownDevice;
  138. extern EFI_GUID EfiPartTypeSystemPartitionGuid;
  139. extern EFI_GUID EfiPartTypeLegacyMbrGuid;
  140. extern EFI_GUID MpsTableGuid;
  141. extern EFI_GUID AcpiTableGuid;
  142. extern EFI_GUID SMBIOSTableGuid;
  143. extern EFI_GUID SMBIOS3TableGuid;
  144. extern EFI_GUID SalSystemTableGuid;
  145. extern EFI_GUID EfiDtbTableGuid;
  146. extern EFI_GUID SimplePointerProtocol;
  147. extern EFI_GUID AbsolutePointerProtocol;
  148. extern EFI_GUID gEfiDebugImageInfoTableGuid;
  149. extern EFI_GUID gEfiDebugSupportProtocolGuid;
  150. extern EFI_GUID SimpleTextInputExProtocol;
  151. extern EFI_GUID ShellProtocolGuid;
  152. extern EFI_GUID ShellParametersProtocolGuid;
  153. extern EFI_GUID ShellDynamicCommandProtocolGuid;
  154. //
  155. // EFI Variable strings
  156. //
  157. #define LOAD_OPTION_ACTIVE 0x00000001
  158. #define VarLanguageCodes L"LangCodes"
  159. #define VarLanguage L"Lang"
  160. #define VarTimeout L"Timeout"
  161. #define VarConsoleInp L"ConIn"
  162. #define VarConsoleOut L"ConOut"
  163. #define VarErrorOut L"ErrOut"
  164. #define VarBootOption L"Boot%04x"
  165. #define VarBootOrder L"BootOrder"
  166. #define VarBootNext L"BootNext"
  167. #define VarBootCurrent L"BootCurrent"
  168. #define VarDriverOption L"Driver%04x"
  169. #define VarDriverOrder L"DriverOrder"
  170. #define VarConsoleInpDev L"ConInDev"
  171. #define VarConsoleOutDev L"ConOutDev"
  172. #define VarErrorOutDev L"ErrOutDev"
  173. #define LanguageCodeEnglish "eng"
  174. extern EFI_DEVICE_PATH RootDevicePath[];
  175. extern EFI_DEVICE_PATH EndDevicePath[];
  176. extern EFI_DEVICE_PATH EndInstanceDevicePath[];
  177. //
  178. // Other public data in the EFI library
  179. //
  180. extern EFI_MEMORY_TYPE PoolAllocationType;
  181. //
  182. // STATIC - Name is internal to the module
  183. // INTERNAL - Name is internal to the component (i.e., directory)
  184. // BOOTSERVCE - Name of a boot service function
  185. //
  186. #define STATIC
  187. #define INTERNAL
  188. #define BOOTSERVICE
  189. //
  190. // Prototypes
  191. //
  192. VOID
  193. InitializeLib (
  194. IN EFI_HANDLE ImageHandle,
  195. IN EFI_SYSTEM_TABLE *SystemTable
  196. );
  197. VOID
  198. InitializeUnicodeSupport (
  199. CHAR8 *LangCode
  200. );
  201. VOID
  202. EFIDebugVariable (
  203. VOID
  204. );
  205. VOID
  206. Exit(
  207. IN EFI_STATUS ExitStatus,
  208. IN UINTN ExitDataSize,
  209. IN CHAR16 *ExitData OPTIONAL
  210. );
  211. INTN
  212. GetShellArgcArgv(
  213. EFI_HANDLE ImageHandle,
  214. CHAR16 **Argv[] /* Statically allocated */
  215. );
  216. VOID
  217. SetCrc (
  218. IN OUT EFI_TABLE_HEADER *Hdr
  219. );
  220. VOID
  221. SetCrcAltSize (
  222. IN UINTN Size,
  223. IN OUT EFI_TABLE_HEADER *Hdr
  224. );
  225. BOOLEAN
  226. CheckCrc (
  227. IN UINTN MaxSize,
  228. IN OUT EFI_TABLE_HEADER *Hdr
  229. );
  230. BOOLEAN
  231. CheckCrcAltSize (
  232. IN UINTN MaxSize,
  233. IN UINTN Size,
  234. IN OUT EFI_TABLE_HEADER *Hdr
  235. );
  236. UINT32
  237. CalculateCrc (
  238. UINT8 *pt,
  239. UINTN Size
  240. );
  241. VOID
  242. ZeroMem (
  243. IN VOID *Buffer,
  244. IN UINTN Size
  245. );
  246. VOID EFIAPI
  247. SetMem (
  248. IN VOID *Buffer,
  249. IN UINTN Size,
  250. IN UINT8 Value
  251. );
  252. VOID EFIAPI
  253. CopyMem (
  254. IN VOID *Dest,
  255. IN VOID *Src,
  256. IN UINTN len
  257. );
  258. INTN
  259. CompareMem (
  260. IN CONST VOID *Dest,
  261. IN CONST VOID *Src,
  262. IN UINTN len
  263. );
  264. INTN
  265. StrCmp (
  266. IN CONST CHAR16 *s1,
  267. IN CONST CHAR16 *s2
  268. );
  269. INTN
  270. StrnCmp (
  271. IN CONST CHAR16 *s1,
  272. IN CONST CHAR16 *s2,
  273. IN UINTN len
  274. );
  275. INTN
  276. StriCmp (
  277. IN CONST CHAR16 *s1,
  278. IN CONST CHAR16 *s2
  279. );
  280. VOID
  281. StrLwr (
  282. IN CHAR16 *Str
  283. );
  284. VOID
  285. StrUpr (
  286. IN CHAR16 *Str
  287. );
  288. VOID
  289. StrCpy (
  290. IN CHAR16 *Dest,
  291. IN CONST CHAR16 *Src
  292. );
  293. VOID
  294. StrnCpy (
  295. IN CHAR16 *Dest,
  296. IN CONST CHAR16 *Src,
  297. IN UINTN Len
  298. );
  299. CHAR16 *
  300. StpCpy (
  301. IN CHAR16 *Dest,
  302. IN CONST CHAR16 *Src
  303. );
  304. CHAR16 *
  305. StpnCpy (
  306. IN CHAR16 *Dest,
  307. IN CONST CHAR16 *Src,
  308. IN UINTN Len
  309. );
  310. VOID
  311. StrCat (
  312. IN CHAR16 *Dest,
  313. IN CONST CHAR16 *Src
  314. );
  315. VOID
  316. StrnCat (
  317. IN CHAR16 *Dest,
  318. IN CONST CHAR16 *Src,
  319. IN UINTN Len
  320. );
  321. UINTN
  322. StrLen (
  323. IN CONST CHAR16 *s1
  324. );
  325. UINTN
  326. StrnLen (
  327. IN CONST CHAR16 *s1,
  328. IN UINTN Len
  329. );
  330. UINTN
  331. StrSize (
  332. IN CONST CHAR16 *s1
  333. );
  334. CHAR16 *
  335. StrDuplicate (
  336. IN CONST CHAR16 *Src
  337. );
  338. UINTN
  339. strlena (
  340. IN CONST CHAR8 *s1
  341. );
  342. UINTN
  343. strcmpa (
  344. IN CONST CHAR8 *s1,
  345. IN CONST CHAR8 *s2
  346. );
  347. UINTN
  348. strncmpa (
  349. IN CONST CHAR8 *s1,
  350. IN CONST CHAR8 *s2,
  351. IN UINTN len
  352. );
  353. UINTN
  354. xtoi (
  355. CONST CHAR16 *str
  356. );
  357. UINTN
  358. Atoi (
  359. CONST CHAR16 *str
  360. );
  361. BOOLEAN
  362. MetaMatch (
  363. IN CHAR16 *String,
  364. IN CHAR16 *Pattern
  365. );
  366. BOOLEAN
  367. MetaiMatch (
  368. IN CHAR16 *String,
  369. IN CHAR16 *Pattern
  370. );
  371. UINT64
  372. LShiftU64 (
  373. IN UINT64 Operand,
  374. IN UINTN Count
  375. );
  376. UINT64
  377. RShiftU64 (
  378. IN UINT64 Operand,
  379. IN UINTN Count
  380. );
  381. UINT64
  382. MultU64x32 (
  383. IN UINT64 Multiplicand,
  384. IN UINTN Multiplier
  385. );
  386. UINT64
  387. DivU64x32 (
  388. IN UINT64 Dividend,
  389. IN UINTN Divisor,
  390. OUT UINTN *Remainder OPTIONAL
  391. );
  392. VOID
  393. InitializeLock (
  394. IN OUT FLOCK *Lock,
  395. IN EFI_TPL Priority
  396. );
  397. VOID
  398. AcquireLock (
  399. IN FLOCK *Lock
  400. );
  401. VOID
  402. ReleaseLock (
  403. IN FLOCK *Lock
  404. );
  405. INTN
  406. CompareGuid(
  407. IN EFI_GUID *Guid1,
  408. IN EFI_GUID *Guid2
  409. );
  410. VOID *
  411. AllocatePool (
  412. IN UINTN Size
  413. );
  414. VOID *
  415. AllocateZeroPool (
  416. IN UINTN Size
  417. );
  418. VOID *
  419. ReallocatePool (
  420. IN VOID *OldPool,
  421. IN UINTN OldSize,
  422. IN UINTN NewSize
  423. );
  424. VOID
  425. FreePool (
  426. IN VOID *p
  427. );
  428. VOID
  429. Output (
  430. IN CHAR16 *Str
  431. );
  432. VOID
  433. Input (
  434. IN CHAR16 *Prompt OPTIONAL,
  435. OUT CHAR16 *InStr,
  436. IN UINTN StrLen
  437. );
  438. VOID
  439. IInput (
  440. IN SIMPLE_TEXT_OUTPUT_INTERFACE *ConOut,
  441. IN SIMPLE_INPUT_INTERFACE *ConIn,
  442. IN CHAR16 *Prompt OPTIONAL,
  443. OUT CHAR16 *InStr,
  444. IN UINTN StrLen
  445. );
  446. UINTN
  447. Print (
  448. IN CONST CHAR16 *fmt,
  449. ...
  450. );
  451. UINTN
  452. VPrint (
  453. IN CONST CHAR16 *fmt,
  454. va_list args
  455. );
  456. UINTN
  457. UnicodeSPrint (
  458. OUT CHAR16 *Str,
  459. IN UINTN StrSize,
  460. IN CONST CHAR16 *fmt,
  461. ...
  462. );
  463. UINTN
  464. UnicodeVSPrint (
  465. OUT CHAR16 *Str,
  466. IN UINTN StrSize,
  467. IN CONST CHAR16 *fmt,
  468. va_list args
  469. );
  470. CHAR16 *
  471. VPoolPrint (
  472. IN CONST CHAR16 *fmt,
  473. va_list args
  474. );
  475. CHAR16 *
  476. PoolPrint (
  477. IN CONST CHAR16 *fmt,
  478. ...
  479. );
  480. typedef struct {
  481. CHAR16 *str;
  482. UINTN len;
  483. UINTN maxlen;
  484. } POOL_PRINT;
  485. CHAR16 *
  486. CatPrint (
  487. IN OUT POOL_PRINT *Str,
  488. IN CONST CHAR16 *fmt,
  489. ...
  490. );
  491. UINTN
  492. PrintAt (
  493. IN UINTN Column,
  494. IN UINTN Row,
  495. IN CONST CHAR16 *fmt,
  496. ...
  497. );
  498. UINTN
  499. IPrint (
  500. IN SIMPLE_TEXT_OUTPUT_INTERFACE *Out,
  501. IN CONST CHAR16 *fmt,
  502. ...
  503. );
  504. UINTN
  505. IPrintAt (
  506. IN SIMPLE_TEXT_OUTPUT_INTERFACE *Out,
  507. IN UINTN Column,
  508. IN UINTN Row,
  509. IN CONST CHAR16 *fmt,
  510. ...
  511. );
  512. UINTN
  513. AsciiPrint (
  514. IN CONST CHAR8 *fmt,
  515. ...
  516. );
  517. UINTN
  518. AsciiVSPrint(
  519. OUT CHAR8 *Str,
  520. IN UINTN StrSize,
  521. IN CONST CHAR8 *fmt,
  522. va_list args
  523. );
  524. //
  525. // For compatibility with previous gnu-efi versions
  526. //
  527. #define SPrint UnicodeSPrint
  528. #define VSPrint UnicodeVSPrint
  529. #define APrint AsciiPrint
  530. VOID
  531. ValueToHex (
  532. IN CHAR16 *Buffer,
  533. IN UINT64 v
  534. );
  535. VOID
  536. ValueToString (
  537. IN CHAR16 *Buffer,
  538. IN BOOLEAN Comma,
  539. IN INT64 v
  540. );
  541. VOID
  542. FloatToString (
  543. IN CHAR16 *Buffer,
  544. IN BOOLEAN Comma,
  545. IN double v
  546. );
  547. VOID
  548. TimeToString (
  549. OUT CHAR16 *Buffer,
  550. IN EFI_TIME *Time
  551. );
  552. VOID
  553. GuidToString (
  554. OUT CHAR16 *Buffer,
  555. IN EFI_GUID *Guid
  556. );
  557. VOID
  558. StatusToString (
  559. OUT CHAR16 *Buffer,
  560. EFI_STATUS Status
  561. );
  562. VOID
  563. DumpHex (
  564. IN UINTN Indent,
  565. IN UINTN Offset,
  566. IN UINTN DataSize,
  567. IN VOID *UserData
  568. );
  569. BOOLEAN
  570. GrowBuffer(
  571. IN OUT EFI_STATUS *Status,
  572. IN OUT VOID **Buffer,
  573. IN UINTN BufferSize
  574. );
  575. EFI_MEMORY_DESCRIPTOR *
  576. LibMemoryMap (
  577. OUT UINTN *NoEntries,
  578. OUT UINTN *MapKey,
  579. OUT UINTN *DescriptorSize,
  580. OUT UINT32 *DescriptorVersion
  581. );
  582. VOID *
  583. LibGetVariable (
  584. IN CHAR16 *Name,
  585. IN EFI_GUID *VendorGuid
  586. );
  587. VOID *
  588. LibGetVariableAndSize (
  589. IN CHAR16 *Name,
  590. IN EFI_GUID *VendorGuid,
  591. OUT UINTN *VarSize
  592. );
  593. EFI_STATUS
  594. LibDeleteVariable (
  595. IN CHAR16 *VarName,
  596. IN EFI_GUID *VarGuid
  597. );
  598. EFI_STATUS
  599. LibSetNVVariable (
  600. IN CHAR16 *VarName,
  601. IN EFI_GUID *VarGuid,
  602. IN UINTN DataSize,
  603. IN VOID *Data
  604. );
  605. EFI_STATUS
  606. LibSetVariable (
  607. IN CHAR16 *VarName,
  608. IN EFI_GUID *VarGuid,
  609. IN UINTN DataSize,
  610. IN VOID *Data
  611. );
  612. EFI_STATUS
  613. LibInsertToTailOfBootOrder (
  614. IN UINT16 BootOption,
  615. IN BOOLEAN OnlyInsertIfEmpty
  616. );
  617. EFI_STATUS
  618. LibLocateProtocol (
  619. IN EFI_GUID *ProtocolGuid,
  620. OUT VOID **Interface
  621. );
  622. EFI_STATUS
  623. LibLocateHandle (
  624. IN EFI_LOCATE_SEARCH_TYPE SearchType,
  625. IN EFI_GUID *Protocol OPTIONAL,
  626. IN VOID *SearchKey OPTIONAL,
  627. IN OUT UINTN *NoHandles,
  628. OUT EFI_HANDLE **Buffer
  629. );
  630. EFI_STATUS
  631. LibLocateHandleByDiskSignature (
  632. IN UINT8 MBRType,
  633. IN UINT8 SignatureType,
  634. IN VOID *Signature,
  635. IN OUT UINTN *NoHandles,
  636. OUT EFI_HANDLE **Buffer
  637. );
  638. EFI_STATUS
  639. LibInstallProtocolInterfaces (
  640. IN OUT EFI_HANDLE *Handle,
  641. ...
  642. );
  643. VOID
  644. LibUninstallProtocolInterfaces (
  645. IN EFI_HANDLE Handle,
  646. ...
  647. );
  648. EFI_STATUS
  649. LibReinstallProtocolInterfaces (
  650. IN OUT EFI_HANDLE *Handle,
  651. ...
  652. );
  653. EFI_EVENT
  654. LibCreateProtocolNotifyEvent (
  655. IN EFI_GUID *ProtocolGuid,
  656. IN EFI_TPL NotifyTpl,
  657. IN EFI_EVENT_NOTIFY NotifyFunction,
  658. IN VOID *NotifyContext,
  659. OUT VOID *Registration
  660. );
  661. EFI_STATUS
  662. WaitForSingleEvent (
  663. IN EFI_EVENT Event,
  664. IN UINT64 Timeout OPTIONAL
  665. );
  666. VOID
  667. WaitForEventWithTimeout (
  668. IN EFI_EVENT Event,
  669. IN UINTN Timeout,
  670. IN UINTN Row,
  671. IN UINTN Column,
  672. IN CHAR16 *String,
  673. IN EFI_INPUT_KEY TimeoutKey,
  674. OUT EFI_INPUT_KEY *Key
  675. );
  676. EFI_FILE_HANDLE
  677. LibOpenRoot (
  678. IN EFI_HANDLE DeviceHandle
  679. );
  680. EFI_FILE_INFO *
  681. LibFileInfo (
  682. IN EFI_FILE_HANDLE FHand
  683. );
  684. EFI_FILE_SYSTEM_INFO *
  685. LibFileSystemInfo (
  686. IN EFI_FILE_HANDLE FHand
  687. );
  688. EFI_FILE_SYSTEM_VOLUME_LABEL_INFO *
  689. LibFileSystemVolumeLabelInfo (
  690. IN EFI_FILE_HANDLE FHand
  691. );
  692. BOOLEAN
  693. ValidMBR(
  694. IN MASTER_BOOT_RECORD *Mbr,
  695. IN EFI_BLOCK_IO *BlkIo
  696. );
  697. BOOLEAN
  698. LibMatchDevicePaths (
  699. IN EFI_DEVICE_PATH *Multi,
  700. IN EFI_DEVICE_PATH *Single
  701. );
  702. EFI_DEVICE_PATH *
  703. LibDuplicateDevicePathInstance (
  704. IN EFI_DEVICE_PATH *DevPath
  705. );
  706. EFI_DEVICE_PATH *
  707. DevicePathFromHandle (
  708. IN EFI_HANDLE Handle
  709. );
  710. EFI_DEVICE_PATH *
  711. DevicePathInstance (
  712. IN OUT EFI_DEVICE_PATH **DevicePath,
  713. OUT UINTN *Size
  714. );
  715. UINTN
  716. DevicePathInstanceCount (
  717. IN EFI_DEVICE_PATH *DevicePath
  718. );
  719. EFI_DEVICE_PATH *
  720. AppendDevicePath (
  721. IN EFI_DEVICE_PATH *Src1,
  722. IN EFI_DEVICE_PATH *Src2
  723. );
  724. EFI_DEVICE_PATH *
  725. AppendDevicePathNode (
  726. IN EFI_DEVICE_PATH *Src1,
  727. IN EFI_DEVICE_PATH *Src2
  728. );
  729. EFI_DEVICE_PATH*
  730. AppendDevicePathInstance (
  731. IN EFI_DEVICE_PATH *Src,
  732. IN EFI_DEVICE_PATH *Instance
  733. );
  734. EFI_DEVICE_PATH *
  735. FileDevicePath (
  736. IN EFI_HANDLE Device OPTIONAL,
  737. IN CHAR16 *FileName
  738. );
  739. UINTN
  740. DevicePathSize (
  741. IN EFI_DEVICE_PATH *DevPath
  742. );
  743. EFI_DEVICE_PATH *
  744. DuplicateDevicePath (
  745. IN EFI_DEVICE_PATH *DevPath
  746. );
  747. EFI_DEVICE_PATH *
  748. UnpackDevicePath (
  749. IN EFI_DEVICE_PATH *DevPath
  750. );
  751. EFI_STATUS
  752. LibDevicePathToInterface (
  753. IN EFI_GUID *Protocol,
  754. IN EFI_DEVICE_PATH *FilePath,
  755. OUT VOID **Interface
  756. );
  757. CHAR16 *
  758. DevicePathToStr (
  759. EFI_DEVICE_PATH *DevPath
  760. );
  761. //
  762. // BugBug: I need my own include files
  763. //
  764. typedef struct {
  765. UINT8 Register;
  766. UINT8 Function;
  767. UINT8 Device;
  768. UINT8 Bus;
  769. UINT32 Reserved;
  770. } EFI_ADDRESS;
  771. typedef union {
  772. UINT64 Address;
  773. EFI_ADDRESS EfiAddress;
  774. } EFI_PCI_ADDRESS_UNION;
  775. EFI_STATUS
  776. PciFindDeviceClass (
  777. IN OUT EFI_PCI_ADDRESS_UNION *Address,
  778. IN UINT8 BaseClass,
  779. IN UINT8 SubClass
  780. );
  781. EFI_STATUS
  782. PciFindDevice (
  783. IN OUT EFI_PCI_ADDRESS_UNION *DeviceAddress,
  784. IN UINT16 VendorId,
  785. IN UINT16 DeviceId,
  786. IN OUT PCI_TYPE00 *Pci
  787. );
  788. //
  789. // SIMPLE_READ_FILE object used to access files
  790. //
  791. typedef VOID *SIMPLE_READ_FILE;
  792. EFI_STATUS
  793. OpenSimpleReadFile (
  794. IN BOOLEAN BootPolicy,
  795. IN VOID *SourceBuffer OPTIONAL,
  796. IN UINTN SourceSize,
  797. IN OUT EFI_DEVICE_PATH **FilePath,
  798. OUT EFI_HANDLE *DeviceHandle,
  799. OUT SIMPLE_READ_FILE *SimpleReadHandle
  800. );
  801. EFI_STATUS
  802. ReadSimpleReadFile (
  803. IN SIMPLE_READ_FILE SimpleReadHandle,
  804. IN UINTN Offset,
  805. IN OUT UINTN *ReadSize,
  806. OUT VOID *Buffer
  807. );
  808. VOID
  809. CloseSimpleReadFile (
  810. IN SIMPLE_READ_FILE SimpleReadHandle
  811. );
  812. VOID
  813. InitializeGuid (
  814. VOID
  815. );
  816. UINT8
  817. DecimaltoBCD(
  818. IN UINT8 DecValue
  819. );
  820. UINT8
  821. BCDtoDecimal(
  822. IN UINT8 BcdValue
  823. );
  824. EFI_STATUS
  825. LibGetSystemConfigurationTable(
  826. IN EFI_GUID *TableGuid,
  827. IN OUT VOID **Table
  828. );
  829. BOOLEAN
  830. LibIsValidTextGraphics (
  831. IN CHAR16 Graphic,
  832. OUT CHAR8 *PcAnsi, OPTIONAL
  833. OUT CHAR8 *Ascii OPTIONAL
  834. );
  835. BOOLEAN
  836. IsValidAscii (
  837. IN CHAR16 Ascii
  838. );
  839. BOOLEAN
  840. IsValidEfiCntlChar (
  841. IN CHAR16 c
  842. );
  843. CHAR16 *
  844. LibGetUiString (
  845. IN EFI_HANDLE Handle,
  846. IN UI_STRING_TYPE StringType,
  847. IN ISO_639_2 *LangCode,
  848. IN BOOLEAN ReturnDevicePathStrOnMismatch
  849. );
  850. CHAR8*
  851. LibGetSmbiosString (
  852. IN SMBIOS_STRUCTURE_POINTER *Smbios,
  853. IN UINT16 StringNumber
  854. );
  855. EFI_STATUS
  856. LibGetSmbiosSystemGuidAndSerialNumber (
  857. IN EFI_GUID *SystemGuid,
  858. OUT CHAR8 **SystemSerialNumber
  859. );
  860. EFI_STATUS
  861. InitializeGlobalIoDevice (
  862. IN EFI_DEVICE_PATH *DevicePath,
  863. IN EFI_GUID *Protocol,
  864. IN CHAR8 *ErrorStr,
  865. OUT EFI_DEVICE_IO_INTERFACE **GlobalIoFncs
  866. );
  867. UINT32
  868. ReadPort (
  869. IN EFI_DEVICE_IO_INTERFACE *GlobalIoFncs,
  870. IN EFI_IO_WIDTH Width,
  871. IN UINTN Port
  872. );
  873. UINT32
  874. WritePort (
  875. IN EFI_DEVICE_IO_INTERFACE *GlobalIoFncs,
  876. IN EFI_IO_WIDTH Width,
  877. IN UINTN Port,
  878. IN UINTN Data
  879. );
  880. UINT32
  881. ReadPciConfig (
  882. IN EFI_DEVICE_IO_INTERFACE *GlobalIoFncs,
  883. IN EFI_IO_WIDTH Width,
  884. IN UINTN Port
  885. );
  886. UINT32
  887. WritePciConfig (
  888. IN EFI_DEVICE_IO_INTERFACE *GlobalIoFncs,
  889. IN EFI_IO_WIDTH Width,
  890. IN UINTN Port,
  891. IN UINTN Data
  892. );
  893. VOID
  894. Pause (
  895. VOID
  896. );
  897. extern EFI_DEVICE_IO_INTERFACE *GlobalIoFncs;
  898. #define outp(_Port, _DataByte) (UINT8)WritePort(GlobalIoFncs, IO_UINT8, (UINTN)_Port, (UINTN)_DataByte)
  899. #define inp(_Port) (UINT8)ReadPort(GlobalIoFncs, IO_UINT8, (UINTN)_Port)
  900. #define outpw(_Port, _DataByte) (UINT16)WritePort(GlobalIoFncs, IO_UINT16, (UINTN)_Port, (UINTN)_DataByte)
  901. #define inpw(_Port) (UINT16)ReadPort(GlobalIoFncs, IO_UINT16, (UINTN)_Port)
  902. #define outpd(_Port, _DataByte) (UINT32)WritePort(GlobalIoFncs, IO_UINT32, (UINTN)_Port, (UINTN)_DataByte)
  903. #define inpd(_Port) (UINT32)ReadPort(GlobalIoFncs, IO_UINT32, (UINTN)_Port)
  904. #define writepci8(_Addr, _DataByte) (UINT8)WritePciConfig(GlobalIoFncs, IO_UINT8, (UINTN)_Addr, (UINTN)_DataByte)
  905. #define readpci8(_Addr) (UINT8)ReadPciConfig(GlobalIoFncs, IO_UINT8, (UINTN)_Addr)
  906. #define writepci16(_Addr, _DataByte) (UINT16)WritePciConfig(GlobalIoFncs, IO_UINT16, (UINTN)_Addr, (UINTN)_DataByte)
  907. #define readpci16(_Addr) (UINT16)ReadPciConfig(GlobalIoFncs, IO_UINT16, (UINTN)_Addr)
  908. #define writepci32(_Addr, _DataByte) (UINT32)WritePciConfig(GlobalIoFncs, IO_UINT32, (UINTN)_Addr, (UINTN)_DataByte)
  909. #define readpci32(_Addr) (UINT32)ReadPciConfig(GlobalIoFncs, IO_UINT32, (UINTN)_Addr)
  910. #define Port80(_PostCode) GlobalIoFncs->Io.Write (GlobalIoFncs, IO_UINT16, (UINT64)0x80, 1, &(_PostCode))
  911. #ifdef __cplusplus
  912. }
  913. #endif
  914. #endif