PageRenderTime 63ms CodeModel.GetById 35ms RepoModel.GetById 0ms app.codeStats 0ms

/EdkCompatibilityPkg/Foundation/Library/Pei/Include/PeiLib.h

https://bitbucket.org/incubaid/edk2
C Header | 1433 lines | 371 code | 70 blank | 992 comment | 1 complexity | 2c6f1bd58038175b4f721d43b9b236aa MD5 | raw file
  1. /*++
  2. Copyright (c) 2004 - 2010, 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. PeiLib.h
  11. Abstract:
  12. PEI Library Functions
  13. --*/
  14. #ifndef _PEI_LIB_H_
  15. #define _PEI_LIB_H_
  16. #include "Tiano.h"
  17. #include "Pei.h"
  18. #include "PeiHobLib.h"
  19. #include "PeiPerf.h"
  20. #include EFI_PROTOCOL_DEFINITION (Decompress)
  21. #include EFI_PROTOCOL_DEFINITION (TianoDecompress)
  22. #include EFI_GUID_DEFINITION (PeiPeCoffLoader)
  23. #include EFI_PPI_DEFINITION (FindFv)
  24. #if defined(__GNUC__) && defined(ECP_CPU_IPF)
  25. VOID
  26. EFIAPI
  27. EcpEfiBreakPoint (
  28. VOID
  29. )
  30. /*++
  31. Routine Description:
  32. Generates a breakpoint on the CPU.
  33. Generates a breakpoint on the CPU. The breakpoint must be implemented such
  34. that code can resume normal execution after the breakpoint.
  35. Arguments:
  36. VOID
  37. Returns:
  38. VOID
  39. --*/
  40. ;
  41. VOID
  42. EFIAPI
  43. EcpMemoryFence (
  44. VOID
  45. )
  46. /*++
  47. Routine Description:
  48. Used to serialize load and store operations.
  49. All loads and stores that proceed calls to this function are guaranteed to be
  50. globally visible when this function returns.
  51. Arguments:
  52. VOID
  53. Returns:
  54. VOID
  55. --*/
  56. ;
  57. #endif
  58. #if (PI_SPECIFICATION_VERSION >= 0x00010000)
  59. typedef struct {
  60. UINT32 PeiServiceTable;
  61. } PEI_IDT_TABLE;
  62. VOID *
  63. EFIAPI
  64. ScanGuid (
  65. IN VOID *Buffer,
  66. IN UINTN Length,
  67. IN EFI_GUID *Guid
  68. )
  69. /*++
  70. Routine Description:
  71. Scans a target buffer for a GUID, and returns a pointer to the matching GUID
  72. in the target buffer.
  73. This function searches target the buffer specified by Buffer and Length from
  74. the lowest address to the highest address at 128-bit increments for the 128-bit
  75. GUID value that matches Guid. If a match is found, then a pointer to the matching
  76. GUID in the target buffer is returned. If no match is found, then NULL is returned.
  77. If Length is 0, then NULL is returned.
  78. If Length > 0 and Buffer is NULL, then ASSERT().
  79. If Buffer is not aligned on a 32-bit boundary, then ASSERT().
  80. If Length is not aligned on a 128-bit boundary, then ASSERT().
  81. If Length is greater than (EFI_MAX_ADDRESS ?Buffer + 1), then ASSERT().
  82. Arguments:
  83. Buffer - Pointer to the target buffer to scan.
  84. Length - Number of bytes in Buffer to scan.
  85. Guid - Value to search for in the target buffer.
  86. Returns:
  87. A pointer to the matching Guid in the target buffer or NULL otherwise.
  88. --*/
  89. ;
  90. VOID *
  91. EFIAPI
  92. InvalidateInstructionCacheRange (
  93. IN VOID *Address,
  94. IN UINTN Length
  95. )
  96. /*++
  97. Routine Description:
  98. Invalidates a range of instruction cache lines in the cache coherency domain
  99. of the calling CPU.
  100. Invalidates the instruction cache lines specified by Address and Length. If
  101. Address is not aligned on a cache line boundary, then entire instruction
  102. cache line containing Address is invalidated. If Address + Length is not
  103. aligned on a cache line boundary, then the entire instruction cache line
  104. containing Address + Length -1 is invalidated. This function may choose to
  105. invalidate the entire instruction cache if that is more efficient than
  106. invalidating the specified range. If Length is 0, the no instruction cache
  107. lines are invalidated. Address is returned.
  108. If Length is greater than (EFI_MAX_ADDRESS - Address + 1), then ASSERT().
  109. Arguments:
  110. Address - The base address of the instruction cache lines to
  111. invalidate. If the CPU is in a physical addressing mode, then
  112. Address is a physical address. If the CPU is in a virtual
  113. addressing mode, then Address is a virtual address.
  114. Length - The number of bytes to invalidate from the instruction cache.
  115. Returns:
  116. Address
  117. **/
  118. ;
  119. EFI_STATUS
  120. EFIAPI
  121. PeiLibFfsFindNextVolume (
  122. IN UINTN Instance,
  123. IN OUT EFI_PEI_FV_HANDLE *VolumeHandle
  124. )
  125. /*++
  126. Routine Description:
  127. The wrapper of Pei Core Service function FfsFindNextVolume.
  128. Arguments:
  129. Instance - The Fv Volume Instance.
  130. VolumeHandle - Pointer to the current Fv Volume to search.
  131. Returns:
  132. EFI_STATUS
  133. --*/
  134. ;
  135. EFI_STATUS
  136. EFIAPI
  137. PeiLibFfsFindNextFile (
  138. IN EFI_FV_FILETYPE SearchType,
  139. IN EFI_PEI_FV_HANDLE FvHandle,
  140. IN OUT EFI_PEI_FILE_HANDLE *FileHandle
  141. )
  142. /*++
  143. Routine Description:
  144. The wrapper of Pei Core Service function FfsFindNextFile.
  145. Arguments:
  146. SearchType - Filter to find only file of this type.
  147. FvHandle - Pointer to the current FV to search.
  148. FileHandle - Pointer to the file matching SearchType in FwVolHeader.
  149. - NULL if file not found
  150. Returns:
  151. EFI_STATUS
  152. --*/
  153. ;
  154. EFI_STATUS
  155. EFIAPI
  156. PeiLibFfsFindFileByName (
  157. IN EFI_GUID *FileName,
  158. IN EFI_PEI_FV_HANDLE VolumeHandle,
  159. OUT EFI_PEI_FILE_HANDLE *FileHandle
  160. )
  161. /*++
  162. Routine Description:
  163. The wrapper of Pei Core Service function FfsFindFileByName.
  164. Arguments:
  165. FileName - File name to search.
  166. VolumeHandle - The current FV to search.
  167. FileHandle - Pointer to the file matching name in VolumeHandle.
  168. - NULL if file not found
  169. Returns:
  170. EFI_STATUS
  171. --*/
  172. ;
  173. EFI_STATUS
  174. EFIAPI
  175. PeiLibFfsFindSectionData (
  176. IN EFI_SECTION_TYPE SectionType,
  177. IN EFI_FFS_FILE_HEADER *FfsFileHeader,
  178. IN OUT VOID **SectionData
  179. )
  180. /*++
  181. Routine Description:
  182. The wrapper of Pei Core Service function FfsFindSectionData.
  183. Arguments:
  184. SearchType - Filter to find only sections of this type.
  185. FileHandle - Pointer to the current file to search.
  186. SectionData - Pointer to the Section matching SectionType in FfsFileHeader.
  187. - NULL if section not found
  188. Returns:
  189. EFI_STATUS
  190. --*/
  191. ;
  192. EFI_STATUS
  193. EFIAPI
  194. PeiLibFfsGetVolumeInfo (
  195. IN EFI_PEI_FV_HANDLE VolumeHandle,
  196. OUT EFI_FV_INFO *VolumeInfo
  197. )
  198. /*++
  199. Routine Description:
  200. The wrapper of Pei Core Service function FfsGetVolumeInfo.
  201. Arguments:
  202. VolumeHandle - The handle to Fv Volume.
  203. VolumeInfo - The pointer to volume information.
  204. Returns:
  205. EFI_STATUS
  206. --*/
  207. ;
  208. EFI_STATUS
  209. EFIAPI
  210. PeiServicesLocatePpi (
  211. IN EFI_GUID *Guid,
  212. IN UINTN Instance,
  213. IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,
  214. IN OUT VOID **Ppi
  215. )
  216. /*++
  217. Routine Description:
  218. The wrapper of Pei Core Service function LocatePpi.
  219. Arguments:
  220. Guid - Pointer to GUID of the PPI.
  221. Instance - Instance Number to discover.
  222. PpiDescriptor - Pointer to reference the found descriptor. If not NULL,
  223. returns a pointer to the descriptor (includes flags, etc)
  224. Ppi - Pointer to reference the found PPI
  225. Returns:
  226. Status - EFI_SUCCESS if the PPI is in the database
  227. EFI_NOT_FOUND if the PPI is not in the database
  228. --*/
  229. ;
  230. VOID
  231. EFIAPI
  232. BuildFvHob (
  233. IN EFI_PHYSICAL_ADDRESS BaseAddress,
  234. IN UINT64 Length
  235. )
  236. /*++
  237. Routine Description:
  238. Build FvHob.
  239. Arguments:
  240. BaseAddress - Fv base address.
  241. Length - Fv Length.
  242. Returns:
  243. NONE.
  244. --*/
  245. ;
  246. VOID
  247. EFIAPI
  248. BuildFvHob2 (
  249. IN EFI_PHYSICAL_ADDRESS BaseAddress,
  250. IN UINT64 Length,
  251. IN EFI_GUID *FvNameGuid,
  252. IN EFI_GUID *FileNameGuid
  253. )
  254. /*++
  255. Routine Description:
  256. Build FvHob2.
  257. Arguments:
  258. BaseAddress - Fv base address.
  259. Length - Fv length.
  260. FvNameGuid - Fv name.
  261. FileNameGuid - File name which contians encapsulated Fv.
  262. Returns:
  263. NONE.
  264. --*/
  265. ;
  266. VOID
  267. EFIAPI
  268. BuildGuidDataHob (
  269. IN EFI_GUID *Guid,
  270. IN VOID *Data,
  271. IN UINTN DataLength
  272. )
  273. /*++
  274. Routine Description:
  275. Build Guid data Hob.
  276. Arguments:
  277. Guid - guid to build data hob.
  278. Data - data to build data hob.
  279. DataLength - the length of data.
  280. Returns:
  281. NONE
  282. --*/
  283. ;
  284. VOID *
  285. EFIAPI
  286. AllocatePages (
  287. IN UINTN Pages
  288. )
  289. /*++
  290. Routine Description:
  291. Allocate Memory.
  292. Arguments:
  293. Pages - Pages to allocate.
  294. Returns:
  295. Address if successful to allocate memory.
  296. NULL if fail to allocate memory.
  297. --*/
  298. ;
  299. VOID
  300. SetPeiServicesTablePointer (
  301. IN EFI_PEI_SERVICES **PeiServices
  302. )
  303. /*++
  304. Routine Description:
  305. Save PeiService pointer so that it can be retrieved anywhere.
  306. Arguments:
  307. PeiServices - The direct pointer to PeiServiceTable.
  308. Returns:
  309. NONE
  310. --*/
  311. ;
  312. EFI_PEI_SERVICES **
  313. GetPeiServicesTablePointer (
  314. VOID
  315. )
  316. /*++
  317. Routine Description:
  318. Get PeiService pointer.
  319. Arguments:
  320. NONE.
  321. Returns:
  322. The direct pointer to PeiServiceTable.
  323. --*/
  324. ;
  325. VOID
  326. MigrateIdtTable (
  327. IN EFI_PEI_SERVICES **PeiServices
  328. )
  329. /*++
  330. Routine Description:
  331. Migrate IDT from CAR to real memory where preceded with 4 bytes for
  332. storing PeiService pointer.
  333. Arguments:
  334. PeiServices - The direct pointer to PeiServiceTable.
  335. Returns:
  336. NONE.
  337. --*/
  338. ;
  339. UINTN
  340. ReadIdtBase (
  341. VOID
  342. )
  343. /*++
  344. Routine Description:
  345. Read IDT Register BaseAddress.
  346. Arguments:
  347. NONE
  348. Returns:
  349. IDT Register BaseAddress.
  350. --*/
  351. ;
  352. UINT16
  353. ReadIdtLimit (
  354. VOID
  355. )
  356. /*++
  357. Routine Description:
  358. Read IDT Register Limit.
  359. Arguments:
  360. NONE
  361. Returns:
  362. IDT Register Limit.
  363. --*/
  364. ;
  365. VOID
  366. SetIdtBase (
  367. UINT32 IdtBase,
  368. UINT16 IdtLimit
  369. )
  370. /*++
  371. Routine Description:
  372. Set IDT Register BaseAddress.
  373. Arguments:
  374. IdtBase - IDT.BaseAddress
  375. IdtLimit - IDT.Limit
  376. Returns:
  377. NONE
  378. --*/
  379. ;
  380. VOID
  381. AsmWriteKr7 (
  382. UINT64 Address
  383. )
  384. /*++
  385. Routine Description:
  386. Write 64 bit into Kernel Register7 on IPF.
  387. Arguments:
  388. Address - Data to write into kr7.
  389. Returns:
  390. NONE
  391. --*/
  392. ;
  393. UINT64
  394. AsmReadKr7 (
  395. VOID
  396. )
  397. /*++
  398. Routine Description:
  399. Read 64 bit from Kernel Register7 on IPF.
  400. Arguments:
  401. NONE
  402. Returns:
  403. Data in kr7.
  404. --*/
  405. ;
  406. #endif
  407. VOID
  408. PeiCopyMem (
  409. IN VOID *Destination,
  410. IN VOID *Source,
  411. IN UINTN Length
  412. )
  413. /*++
  414. Routine Description:
  415. Copy Length bytes from Source to Destination.
  416. Arguments:
  417. Destination - Target of copy
  418. Source - Place to copy from
  419. Length - Number of bytes to copy
  420. Returns:
  421. None
  422. --*/
  423. ;
  424. VOID
  425. ZeroMem (
  426. IN VOID *Buffer,
  427. IN UINTN Size
  428. )
  429. /*++
  430. Routine Description:
  431. Set Buffer to zero for Size bytes.
  432. Arguments:
  433. Buffer - Memory to set.
  434. Size - Number of bytes to set
  435. Returns:
  436. None
  437. --*/
  438. ;
  439. VOID
  440. CopyMem (
  441. IN VOID *Destination,
  442. IN VOID *Source,
  443. IN UINTN Length
  444. )
  445. /*++
  446. Routine Description:
  447. Copy Length bytes from Source to Destination.
  448. Arguments:
  449. Destination - Target of copy
  450. Source - Place to copy from
  451. Length - Number of bytes to copy
  452. Returns:
  453. None
  454. --*/
  455. ;
  456. BOOLEAN
  457. CompareGuid (
  458. IN EFI_GUID *Guid1,
  459. IN EFI_GUID *Guid2
  460. )
  461. /*++
  462. Routine Description:
  463. Compares two GUIDs
  464. Arguments:
  465. Guid1 - guid to compare
  466. Guid2 - guid to compare
  467. Returns:
  468. = TRUE if Guid1 == Guid2
  469. = FALSE if Guid1 != Guid2
  470. --*/
  471. ;
  472. EFI_STATUS
  473. InstallEfiPeiPeCoffLoader (
  474. IN EFI_PEI_SERVICES **PeiServices,
  475. IN EFI_PEI_PE_COFF_LOADER_PROTOCOL **This,
  476. IN EFI_PEI_PPI_DESCRIPTOR *ThisPpi
  477. )
  478. /*++
  479. Routine Description:
  480. Install EFI Pei PE coff loader protocol.
  481. Arguments:
  482. PeiServices - The PEI core services table.
  483. This - Pointer to get Pei PE coff loader protocol as output
  484. ThisPpi - Passed in as EFI_NT_LOAD_AS_DLL_PPI on NT_EMULATOR platform
  485. Returns:
  486. EFI_SUCCESS
  487. --*/
  488. ;
  489. EFI_STATUS
  490. InstallEfiPeiPeCoffLoader64 (
  491. IN EFI_PEI_SERVICES **PeiServices,
  492. IN OUT EFI_PEI_PE_COFF_LOADER_PROTOCOL **This,
  493. IN EFI_PEI_PPI_DESCRIPTOR *ThisPpi
  494. );
  495. EFI_STATUS
  496. InstallEfiDecompress (
  497. EFI_DECOMPRESS_PROTOCOL **This
  498. )
  499. /*++
  500. Routine Description:
  501. Install EFI decompress protocol.
  502. Arguments:
  503. This - Pointer to get decompress protocol as output
  504. Returns:
  505. EFI_SUCCESS - EFI decompress protocol successfully installed.
  506. --*/
  507. ;
  508. EFI_STATUS
  509. InstallTianoDecompress (
  510. EFI_TIANO_DECOMPRESS_PROTOCOL **This
  511. )
  512. /*++
  513. Routine Description:
  514. Install Tiano decompress protocol.
  515. Arguments:
  516. This - Pointer to get decompress protocol as output
  517. Returns:
  518. EFI_SUCCESS - Tiano decompress protocol successfully installed.
  519. --*/
  520. ;
  521. EFI_STATUS
  522. GetTimerValue (
  523. OUT UINT64 *TimerValue
  524. )
  525. /*++
  526. Routine Description:
  527. Get timer value.
  528. Arguments:
  529. TimerValue - Pointer to the returned timer value
  530. Returns:
  531. EFI_SUCCESS - Successfully got timer value
  532. --*/
  533. ;
  534. #ifdef EFI_NT_EMULATOR
  535. EFI_STATUS
  536. PeCoffLoaderWinNtLoadAsDll (
  537. IN CHAR8 *PdbFileName,
  538. IN VOID **ImageEntryPoint,
  539. OUT VOID **ModHandle
  540. )
  541. /*++
  542. Routine Description:
  543. Loads the .DLL file is present when a PE/COFF file is loaded. This provides source level
  544. debugging for drivers that have cooresponding .DLL files on the local system.
  545. Arguments:
  546. PdbFileName - The name of the .PDB file. This was found from the PE/COFF
  547. file's debug directory entry.
  548. ImageEntryPoint - A pointer to the DLL entry point of the .DLL file was loaded.
  549. ModHandle - Pointer to loaded library.
  550. Returns:
  551. EFI_SUCCESS - The .DLL file was loaded, and the DLL entry point is returned in ImageEntryPoint
  552. EFI_NOT_FOUND - The .DLL file could not be found
  553. EFI_UNSUPPORTED - The .DLL file was loaded, but the entry point to the .DLL file could not
  554. determined.
  555. --*/
  556. ;
  557. #endif
  558. //
  559. // hob.c
  560. //
  561. EFI_STATUS
  562. PeiBuildHobModule (
  563. IN EFI_PEI_SERVICES **PeiServices,
  564. IN EFI_GUID *ModuleName,
  565. IN EFI_PHYSICAL_ADDRESS Module,
  566. IN UINT64 ModuleLength,
  567. IN EFI_PHYSICAL_ADDRESS EntryPoint
  568. )
  569. /*++
  570. Routine Description:
  571. Builds a HOB for a loaded PE32 module
  572. Arguments:
  573. PeiServices - The PEI core services table.
  574. ModuleName - The GUID File Name of the module
  575. Memory - The 64 bit physical address of the module
  576. ModuleLength - The length of the module in bytes
  577. EntryPoint - The 64 bit physical address of the entry point
  578. to the module
  579. Returns:
  580. EFI_SUCCESS - Hob is successfully built.
  581. Others - Errors occur while creating new Hob
  582. --*/
  583. ;
  584. EFI_STATUS
  585. PeiBuildHobResourceDescriptor (
  586. IN EFI_PEI_SERVICES **PeiServices,
  587. IN EFI_RESOURCE_TYPE ResourceType,
  588. IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute,
  589. IN EFI_PHYSICAL_ADDRESS PhysicalStart,
  590. IN UINT64 NumberOfBytes
  591. )
  592. /*++
  593. Routine Description:
  594. Builds a HOB that describes a chunck of system memory
  595. Arguments:
  596. PeiServices - The PEI core services table.
  597. ResourceType - The type of resource described by this HOB
  598. ResourceAttribute - The resource attributes of the memory described by this HOB
  599. PhysicalStart - The 64 bit physical address of memory described by this HOB
  600. NumberOfBytes - The length of the memoty described by this HOB in bytes
  601. Returns:
  602. EFI_SUCCESS - Hob is successfully built.
  603. Others - Errors occur while creating new Hob
  604. --*/
  605. ;
  606. EFI_STATUS
  607. PeiBuildHobGuid (
  608. IN EFI_PEI_SERVICES **PeiServices,
  609. IN EFI_GUID *Guid,
  610. IN UINTN DataLength,
  611. IN OUT VOID **Hob
  612. )
  613. /*++
  614. Routine Description:
  615. Builds a custom HOB that is tagged with a GUID for identification
  616. Arguments:
  617. PeiServices - The PEI core services table.
  618. Guid - The GUID of the custome HOB type
  619. DataLength - The size of the data payload for the GUIDed HOB
  620. Hob - Pointer to the Hob
  621. Returns:
  622. EFI_SUCCESS - Hob is successfully built.
  623. Others - Errors occur while creating new Hob
  624. --*/
  625. ;
  626. EFI_STATUS
  627. PeiBuildHobGuidData (
  628. IN EFI_PEI_SERVICES **PeiServices,
  629. IN EFI_GUID *Guid,
  630. IN VOID *Data,
  631. IN UINTN DataLength
  632. )
  633. /*++
  634. Routine Description:
  635. Builds a custom HOB that is tagged with a GUID for identification
  636. Arguments:
  637. PeiServices - The PEI core services table.
  638. Guid - The GUID of the custome HOB type
  639. Data - The data to be copied into the GUIDed HOB data field.
  640. DataLength - The data field length.
  641. Returns:
  642. EFI_SUCCESS - Hob is successfully built.
  643. Others - Errors occur while creating new Hob
  644. --*/
  645. ;
  646. EFI_STATUS
  647. PeiBuildHobFv (
  648. IN EFI_PEI_SERVICES **PeiServices,
  649. IN EFI_PHYSICAL_ADDRESS BaseAddress,
  650. IN UINT64 Length
  651. )
  652. /*++
  653. Routine Description:
  654. Builds a Firmware Volume HOB
  655. Arguments:
  656. PeiServices - The PEI core services table.
  657. BaseAddress - The base address of the Firmware Volume
  658. Length - The size of the Firmware Volume in bytes
  659. Returns:
  660. EFI_SUCCESS - Hob is successfully built.
  661. Others - Errors occur while creating new Hob
  662. --*/
  663. ;
  664. EFI_STATUS
  665. PeiBuildHobCpu (
  666. IN EFI_PEI_SERVICES **PeiServices,
  667. IN UINT8 SizeOfMemorySpace,
  668. IN UINT8 SizeOfIoSpace
  669. )
  670. /*++
  671. Routine Description:
  672. Builds a HOB for the CPU
  673. Arguments:
  674. PeiServices - The PEI core services table.
  675. SizeOfMemorySpace - Identifies the maximum
  676. physical memory addressibility of the processor.
  677. SizeOfIoSpace - Identifies the maximum physical I/O addressibility
  678. of the processor.
  679. Returns:
  680. EFI_SUCCESS - Hob is successfully built.
  681. Others - Errors occur while creating new Hob
  682. --*/
  683. ;
  684. EFI_STATUS
  685. PeiBuildHobStack (
  686. IN EFI_PEI_SERVICES **PeiServices,
  687. IN EFI_PHYSICAL_ADDRESS BaseAddress,
  688. IN UINT64 Length
  689. )
  690. /*++
  691. Routine Description:
  692. Builds a HOB for the Stack
  693. Arguments:
  694. PeiServices - The PEI core services table.
  695. BaseAddress - The 64 bit physical address of the Stack
  696. Length - The length of the stack in bytes
  697. Returns:
  698. EFI_SUCCESS - Hob is successfully built.
  699. Others - Errors occur while creating new Hob
  700. --*/
  701. ;
  702. EFI_STATUS
  703. PeiBuildHobBspStore (
  704. IN EFI_PEI_SERVICES **PeiServices,
  705. IN EFI_PHYSICAL_ADDRESS BaseAddress,
  706. IN UINT64 Length,
  707. IN EFI_MEMORY_TYPE MemoryType
  708. )
  709. /*++
  710. Routine Description:
  711. Builds a HOB for the bsp store
  712. Arguments:
  713. PeiServices - The PEI core services table.
  714. BaseAddress - The 64 bit physical address of the bsp store
  715. Length - The length of the bsp store in bytes
  716. MemoryType - Memory type
  717. Returns:
  718. EFI_SUCCESS - Hob is successfully built.
  719. Others - Errors occur while creating new Hob
  720. --*/
  721. ;
  722. EFI_STATUS
  723. PeiBuildHobMemoryAllocation (
  724. IN EFI_PEI_SERVICES **PeiServices,
  725. IN EFI_PHYSICAL_ADDRESS BaseAddress,
  726. IN UINT64 Length,
  727. IN EFI_GUID *Name,
  728. IN EFI_MEMORY_TYPE MemoryType
  729. )
  730. /*++
  731. Routine Description:
  732. Builds a HOB for the memory allocation
  733. Arguments:
  734. PeiServices - The PEI core services table.
  735. BaseAddress - The 64 bit physical address of the memory
  736. Length - The length of the memory allocation in bytes
  737. Name - Name for Hob
  738. MemoryType - Memory type
  739. Returns:
  740. EFI_SUCCESS - Hob is successfully built.
  741. Others - Errors occur while creating new Hob
  742. --*/
  743. ;
  744. //
  745. // print.c
  746. //
  747. UINTN
  748. AvSPrint (
  749. OUT CHAR8 *StartOfBuffer,
  750. IN UINTN StrSize,
  751. IN CONST CHAR8 *Format,
  752. IN VA_LIST Marker
  753. )
  754. /*++
  755. Routine Description:
  756. AvSPrint function to process format and place the results in Buffer. Since a
  757. VA_LIST is used this rountine allows the nesting of Vararg routines. Thus
  758. this is the main print working routine
  759. Arguments:
  760. StartOfBuffer - Ascii buffer to print the results of the parsing of Format into.
  761. StrSize - Maximum number of characters to put into buffer. Zero means
  762. no limit.
  763. FormatString - Ascii format string see file header for more details.
  764. Marker - Vararg list consumed by processing Format.
  765. Returns:
  766. Number of characters printed.
  767. --*/
  768. ;
  769. UINTN
  770. ASPrint (
  771. OUT CHAR8 *Buffer,
  772. IN UINTN BufferSize,
  773. IN CONST CHAR8 *Format,
  774. ...
  775. )
  776. /*++
  777. Routine Description:
  778. ASPrint function to process format and place the results in Buffer.
  779. Arguments:
  780. Buffer - Ascii buffer to print the results of the parsing of Format into.
  781. BufferSize - Maximum number of characters to put into buffer. Zero means no
  782. limit.
  783. Format - Ascii format string see file header for more details.
  784. ... - Vararg list consumed by processing Format.
  785. Returns:
  786. Number of characters printed.
  787. --*/
  788. ;
  789. //
  790. // math.c
  791. //
  792. UINT64
  793. MultU64x32 (
  794. IN UINT64 Multiplicand,
  795. IN UINTN Multiplier
  796. )
  797. /*++
  798. Routine Description:
  799. This routine allows a 64 bit value to be multiplied with a 32 bit
  800. value returns 64bit result.
  801. No checking if the result is greater than 64bits
  802. Arguments:
  803. Multiplicand - multiplicand
  804. Multiplier - multiplier
  805. Returns:
  806. Multiplicand * Multiplier
  807. --*/
  808. ;
  809. UINT64
  810. DivU64x32 (
  811. IN UINT64 Dividend,
  812. IN UINTN Divisor,
  813. OUT UINTN *Remainder OPTIONAL
  814. )
  815. /*++
  816. Routine Description:
  817. This routine allows a 64 bit value to be divided with a 32 bit value returns
  818. 64bit result and the Remainder.
  819. N.B. only works for 31bit divisors!!
  820. Arguments:
  821. Dividend - dividend
  822. Divisor - divisor
  823. Remainder - buffer for remainder
  824. Returns:
  825. Dividend / Divisor
  826. Remainder = Dividend mod Divisor
  827. --*/
  828. ;
  829. UINT64
  830. RShiftU64 (
  831. IN UINT64 Operand,
  832. IN UINTN Count
  833. )
  834. /*++
  835. Routine Description:
  836. This routine allows a 64 bit value to be right shifted by 32 bits and returns the
  837. shifted value.
  838. Count is valid up 63. (Only Bits 0-5 is valid for Count)
  839. Arguments:
  840. Operand - Value to be shifted
  841. Count - Number of times to shift right.
  842. Returns:
  843. Value shifted right identified by the Count.
  844. --*/
  845. ;
  846. UINT64
  847. LShiftU64 (
  848. IN UINT64 Operand,
  849. IN UINTN Count
  850. )
  851. /*++
  852. Routine Description:
  853. This routine allows a 64 bit value to be left shifted by 32 bits and
  854. returns the shifted value.
  855. Count is valid up 63. (Only Bits 0-5 is valid for Count)
  856. Arguments:
  857. Operand - Value to be shifted
  858. Count - Number of times to shift left.
  859. Returns:
  860. Value shifted left identified by the Count.
  861. --*/
  862. ;
  863. VOID
  864. RegisterNativeCpuIo (
  865. IN EFI_PEI_SERVICES **PeiServices,
  866. IN VOID *CpuIo
  867. )
  868. /*++
  869. Routine Description:
  870. Register a native Cpu IO
  871. Arguments:
  872. PeiServices - Calling context
  873. CpuIo - CpuIo instance to register
  874. Returns:
  875. None
  876. --*/
  877. ;
  878. VOID
  879. GetNativeCpuIo (
  880. IN EFI_PEI_SERVICES **PeiServices,
  881. OUT VOID **CpuIo
  882. )
  883. /*++
  884. Routine Description:
  885. Get registered Cpu IO.
  886. Arguments:
  887. PeiServices - Calling context
  888. CpuIo - CpuIo instance registered before
  889. Returns:
  890. None
  891. --*/
  892. ;
  893. EFI_STATUS
  894. EFIAPI
  895. FindFv (
  896. IN EFI_FIND_FV_PPI *This,
  897. IN EFI_PEI_SERVICES **PeiServices,
  898. IN OUT UINT8 *FvNumber,
  899. IN OUT EFI_FIRMWARE_VOLUME_HEADER **FVAddress
  900. )
  901. /*++
  902. Routine Description:
  903. Search Fv in Hob.
  904. Arguments:
  905. This - Interface pointer that implement the Find Fv PPI
  906. PeiServices - Pointer to the PEI Service Table
  907. FvNumber - On input, the number of the fireware volume which supports FFS to locate
  908. On output, the next FV number which supports FFS.
  909. FVAddress - The address of the volume which supports FFS to discover
  910. Returns:
  911. EFI_SUCCESS - An addtional FV which supports FFS found
  912. EFI_OUT_OF_RESOURCES - There are no fireware volume which supports FFS for given fvnumber
  913. EFI_INVALID_PARAMETER - FvAddress is NULL
  914. --*/
  915. ;
  916. EFI_STATUS
  917. EFIAPI
  918. PeiLibPciCfgModify (
  919. IN EFI_PEI_SERVICES **PeiServices,
  920. IN PEI_PCI_CFG_PPI *PciCfg,
  921. IN PEI_PCI_CFG_PPI_WIDTH Width,
  922. IN UINT64 Address,
  923. IN UINTN SetBits,
  924. IN UINTN ClearBits
  925. )
  926. /*++
  927. Routine Description:
  928. PCI read-modify-write operations.
  929. PIWG's PI specification replaces Inte's EFI Specification 1.10.
  930. EFI_PEI_PCI_CFG_PPI defined in Inte's EFI Specification 1.10 is replaced by
  931. EFI_PEI_PCI_CFG2_PPI in PI 1.0. "Modify" function in these two PPI are not
  932. compatibile with each other.
  933. For Framework code that make the following call:
  934. PciCfg->Modify (
  935. PeiServices,
  936. PciCfg,
  937. Width,
  938. Address,
  939. SetBits,
  940. ClearBits
  941. );
  942. it will be updated to the following code which call this library API:
  943. PeiLibPciCfgModify (
  944. PeiServices,
  945. PciCfg,
  946. Width,
  947. Address,
  948. SetBits,
  949. ClearBits
  950. );
  951. The
  952. Arguments:
  953. PeiServices An indirect pointer to the PEI Services Table
  954. published by the PEI Foundation.
  955. PciCfg A pointer to the this pointer of EFI_PEI_PCI_CFG_PPI.
  956. This parameter is unused as a place holder to make
  957. the parameter list identical to PEI_PCI_CFG_PPI_RW.
  958. Width The width of the access. Enumerated in bytes. Type
  959. EFI_PEI_PCI_CFG_PPI_WIDTH is defined in Read().
  960. Address The physical address of the access.
  961. SetBits Points to value to bitwise-OR with the read configuration value.
  962. The size of the value is determined by Width.
  963. ClearBits Points to the value to negate and bitwise-AND with the read configuration value.
  964. The size of the value is determined by Width.
  965. Returns:
  966. EFI_SUCCESS The function completed successfully.
  967. EFI_DEVICE_ERROR There was a problem with the transaction.
  968. --*/
  969. ;
  970. #endif