PageRenderTime 56ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

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

https://bitbucket.org/incubaid/edk2
C Header | 1359 lines | 359 code | 58 blank | 942 comment | 0 complexity | e2c7e45f7612dada00253dae7b5c8606 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. EfiCommonLib.h
  11. Abstract:
  12. Light weight lib to support EFI drivers.
  13. --*/
  14. #ifndef _EFI_COMMON_LIB_H_
  15. #define _EFI_COMMON_LIB_H_
  16. EFI_STATUS
  17. EfiLibGetSystemConfigurationTable (
  18. IN EFI_GUID *TableGuid,
  19. IN OUT VOID **Table
  20. )
  21. /*++
  22. Routine Description:
  23. Return the EFI 1.0 System Tabl entry with TableGuid
  24. Arguments:
  25. TableGuid - Name of entry to return in the system table
  26. Table - Pointer in EFI system table associated with TableGuid
  27. Returns:
  28. EFI_SUCCESS - Table returned;
  29. EFI_NOT_FOUND - TableGuid not in EFI system table
  30. --*/
  31. ;
  32. //
  33. // ASPrint and AvSPrint definitions you must include the specific library
  34. // to get the expected behavior from the two functions
  35. // PEI: PeiLib
  36. // Graphics: Dxe\Graphics\Unicode Dxe\Graphics\ASCII
  37. // ASCII: Dxe\Print\ASCII
  38. // Unicode: Dxe\Print\Unicode
  39. //
  40. UINTN
  41. ASPrint (
  42. OUT CHAR8 *Buffer,
  43. IN UINTN BufferSize,
  44. IN CONST CHAR8 *Format,
  45. ...
  46. )
  47. /*++
  48. Routine Description:
  49. Process format and place the results in Buffer for narrow chars.
  50. Arguments:
  51. Buffer - Narrow char buffer to print the results of the parsing of Format into.
  52. BufferSize - Maximum number of characters to put into buffer.
  53. Format - Format string
  54. ... - Vararg list consumed by processing Format.
  55. Returns:
  56. Number of characters printed.
  57. --*/
  58. ;
  59. UINTN
  60. AvSPrint (
  61. OUT CHAR8 *StartOfBuffer,
  62. IN UINTN StrSize,
  63. IN CONST CHAR8 *Format,
  64. IN VA_LIST Marker
  65. )
  66. /*++
  67. Routine Description:
  68. Internal implementation of ASPrint.
  69. Process format and place the results in Buffer for narrow chars.
  70. Arguments:
  71. StartOfBuffer - Narrow char buffer to print the results of the parsing of Format into.
  72. StrSize - Maximum number of characters to put into buffer.
  73. FormatString - Format string
  74. Marker - Vararg list consumed by processing Format.
  75. Returns:
  76. Number of characters printed.
  77. --*/
  78. ;
  79. //
  80. // Lib functions which can be used in both PEI and DXE pahse
  81. //
  82. EFI_STATUS
  83. EfiInitializeCommonDriverLib (
  84. IN EFI_HANDLE ImageHandle,
  85. IN VOID *SystemTable
  86. )
  87. /*++
  88. Routine Description:
  89. Initialize lib function calling phase: PEI or DXE
  90. Arguments:
  91. ImageHandle - The firmware allocated handle for the EFI image.
  92. SystemTable - A pointer to the EFI System Table.
  93. Returns:
  94. EFI_STATUS always returns EFI_SUCCESS
  95. --*/
  96. ;
  97. EFI_STATUS
  98. EfiCommonIoRead (
  99. IN UINT8 Width,
  100. IN UINTN Address,
  101. IN UINTN Count,
  102. IN OUT VOID *Buffer
  103. )
  104. /*++
  105. Routine Description:
  106. Io read operation.
  107. Arguments:
  108. Width - Width of read operation
  109. Address - Start IO address to read
  110. Count - Read count
  111. Buffer - Buffer to store result
  112. Returns:
  113. Status code
  114. --*/
  115. ;
  116. EFI_STATUS
  117. EfiCommonIoWrite (
  118. IN UINT8 Width,
  119. IN UINTN Address,
  120. IN UINTN Count,
  121. IN OUT VOID *Buffer
  122. )
  123. /*++
  124. Routine Description:
  125. Io write operation.
  126. Arguments:
  127. Width - Width of write operation
  128. Address - Start IO address to write
  129. Count - Write count
  130. Buffer - Buffer to write to the address
  131. Returns:
  132. Status code
  133. --*/
  134. ;
  135. EFI_STATUS
  136. EfiCommonPciRead (
  137. IN UINT8 Width,
  138. IN UINT64 Address,
  139. IN UINTN Count,
  140. IN OUT VOID *Buffer
  141. )
  142. /*++
  143. Routine Description:
  144. Pci read operation
  145. Arguments:
  146. Width - Width of PCI read
  147. Address - PCI address to read
  148. Count - Read count
  149. Buffer - Output buffer for the read
  150. Returns:
  151. Status code
  152. --*/
  153. ;
  154. EFI_STATUS
  155. EfiCommonPciWrite (
  156. IN UINT8 Width,
  157. IN UINT64 Address,
  158. IN UINTN Count,
  159. IN OUT VOID *Buffer
  160. )
  161. /*++
  162. Routine Description:
  163. Pci write operation
  164. Arguments:
  165. Width - Width of PCI write
  166. Address - PCI address to write
  167. Count - Write count
  168. Buffer - Buffer to write to the address
  169. Returns:
  170. Status code
  171. --*/
  172. ;
  173. BOOLEAN
  174. EfiCompareGuid (
  175. IN EFI_GUID *Guid1,
  176. IN EFI_GUID *Guid2
  177. )
  178. /*++
  179. Routine Description:
  180. Compares two GUIDs
  181. Arguments:
  182. Guid1 - guid to compare
  183. Guid2 - guid to compare
  184. Returns:
  185. TRUE if Guid1 == Guid2
  186. FALSE if Guid1 != Guid2
  187. --*/
  188. ;
  189. VOID
  190. EfiCommonLibSetMem (
  191. IN VOID *Buffer,
  192. IN UINTN Size,
  193. IN UINT8 Value
  194. )
  195. /*++
  196. Routine Description:
  197. Set Buffer to Value for Size bytes.
  198. Arguments:
  199. Buffer - Memory to set.
  200. Size - Number of bytes to set
  201. Value - Value of the set operation.
  202. Returns:
  203. None
  204. --*/
  205. ;
  206. VOID
  207. EfiCommonLibCopyMem (
  208. IN VOID *Destination,
  209. IN VOID *Source,
  210. IN UINTN Length
  211. )
  212. /*++
  213. Routine Description:
  214. Copy Length bytes from Source to Destination.
  215. Arguments:
  216. Destination - Target of copy
  217. Source - Place to copy from
  218. Length - Number of bytes to copy
  219. Returns:
  220. None
  221. --*/
  222. ;
  223. INTN
  224. EfiCompareMem (
  225. IN VOID *MemOne,
  226. IN VOID *MemTwo,
  227. IN UINTN Len
  228. )
  229. /*++
  230. Routine Description:
  231. Compares two memory buffers of a given length.
  232. Arguments:
  233. MemOne - First memory buffer
  234. MemTwo - Second memory buffer
  235. Len - Length of Mem1 and Mem2 memory regions to compare
  236. Returns:
  237. = 0 if MemOne == MemTwo
  238. > 0 if MemOne > MemTwo
  239. < 0 if MemOne < MemTwo
  240. --*/
  241. ;
  242. VOID
  243. EfiCommonLibZeroMem (
  244. IN VOID *Buffer,
  245. IN UINTN Size
  246. )
  247. /*++
  248. Routine Description:
  249. Set Buffer to 0 for Size bytes.
  250. Arguments:
  251. Buffer - Memory to set.
  252. Size - Number of bytes to set
  253. Returns:
  254. None
  255. --*/
  256. ;
  257. //
  258. // Min Max
  259. //
  260. #define EFI_MIN(a, b) (((a) < (b)) ? (a) : (b))
  261. #define EFI_MAX(a, b) (((a) > (b)) ? (a) : (b))
  262. //
  263. // Align a pointer. The pointer represented by ptr is aligned to the bound.
  264. // The resulting pointer is always equal or greater (by no more than bound-1)
  265. // than the ptr. I.e., if the ptr is already aligned, the result will be equal to ptr.
  266. // Valid values for bound are powers of two: 2, 4, 8, 16, 32 etc.
  267. // The returned pointer is VOID* this assignment-compatible with all pointer types.
  268. //
  269. #define EFI_ALIGN(ptr, bound) ((VOID *) (((UINTN) (ptr) + ((UINTN) (bound) - 1)) &~((UINTN) (bound) - 1)))
  270. //
  271. // Alignment tests.
  272. //
  273. #define EFI_UINTN_ALIGN_MASK (sizeof (UINTN) - 1)
  274. #define EFI_UINTN_ALIGNED(ptr) (((UINTN) (ptr)) & EFI_UINTN_ALIGN_MASK)
  275. //
  276. // Integer division with rounding to the nearest rather than truncating.
  277. // For example 8/3=2 but EFI_IDIV_ROUND(8,3)=3. 1/3=0 and EFI_IDIV_ROUND(1,3)=0.
  278. // A half is rounded up e.g., EFI_IDIV_ROUND(1,2)=1 but 1/2=0.
  279. //
  280. #define EFI_IDIV_ROUND(r, s) ((r) / (s) + (((2 * ((r) % (s))) < (s)) ? 0 : 1))
  281. //
  282. // ReportStatusCode.c init
  283. //
  284. VOID *
  285. EfiConstructStatusCodeData (
  286. IN UINT16 DataSize,
  287. IN EFI_GUID *TypeGuid,
  288. IN OUT EFI_STATUS_CODE_DATA *Data
  289. )
  290. /*++
  291. Routine Description:
  292. Construct stanader header for optional data passed into ReportStatusCode
  293. Arguments:
  294. DataSize - Size of optional data. Does not include EFI_STATUS_CODE_DATA header
  295. TypeGuid - GUID to place in EFI_STATUS_CODE_DATA
  296. Data - Buffer to use.
  297. Returns:
  298. Return pointer to Data buffer pointing past the end of EFI_STATUS_CODE_DATA
  299. --*/
  300. ;
  301. EFI_STATUS
  302. EfiDebugVPrintWorker (
  303. IN UINTN ErrorLevel,
  304. IN CHAR8 *Format,
  305. IN VA_LIST Marker,
  306. IN UINTN BufferSize,
  307. IN OUT VOID *Buffer
  308. )
  309. /*++
  310. Routine Description:
  311. Worker function for DEBUG(). If Error Logging hub is loaded log ASSERT
  312. information. If Error Logging hub is not loaded do nothing.
  313. We use UINT64 buffers due to IPF alignment concerns.
  314. Arguments:
  315. ErrorLevel - If error level is set do the debug print.
  316. Format - String to use for the print, followed by Print arguments.
  317. Marker - VarArgs
  318. BufferSize - Size of Buffer.
  319. Buffer - Caller allocated buffer, contains ReportStatusCode extended data
  320. Returns:
  321. Status code
  322. --*/
  323. ;
  324. EFI_STATUS
  325. EfiDebugAssertWorker (
  326. IN CHAR8 *FileName,
  327. IN INTN LineNumber,
  328. IN CHAR8 *Description,
  329. IN UINTN BufferSize,
  330. IN OUT VOID *Buffer
  331. )
  332. /*++
  333. Routine Description:
  334. Worker function for ASSERT (). If Error Logging hub is loaded log ASSERT
  335. information. If Error Logging hub is not loaded DEADLOOP ().
  336. We use UINT64 buffers due to IPF alignment concerns.
  337. Arguments:
  338. FileName - File name of failing routine.
  339. LineNumber - Line number of failing ASSERT().
  340. Description - Description, usually the assertion,
  341. BufferSize - Size of Buffer.
  342. Buffer - Caller allocated buffer, contains ReportStatusCode extendecd data
  343. Returns:
  344. Status code
  345. --*/
  346. ;
  347. BOOLEAN
  348. ReportStatusCodeExtractAssertInfo (
  349. IN EFI_STATUS_CODE_TYPE CodeType,
  350. IN EFI_STATUS_CODE_VALUE Value,
  351. IN EFI_STATUS_CODE_DATA *Data,
  352. OUT CHAR8 **Filename,
  353. OUT CHAR8 **Description,
  354. OUT UINT32 *LineNumber
  355. )
  356. /*++
  357. Routine Description:
  358. Extract assert information from status code data.
  359. Arguments:
  360. CodeType - Code type
  361. Value - Code value
  362. Data - Optional data associated with this status code.
  363. Filename - Filename extracted from Data
  364. Description - Description extracted from Data
  365. LineNumber - Line number extracted from Data
  366. Returns:
  367. TRUE - Successfully extracted
  368. FALSE - Extraction failed
  369. --*/
  370. ;
  371. BOOLEAN
  372. ReportStatusCodeExtractDebugInfo (
  373. IN EFI_STATUS_CODE_DATA *Data,
  374. OUT UINT32 *ErrorLevel,
  375. OUT VA_LIST *Marker,
  376. OUT CHAR8 **Format
  377. )
  378. /*++
  379. Routine Description:
  380. Extract debug information from status code data.
  381. Arguments:
  382. Data - Optional data associated with status code.
  383. ErrorLevel - Error level extracted from Data
  384. Marker - VA_LIST extracted from Data
  385. Format - Format string extracted from Data
  386. Returns:
  387. TRUE - Successfully extracted
  388. FALSE - Extraction failed
  389. --*/
  390. ;
  391. BOOLEAN
  392. CodeTypeToPostCode (
  393. IN EFI_STATUS_CODE_TYPE CodeType,
  394. IN EFI_STATUS_CODE_VALUE Value,
  395. OUT UINT8 *PostCode
  396. )
  397. /*++
  398. Routine Description:
  399. Convert code value to an 8 bit post code
  400. Arguments:
  401. CodeType - Code type
  402. Value - Code value
  403. PostCode - Post code as output
  404. Returns:
  405. TRUE - Successfully converted
  406. FALSE - Convertion failed
  407. --*/
  408. ;
  409. //
  410. // math.c
  411. //
  412. UINT64
  413. MultU64x32 (
  414. IN UINT64 Multiplicand,
  415. IN UINTN Multiplier
  416. )
  417. /*++
  418. Routine Description:
  419. This routine allows a 64 bit value to be multiplied with a 32 bit
  420. value returns 64bit result.
  421. No checking if the result is greater than 64bits
  422. Arguments:
  423. Multiplicand - multiplicand
  424. Multiplier - multiplier
  425. Returns:
  426. Multiplicand * Multiplier
  427. --*/
  428. ;
  429. UINT64
  430. DivU64x32 (
  431. IN UINT64 Dividend,
  432. IN UINTN Divisor,
  433. OUT UINTN *Remainder OPTIONAL
  434. )
  435. /*++
  436. Routine Description:
  437. This routine allows a 64 bit value to be divided with a 32 bit value returns
  438. 64bit result and the Remainder.
  439. Arguments:
  440. Dividend - dividend
  441. Divisor - divisor
  442. Remainder - buffer for remainder
  443. Returns:
  444. Dividend / Divisor
  445. Remainder = Dividend mod Divisor
  446. --*/
  447. ;
  448. UINT64
  449. RShiftU64 (
  450. IN UINT64 Operand,
  451. IN UINTN Count
  452. )
  453. /*++
  454. Routine Description:
  455. This routine allows a 64 bit value to be right shifted by 32 bits and returns the
  456. shifted value.
  457. Count is valid up 63. (Only Bits 0-5 is valid for Count)
  458. Arguments:
  459. Operand - Value to be shifted
  460. Count - Number of times to shift right.
  461. Returns:
  462. Value shifted right identified by the Count.
  463. --*/
  464. ;
  465. UINT64
  466. LShiftU64 (
  467. IN UINT64 Operand,
  468. IN UINTN Count
  469. )
  470. /*++
  471. Routine Description:
  472. This routine allows a 64 bit value to be left shifted by 32 bits and
  473. returns the shifted value.
  474. Count is valid up 63. (Only Bits 0-5 is valid for Count)
  475. Arguments:
  476. Operand - Value to be shifted
  477. Count - Number of times to shift left.
  478. Returns:
  479. Value shifted left identified by the Count.
  480. --*/
  481. ;
  482. UINT64
  483. Power10U64 (
  484. IN UINT64 Operand,
  485. IN UINTN Power
  486. )
  487. /*++
  488. Routine Description:
  489. Raise 10 to the power of Power, and multiply the result with Operand
  490. Arguments:
  491. Operand - multiplicand
  492. Power - power
  493. Returns:
  494. Operand * 10 ^ Power
  495. --*/
  496. ;
  497. UINT8
  498. Log2 (
  499. IN UINT64 Operand
  500. )
  501. /*++
  502. Routine Description:
  503. Calculates and floors logarithms based on 2
  504. Arguments:
  505. Operand - value to calculate logarithm
  506. Returns:
  507. The largest integer that is less than or equal
  508. to the logarithm of Operand based on 2
  509. --*/
  510. ;
  511. UINT64
  512. GetPowerOfTwo (
  513. IN UINT64 Input
  514. )
  515. /*++
  516. Routine Description:
  517. Calculates the largest integer that is both
  518. a power of two and less than Input
  519. Arguments:
  520. Input - value to calculate power of two
  521. Returns:
  522. the largest integer that is both a power of
  523. two and less than Input
  524. --*/
  525. ;
  526. //
  527. // Unicode String primatives
  528. //
  529. VOID
  530. EfiStrCpy (
  531. IN CHAR16 *Destination,
  532. IN CHAR16 *Source
  533. )
  534. /*++
  535. Routine Description:
  536. Copy the Unicode string Source to Destination.
  537. Arguments:
  538. Destination - Location to copy string
  539. Source - String to copy
  540. Returns:
  541. NONE
  542. --*/
  543. ;
  544. VOID
  545. EfiStrnCpy (
  546. OUT CHAR16 *Dst,
  547. IN CHAR16 *Src,
  548. IN UINTN Length
  549. )
  550. /*++
  551. Routine Description:
  552. Copy a string from source to destination
  553. Arguments:
  554. Dst Destination string
  555. Src Source string
  556. Length Length of destination string
  557. Returns:
  558. --*/
  559. ;
  560. UINTN
  561. EfiStrLen (
  562. IN CHAR16 *String
  563. )
  564. /*++
  565. Routine Description:
  566. Return the number of Unicode characters in String. This is not the same as
  567. the length of the string in bytes.
  568. Arguments:
  569. String - String to process
  570. Returns:
  571. Number of Unicode characters in String
  572. --*/
  573. ;
  574. UINTN
  575. EfiStrSize (
  576. IN CHAR16 *String
  577. )
  578. /*++
  579. Routine Description:
  580. Return the number bytes in the Unicode String. This is not the same as
  581. the length of the string in characters. The string size includes the NULL
  582. Arguments:
  583. String - String to process
  584. Returns:
  585. Number of bytes in String
  586. --*/
  587. ;
  588. INTN
  589. EfiStrCmp (
  590. IN CHAR16 *String,
  591. IN CHAR16 *String2
  592. )
  593. /*++
  594. Routine Description:
  595. Return the alphabetic relationship between two stirngs.
  596. Arguments:
  597. String - Compare to String2
  598. String2 - Compare to String
  599. Returns:
  600. 0 - Identical
  601. > 0 - String is alphabeticly greater than String2
  602. < 0 - String is alphabeticly less than String2
  603. --*/
  604. ;
  605. INTN
  606. EfiStrnCmp (
  607. IN CHAR16 *String,
  608. IN CHAR16 *String2,
  609. IN UINTN Length
  610. )
  611. /*++
  612. Routine Description:
  613. This function compares the Unicode string String to the Unicode
  614. string String2 for len characters. If the first len characters
  615. of String is identical to the first len characters of String2,
  616. then 0 is returned. If substring of String sorts lexicographically
  617. after String2, the function returns a number greater than 0. If
  618. substring of String sorts lexicographically before String2, the
  619. function returns a number less than 0.
  620. Arguments:
  621. String - Compare to String2
  622. String2 - Compare to String
  623. Length - Number of Unicode characters to compare
  624. Returns:
  625. 0 - The substring of String and String2 is identical.
  626. > 0 - The substring of String sorts lexicographically after String2
  627. < 0 - The substring of String sorts lexicographically before String2
  628. --*/
  629. ;
  630. VOID
  631. EfiStrCat (
  632. IN CHAR16 *Destination,
  633. IN CHAR16 *Source
  634. )
  635. /*++
  636. Routine Description:
  637. Concatinate Source on the end of Destination
  638. Arguments:
  639. Destination - String to added to the end of.
  640. Source - String to concatinate.
  641. Returns:
  642. NONE
  643. --*/
  644. ;
  645. VOID
  646. EfiStrnCat (
  647. IN CHAR16 *Dest,
  648. IN CHAR16 *Src,
  649. IN UINTN Length
  650. )
  651. /*++
  652. Routine Description:
  653. Concatinate Source on the end of Destination
  654. Arguments:
  655. Dst Destination string
  656. Src Source string
  657. Length Length of destination string
  658. Returns:
  659. --*/
  660. ;
  661. UINTN
  662. EfiAsciiStrLen (
  663. IN CHAR8 *String
  664. )
  665. /*++
  666. Routine Description:
  667. Return the number of Ascii characters in String. This is not the same as
  668. the length of the string in bytes.
  669. Arguments:
  670. String - String to process
  671. Returns:
  672. Number of Unicode characters in String
  673. --*/
  674. ;
  675. CHAR8 *
  676. EfiAsciiStrCpy (
  677. IN CHAR8 *Destination,
  678. IN CHAR8 *Source
  679. )
  680. /*++
  681. Routine Description:
  682. Copy the Ascii string Source to Destination.
  683. Arguments:
  684. Destination - Location to copy string
  685. Source - String to copy
  686. Returns:
  687. Pointer just pass the end of Destination
  688. --*/
  689. ;
  690. VOID
  691. EfiAsciiStrnCpy (
  692. OUT CHAR8 *Dst,
  693. IN CHAR8 *Src,
  694. IN UINTN Length
  695. )
  696. /*++
  697. Routine Description:
  698. Copy the Ascii string from source to destination
  699. Arguments:
  700. Dst Destination string
  701. Src Source string
  702. Length Length of destination string
  703. Returns:
  704. --*/
  705. ;
  706. UINTN
  707. EfiAsciiStrSize (
  708. IN CHAR8 *String
  709. )
  710. /*++
  711. Routine Description:
  712. Return the number bytes in the Ascii String. This is not the same as
  713. the length of the string in characters. The string size includes the NULL
  714. Arguments:
  715. String - String to process
  716. Returns:
  717. Number of bytes in String
  718. --*/
  719. ;
  720. INTN
  721. EfiAsciiStrCmp (
  722. IN CHAR8 *String,
  723. IN CHAR8 *String2
  724. )
  725. /*++
  726. Routine Description:
  727. Compare the Ascii string pointed by String to the string pointed by String2.
  728. Arguments:
  729. String - String to process
  730. String2 - The other string to process
  731. Returns:
  732. Return a positive integer if String is lexicall greater than String2; Zero if
  733. the two strings are identical; and a negative interger if String is lexically
  734. less than String2.
  735. --*/
  736. ;
  737. INTN
  738. EfiAsciiStrnCmp (
  739. IN CHAR8 *String,
  740. IN CHAR8 *String2,
  741. IN UINTN Length
  742. )
  743. /*++
  744. Routine Description:
  745. This function compares the ASCII string String to the ASCII
  746. string String2 for len characters. If the first len characters
  747. of String is identical to the first len characters of String2,
  748. then 0 is returned. If substring of String sorts lexicographically
  749. after String2, the function returns a number greater than 0. If
  750. substring of String sorts lexicographically before String2, the
  751. function returns a number less than 0.
  752. Arguments:
  753. String - Compare to String2
  754. String2 - Compare to String
  755. Length - Number of ASCII characters to compare
  756. Returns:
  757. 0 - The substring of String and String2 is identical.
  758. > 0 - The substring of String sorts lexicographically after String2
  759. < 0 - The substring of String sorts lexicographically before String2
  760. --*/
  761. ;
  762. VOID
  763. EfiAsciiStrCat (
  764. IN CHAR8 *Destination,
  765. IN CHAR8 *Source
  766. )
  767. /*++
  768. Routine Description:
  769. Concatinate Source on the end of Destination
  770. Arguments:
  771. Destination - String to added to the end of.
  772. Source - String to concatinate.
  773. Returns:
  774. NONE
  775. --*/
  776. ;
  777. VOID
  778. EfiAsciiStrnCat (
  779. IN CHAR8 *Destination,
  780. IN CHAR8 *Source,
  781. IN UINTN Length
  782. )
  783. /*++
  784. Routine Description:
  785. Concatinate Source on the end of Destination
  786. Arguments:
  787. Destination - String to added to the end of.
  788. Source - String to concatinate.
  789. Returns:
  790. NONE
  791. --*/
  792. ;
  793. //
  794. // Print primitives
  795. //
  796. #define LEFT_JUSTIFY 0x01
  797. #define PREFIX_SIGN 0x02
  798. #define PREFIX_BLANK 0x04
  799. #define COMMA_TYPE 0x08
  800. #define LONG_TYPE 0x10
  801. #define PREFIX_ZERO 0x20
  802. //
  803. // Length of temp string buffer to store value string.
  804. //
  805. #define CHARACTER_NUMBER_FOR_VALUE 30
  806. UINTN
  807. EfiValueToHexStr (
  808. IN OUT CHAR16 *Buffer,
  809. IN UINT64 Value,
  810. IN UINTN Flags,
  811. IN UINTN Width
  812. )
  813. /*++
  814. Routine Description:
  815. VSPrint worker function that prints a Value as a hex number in Buffer
  816. Arguments:
  817. Buffer - Location to place ascii hex string of Value.
  818. Value - Hex value to convert to a string in Buffer.
  819. Flags - Flags to use in printing Hex string, see file header for details.
  820. Width - Width of hex value.
  821. Returns:
  822. Number of characters printed.
  823. --*/
  824. ;
  825. UINTN
  826. EfiValueToString (
  827. IN OUT CHAR16 *Buffer,
  828. IN INT64 Value,
  829. IN UINTN Flags,
  830. IN UINTN Width
  831. )
  832. /*++
  833. Routine Description:
  834. VSPrint worker function that prints a Value as a decimal number in Buffer
  835. Arguments:
  836. Buffer - Location to place ascii decimal number string of Value.
  837. Value - Decimal value to convert to a string in Buffer.
  838. Flags - Flags to use in printing decimal string, see file header for details.
  839. Width - Width of hex value.
  840. Returns:
  841. Number of characters printed.
  842. --*/
  843. ;
  844. BOOLEAN
  845. IsHexDigit (
  846. OUT UINT8 *Digit,
  847. IN CHAR16 Char
  848. )
  849. /*++
  850. Routine Description:
  851. Determines if a Unicode character is a hexadecimal digit.
  852. The test is case insensitive.
  853. Arguments:
  854. Digit - Pointer to byte that receives the value of the hex character.
  855. Char - Unicode character to test.
  856. Returns:
  857. TRUE - If the character is a hexadecimal digit.
  858. FALSE - Otherwise.
  859. --*/
  860. ;
  861. CHAR16
  862. NibbleToHexChar (
  863. UINT8 Nibble
  864. )
  865. /*++
  866. Routine Description:
  867. Converts the low nibble of a byte to hex unicode character.
  868. Arguments:
  869. Nibble - lower nibble of a byte.
  870. Returns:
  871. Hex unicode character.
  872. --*/
  873. ;
  874. EFI_STATUS
  875. HexStringToBuf (
  876. IN OUT UINT8 *Buf,
  877. IN OUT UINTN *Len,
  878. IN CHAR16 *Str,
  879. OUT UINTN *ConvertedStrLen OPTIONAL
  880. )
  881. /*++
  882. Routine Description:
  883. Converts Unicode string to binary buffer.
  884. The conversion may be partial.
  885. The first character in the string that is not hex digit stops the conversion.
  886. At a minimum, any blob of data could be represented as a hex string.
  887. Arguments:
  888. Buf - Pointer to buffer that receives the data.
  889. Len - Length in bytes of the buffer to hold converted data.
  890. If routine return with EFI_SUCCESS, containing length of converted data.
  891. If routine return with EFI_BUFFER_TOO_SMALL, containg length of buffer desired.
  892. Str - String to be converted from.
  893. ConvertedStrLen - Length of the Hex String consumed.
  894. Returns:
  895. EFI_SUCCESS: Routine Success.
  896. EFI_BUFFER_TOO_SMALL: The buffer is too small to hold converted data.
  897. EFI_
  898. --*/
  899. ;
  900. EFI_STATUS
  901. BufToHexString (
  902. IN OUT CHAR16 *Str,
  903. IN OUT UINTN *HexStringBufferLength,
  904. IN UINT8 *Buf,
  905. IN UINTN Len
  906. )
  907. /*++
  908. Routine Description:
  909. Converts binary buffer to Unicode string.
  910. At a minimum, any blob of data could be represented as a hex string.
  911. Arguments:
  912. Str - Pointer to the string.
  913. HexStringBufferLength - Length in bytes of buffer to hold the hex string. Includes tailing '\0' character.
  914. If routine return with EFI_SUCCESS, containing length of hex string buffer.
  915. If routine return with EFI_BUFFER_TOO_SMALL, containg length of hex string buffer desired.
  916. Buf - Buffer to be converted from.
  917. Len - Length in bytes of the buffer to be converted.
  918. Returns:
  919. EFI_SUCCESS: Routine success.
  920. EFI_BUFFER_TOO_SMALL: The hex string buffer is too small.
  921. --*/
  922. ;
  923. VOID
  924. EfiStrTrim (
  925. IN OUT CHAR16 *str,
  926. IN CHAR16 CharC
  927. )
  928. /*++
  929. Routine Description:
  930. Removes (trims) specified leading and trailing characters from a string.
  931. Arguments:
  932. str - Pointer to the null-terminated string to be trimmed. On return,
  933. str will hold the trimmed string.
  934. CharC - Character will be trimmed from str.
  935. Returns:
  936. None
  937. --*/
  938. ;
  939. CHAR16*
  940. EfiStrStr (
  941. IN CHAR16 *String,
  942. IN CHAR16 *StrCharSet
  943. )
  944. /*++
  945. Routine Description:
  946. Find a substring.
  947. Arguments:
  948. String - Null-terminated string to search.
  949. StrCharSet - Null-terminated string to search for.
  950. Returns:
  951. The address of the first occurrence of the matching substring if successful, or NULL otherwise.
  952. --*/
  953. ;
  954. CHAR8*
  955. EfiAsciiStrStr (
  956. IN CHAR8 *String,
  957. IN CHAR8 *StrCharSet
  958. )
  959. /*++
  960. Routine Description:
  961. Find a Ascii substring.
  962. Arguments:
  963. String - Null-terminated Ascii string to search.
  964. StrCharSet - Null-terminated Ascii string to search for.
  965. Returns:
  966. The address of the first occurrence of the matching Ascii substring if successful, or NULL otherwise.
  967. --*/
  968. ;
  969. #endif