PageRenderTime 61ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiRuntimeLib.h

https://bitbucket.org/incubaid/edk2
C Header | 1745 lines | 491 code | 82 blank | 1172 comment | 1 complexity | 683f7eaba1d62c6f701de427513d43c1 MD5 | raw file
  1. /*++
  2. Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
  3. This program and the accompanying materials
  4. are licensed and made available under the terms and conditions of the BSD License
  5. which accompanies this distribution. The full text of the license may be found at
  6. http://opensource.org/licenses/bsd-license.php
  7. THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
  9. Module Name:
  10. EfiRuntimeLib.h
  11. Abstract:
  12. Light weight lib to support EFI drivers.
  13. --*/
  14. #ifndef _EFI_RUNTIME_LIB_H_
  15. #define _EFI_RUNTIME_LIB_H_
  16. #define MAX_FVB_COUNT 16
  17. #include "EfiStatusCode.h"
  18. #include "EfiCommonLib.h"
  19. #include "LinkedList.h"
  20. #include "GetImage.h"
  21. #include "RtDevicePath.h"
  22. #include EFI_GUID_DEFINITION (DxeServices)
  23. #include EFI_GUID_DEFINITION (EventGroup)
  24. #include EFI_GUID_DEFINITION (EventLegacyBios)
  25. #include EFI_PROTOCOL_DEFINITION (CpuIo)
  26. #include EFI_PROTOCOL_DEFINITION (FirmwareVolume)
  27. #include EFI_PROTOCOL_DEFINITION (FirmwareVolume2)
  28. #include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock)
  29. #include EFI_PROTOCOL_DEFINITION (FvbExtension)
  30. #include "ProcDep.h"
  31. typedef struct {
  32. EFI_HANDLE Handle;
  33. EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb;
  34. EFI_FVB_EXTENSION_PROTOCOL *FvbExtension;
  35. } FVB_ENTRY;
  36. //
  37. // Driver Lib Globals.
  38. //
  39. extern EFI_BOOT_SERVICES *gBS;
  40. extern EFI_SYSTEM_TABLE *gST;
  41. extern EFI_DXE_SERVICES *gDS;
  42. extern UINTN gRtErrorLevel;
  43. extern FVB_ENTRY *mFvbEntry;
  44. #if defined(__GNUC__) && defined(ECP_CPU_IPF)
  45. VOID
  46. EFIAPI
  47. EcpEfiBreakPoint (
  48. VOID
  49. )
  50. /*++
  51. Routine Description:
  52. Generates a breakpoint on the CPU.
  53. Generates a breakpoint on the CPU. The breakpoint must be implemented such
  54. that code can resume normal execution after the breakpoint.
  55. Arguments:
  56. VOID
  57. Returns:
  58. VOID
  59. --*/
  60. ;
  61. VOID
  62. EFIAPI
  63. EcpMemoryFence (
  64. VOID
  65. )
  66. /*++
  67. Routine Description:
  68. Used to serialize load and store operations.
  69. All loads and stores that proceed calls to this function are guaranteed to be
  70. globally visible when this function returns.
  71. Arguments:
  72. VOID
  73. Returns:
  74. VOID
  75. --*/
  76. ;
  77. #endif
  78. VOID
  79. EFIAPI
  80. EfiRuntimeLibFvbVirtualNotifyEvent (
  81. IN EFI_EVENT Event,
  82. IN VOID *Context
  83. )
  84. /*++
  85. Routine Description:
  86. Notify function to convert pointers to Fvb functions after ExitBootServices
  87. Arguments:
  88. Event - Event whose notification function is being invoked.
  89. Context - Pointer to the notification function's context, which is
  90. implementation-dependent.
  91. Returns:
  92. None
  93. --*/
  94. ;
  95. EFI_STATUS
  96. EfiInitializeRuntimeDriverLib (
  97. IN EFI_HANDLE ImageHandle,
  98. IN EFI_SYSTEM_TABLE *SystemTable,
  99. IN EFI_EVENT_NOTIFY RuntimeNotifyEventHandler
  100. )
  101. /*++
  102. Routine Description:
  103. Intialize Runtime Driver Lib if it has not yet been initialized.
  104. Arguments:
  105. ImageHandle - The firmware allocated handle for the EFI image.
  106. SystemTable - A pointer to the EFI System Table.
  107. RuntimeNotifyEventHandler - Virtual address change notification event
  108. Returns:
  109. EFI_STATUS always returns EFI_SUCCESS
  110. --*/
  111. ;
  112. EFI_STATUS
  113. EfiShutdownRuntimeDriverLib (
  114. VOID
  115. )
  116. /*++
  117. Routine Description:
  118. This routine will free some resources which have been allocated in
  119. EfiInitializeRuntimeDriverLib(). If a runtime driver exits with an error,
  120. it must call this routine to free the allocated resource before the exiting.
  121. Arguments:
  122. None
  123. Returns:
  124. EFI_SUCCESS - Shotdown the Runtime Driver Lib successfully
  125. EFI_UNSUPPORTED - Runtime Driver lib was not initialized at all
  126. --*/
  127. ;
  128. EFI_STATUS
  129. EfiInitializeSmmDriverLib (
  130. IN EFI_HANDLE ImageHandle,
  131. IN EFI_SYSTEM_TABLE *SystemTable
  132. )
  133. /*++
  134. Routine Description:
  135. Intialize Smm Driver Lib if it has not yet been initialized.
  136. Arguments:
  137. ImageHandle - The firmware allocated handle for the EFI image.
  138. SystemTable - A pointer to the EFI System Table.
  139. Returns:
  140. EFI_STATUS always returns EFI_SUCCESS
  141. --*/
  142. ;
  143. EFI_STATUS
  144. EfiLibGetSystemConfigurationTable (
  145. IN EFI_GUID *TableGuid,
  146. IN OUT VOID **Table
  147. )
  148. /*++
  149. Routine Description:
  150. Return the EFI 1.0 System Tabl entry with TableGuid
  151. Arguments:
  152. TableGuid - Name of entry to return in the system table
  153. Table - Pointer in EFI system table associated with TableGuid
  154. Returns:
  155. EFI_SUCCESS - Table returned;
  156. EFI_NOT_FOUND - TableGuid not in EFI system table
  157. --*/
  158. ;
  159. BOOLEAN
  160. EfiAtRuntime (
  161. VOID
  162. )
  163. /*++
  164. Routine Description:
  165. Am I at runtime?
  166. Arguments:
  167. None
  168. Returns:
  169. TRUE - At runtime
  170. FALSE - Not at runtime
  171. --*/
  172. ;
  173. BOOLEAN
  174. EfiGoneVirtual (
  175. VOID
  176. )
  177. /*++
  178. Routine Description:
  179. Return TRUE if SetVirtualAddressMap () has been called
  180. Arguments:
  181. NONE
  182. Returns:
  183. TRUE - If SetVirtualAddressMap () has been called
  184. FALSE - If SetVirtualAddressMap () has not been called
  185. --*/
  186. ;
  187. EFI_STATUS
  188. EfiLibGetSystemConfigurationTable (
  189. IN EFI_GUID *TableGuid,
  190. IN OUT VOID **Table
  191. )
  192. /*++
  193. Routine Description:
  194. Get table from configuration table by name
  195. Arguments:
  196. TableGuid - Table name to search
  197. Table - Pointer to the table caller wants
  198. Returns:
  199. EFI_NOT_FOUND - Not found the table
  200. EFI_SUCCESS - Found the table
  201. --*/
  202. ;
  203. EFI_EVENT
  204. RtEfiLibCreateProtocolNotifyEvent (
  205. IN EFI_GUID *ProtocolGuid,
  206. IN EFI_TPL NotifyTpl,
  207. IN EFI_EVENT_NOTIFY NotifyFunction,
  208. IN VOID *NotifyContext,
  209. OUT VOID **Registration
  210. )
  211. /*++
  212. Routine Description:
  213. Create a protocol notification event and return it.
  214. Arguments:
  215. ProtocolGuid - Protocol to register notification event on.
  216. NotifyTpl - Maximum TPL to single the NotifyFunction.
  217. NotifyFunction - EFI notification routine.
  218. NotifyContext - Context passed into Event when it is created.
  219. Registration - Registration key returned from RegisterProtocolNotify().
  220. Returns:
  221. The EFI_EVENT that has been registered to be signaled when a ProtocolGuid
  222. is added to the system.
  223. --*/
  224. ;
  225. //
  226. // Lock.c
  227. //
  228. typedef struct {
  229. EFI_TPL Tpl;
  230. EFI_TPL OwnerTpl;
  231. UINTN Lock;
  232. } EFI_LOCK;
  233. VOID
  234. EfiInitializeLock (
  235. IN OUT EFI_LOCK *Lock,
  236. IN EFI_TPL Priority
  237. )
  238. /*++
  239. Routine Description:
  240. Initialize a basic mutual exclusion lock. Each lock
  241. provides mutual exclusion access at it's task priority
  242. level. Since there is no-premption (at any TPL) or
  243. multiprocessor support, acquiring the lock only consists
  244. of raising to the locks TPL.
  245. Note on a check build ASSERT()s are used to ensure proper
  246. lock usage.
  247. Arguments:
  248. Lock - The EFI_LOCK structure to initialize
  249. Priority - The task priority level of the lock
  250. Returns:
  251. An initialized Efi Lock structure.
  252. --*/
  253. ;
  254. //
  255. // Macro to initialize the state of a lock when a lock variable is declared
  256. //
  257. #define EFI_INITIALIZE_LOCK_VARIABLE(Tpl) {Tpl,0,0}
  258. VOID
  259. EfiAcquireLock (
  260. IN EFI_LOCK *Lock
  261. )
  262. /*++
  263. Routine Description:
  264. Raising to the task priority level of the mutual exclusion
  265. lock, and then acquires ownership of the lock.
  266. Arguments:
  267. Lock - The lock to acquire
  268. Returns:
  269. Lock owned
  270. --*/
  271. ;
  272. EFI_STATUS
  273. EfiAcquireLockOrFail (
  274. IN EFI_LOCK *Lock
  275. )
  276. /*++
  277. Routine Description:
  278. Initialize a basic mutual exclusion lock. Each lock
  279. provides mutual exclusion access at it's task priority
  280. level. Since there is no-premption (at any TPL) or
  281. multiprocessor support, acquiring the lock only consists
  282. of raising to the locks TPL.
  283. Arguments:
  284. Lock - The EFI_LOCK structure to initialize
  285. Returns:
  286. EFI_SUCCESS - Lock Owned.
  287. EFI_ACCESS_DENIED - Reentrant Lock Acquisition, Lock not Owned.
  288. --*/
  289. ;
  290. VOID
  291. EfiReleaseLock (
  292. IN EFI_LOCK *Lock
  293. )
  294. /*++
  295. Routine Description:
  296. Releases ownership of the mutual exclusion lock, and
  297. restores the previous task priority level.
  298. Arguments:
  299. Lock - The lock to release
  300. Returns:
  301. None
  302. --*/
  303. ;
  304. #define EfiCopyMem EfiCommonLibCopyMem
  305. #define EfiSetMem EfiCommonLibSetMem
  306. #define EfiZeroMem EfiCommonLibZeroMem
  307. INTN
  308. EfiCompareMem (
  309. IN VOID *MemOne,
  310. IN VOID *MemTwo,
  311. IN UINTN Len
  312. )
  313. /*++
  314. Routine Description:
  315. Compares two memory buffers of a given length.
  316. Arguments:
  317. MemOne - First memory buffer
  318. MemTwo - Second memory buffer
  319. Len - Length of Mem1 and Mem2 memory regions to compare
  320. Returns:
  321. = 0 if MemOne == MemTwo
  322. > 0 if MemOne > MemTwo
  323. < 0 if MemOne < MemTwo
  324. --*/
  325. ;
  326. //
  327. // Debug.c init
  328. //
  329. EFI_STATUS
  330. EfiDebugAssertInit (
  331. VOID
  332. )
  333. /*++
  334. Routine Description:
  335. Locate Debug Assert Protocol and set as mDebugAssert
  336. Arguments:
  337. None
  338. Returns:
  339. Status code
  340. --*/
  341. ;
  342. //
  343. // Wrapper for EFI runtime functions
  344. //
  345. VOID
  346. EfiResetSystem (
  347. IN EFI_RESET_TYPE ResetType,
  348. IN EFI_STATUS ResetStatus,
  349. IN UINTN DataSize,
  350. IN CHAR16 *ResetData
  351. )
  352. /*++
  353. Routine Description:
  354. Resets the entire platform.
  355. Arguments:
  356. ResetType - The type of reset to perform.
  357. ResetStatus - The status code for the reset.
  358. DataSize - The size, in bytes, of ResetData.
  359. ResetData - A data buffer that includes a Null-terminated Unicode string, optionally
  360. followed by additional binary data.
  361. Returns:
  362. None
  363. --*/
  364. ;
  365. EFI_STATUS
  366. EfiGetNextHighMonotonicCount (
  367. OUT UINT32 *HighCount
  368. )
  369. /*++
  370. Routine Description:
  371. Returns the next high 32 bits of the platform's monotonic counter.
  372. Arguments:
  373. HighCount - Pointer to returned value.
  374. Returns:
  375. Status code
  376. --*/
  377. ;
  378. EFI_STATUS
  379. EfiGetTime (
  380. OUT EFI_TIME *Time,
  381. OUT EFI_TIME_CAPABILITIES *Capabilities
  382. )
  383. /*++
  384. Routine Description:
  385. Returns the current time and date information, and the time-keeping
  386. capabilities of the hardware platform.
  387. Arguments:
  388. Time - A pointer to storage to receive a snapshot of the current time.
  389. Capabilities - An optional pointer to a buffer to receive the real time clock device's
  390. capabilities.
  391. Returns:
  392. Status code
  393. --*/
  394. ;
  395. EFI_STATUS
  396. EfiSetTime (
  397. OUT EFI_TIME *Time
  398. )
  399. /*++
  400. Routine Description:
  401. Sets the current local time and date information.
  402. Arguments:
  403. Time - A pointer to the current time.
  404. Returns:
  405. Status code
  406. --*/
  407. ;
  408. EFI_STATUS
  409. EfiGetWakeupTime (
  410. OUT BOOLEAN *Enabled,
  411. OUT BOOLEAN *Pending,
  412. OUT EFI_TIME *Time
  413. )
  414. /*++
  415. Routine Description:
  416. Returns the current wakeup alarm clock setting.
  417. Arguments:
  418. Enabled - Indicates if the alarm is currently enabled or disabled.
  419. Pending - Indicates if the alarm signal is pending and requires acknowledgement.
  420. Time - The current alarm setting.
  421. Returns:
  422. Status code
  423. --*/
  424. ;
  425. EFI_STATUS
  426. EfiSetWakeupTime (
  427. IN BOOLEAN Enable,
  428. IN EFI_TIME *Time
  429. )
  430. /*++
  431. Routine Description:
  432. Sets the system wakeup alarm clock time.
  433. Arguments:
  434. Enable - Enable or disable the wakeup alarm.
  435. Time - If Enable is TRUE, the time to set the wakeup alarm for.
  436. If Enable is FALSE, then this parameter is optional, and may be NULL.
  437. Returns:
  438. Status code
  439. --*/
  440. ;
  441. EFI_STATUS
  442. EfiGetVariable (
  443. IN CHAR16 *VariableName,
  444. IN EFI_GUID * VendorGuid,
  445. OUT UINT32 *Attributes OPTIONAL,
  446. IN OUT UINTN *DataSize,
  447. OUT VOID *Data
  448. )
  449. /*++
  450. Routine Description:
  451. Returns the value of a variable.
  452. Arguments:
  453. VariableName - A Null-terminated Unicode string that is the name of the
  454. vendor's variable.
  455. VendorGuid - A unique identifier for the vendor.
  456. Attributes - If not NULL, a pointer to the memory location to return the
  457. attributes bitmask for the variable.
  458. DataSize - On input, the size in bytes of the return Data buffer.
  459. On output the size of data returned in Data.
  460. Data - The buffer to return the contents of the variable.
  461. Returns:
  462. Status code
  463. --*/
  464. ;
  465. EFI_STATUS
  466. EfiGetNextVariableName (
  467. IN OUT UINTN *VariableNameSize,
  468. IN OUT CHAR16 *VariableName,
  469. IN OUT EFI_GUID *VendorGuid
  470. )
  471. /*++
  472. Routine Description:
  473. Enumerates the current variable names.
  474. Arguments:
  475. VariableNameSize - The size of the VariableName buffer.
  476. VariableName - On input, supplies the last VariableName that was returned
  477. by GetNextVariableName().
  478. On output, returns the Nullterminated Unicode string of the
  479. current variable.
  480. VendorGuid - On input, supplies the last VendorGuid that was returned by
  481. GetNextVariableName().
  482. On output, returns the VendorGuid of the current variable.
  483. Returns:
  484. Status code
  485. --*/
  486. ;
  487. EFI_STATUS
  488. EfiSetVariable (
  489. IN CHAR16 *VariableName,
  490. IN EFI_GUID *VendorGuid,
  491. IN UINT32 Attributes,
  492. IN UINTN DataSize,
  493. IN VOID *Data
  494. )
  495. /*++
  496. Routine Description:
  497. Sets the value of a variable.
  498. Arguments:
  499. VariableName - A Null-terminated Unicode string that is the name of the
  500. vendor's variable.
  501. VendorGuid - A unique identifier for the vendor.
  502. Attributes - Attributes bitmask to set for the variable.
  503. DataSize - The size in bytes of the Data buffer.
  504. Data - The contents for the variable.
  505. Returns:
  506. Status code
  507. --*/
  508. ;
  509. #if (EFI_SPECIFICATION_VERSION >= 0x00020000)
  510. EFI_STATUS
  511. EfiQueryVariableInfo (
  512. IN UINT32 Attributes,
  513. OUT UINT64 *MaximumVariableStorageSize,
  514. OUT UINT64 *RemainingVariableStorageSize,
  515. OUT UINT64 *MaximumVariableSize
  516. )
  517. /*++
  518. Routine Description:
  519. This code returns information about the EFI variables.
  520. Arguments:
  521. Attributes Attributes bitmask to specify the type of variables
  522. on which to return information.
  523. MaximumVariableStorageSize Pointer to the maximum size of the storage space available
  524. for the EFI variables associated with the attributes specified.
  525. RemainingVariableStorageSize Pointer to the remaining size of the storage space available
  526. for the EFI variables associated with the attributes specified.
  527. MaximumVariableSize Pointer to the maximum size of the individual EFI variables
  528. associated with the attributes specified.
  529. Returns:
  530. Status code
  531. --*/
  532. ;
  533. #endif
  534. EFI_STATUS
  535. EfiReportStatusCode (
  536. IN EFI_STATUS_CODE_TYPE CodeType,
  537. IN EFI_STATUS_CODE_VALUE Value,
  538. IN UINT32 Instance,
  539. IN EFI_GUID * CallerId,
  540. IN EFI_STATUS_CODE_DATA * Data OPTIONAL
  541. )
  542. /*++
  543. Routine Description:
  544. Status Code reporter
  545. Arguments:
  546. CodeType - Type of Status Code.
  547. Value - Value to output for Status Code.
  548. Instance - Instance Number of this status code.
  549. CallerId - ID of the caller of this status code.
  550. Data - Optional data associated with this status code.
  551. Returns:
  552. Status code
  553. --*/
  554. ;
  555. EFI_STATUS
  556. EfiConvertPointer (
  557. IN UINTN DebugDisposition,
  558. IN OUT VOID *Address
  559. )
  560. /*++
  561. Routine Description:
  562. Determines the new virtual address that is to be used on subsequent memory accesses.
  563. Arguments:
  564. DebugDisposition - Supplies type information for the pointer being converted.
  565. Address - A pointer to a pointer that is to be fixed to be the value needed
  566. for the new virtual address mappings being applied.
  567. Returns:
  568. Status code
  569. --*/
  570. ;
  571. EFI_STATUS
  572. EfiConvertList (
  573. IN UINTN DebugDisposition,
  574. IN OUT EFI_LIST_ENTRY *ListHead
  575. )
  576. /*++
  577. Routine Description:
  578. Conver the standard Lib double linked list to a virtual mapping.
  579. Arguments:
  580. DebugDisposition - Argument to EfiConvertPointer (EFI 1.0 API)
  581. ListHead - Head of linked list to convert
  582. Returns:
  583. EFI_SUCCESS
  584. --*/
  585. ;
  586. //
  587. // Base IO Class Functions
  588. //
  589. EFI_STATUS
  590. EfiIoRead (
  591. IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
  592. IN UINT64 Address,
  593. IN UINTN Count,
  594. IN OUT VOID *Buffer
  595. )
  596. /*++
  597. Routine Description:
  598. Perform an IO read into Buffer.
  599. Arguments:
  600. Width - Width of read transaction, and repeat operation to use
  601. Address - IO address to read
  602. Count - Number of times to read the IO address.
  603. Buffer - Buffer to read data into. size is Width * Count
  604. Returns:
  605. Status code
  606. --*/
  607. ;
  608. UINT8
  609. IoRead8 (
  610. IN UINT64 Address
  611. )
  612. /*++
  613. Routine Description:
  614. Do a one byte IO read
  615. Arguments:
  616. Address - IO address to read
  617. Returns:
  618. Data read
  619. --*/
  620. ;
  621. UINT16
  622. IoRead16 (
  623. IN UINT64 Address
  624. )
  625. /*++
  626. Routine Description:
  627. Do a two byte IO read
  628. Arguments:
  629. Address - IO address to read
  630. Returns:
  631. Data read
  632. --*/
  633. ;
  634. UINT32
  635. IoRead32 (
  636. IN UINT64 Address
  637. )
  638. /*++
  639. Routine Description:
  640. Do a four byte IO read
  641. Arguments:
  642. Address - IO address to read
  643. Returns:
  644. Data read
  645. --*/
  646. ;
  647. EFI_STATUS
  648. EfiIoWrite (
  649. IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
  650. IN UINT64 Address,
  651. IN UINTN Count,
  652. IN OUT VOID *Buffer
  653. )
  654. /*++
  655. Routine Description:
  656. Perform an IO write into Buffer.
  657. Arguments:
  658. Width - Width of write transaction, and repeat operation to use
  659. Address - IO address to write
  660. Count - Number of times to write the IO address.
  661. Buffer - Buffer to write data from. size is Width * Count
  662. Returns:
  663. Status code
  664. --*/
  665. ;
  666. VOID
  667. IoWrite8 (
  668. IN UINT64 Address,
  669. IN UINT8 Data
  670. )
  671. /*++
  672. Routine Description:
  673. Do a one byte IO write
  674. Arguments:
  675. Address - IO address to write
  676. Data - Data to write to Address
  677. Returns:
  678. NONE
  679. --*/
  680. ;
  681. VOID
  682. IoWrite16 (
  683. IN UINT64 Address,
  684. IN UINT16 Data
  685. )
  686. /*++
  687. Routine Description:
  688. Do a two byte IO write
  689. Arguments:
  690. Address - IO address to write
  691. Data - Data to write to Address
  692. Returns:
  693. NONE
  694. --*/
  695. ;
  696. VOID
  697. IoWrite32 (
  698. IN UINT64 Address,
  699. IN UINT32 Data
  700. )
  701. /*++
  702. Routine Description:
  703. Do a four byte IO write
  704. Arguments:
  705. Address - IO address to write
  706. Data - Data to write to Address
  707. Returns:
  708. NONE
  709. --*/
  710. ;
  711. EFI_STATUS
  712. EfiMemRead (
  713. IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
  714. IN UINT64 Address,
  715. IN UINTN Count,
  716. IN OUT VOID *Buffer
  717. )
  718. /*++
  719. Routine Description:
  720. Perform a Memory mapped IO read into Buffer.
  721. Arguments:
  722. Width - Width of each read transaction.
  723. Address - Memory mapped IO address to read
  724. Count - Number of Width quanta to read
  725. Buffer - Buffer to read data into. size is Width * Count
  726. Returns:
  727. Status code
  728. --*/
  729. ;
  730. UINT8
  731. MemRead8 (
  732. IN UINT64 Address
  733. )
  734. /*++
  735. Routine Description:
  736. Do a one byte Memory mapped IO read
  737. Arguments:
  738. Address - Memory mapped IO address to read
  739. Returns:
  740. Data read
  741. --*/
  742. ;
  743. UINT16
  744. MemRead16 (
  745. IN UINT64 Address
  746. )
  747. /*++
  748. Routine Description:
  749. Do a two byte Memory mapped IO read
  750. Arguments:
  751. Address - Memory mapped IO address to read
  752. Returns:
  753. Data read
  754. --*/
  755. ;
  756. UINT32
  757. MemRead32 (
  758. IN UINT64 Address
  759. )
  760. /*++
  761. Routine Description:
  762. Do a four byte Memory mapped IO read
  763. Arguments:
  764. Address - Memory mapped IO address to read
  765. Returns:
  766. Data read
  767. --*/
  768. ;
  769. UINT64
  770. MemRead64 (
  771. IN UINT64 Address
  772. )
  773. /*++
  774. Routine Description:
  775. Do a eight byte Memory mapped IO read
  776. Arguments:
  777. Address - Memory mapped IO address to read
  778. Returns:
  779. Data read
  780. --*/
  781. ;
  782. EFI_STATUS
  783. EfiMemWrite (
  784. IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
  785. IN UINT64 Address,
  786. IN UINTN Count,
  787. IN OUT VOID *Buffer
  788. )
  789. /*++
  790. Routine Description:
  791. Perform a memory mapped IO write into Buffer.
  792. Arguments:
  793. Width - Width of write transaction, and repeat operation to use
  794. Address - IO address to write
  795. Count - Number of times to write the IO address.
  796. Buffer - Buffer to write data from. size is Width * Count
  797. Returns:
  798. Status code
  799. --*/
  800. ;
  801. VOID
  802. MemWrite8 (
  803. IN UINT64 Address,
  804. IN UINT8 Data
  805. )
  806. /*++
  807. Routine Description:
  808. Do a one byte Memory mapped IO write
  809. Arguments:
  810. Address - Memory mapped IO address to write
  811. Data - Data to write to Address
  812. Returns:
  813. NONE
  814. --*/
  815. ;
  816. VOID
  817. MemWrite16 (
  818. IN UINT64 Address,
  819. IN UINT16 Data
  820. )
  821. /*++
  822. Routine Description:
  823. Do a two byte Memory mapped IO write
  824. Arguments:
  825. Address - Memory mapped IO address to write
  826. Data - Data to write to Address
  827. Returns:
  828. NONE
  829. --*/
  830. ;
  831. VOID
  832. MemWrite32 (
  833. IN UINT64 Address,
  834. IN UINT32 Data
  835. )
  836. /*++
  837. Routine Description:
  838. Do a four byte Memory mapped IO write
  839. Arguments:
  840. Address - Memory mapped IO address to write
  841. Data - Data to write to Address
  842. Returns:
  843. NONE
  844. --*/
  845. ;
  846. VOID
  847. MemWrite64 (
  848. IN UINT64 Address,
  849. IN UINT64 Data
  850. )
  851. /*++
  852. Routine Description:
  853. Do a eight byte Memory mapped IO write
  854. Arguments:
  855. Address - Memory mapped IO address to write
  856. Data - Data to write to Address
  857. Returns:
  858. NONE
  859. --*/
  860. ;
  861. //
  862. // Platform specific functions
  863. //
  864. UINT8
  865. PciRead8 (
  866. UINT8 Segment,
  867. UINT8 Bus,
  868. UINT8 DevFunc,
  869. UINT8 Register
  870. )
  871. /*++
  872. Routine Description:
  873. Perform an one byte PCI config cycle read
  874. Arguments:
  875. Segment - PCI Segment ACPI _SEG
  876. Bus - PCI Bus
  877. DevFunc - PCI Device(7:3) and Func(2:0)
  878. Register - PCI config space register
  879. Returns:
  880. Data read from PCI config space
  881. --*/
  882. ;
  883. UINT16
  884. PciRead16 (
  885. UINT8 Segment,
  886. UINT8 Bus,
  887. UINT8 DevFunc,
  888. UINT8 Register
  889. )
  890. /*++
  891. Routine Description:
  892. Perform an two byte PCI config cycle read
  893. Arguments:
  894. Segment - PCI Segment ACPI _SEG
  895. Bus - PCI Bus
  896. DevFunc - PCI Device(7:3) and Func(2:0)
  897. Register - PCI config space register
  898. Returns:
  899. Data read from PCI config space
  900. --*/
  901. ;
  902. UINT32
  903. PciRead32 (
  904. UINT8 Segment,
  905. UINT8 Bus,
  906. UINT8 DevFunc,
  907. UINT8 Register
  908. )
  909. /*++
  910. Routine Description:
  911. Perform an four byte PCI config cycle read
  912. Arguments:
  913. Segment - PCI Segment ACPI _SEG
  914. Bus - PCI Bus
  915. DevFunc - PCI Device(7:3) and Func(2:0)
  916. Register - PCI config space register
  917. Returns:
  918. Data read from PCI config space
  919. --*/
  920. ;
  921. VOID
  922. PciWrite8 (
  923. UINT8 Segment,
  924. UINT8 Bus,
  925. UINT8 DevFunc,
  926. UINT8 Register,
  927. UINT8 Data
  928. )
  929. /*++
  930. Routine Description:
  931. Perform an one byte PCI config cycle write
  932. Arguments:
  933. Segment - PCI Segment ACPI _SEG
  934. Bus - PCI Bus
  935. DevFunc - PCI Device(7:3) and Func(2:0)
  936. Register - PCI config space register
  937. Data - Data to write
  938. Returns:
  939. NONE
  940. --*/
  941. ;
  942. VOID
  943. PciWrite16 (
  944. UINT8 Segment,
  945. UINT8 Bus,
  946. UINT8 DevFunc,
  947. UINT8 Register,
  948. UINT16 Data
  949. )
  950. /*++
  951. Routine Description:
  952. Perform an two byte PCI config cycle write
  953. Arguments:
  954. Segment - PCI Segment ACPI _SEG
  955. Bus - PCI Bus
  956. DevFunc - PCI Device(7:3) and Func(2:0)
  957. Register - PCI config space register
  958. Data - Data to write
  959. Returns:
  960. NONE
  961. --*/
  962. ;
  963. VOID
  964. PciWrite32 (
  965. UINT8 Segment,
  966. UINT8 Bus,
  967. UINT8 DevFunc,
  968. UINT8 Register,
  969. UINT32 Data
  970. )
  971. /*++
  972. Routine Description:
  973. Perform an four byte PCI config cycle write
  974. Arguments:
  975. Segment - PCI Segment ACPI _SEG
  976. Bus - PCI Bus
  977. DevFunc - PCI Device(7:3) and Func(2:0)
  978. Register - PCI config space register
  979. Data - Data to write
  980. Returns:
  981. NONE
  982. --*/
  983. ;
  984. VOID
  985. EfiStall (
  986. IN UINTN Microseconds
  987. )
  988. /*++
  989. Routine Description:
  990. Delay for at least the request number of microseconds
  991. Arguments:
  992. Microseconds - Number of microseconds to delay.
  993. Returns:
  994. NONE
  995. --*/
  996. ;
  997. //
  998. // FVB Services.
  999. //
  1000. EFI_STATUS
  1001. EfiFvbInitialize (
  1002. VOID
  1003. )
  1004. /*++
  1005. Routine Description:
  1006. Initialize globals and register Fvb Protocol notification function.
  1007. Arguments:
  1008. None
  1009. Returns:
  1010. EFI_SUCCESS
  1011. --*/
  1012. ;
  1013. EFI_STATUS
  1014. EfiFvbShutdown (
  1015. VOID
  1016. )
  1017. /*++
  1018. Routine Description:
  1019. Release resources allocated in EfiFvbInitialize.
  1020. Arguments:
  1021. None
  1022. Returns:
  1023. EFI_SUCCESS
  1024. --*/
  1025. ;
  1026. EFI_STATUS
  1027. EfiFvbReadBlock (
  1028. IN UINTN Instance,
  1029. IN EFI_LBA Lba,
  1030. IN UINTN Offset,
  1031. IN OUT UINTN *NumBytes,
  1032. IN UINT8 *Buffer
  1033. )
  1034. /*++
  1035. Routine Description:
  1036. Reads specified number of bytes into a buffer from the specified block
  1037. Arguments:
  1038. Instance - The FV instance to be read from
  1039. Lba - The logical block address to be read from
  1040. Offset - Offset into the block at which to begin reading
  1041. NumBytes - Pointer that on input contains the total size of
  1042. the buffer. On output, it contains the total number
  1043. of bytes read
  1044. Buffer - Pointer to a caller allocated buffer that will be
  1045. used to hold the data read
  1046. Returns:
  1047. Status code
  1048. --*/
  1049. ;
  1050. EFI_STATUS
  1051. EfiFvbWriteBlock (
  1052. IN UINTN Instance,
  1053. IN EFI_LBA Lba,
  1054. IN UINTN Offset,
  1055. IN OUT UINTN *NumBytes,
  1056. IN UINT8 *Buffer
  1057. )
  1058. /*++
  1059. Routine Description:
  1060. Writes specified number of bytes from the input buffer to the block
  1061. Arguments:
  1062. Instance - The FV instance to be written to
  1063. Lba - The starting logical block index to write to
  1064. Offset - Offset into the block at which to begin writing
  1065. NumBytes - Pointer that on input contains the total size of
  1066. the buffer. On output, it contains the total number
  1067. of bytes actually written
  1068. Buffer - Pointer to a caller allocated buffer that contains
  1069. the source for the write
  1070. Returns:
  1071. Status code
  1072. --*/
  1073. ;
  1074. EFI_STATUS
  1075. EfiFvbEraseBlock (
  1076. IN UINTN Instance,
  1077. IN EFI_LBA Lba
  1078. )
  1079. /*++
  1080. Routine Description:
  1081. Erases and initializes a firmware volume block
  1082. Arguments:
  1083. Instance - The FV instance to be erased
  1084. Lba - The logical block index to be erased
  1085. Returns:
  1086. Status code
  1087. --*/
  1088. ;
  1089. EFI_STATUS
  1090. EfiFvbGetVolumeAttributes (
  1091. IN UINTN Instance,
  1092. OUT EFI_FVB_ATTRIBUTES *Attributes
  1093. )
  1094. /*++
  1095. Routine Description:
  1096. Retrieves attributes, insures positive polarity of attribute bits, returns
  1097. resulting attributes in output parameter
  1098. Arguments:
  1099. Instance - The FV instance whose attributes is going to be
  1100. returned
  1101. Attributes - Output buffer which contains attributes
  1102. Returns:
  1103. Status code
  1104. --*/
  1105. ;
  1106. EFI_STATUS
  1107. EfiFvbSetVolumeAttributes (
  1108. IN UINTN Instance,
  1109. IN EFI_FVB_ATTRIBUTES Attributes
  1110. )
  1111. /*++
  1112. Routine Description:
  1113. Modifies the current settings of the firmware volume according to the
  1114. input parameter.
  1115. Arguments:
  1116. Instance - The FV instance whose attributes is going to be
  1117. modified
  1118. Attributes - It is a pointer to EFI_FVB_ATTRIBUTES
  1119. containing the desired firmware volume settings.
  1120. Returns:
  1121. Status code
  1122. --*/
  1123. ;
  1124. EFI_STATUS
  1125. EfiFvbGetPhysicalAddress (
  1126. IN UINTN Instance,
  1127. OUT EFI_PHYSICAL_ADDRESS *Address
  1128. )
  1129. /*++
  1130. Routine Description:
  1131. Retrieves the physical address of a memory mapped FV
  1132. Arguments:
  1133. Instance - The FV instance whose base address is going to be
  1134. returned
  1135. Address - Pointer to a caller allocated EFI_PHYSICAL_ADDRESS
  1136. that on successful return, contains the base address
  1137. of the firmware volume.
  1138. Returns:
  1139. Status code
  1140. --*/
  1141. ;
  1142. EFI_STATUS
  1143. EfiFvbGetBlockSize (
  1144. IN UINTN Instance,
  1145. IN EFI_LBA Lba,
  1146. OUT UINTN *BlockSize,
  1147. OUT UINTN *NumOfBlocks
  1148. )
  1149. /*++
  1150. Routine Description:
  1151. Retrieve the size of a logical block
  1152. Arguments:
  1153. Instance - The FV instance whose block size is going to be
  1154. returned
  1155. Lba - Indicates which block to return the size for.
  1156. BlockSize - A pointer to a caller allocated UINTN in which
  1157. the size of the block is returned
  1158. NumOfBlocks - a pointer to a caller allocated UINTN in which the
  1159. number of consecutive blocks starting with Lba is
  1160. returned. All blocks in this range have a size of
  1161. BlockSize
  1162. Returns:
  1163. EFI_SUCCESS - The firmware volume was read successfully and
  1164. contents are in Buffer
  1165. --*/
  1166. ;
  1167. EFI_STATUS
  1168. EfiFvbEraseCustomBlockRange (
  1169. IN UINTN Instance,
  1170. IN EFI_LBA StartLba,
  1171. IN UINTN OffsetStartLba,
  1172. IN EFI_LBA LastLba,
  1173. IN UINTN OffsetLastLba
  1174. )
  1175. /*++
  1176. Routine Description:
  1177. Erases and initializes a specified range of a firmware volume
  1178. Arguments:
  1179. Instance - The FV instance to be erased
  1180. StartLba - The starting logical block index to be erased
  1181. OffsetStartLba - Offset into the starting block at which to
  1182. begin erasing
  1183. LastLba - The last logical block index to be erased
  1184. OffsetLastLba - Offset into the last block at which to end erasing
  1185. Returns:
  1186. Status code
  1187. --*/
  1188. ;
  1189. EFI_STATUS
  1190. EfiCpuFlushCache (
  1191. IN EFI_PHYSICAL_ADDRESS Start,
  1192. IN UINT64 Length
  1193. )
  1194. /*++
  1195. Routine Description:
  1196. Flush cache with specified range.
  1197. Arguments:
  1198. Start - Start address
  1199. Length - Length in bytes
  1200. Returns:
  1201. Status code
  1202. --*/
  1203. ;
  1204. EFI_STATUS
  1205. EFIAPI
  1206. RtEfiCreateEventLegacyBoot (
  1207. IN EFI_TPL NotifyTpl,
  1208. IN EFI_EVENT_NOTIFY NotifyFunction,
  1209. IN VOID *NotifyContext,
  1210. OUT EFI_EVENT *LegacyBootEvent
  1211. )
  1212. /*++
  1213. Routine Description:
  1214. Create a Legacy Boot Event.
  1215. Tiano extended the CreateEvent Type enum to add a legacy boot event type.
  1216. This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
  1217. added and now it's possible to not voilate the UEFI specification by
  1218. declaring a GUID for the legacy boot event class. This library supports
  1219. the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to
  1220. work both ways.
  1221. Arguments:
  1222. LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex)
  1223. Returns:
  1224. EFI_SUCCESS Event was created.
  1225. Other Event was not created.
  1226. --*/
  1227. ;
  1228. EFI_STATUS
  1229. EFIAPI
  1230. RtEfiCreateEventReadyToBoot (
  1231. IN EFI_TPL NotifyTpl,
  1232. IN EFI_EVENT_NOTIFY NotifyFunction,
  1233. IN VOID *NotifyContext,
  1234. OUT EFI_EVENT *ReadyToBootEvent
  1235. )
  1236. /*++
  1237. Routine Description:
  1238. Create a Read to Boot Event.
  1239. Tiano extended the CreateEvent Type enum to add a ready to boot event type.
  1240. This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
  1241. added and now it's possible to not voilate the UEFI specification and use
  1242. the ready to boot event class defined in UEFI 2.0. This library supports
  1243. the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to
  1244. work both ways.
  1245. Arguments:
  1246. ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex)
  1247. Return:
  1248. EFI_SUCCESS - Event was created.
  1249. Other - Event was not created.
  1250. --*/
  1251. ;
  1252. #endif