EDK-II常用库函数及API

1 EDK-II module Type

EDK-II module type
Module TypeDescription
SECCPU specific assembly code of SEC phase
PEI_COREPEI Core implementation
PEIMPEIMs that are complaint with PI specification
DXE_COREDXE Core implementation
DXE_DRIVERDXE drivers that exist in boot services and destroied when ExitBootServices() is called
DXE_RUNTIME_DREVERThis Module exist both in boot service environment and runtime service environment
DXE_SAL_DRVIERThis Module is only available to IPF CPUs
DXE_SMM_DRIVERThis Moudle type is used by DXE deivers that are loaded into SMRAM
UEFI_DIRVERUEFI Drivers that are complaint with UEFI specification
UEFI_APPLICATIONUEFI application. They are always unloaded after exit.

2 PCD Access Functions

PCD access functions
PcdGetx()/PcdSetx()Common get/set function for all PCDs type
FeaturePcdGet()/FeaturePcdSet()Get/set function for "FeaturePcd"
FixedPcdGetx()Get function for "FixedPcd"
PatchPcdGetx()/PatchPcdSetxGet/Set function for "PatchPcd"

3 Commonly Use Library Classes

BaseLibString, Linked List, Math, CPU realted
SynchronizationLibSynchronization Functions
PrintLibPrint a formated string to buffer
BaseMemoryLibFill Mem, Copy Mem, Zero Mem, GUID Operation
MemoryAllocationLibAllocate and free Memory
DebugLibPrint debug or assert memssages
PostCodeLibPOST code
StatusCodeLibProvide services to log status code
IoLibI/O or MMIO
PciExpressLibPCI configuration space Access using MMIO
PciLibPCI configuatrion space using I/O
TimerLibdelay function and performance calculation
PcdLibGet and Set PCD

4 The APIs which are frequently used in the commonly used Library

4.1 BaseLib

4.1.1 Linked List related declaration
#include <Library/BaseLib.h>
LIST_ENTRY * EFIAPI
InitializeListHead (
  IN OUT  LIST_ENTRY                *ListHead
  );

LIST_ENTRY * EFIAPI
InsertHeadList (
  IN OUT  LIST_ENTRY                *ListHead,
  IN OUT  LIST_ENTRY                *Entry
  );

LIST_ENTRY * EFIAPI
InsertTailList (
  IN OUT  LIST_ENTRY                *ListHead,
  IN OUT  LIST_ENTRY                *Entry
  );

LIST_ENTRY * EFIAPI
GetFirstNode (
  IN      CONST LIST_ENTRY          *List
  );

LIST_ENTRY * EFIAPI
GetPreviousNode (
  IN      CONST LIST_ENTRY          *List,
  IN      CONST LIST_ENTRY          *Node
  );

LIST_ENTRY * EFIAPI
GetNextNode (
  IN      CONST LIST_ENTRY          *List,
  IN      CONST LIST_ENTRY          *Node
  );

BOOLEAN EFIAPI
IsNodeAtEnd (
  IN      CONST LIST_ENTRY          *List,
  IN      CONST LIST_ENTRY          *Node
  );

LIST_ENTRY * EFIAPI
RemoveEntryList (
  IN      CONST LIST_ENTRY          *Entry
  );
4.1.2 String Related
For (char) string:
  AsciiStrCat(dst, src);
  AsciiStrCmp(first_str, sec_str);
  AsciiStrCpy(dst, src);
  AsciiStrLen(str);
  AsciiStrSize(str);

For (unicode) string:
  StrCat(dst, src);
  StrCmp(fist_str, sec_str);
  StrCpy(dst, src);
  StrLen(str);
  StrSize(str);

4.2 IoLib

IO Operation:
  IoRead8/16/32/64(port);
  IoWrite8/16/32/64(port);
  IoAnd8/16/32/64(port, and_data);
  IoOr8/16/32/64(port, or_data);
  IoAndThenOr8/16/32/64(port, and_data, or_data);

MMIO Operation:
  MmioRead8/16/32/64(address);
  MmioWrite8/16/32/64(address);
  MmioReadBuffer8/16/32/64(addr, len, buffer);
  MmioWriteBuffer8/16/32/64(addr, len, buffer);
  MmioAnd8/16/32/64(addr, and_data);
  MmioOr8/16/32/64(addr, or_data);
  MmioAndThenOr8/16/32/64(addr, and_data, or_data);

4.3 DebugLib

VOID
EFIAPI
DebugPrint (
  IN  UINTN        ErrorLevel,
  IN  CONST CHAR8  *Format,
  ...
  );

4.4 BaseMemoryLib

ScanMem8/16/32/64(buf, len, val);
SetMem/16/32/64(buf, len, val);
CopyMem(dst, src, len);
CopyGuid(dst, src);
CompareMem(dst, src, len);

4.5 MemoryAllocationLib

AllocateAlignedPages/ReservedPages/RuntimePages(pages, algin);
AllocatePool(size);
ReallocatePool(old_size, new_size, buffer);
AllocateZeroPoll(size);
FreePool(buf);

4.6 PciExpressLib

MACRO:
  PCI_EXPRESS_LIB_ADDRESS(Bus,Device,Function,Offset)
Functions:
  PciExpressRead8/16/32(addr);
  PciExpressWrite8/16/32(addr, data);
  PciExpressReadBuffer(addr, size, buf);
  PciExpressWriteBuffer(addr, size, buf);
  PciExpressAnd8/16/32(addr, and_data);
  PciExpressOr8/16/32(addr, or_data);
  PciExpressAndThenOr8/16/32(addr, and_data, or_data);

4.7 PciLib

MACRO:
  PCI_LIB_ADDRESS(Bus,Device,Function,Register)
Functions:
  PciRead8/16/32(addr);
  PciWrite8/16/32(addr, data);
  PciReadBuffer(addr, size, buf);
  PciWriteBuffer(addr, size, buf);
  PciAnd8/16/32(addr, and_data);
  PciOr8/16/32(addr, or_data);
  PciAndThenOr8/16/32(addr, and_data, or_data);

4.8 PcdLib

MACROs:
  PcdGet8/16/32/64(token);
  PcdSet8/16/32/64(token);
  FeaturePcdGet(token);
  FixedPcdGet8/16/32/64(token);


  • 2
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值