EDK-II常用库函数及API

Table of Contents

  • 1 EDK-II module Type
  • 2 PCD Access Functions
  • 3 Commonly Use Library Classes
  • 4 The APIs which are frequently used in the commonly used Library
    • 4.1 BaseLib
      • 4.1.1 Linked List related declaration
      • 4.1.2 String Related
    • 4.2 IoLib
    • 4.3 DebugLib
    • 4.4 BaseMemoryLib
    • 4.5 MemoryAllocationLib
    • 4.6 PciExpressLib
    • 4.7 PciLib
    • 4.8 PcdLib

1 EDK-II module Type

EDK-II module type
Module Type Description
SEC CPU specific assembly code of SEC phase
PEI_CORE PEI Core implementation
PEIM PEIMs that are complaint with PI specification
DXE_CORE DXE Core implementation
DXE_DRIVER DXE drivers that exist in boot services and destroied when ExitBootServices() is called
DXE_RUNTIME_DREVER This Module exist both in boot service environment and runtime service environment
DXE_SAL_DRVIER This Module is only available to IPF CPUs
DXE_SMM_DRIVER This Moudle type is used by DXE deivers that are loaded into SMRAM
UEFI_DIRVER UEFI Drivers that are complaint with UEFI specification
UEFI_APPLICATION UEFI 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()/PatchPcdSetx Get/Set function for "PatchPcd"

3 Commonly Use Library Classes

BaseLib String, Linked List, Math, CPU realted
SynchronizationLib Synchronization Functions
PrintLib Print a formated string to buffer
BaseMemoryLib Fill Mem, Copy Mem, Zero Mem, GUID Operation
MemoryAllocationLib Allocate and free Memory
DebugLib Print debug or assert memssages
PostCodeLib POST code
StatusCodeLib Provide services to log status code
IoLib I/O or MMIO
PciExpressLib PCI configuration space Access using MMIO
PciLib PCI configuatrion space using I/O
TimerLib delay function and performance calculation
PcdLib Get 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);


你可能感兴趣的:(EDK-II常用库函数及API)