Clean up GenericBdsLib library Instance.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5449 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
qwang12 2008-07-11 06:02:04 +00:00
parent 7b3e2a1b9a
commit 11ef23f9d1
12 changed files with 496 additions and 192 deletions

View File

@ -218,7 +218,7 @@ BdsLibBootViaBootOption (
// machinename is ia32, ia64, x64, ... // machinename is ia32, ia64, x64, ...
// //
FilePath = FileDevicePath (Handle, DEFAULT_REMOVABLE_FILE_NAME); FilePath = FileDevicePath (Handle, DEFAULT_REMOVABLE_FILE_NAME);
if (FilePath) { if (FilePath != NULL) {
Status = gBS->LoadImage ( Status = gBS->LoadImage (
TRUE, TRUE,
mBdsImageHandle, mBdsImageHandle,
@ -582,7 +582,7 @@ MatchPartitionDevicePathNode (
/** /**
Delete the boot option associated with the handle passed in Delete the boot option associated with the handle passed in.
@param Handle The handle which present the device path to create @param Handle The handle which present the device path to create
boot option boot option
@ -944,7 +944,7 @@ BdsLibEnumerateAllBootOption (
} }
} }
if (NumberBlockIoHandles) { if (NumberBlockIoHandles != 0) {
gBS->FreePool (BlockIoHandles); gBS->FreePool (BlockIoHandles);
} }
@ -1006,7 +1006,7 @@ BdsLibEnumerateAllBootOption (
} }
} }
if (NumberFileSystemHandles) { if (NumberFileSystemHandles != 0) {
gBS->FreePool (FileSystemHandles); gBS->FreePool (FileSystemHandles);
} }
@ -1029,7 +1029,7 @@ BdsLibEnumerateAllBootOption (
BdsLibBuildOptionFromHandle (SimpleNetworkHandles[Index], BdsBootOptionList, Buffer); BdsLibBuildOptionFromHandle (SimpleNetworkHandles[Index], BdsBootOptionList, Buffer);
} }
if (NumberSimpleNetworkHandles) { if (NumberSimpleNetworkHandles != 0) {
gBS->FreePool (SimpleNetworkHandles); gBS->FreePool (SimpleNetworkHandles);
} }
@ -1083,7 +1083,7 @@ BdsLibEnumerateAllBootOption (
BdsLibBuildOptionFromShell (FvHandleBuffer[Index], BdsBootOptionList); BdsLibBuildOptionFromShell (FvHandleBuffer[Index], BdsBootOptionList);
} }
if (FvHandleCount) { if (FvHandleCount != 0) {
gBS->FreePool (FvHandleBuffer); gBS->FreePool (FvHandleBuffer);
} }
// //
@ -1098,14 +1098,13 @@ BdsLibEnumerateAllBootOption (
/** /**
Build the boot option with the handle parsed in Build the boot option with the handle parsed in.
@param Handle The handle which present the device path to create @param Handle The handle which present the device path to create
boot option boot option
@param BdsBootOptionList The header of the link list which indexed all @param BdsBootOptionList The header of the link list which indexed all
current boot options current boot options
@param String Boot option name.
@return VOID
**/ **/
VOID VOID
@ -1128,15 +1127,13 @@ BdsLibBuildOptionFromHandle (
/** /**
Build the on flash shell boot option with the handle parsed in Build the on flash shell boot option with the handle parsed in.
@param Handle The handle which present the device path to create @param Handle The handle which present the device path to create
on flash shell boot option on flash shell boot option
@param BdsBootOptionList The header of the link list which indexed all @param BdsBootOptionList The header of the link list which indexed all
current boot options current boot options
@return None
**/ **/
VOID VOID
EFIAPI EFIAPI
@ -1459,7 +1456,7 @@ BdsLibNetworkBootWithMediaPresent (
/** /**
For a bootable Device path, return its boot type For a bootable Device path, return its boot type.
@param DevicePath The bootable device Path to check @param DevicePath The bootable device Path to check
@ -1547,8 +1544,8 @@ BdsGetBootTypeFromDevicePath (
Check whether the Device path in a boot option point to a valide bootable device, Check whether the Device path in a boot option point to a valide bootable device,
And if CheckMedia is true, check the device is ready to boot now. And if CheckMedia is true, check the device is ready to boot now.
DevPath -- the Device path in a boot option @param DevPath -- the Device path in a boot option
CheckMedia -- if true, check the device is ready to boot now. @param CheckMedia -- if true, check the device is ready to boot now.
@return TRUE -- the Device path is valide @return TRUE -- the Device path is valide
@return FALSE -- the Device path is invalide . @return FALSE -- the Device path is invalide .

View File

@ -309,7 +309,7 @@ BdsLibConnectAllDriversToAllControllers (
/** /**
Connect the specific Usb device which match the short form device path, Connect the specific Usb device which match the short form device path,
and whose bus is determined by Host Controller (Uhci or Ehci) and whose bus is determined by Host Controller (Uhci or Ehci).
@param HostControllerPI Uhci (0x00) or Ehci (0x20) or Both uhci and ehci @param HostControllerPI Uhci (0x00) or Ehci (0x20) or Both uhci and ehci
(0xFF) (0xFF)

View File

@ -14,6 +14,15 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "InternalBdsLib.h" #include "InternalBdsLib.h"
/**
Check if we need to save the EFI variable with "ConVarName" as name
as NV type
@param ConVarName The name of the EFI variable.
@retval TRUE Set the EFI variabel as NV type.
@retval FALSE EFI variabel as NV type can be set NonNV.
**/
BOOLEAN BOOLEAN
IsNvNeed ( IsNvNeed (
IN CHAR16 *ConVarName IN CHAR16 *ConVarName
@ -27,7 +36,7 @@ IsNvNeed (
// If the variable includes "Dev" at last, we consider // If the variable includes "Dev" at last, we consider
// it does not support NV attribute. // it does not support NV attribute.
// //
while (*Ptr) { while (*Ptr != L'\0') {
Ptr++; Ptr++;
} }

View File

@ -17,8 +17,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#define MAX_STRING_LEN 200 #define MAX_STRING_LEN 200
static BOOLEAN mFeaturerSwitch = TRUE; BOOLEAN mFeaturerSwitch = TRUE;
static BOOLEAN mResetRequired = FALSE; BOOLEAN mResetRequired = FALSE;
extern UINT16 gPlatformBootTimeOutDefault; extern UINT16 gPlatformBootTimeOutDefault;
@ -174,8 +174,8 @@ BdsLibLoadDrivers (
/** /**
Get the Option Number that does not used Get the Option Number that does not used.
Try to locate the specific option variable one by one untile find a free number Try to locate the specific option variable one by one untile find a free number.
@param VariableName Indicate if the boot#### or driver#### option @param VariableName Indicate if the boot#### or driver#### option
@ -432,7 +432,7 @@ BdsLibRegisterNewOption (
/** /**
Build the boot#### or driver#### option from the VariableName, the Build the boot#### or driver#### option from the VariableName, the
build boot#### or driver#### will also be linked to BdsCommonOptionList build boot#### or driver#### will also be linked to BdsCommonOptionList.
@param BdsCommonOptionList The header of the boot#### or driver#### option @param BdsCommonOptionList The header of the boot#### or driver#### option
link list link list
@ -774,7 +774,7 @@ BdsLibMatchDevicePaths (
EFI_DEVICE_PATH_PROTOCOL *DevicePathInst; EFI_DEVICE_PATH_PROTOCOL *DevicePathInst;
UINTN Size; UINTN Size;
if (!Multi || !Single) { if (Multi != NULL || Single != NULL) {
return FALSE; return FALSE;
} }
@ -820,19 +820,19 @@ BdsLibOutputStrings (
... ...
) )
{ {
VA_LIST args; VA_LIST Args;
EFI_STATUS Status; EFI_STATUS Status;
CHAR16 *String; CHAR16 *String;
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
VA_START (args, ConOut); VA_START (Args, ConOut);
while (!EFI_ERROR (Status)) { while (!EFI_ERROR (Status)) {
// //
// If String is NULL, then it's the end of the list // If String is NULL, then it's the end of the list
// //
String = VA_ARG (args, CHAR16 *); String = VA_ARG (Args, CHAR16 *);
if (!String) { if (String != NULL) {
break; break;
} }
@ -992,13 +992,12 @@ SetupResetReminder (
/** /**
Get the headers (dos, image, optional header) from an image Get the headers (dos, image, optional header) from an image.
@param Device SimpleFileSystem device handle @param Device SimpleFileSystem device handle
@param FileName File name for the image @param FileName File name for the image
@param DosHeader Pointer to dos header @param DosHeader Pointer to dos header
@param ImageHeader Pointer to image header @param Hdr Pointer to optional header
@param OptionalHeader Pointer to optional header
@retval EFI_SUCCESS Successfully get the machine type. @retval EFI_SUCCESS Successfully get the machine type.
@retval EFI_NOT_FOUND The file is not found. @retval EFI_NOT_FOUND The file is not found.
@ -1130,30 +1129,25 @@ BdsLibGetImageHeader (
return Status; return Status;
} }
/**
This routine is a notification function for legayc boot or exit boot
service event. It will adjust the memory information for different
memory type and save them into the variables for next boot.
@param Event The event that triggered this notification function.
@param Context Pointer to the notification functions context.
EDES_TODO: Incomplete Descriptions None.
**/
VOID VOID
EFIAPI EFIAPI
BdsSetMemoryTypeInformationVariable ( BdsSetMemoryTypeInformationVariable (
EFI_EVENT Event, EFI_EVENT Event,
VOID *Context VOID *Context
) )
/*++
Routine Description:
This routine is a notification function for legayc boot or exit boot
service event. It will adjust the memory information for different
memory type and save them into the variables for next boot
Arguments:
Event - The event that triggered this notification function
Context - Pointer to the notification functions context
Returns:
None.
--*/
{ {
EFI_STATUS Status; EFI_STATUS Status;
EFI_MEMORY_TYPE_INFORMATION *PreviousMemoryTypeInformation; EFI_MEMORY_TYPE_INFORMATION *PreviousMemoryTypeInformation;
@ -1253,7 +1247,7 @@ Returns:
/** /**
This routine register a function to adjust the different type memory page number just before booting This routine register a function to adjust the different type memory page number just before booting
and save the updated info into the variable for next boot to use and save the updated info into the variable for next boot to use.
**/ **/
VOID VOID

View File

@ -21,45 +21,34 @@ EFI_GUID mEfiDevicePathMessagingUartFlowControlGuid = DEVICE_PATH_MESSAGING_UAR
EFI_GUID mEfiDevicePathMessagingSASGuid = DEVICE_PATH_MESSAGING_SAS; EFI_GUID mEfiDevicePathMessagingSASGuid = DEVICE_PATH_MESSAGING_SAS;
/**
Adjusts the size of a previously allocated buffer.
@param OldPool A pointer to the buffer whose size is being adjusted.
@param OldSize The size of the current buffer.
@param NewSize The size of the new buffer.
@return The new buffer allocated. If allocatio failed, NULL will be returned.
**/
VOID * VOID *
ReallocatePool ( ReallocatePool (
IN VOID *OldPool, IN VOID *OldPool,
IN UINTN OldSize, IN UINTN OldSize,
IN UINTN NewSize IN UINTN NewSize
) )
/*++
Routine Description:
Adjusts the size of a previously allocated buffer.
Arguments:
OldPool - A pointer to the buffer whose size is being adjusted.
OldSize - The size of the current buffer.
NewSize - The size of the new buffer.
Returns:
EFI_SUCEESS - The requested number of bytes were allocated.
EFI_OUT_OF_RESOURCES - The pool requested could not be allocated.
EFI_INVALID_PARAMETER - The buffer was invalid.
--*/
{ {
VOID *NewPool; VOID *NewPool;
NewPool = NULL; NewPool = NULL;
if (NewSize) { if (NewSize != 0) {
NewPool = AllocateZeroPool (NewSize); NewPool = AllocateZeroPool (NewSize);
} }
if (OldPool) { if (OldPool != NULL) {
if (NewPool) { if (NewPool != NULL) {
CopyMem (NewPool, OldPool, OldSize < NewSize ? OldSize : NewSize); CopyMem (NewPool, OldPool, OldSize < NewSize ? OldSize : NewSize);
} }
@ -78,9 +67,11 @@ Returns:
allocated. allocated.
@param fmt The format string @param fmt The format string
@param ... Variable argument list.
@return Allocated buffer with the formatted string printed in it. @return Allocated buffer with the formatted string printed in it.
@return The caller must free the allocated buffer. The buffer The caller must free the allocated buffer. The buffer
@return allocation is not packed. allocation is not packed.
**/ **/
CHAR16 * CHAR16 *
@ -92,37 +83,37 @@ CatPrint (
) )
{ {
UINT16 *AppendStr; UINT16 *AppendStr;
VA_LIST args; VA_LIST Args;
UINTN strsize; UINTN StringSize;
AppendStr = AllocateZeroPool (0x1000); AppendStr = AllocateZeroPool (0x1000);
if (AppendStr == NULL) { if (AppendStr == NULL) {
return Str->str; return Str->str;
} }
VA_START (args, fmt); VA_START (Args, fmt);
UnicodeVSPrint (AppendStr, 0x1000, fmt, args); UnicodeVSPrint (AppendStr, 0x1000, fmt, Args);
VA_END (args); VA_END (Args);
if (NULL == Str->str) { if (NULL == Str->str) {
strsize = StrSize (AppendStr); StringSize = StrSize (AppendStr);
Str->str = AllocateZeroPool (strsize); Str->str = AllocateZeroPool (StringSize);
ASSERT (Str->str != NULL); ASSERT (Str->str != NULL);
} else { } else {
strsize = StrSize (AppendStr); StringSize = StrSize (AppendStr);
strsize += (StrSize (Str->str) - sizeof (UINT16)); StringSize += (StrSize (Str->str) - sizeof (UINT16));
Str->str = ReallocatePool ( Str->str = ReallocatePool (
Str->str, Str->str,
StrSize (Str->str), StrSize (Str->str),
strsize StringSize
); );
ASSERT (Str->str != NULL); ASSERT (Str->str != NULL);
} }
Str->maxlen = MAX_CHAR * sizeof (UINT16); Str->maxlen = MAX_CHAR * sizeof (UINT16);
if (strsize < Str->maxlen) { if (StringSize < Str->maxlen) {
StrCat (Str->str, AppendStr); StrCat (Str->str, AppendStr);
Str->len = strsize - sizeof (UINT16); Str->len = StringSize - sizeof (UINT16);
} }
gBS->FreePool (AppendStr); gBS->FreePool (AppendStr);
@ -170,7 +161,7 @@ BdsLibUnpackDevicePath (
// Allocate space for the unpacked path // Allocate space for the unpacked path
// //
NewPath = AllocateZeroPool (Size); NewPath = AllocateZeroPool (Size);
if (NewPath) { if (NewPath != NULL) {
ASSERT (((UINTN) NewPath) % MIN_ALIGNMENT_SIZE == 0); ASSERT (((UINTN) NewPath) % MIN_ALIGNMENT_SIZE == 0);
@ -198,6 +189,16 @@ BdsLibUnpackDevicePath (
return NewPath; return NewPath;
} }
/**
Convert Device Path to a Unicode string for printing.
@param Str The buffer holding the output string.
This buffer contains the length of the
string and the maixmum length reserved
for the string buffer.
@param DevPath The device path.
**/
VOID VOID
DevPathPci ( DevPathPci (
IN OUT POOL_PRINT *Str, IN OUT POOL_PRINT *Str,
@ -210,6 +211,16 @@ DevPathPci (
CatPrint (Str, L"Pci(%x|%x)", (UINTN) Pci->Device, (UINTN) Pci->Function); CatPrint (Str, L"Pci(%x|%x)", (UINTN) Pci->Device, (UINTN) Pci->Function);
} }
/**
Convert Device Path to a Unicode string for printing.
@param Str The buffer holding the output string.
This buffer contains the length of the
string and the maixmum length reserved
for the string buffer.
@param DevPath The device path.
**/
VOID VOID
DevPathPccard ( DevPathPccard (
IN OUT POOL_PRINT *Str, IN OUT POOL_PRINT *Str,
@ -222,6 +233,16 @@ DevPathPccard (
CatPrint (Str, L"Pcmcia(Function%x)", (UINTN) Pccard->FunctionNumber); CatPrint (Str, L"Pcmcia(Function%x)", (UINTN) Pccard->FunctionNumber);
} }
/**
Convert Device Path to a Unicode string for printing.
@param Str The buffer holding the output string.
This buffer contains the length of the
string and the maixmum length reserved
for the string buffer.
@param DevPath The device path.
**/
VOID VOID
DevPathMemMap ( DevPathMemMap (
IN OUT POOL_PRINT *Str, IN OUT POOL_PRINT *Str,
@ -240,6 +261,16 @@ DevPathMemMap (
); );
} }
/**
Convert Device Path to a Unicode string for printing.
@param Str The buffer holding the output string.
This buffer contains the length of the
string and the maixmum length reserved
for the string buffer.
@param DevPath The device path.
**/
VOID VOID
DevPathController ( DevPathController (
IN OUT POOL_PRINT *Str, IN OUT POOL_PRINT *Str,
@ -254,12 +285,13 @@ DevPathController (
/** /**
Convert Vendor device path to device name Convert Device Path to a Unicode string for printing.
@param Str The buffer store device name @param Str The buffer holding the output string.
@param DevPath Pointer to vendor device path This buffer contains the length of the
string and the maixmum length reserved
@return When it return, the device name have been stored in *Str. for the string buffer.
@param DevPath The device path.
**/ **/
VOID VOID
@ -350,9 +382,9 @@ DevPathVendor (
CatPrint ( CatPrint (
Str, Str,
L"%s,%s,%s,", L"%s,%s,%s,",
(Info & (0x1 << 4)) ? L"SATA" : L"SAS", ((Info & (0x1 << 4)) != 0) ? L"SATA" : L"SAS",
(Info & (0x1 << 5)) ? L"External" : L"Internal", ((Info & (0x1 << 5)) != 0) ? L"External" : L"Internal",
(Info & (0x1 << 6)) ? L"Expanded" : L"Direct" ((Info & (0x1 << 6)) != 0) ? L"Expanded" : L"Direct"
); );
if ((Info & 0x0f) == 1) { if ((Info & 0x0f) == 1) {
CatPrint (Str, L"0,"); CatPrint (Str, L"0,");
@ -393,6 +425,16 @@ DevPathVendor (
} }
/**
Convert Device Path to a Unicode string for printing.
@param Str The buffer holding the output string.
This buffer contains the length of the
string and the maixmum length reserved
for the string buffer.
@param DevPath The device path.
**/
VOID VOID
DevPathAcpi ( DevPathAcpi (
IN OUT POOL_PRINT *Str, IN OUT POOL_PRINT *Str,
@ -409,6 +451,16 @@ DevPathAcpi (
} }
} }
/**
Convert Device Path to a Unicode string for printing.
@param Str The buffer holding the output string.
This buffer contains the length of the
string and the maixmum length reserved
for the string buffer.
@param DevPath The device path.
**/
VOID VOID
DevPathExtendedAcpi ( DevPathExtendedAcpi (
IN OUT POOL_PRINT *Str, IN OUT POOL_PRINT *Str,
@ -443,7 +495,7 @@ DevPathExtendedAcpi (
// find HIDSTR // find HIDSTR
// //
Anchor = 16; Anchor = 16;
for (Index = Anchor; Index < Length && AsChar8Array[Index]; Index++) { for (Index = Anchor; Index < Length && AsChar8Array[Index] != '\0'; Index++) {
; ;
} }
if (Index > Anchor) { if (Index > Anchor) {
@ -453,7 +505,7 @@ DevPathExtendedAcpi (
// find UIDSTR // find UIDSTR
// //
Anchor = (UINT16) (Index + 1); Anchor = (UINT16) (Index + 1);
for (Index = Anchor; Index < Length && AsChar8Array[Index]; Index++) { for (Index = Anchor; Index < Length && AsChar8Array[Index] != '\0'; Index++) {
; ;
} }
if (Index > Anchor) { if (Index > Anchor) {
@ -463,7 +515,7 @@ DevPathExtendedAcpi (
// find CIDSTR // find CIDSTR
// //
Anchor = (UINT16) (Index + 1); Anchor = (UINT16) (Index + 1);
for (Index = Anchor; Index < Length && AsChar8Array[Index]; Index++) { for (Index = Anchor; Index < Length && AsChar8Array[Index] != '\0'; Index++) {
; ;
} }
if (Index > Anchor) { if (Index > Anchor) {
@ -520,6 +572,16 @@ DevPathExtendedAcpi (
} }
/**
Convert Device Path to a Unicode string for printing.
@param Str The buffer holding the output string.
This buffer contains the length of the
string and the maixmum length reserved
for the string buffer.
@param DevPath The device path.
**/
VOID VOID
DevPathAdrAcpi ( DevPathAdrAcpi (
IN OUT POOL_PRINT *Str, IN OUT POOL_PRINT *Str,
@ -542,6 +604,16 @@ DevPathAdrAcpi (
CatPrint (Str, L")"); CatPrint (Str, L")");
} }
/**
Convert Device Path to a Unicode string for printing.
@param Str The buffer holding the output string.
This buffer contains the length of the
string and the maixmum length reserved
for the string buffer.
@param DevPath The device path.
**/
VOID VOID
DevPathAtapi ( DevPathAtapi (
IN OUT POOL_PRINT *Str, IN OUT POOL_PRINT *Str,
@ -559,6 +631,16 @@ DevPathAtapi (
); );
} }
/**
Convert Device Path to a Unicode string for printing.
@param Str The buffer holding the output string.
This buffer contains the length of the
string and the maixmum length reserved
for the string buffer.
@param DevPath The device path.
**/
VOID VOID
DevPathScsi ( DevPathScsi (
IN OUT POOL_PRINT *Str, IN OUT POOL_PRINT *Str,
@ -571,6 +653,16 @@ DevPathScsi (
CatPrint (Str, L"Scsi(Pun%x,Lun%x)", (UINTN) Scsi->Pun, (UINTN) Scsi->Lun); CatPrint (Str, L"Scsi(Pun%x,Lun%x)", (UINTN) Scsi->Pun, (UINTN) Scsi->Lun);
} }
/**
Convert Device Path to a Unicode string for printing.
@param Str The buffer holding the output string.
This buffer contains the length of the
string and the maixmum length reserved
for the string buffer.
@param DevPath The device path.
**/
VOID VOID
DevPathFibre ( DevPathFibre (
IN OUT POOL_PRINT *Str, IN OUT POOL_PRINT *Str,
@ -583,18 +675,38 @@ DevPathFibre (
CatPrint (Str, L"Fibre(Wwn%lx,Lun%x)", Fibre->WWN, Fibre->Lun); CatPrint (Str, L"Fibre(Wwn%lx,Lun%x)", Fibre->WWN, Fibre->Lun);
} }
/**
Convert Device Path to a Unicode string for printing.
@param Str The buffer holding the output string.
This buffer contains the length of the
string and the maixmum length reserved
for the string buffer.
@param DevPath The device path.
**/
VOID VOID
DevPath1394 ( DevPath1394 (
IN OUT POOL_PRINT *Str, IN OUT POOL_PRINT *Str,
IN VOID *DevPath IN VOID *DevPath
) )
{ {
F1394_DEVICE_PATH *F1394; F1394_DEVICE_PATH *F1394Path;
F1394 = DevPath; F1394Path = DevPath;
CatPrint (Str, L"1394(%g)", &F1394->Guid); CatPrint (Str, L"1394(%g)", &F1394Path->Guid);
} }
/**
Convert Device Path to a Unicode string for printing.
@param Str The buffer holding the output string.
This buffer contains the length of the
string and the maixmum length reserved
for the string buffer.
@param DevPath The device path.
**/
VOID VOID
DevPathUsb ( DevPathUsb (
IN OUT POOL_PRINT *Str, IN OUT POOL_PRINT *Str,
@ -607,6 +719,16 @@ DevPathUsb (
CatPrint (Str, L"Usb(%x,%x)", (UINTN) Usb->ParentPortNumber, (UINTN) Usb->InterfaceNumber); CatPrint (Str, L"Usb(%x,%x)", (UINTN) Usb->ParentPortNumber, (UINTN) Usb->InterfaceNumber);
} }
/**
Convert Device Path to a Unicode string for printing.
@param Str The buffer holding the output string.
This buffer contains the length of the
string and the maixmum length reserved
for the string buffer.
@param DevPath The device path.
**/
VOID VOID
DevPathUsbWWID ( DevPathUsbWWID (
IN OUT POOL_PRINT *Str, IN OUT POOL_PRINT *Str,
@ -625,6 +747,16 @@ DevPathUsbWWID (
); );
} }
/**
Convert Device Path to a Unicode string for printing.
@param Str The buffer holding the output string.
This buffer contains the length of the
string and the maixmum length reserved
for the string buffer.
@param DevPath The device path.
**/
VOID VOID
DevPathLogicalUnit ( DevPathLogicalUnit (
IN OUT POOL_PRINT *Str, IN OUT POOL_PRINT *Str,
@ -637,6 +769,16 @@ DevPathLogicalUnit (
CatPrint (Str, L"Unit(%x)", (UINTN) LogicalUnit->Lun); CatPrint (Str, L"Unit(%x)", (UINTN) LogicalUnit->Lun);
} }
/**
Convert Device Path to a Unicode string for printing.
@param Str The buffer holding the output string.
This buffer contains the length of the
string and the maixmum length reserved
for the string buffer.
@param DevPath The device path.
**/
VOID VOID
DevPathUsbClass ( DevPathUsbClass (
IN OUT POOL_PRINT *Str, IN OUT POOL_PRINT *Str,
@ -657,6 +799,16 @@ DevPathUsbClass (
); );
} }
/**
Convert Device Path to a Unicode string for printing.
@param Str The buffer holding the output string.
This buffer contains the length of the
string and the maixmum length reserved
for the string buffer.
@param DevPath The device path.
**/
VOID VOID
DevPathSata ( DevPathSata (
IN OUT POOL_PRINT *Str, IN OUT POOL_PRINT *Str,
@ -675,95 +827,145 @@ DevPathSata (
); );
} }
/**
Convert Device Path to a Unicode string for printing.
@param Str The buffer holding the output string.
This buffer contains the length of the
string and the maixmum length reserved
for the string buffer.
@param DevPath The device path.
**/
VOID VOID
DevPathI2O ( DevPathI2O (
IN OUT POOL_PRINT *Str, IN OUT POOL_PRINT *Str,
IN VOID *DevPath IN VOID *DevPath
) )
{ {
I2O_DEVICE_PATH *I2O; I2O_DEVICE_PATH *I2OPath;
I2O = DevPath; I2OPath = DevPath;
CatPrint (Str, L"I2O(%x)", (UINTN) I2O->Tid); CatPrint (Str, L"I2O(%x)", (UINTN) I2OPath->Tid);
} }
/**
Convert Device Path to a Unicode string for printing.
@param Str The buffer holding the output string.
This buffer contains the length of the
string and the maixmum length reserved
for the string buffer.
@param DevPath The device path.
**/
VOID VOID
DevPathMacAddr ( DevPathMacAddr (
IN OUT POOL_PRINT *Str, IN OUT POOL_PRINT *Str,
IN VOID *DevPath IN VOID *DevPath
) )
{ {
MAC_ADDR_DEVICE_PATH *MAC; MAC_ADDR_DEVICE_PATH *MACDevPath;
UINTN HwAddressSize; UINTN HwAddressSize;
UINTN Index; UINTN Index;
MAC = DevPath; MACDevPath = DevPath;
HwAddressSize = sizeof (EFI_MAC_ADDRESS); HwAddressSize = sizeof (EFI_MAC_ADDRESS);
if (MAC->IfType == 0x01 || MAC->IfType == 0x00) { if (MACDevPath->IfType == 0x01 || MACDevPath->IfType == 0x00) {
HwAddressSize = 6; HwAddressSize = 6;
} }
CatPrint (Str, L"Mac("); CatPrint (Str, L"Mac(");
for (Index = 0; Index < HwAddressSize; Index++) { for (Index = 0; Index < HwAddressSize; Index++) {
CatPrint (Str, L"%02x", (UINTN) MAC->MacAddress.Addr[Index]); CatPrint (Str, L"%02x", (UINTN) MACDevPath->MacAddress.Addr[Index]);
} }
CatPrint (Str, L")"); CatPrint (Str, L")");
} }
/**
Convert Device Path to a Unicode string for printing.
@param Str The buffer holding the output string.
This buffer contains the length of the
string and the maixmum length reserved
for the string buffer.
@param DevPath The device path.
**/
VOID VOID
DevPathIPv4 ( DevPathIPv4 (
IN OUT POOL_PRINT *Str, IN OUT POOL_PRINT *Str,
IN VOID *DevPath IN VOID *DevPath
) )
{ {
IPv4_DEVICE_PATH *IP; IPv4_DEVICE_PATH *IPDevPath;
IP = DevPath; IPDevPath = DevPath;
CatPrint ( CatPrint (
Str, Str,
L"IPv4(%d.%d.%d.%d:%d)", L"IPv4(%d.%d.%d.%d:%d)",
(UINTN) IP->RemoteIpAddress.Addr[0], (UINTN) IPDevPath->RemoteIpAddress.Addr[0],
(UINTN) IP->RemoteIpAddress.Addr[1], (UINTN) IPDevPath->RemoteIpAddress.Addr[1],
(UINTN) IP->RemoteIpAddress.Addr[2], (UINTN) IPDevPath->RemoteIpAddress.Addr[2],
(UINTN) IP->RemoteIpAddress.Addr[3], (UINTN) IPDevPath->RemoteIpAddress.Addr[3],
(UINTN) IP->RemotePort (UINTN) IPDevPath->RemotePort
); );
} }
/**
Convert Device Path to a Unicode string for printing.
@param Str The buffer holding the output string.
This buffer contains the length of the
string and the maixmum length reserved
for the string buffer.
@param DevPath The device path.
**/
VOID VOID
DevPathIPv6 ( DevPathIPv6 (
IN OUT POOL_PRINT *Str, IN OUT POOL_PRINT *Str,
IN VOID *DevPath IN VOID *DevPath
) )
{ {
IPv6_DEVICE_PATH *IP; IPv6_DEVICE_PATH *IPv6DevPath;
IP = DevPath; IPv6DevPath = DevPath;
CatPrint ( CatPrint (
Str, Str,
L"IPv6(%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x)", L"IPv6(%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x)",
(UINTN) IP->RemoteIpAddress.Addr[0], (UINTN) IPv6DevPath->RemoteIpAddress.Addr[0],
(UINTN) IP->RemoteIpAddress.Addr[1], (UINTN) IPv6DevPath->RemoteIpAddress.Addr[1],
(UINTN) IP->RemoteIpAddress.Addr[2], (UINTN) IPv6DevPath->RemoteIpAddress.Addr[2],
(UINTN) IP->RemoteIpAddress.Addr[3], (UINTN) IPv6DevPath->RemoteIpAddress.Addr[3],
(UINTN) IP->RemoteIpAddress.Addr[4], (UINTN) IPv6DevPath->RemoteIpAddress.Addr[4],
(UINTN) IP->RemoteIpAddress.Addr[5], (UINTN) IPv6DevPath->RemoteIpAddress.Addr[5],
(UINTN) IP->RemoteIpAddress.Addr[6], (UINTN) IPv6DevPath->RemoteIpAddress.Addr[6],
(UINTN) IP->RemoteIpAddress.Addr[7], (UINTN) IPv6DevPath->RemoteIpAddress.Addr[7],
(UINTN) IP->RemoteIpAddress.Addr[8], (UINTN) IPv6DevPath->RemoteIpAddress.Addr[8],
(UINTN) IP->RemoteIpAddress.Addr[9], (UINTN) IPv6DevPath->RemoteIpAddress.Addr[9],
(UINTN) IP->RemoteIpAddress.Addr[10], (UINTN) IPv6DevPath->RemoteIpAddress.Addr[10],
(UINTN) IP->RemoteIpAddress.Addr[11], (UINTN) IPv6DevPath->RemoteIpAddress.Addr[11],
(UINTN) IP->RemoteIpAddress.Addr[12], (UINTN) IPv6DevPath->RemoteIpAddress.Addr[12],
(UINTN) IP->RemoteIpAddress.Addr[13], (UINTN) IPv6DevPath->RemoteIpAddress.Addr[13],
(UINTN) IP->RemoteIpAddress.Addr[14], (UINTN) IPv6DevPath->RemoteIpAddress.Addr[14],
(UINTN) IP->RemoteIpAddress.Addr[15] (UINTN) IPv6DevPath->RemoteIpAddress.Addr[15]
); );
} }
/**
Convert Device Path to a Unicode string for printing.
@param Str The buffer holding the output string.
This buffer contains the length of the
string and the maixmum length reserved
for the string buffer.
@param DevPath The device path.
**/
VOID VOID
DevPathInfiniBand ( DevPathInfiniBand (
IN OUT POOL_PRINT *Str, IN OUT POOL_PRINT *Str,
@ -784,6 +986,16 @@ DevPathInfiniBand (
); );
} }
/**
Convert Device Path to a Unicode string for printing.
@param Str The buffer holding the output string.
This buffer contains the length of the
string and the maixmum length reserved
for the string buffer.
@param DevPath The device path.
**/
VOID VOID
DevPathUart ( DevPathUart (
IN OUT POOL_PRINT *Str, IN OUT POOL_PRINT *Str,
@ -859,42 +1071,62 @@ DevPathUart (
} }
} }
/**
Convert Device Path to a Unicode string for printing.
@param Str The buffer holding the output string.
This buffer contains the length of the
string and the maixmum length reserved
for the string buffer.
@param DevPath The device path.
**/
VOID VOID
DevPathiSCSI ( DevPathiSCSI (
IN OUT POOL_PRINT *Str, IN OUT POOL_PRINT *Str,
IN VOID *DevPath IN VOID *DevPath
) )
{ {
ISCSI_DEVICE_PATH_WITH_NAME *iSCSI; ISCSI_DEVICE_PATH_WITH_NAME *IScsi;
UINT16 Options; UINT16 Options;
ASSERT (Str != NULL); ASSERT (Str != NULL);
ASSERT (DevPath != NULL); ASSERT (DevPath != NULL);
iSCSI = DevPath; IScsi = DevPath;
CatPrint ( CatPrint (
Str, Str,
L"iSCSI(%s,%x,%lx,", L"iSCSI(%s,%x,%lx,",
iSCSI->iSCSITargetName, IScsi->iSCSITargetName,
iSCSI->TargetPortalGroupTag, IScsi->TargetPortalGroupTag,
iSCSI->Lun IScsi->Lun
); );
Options = iSCSI->LoginOption; Options = IScsi->LoginOption;
CatPrint (Str, L"%s,", ((Options >> 1) & 0x0001) ? L"CRC32C" : L"None"); CatPrint (Str, L"%s,", (((Options >> 1) & 0x0001) != 0) ? L"CRC32C" : L"None");
CatPrint (Str, L"%s,", ((Options >> 3) & 0x0001) ? L"CRC32C" : L"None"); CatPrint (Str, L"%s,", (((Options >> 3) & 0x0001) != 0) ? L"CRC32C" : L"None");
if ((Options >> 11) & 0x0001) { if (((Options >> 11) & 0x0001) != 0) {
CatPrint (Str, L"%s,", L"None"); CatPrint (Str, L"%s,", L"None");
} else if ((Options >> 12) & 0x0001) { } else if (((Options >> 12) & 0x0001) != 0) {
CatPrint (Str, L"%s,", L"CHAP_UNI"); CatPrint (Str, L"%s,", L"CHAP_UNI");
} else { } else {
CatPrint (Str, L"%s,", L"CHAP_BI"); CatPrint (Str, L"%s,", L"CHAP_BI");
} }
CatPrint (Str, L"%s)", (iSCSI->NetworkProtocol == 0) ? L"TCP" : L"reserved"); CatPrint (Str, L"%s)", (IScsi->NetworkProtocol == 0) ? L"TCP" : L"reserved");
} }
/**
Convert Device Path to a Unicode string for printing.
@param Str The buffer holding the output string.
This buffer contains the length of the
string and the maixmum length reserved
for the string buffer.
@param DevPath The device path.
**/
VOID VOID
DevPathHardDrive ( DevPathHardDrive (
IN OUT POOL_PRINT *Str, IN OUT POOL_PRINT *Str,
@ -935,6 +1167,16 @@ DevPathHardDrive (
} }
} }
/**
Convert Device Path to a Unicode string for printing.
@param Str The buffer holding the output string.
This buffer contains the length of the
string and the maixmum length reserved
for the string buffer.
@param DevPath The device path.
**/
VOID VOID
DevPathCDROM ( DevPathCDROM (
IN OUT POOL_PRINT *Str, IN OUT POOL_PRINT *Str,
@ -947,6 +1189,16 @@ DevPathCDROM (
CatPrint (Str, L"CDROM(Entry%x)", (UINTN) Cd->BootEntry); CatPrint (Str, L"CDROM(Entry%x)", (UINTN) Cd->BootEntry);
} }
/**
Convert Device Path to a Unicode string for printing.
@param Str The buffer holding the output string.
This buffer contains the length of the
string and the maixmum length reserved
for the string buffer.
@param DevPath The device path.
**/
VOID VOID
DevPathFilePath ( DevPathFilePath (
IN OUT POOL_PRINT *Str, IN OUT POOL_PRINT *Str,
@ -959,6 +1211,16 @@ DevPathFilePath (
CatPrint (Str, L"%s", Fp->PathName); CatPrint (Str, L"%s", Fp->PathName);
} }
/**
Convert Device Path to a Unicode string for printing.
@param Str The buffer holding the output string.
This buffer contains the length of the
string and the maixmum length reserved
for the string buffer.
@param DevPath The device path.
**/
VOID VOID
DevPathMediaProtocol ( DevPathMediaProtocol (
IN OUT POOL_PRINT *Str, IN OUT POOL_PRINT *Str,
@ -971,6 +1233,16 @@ DevPathMediaProtocol (
CatPrint (Str, L"Media(%g)", &MediaProt->Protocol); CatPrint (Str, L"Media(%g)", &MediaProt->Protocol);
} }
/**
Convert Device Path to a Unicode string for printing.
@param Str The buffer holding the output string.
This buffer contains the length of the
string and the maixmum length reserved
for the string buffer.
@param DevPath The device path.
**/
VOID VOID
DevPathFvFilePath ( DevPathFvFilePath (
IN OUT POOL_PRINT *Str, IN OUT POOL_PRINT *Str,
@ -983,6 +1255,16 @@ DevPathFvFilePath (
CatPrint (Str, L"%g", &FvFilePath->FvFileName); CatPrint (Str, L"%g", &FvFilePath->FvFileName);
} }
/**
Convert Device Path to a Unicode string for printing.
@param Str The buffer holding the output string.
This buffer contains the length of the
string and the maixmum length reserved
for the string buffer.
@param DevPath The device path.
**/
VOID VOID
DevPathBssBss ( DevPathBssBss (
IN OUT POOL_PRINT *Str, IN OUT POOL_PRINT *Str,
@ -1029,6 +1311,16 @@ DevPathBssBss (
CatPrint (Str, L"Legacy-%s", Type); CatPrint (Str, L"Legacy-%s", Type);
} }
/**
Convert Device Path to a Unicode string for printing.
@param Str The buffer holding the output string.
This buffer contains the length of the
string and the maixmum length reserved
for the string buffer.
@param DevPath The device path.
**/
VOID VOID
DevPathEndInstance ( DevPathEndInstance (
IN OUT POOL_PRINT *Str, IN OUT POOL_PRINT *Str,
@ -1038,6 +1330,16 @@ DevPathEndInstance (
CatPrint (Str, L","); CatPrint (Str, L",");
} }
/**
Convert Device Path to a Unicode string for printing.
@param Str The buffer holding the output string.
This buffer contains the length of the
string and the maixmum length reserved
for the string buffer.
@param DevPath The device path.
**/
VOID VOID
DevPathNodeUnknown ( DevPathNodeUnknown (
IN OUT POOL_PRINT *Str, IN OUT POOL_PRINT *Str,
@ -1289,12 +1591,12 @@ LibDuplicateDevicePathInstance (
// Make a copy // Make a copy
// //
NewDevPath = NULL; NewDevPath = NULL;
if (Size) { if (Size != 0) {
NewDevPath = AllocateZeroPool (Size); NewDevPath = AllocateZeroPool (Size);
ASSERT (NewDevPath != NULL); ASSERT (NewDevPath != NULL);
} }
if (NewDevPath) { if (NewDevPath != NULL) {
CopyMem (NewDevPath, DevicePathInst, Size); CopyMem (NewDevPath, DevicePathInst, Size);
} }

View File

@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/ **/
#ifndef _BM_MACHINE_H #ifndef _BM_MACHINE_H_
#define _BM_MACHINE_H #define _BM_MACHINE_H_
// //
// NOTE: This is not defined in UEFI spec. // NOTE: This is not defined in UEFI spec.

View File

@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/ **/
#ifndef _BM_MACHINE_H #ifndef _BM_MACHINE_H_
#define _BM_MACHINE_H #define _BM_MACHINE_H_
#define DEFAULT_REMOVABLE_FILE_NAME L"\\EFI\\BOOT\\BOOTIA32.EFI" #define DEFAULT_REMOVABLE_FILE_NAME L"\\EFI\\BOOT\\BOOTIA32.EFI"

View File

@ -85,6 +85,12 @@ typedef struct {
UINT32 Signiture; UINT32 Signiture;
} PERF_HEADER; } PERF_HEADER;
/**
Allocates a block of memory and writes performance data of booting into it.
OS can processing these record.
**/
VOID VOID
WriteBootToOsPerformanceData ( WriteBootToOsPerformanceData (
VOID VOID

View File

@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/ **/
#ifndef _BM_MACHINE_H #ifndef _BM_MACHINE_H_
#define _BM_MACHINE_H #define _BM_MACHINE_H_
#define DEFAULT_REMOVABLE_FILE_NAME L"\\EFI\\BOOT\\BOOTIA64.EFI" #define DEFAULT_REMOVABLE_FILE_NAME L"\\EFI\\BOOT\\BOOTIA64.EFI"

View File

@ -12,18 +12,17 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/ **/
//@MT:#include "Tiano.h"
//@MT:#include "EfiDriverLib.h"
//@MT:#include EFI_PROTOCOL_DEFINITION (LegacyBios)
#include "InternalBdsLib.h" #include "InternalBdsLib.h"
UINT8 mShadowRomFlag = 0; UINT8 mShadowRomFlag = 0;
/**
Shadow all opton ROM if the it is not done.
**/
VOID VOID
EFIAPI ShadowAllOptionRom(
ShadowAllOptionRom() VOID
)
{ {
EFI_STATUS Status; EFI_STATUS Status;
EFI_LEGACY_BIOS_PROTOCOL *LegacyBios; EFI_LEGACY_BIOS_PROTOCOL *LegacyBios;

View File

@ -19,21 +19,19 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
STATIC PERF_HEADER mPerfHeader; STATIC PERF_HEADER mPerfHeader;
STATIC PERF_DATA mPerfData; STATIC PERF_DATA mPerfData;
STATIC /**
Get the short verion of PDB file name to be
used in performance data logging.
@param PdbFileName The long PDB file name.
@param GaugeString The output string to be logged by performance logger.
**/
VOID VOID
GetShortPdbFileName ( GetShortPdbFileName (
CHAR8 *PdbFileName, IN CONST CHAR8 *PdbFileName,
CHAR8 *GaugeString OUT CHAR8 *GaugeString
) )
/*++
Routine Description:
Arguments:
Returns:
--*/
{ {
UINTN Index; UINTN Index;
UINTN Index1; UINTN Index1;
@ -72,7 +70,15 @@ Returns:
return ; return ;
} }
STATIC /**
Get the name from the Driver handle, which can be a handle with
EFI_LOADED_IMAGE_PROTOCOL or EFI_DRIVER_BINDING_PROTOCOL installed.
This name can be used in performance data logging.
@param Handle Driver handle.
@param GaugeString The output string to be logged by performance logger.
**/
VOID VOID
GetNameFromHandle ( GetNameFromHandle (
IN EFI_HANDLE Handle, IN EFI_HANDLE Handle,
@ -126,25 +132,16 @@ GetNameFromHandle (
return ; return ;
} }
/**
Allocates a block of memory and writes performance data of booting into it.
OS can processing these record.
**/
VOID VOID
WriteBootToOsPerformanceData ( WriteBootToOsPerformanceData (
VOID VOID
) )
/*++
Routine Description:
Allocates a block of memory and writes performance data of booting to OS into it.
Arguments:
None
Returns:
None
--*/
{ {
EFI_STATUS Status; EFI_STATUS Status;
EFI_PHYSICAL_ADDRESS AcpiLowMemoryBase; EFI_PHYSICAL_ADDRESS AcpiLowMemoryBase;

View File

@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/ **/
#ifndef _BM_MACHINE_H #ifndef _BM_MACHINE_H_
#define _BM_MACHINE_H #define _BM_MACHINE_H_
#define DEFAULT_REMOVABLE_FILE_NAME L"\\EFI\\BOOT\\BOOTX64.EFI" #define DEFAULT_REMOVABLE_FILE_NAME L"\\EFI\\BOOT\\BOOTX64.EFI"