\r
BOOLEAN mEnumBootDevice = FALSE;\r
\r
-//\r
-// This GUID is used for an EFI Variable that stores the front device pathes\r
-// for a partial device path that starts with the HD node.\r
-//\r
+///\r
+/// This GUID is used for an EFI Variable that stores the front device pathes\r
+/// for a partial device path that starts with the HD node.\r
+///\r
EFI_GUID mHdBootVariablePrivateGuid = { 0xfab7e9e1, 0x39dd, 0x4f2b, { 0x84, 0x8, 0xe2, 0xe, 0x90, 0x6c, 0xb6, 0xde } };\r
\r
\r
//\r
InitializeListHead (&TempBootLists);\r
BdsLibRegisterNewOption (&TempBootLists, DevicePath, L"EFI Internal Shell", L"BootOrder");\r
+ \r
//\r
// free the temporary device path created by BdsLibUpdateFvFileDevicePath()\r
//\r
- gBS->FreePool (DevicePath); \r
+ SafeFreePool (DevicePath); \r
DevicePath = Option->DevicePath;\r
}\r
\r
// Load the default boot file \EFI\BOOT\boot{machinename}.EFI from removable Media\r
// machinename is ia32, ia64, x64, ...\r
//\r
- FilePath = FileDevicePath (Handle, DEFAULT_REMOVABLE_FILE_NAME);\r
+ FilePath = FileDevicePath (Handle, (CONST CHAR16*)PcdGetPtr(PcdDefaultBootFileName));\r
if (FilePath != NULL) {\r
Status = gBS->LoadImage (\r
TRUE,\r
&mHdBootVariablePrivateGuid,\r
&CachedDevicePathSize\r
);\r
+ \r
if (CachedDevicePath != NULL) {\r
TempNewDevicePath = CachedDevicePath;\r
DeviceExist = FALSE;\r
// Find the matched device path.\r
// Append the file path infomration from the boot option and return the fully expanded device path.\r
//\r
- DevicePath = NextDevicePathNode ((EFI_DEVICE_PATH_PROTOCOL *) HardDriveDevicePath);\r
+ DevicePath = NextDevicePathNode ((EFI_DEVICE_PATH_PROTOCOL *) HardDriveDevicePath);\r
FullDevicePath = AppendDevicePath (Instance, DevicePath);\r
\r
//\r
// First delete the matched instance.\r
//\r
TempNewDevicePath = CachedDevicePath;\r
- CachedDevicePath = BdsLibDelPartMatchInstance ( CachedDevicePath, Instance );\r
+ CachedDevicePath = BdsLibDelPartMatchInstance (CachedDevicePath, Instance );\r
SafeFreePool (TempNewDevicePath);\r
+ \r
//\r
// Second, append the remaining parth after the matched instance\r
//\r
TempNewDevicePath = CachedDevicePath;\r
- CachedDevicePath = AppendDevicePathInstance ( Instance, CachedDevicePath );\r
+ CachedDevicePath = AppendDevicePathInstance (Instance, CachedDevicePath );\r
SafeFreePool (TempNewDevicePath);\r
//\r
// Save the matching Device Path so we don't need to do a connect all next time\r
CachedDevicePath\r
);\r
}\r
- SafeFreePool(Instance);\r
- gBS->FreePool (CachedDevicePath);\r
+ \r
+ SafeFreePool (Instance);\r
+ SafeFreePool (CachedDevicePath);\r
return FullDevicePath;\r
}\r
}\r
break;\r
}\r
}\r
- gBS->FreePool (CachedDevicePath);\r
- gBS->FreePool (BlockIoBuffer);\r
+ \r
+ SafeFreePool (CachedDevicePath);\r
+ SafeFreePool (BlockIoBuffer);\r
return FullDevicePath;\r
}\r
\r
-\r
/**\r
Check whether there is a instance in BlockIoDevicePath, which contain multi device path\r
instances, has the same partition node with HardDriveDevicePath device path\r
device path.\r
\r
@retval TRUE There is a matched device path instance FALSE\r
- -There is no matched device path instance\r
+ @retval FALSE There is no matched device path instance\r
\r
**/\r
BOOLEAN\r
if ((BlockIoDevicePath == NULL) || (HardDriveDevicePath == NULL)) {\r
return FALSE;\r
}\r
+ \r
//\r
// Make PreviousDevicePath == the device path node before the end node\r
//\r
- DevicePath = BlockIoDevicePath;\r
+ DevicePath = BlockIoDevicePath;\r
BlockIoHdDevicePathNode = NULL;\r
\r
//\r
TmpHdPath = (HARDDRIVE_DEVICE_PATH *) BlockIoHdDevicePathNode;\r
TempPath = (HARDDRIVE_DEVICE_PATH *) BdsLibUnpackDevicePath ((EFI_DEVICE_PATH_PROTOCOL *) HardDriveDevicePath);\r
Match = FALSE;\r
+ \r
//\r
// Check for the match\r
//\r
return Match;\r
}\r
\r
-\r
/**\r
Delete the boot option associated with the handle passed in.\r
\r
BootOrder = NULL;\r
BootOrderSize = 0;\r
\r
+ //\r
+ // Check "BootOrder" variable, if no, means there is no any boot order.\r
+ //\r
BootOrder = BdsLibGetVariableAndSize (\r
L"BootOrder",\r
&gEfiGlobalVariableGuid,\r
&BootOrderSize\r
);\r
- if (NULL == BootOrder) {\r
+ if (BootOrder == NULL) {\r
return EFI_NOT_FOUND;\r
}\r
\r
+ //\r
+ // Convert device handle to device path protocol instance\r
+ //\r
DevicePath = DevicePathFromHandle (Handle);\r
if (DevicePath == NULL) {\r
return EFI_NOT_FOUND;\r
}\r
DevicePathSize = GetDevicePathSize (DevicePath);\r
\r
+ //\r
+ // Loop all boot order variable and find the matching device path\r
+ //\r
Index = 0;\r
while (Index < BootOrderSize / sizeof (UINT16)) {\r
UnicodeSPrint (BootOption, sizeof (BootOption), L"Boot%04x", BootOrder[Index]);\r
&gEfiGlobalVariableGuid,\r
&BootOptionSize\r
);\r
- if (NULL == BootOptionVar) {\r
- gBS->FreePool (BootOrder);\r
+ \r
+ if (BootOptionVar == NULL) {\r
+ SafeFreePool (BootOrder);\r
return EFI_OUT_OF_RESOURCES;\r
}\r
\r
if ((OptionDevicePathSize == DevicePathSize) &&\r
(CompareMem (DevicePath, OptionDevicePath, DevicePathSize) == 0)) {\r
BdsDeleteBootOption (BootOrder[Index], BootOrder, &BootOrderSize);\r
- gBS->FreePool (BootOptionVar);\r
+ SafeFreePool (BootOptionVar);\r
break;\r
}\r
\r
- gBS->FreePool (BootOptionVar);\r
+ SafeFreePool (BootOptionVar);\r
Index++;\r
}\r
\r
+ //\r
+ // Adjust number of boot option for "BootOrder" variable.\r
+ //\r
Status = gRT->SetVariable (\r
L"BootOrder",\r
&gEfiGlobalVariableGuid,\r
BootOrder\r
);\r
\r
- gBS->FreePool (BootOrder);\r
+ SafeFreePool (BootOrder);\r
\r
return Status;\r
}\r
Delete all invalid EFI boot options. The probable invalid boot option could\r
be Removable media or Network boot device.\r
\r
- VOID\r
-\r
@retval EFI_SUCCESS Delete all invalid boot option success\r
@retval EFI_NOT_FOUND Variable "BootOrder" is not found\r
@retval EFI_OUT_OF_RESOURCES Lack of memory resource\r
BootOrder = NULL;\r
BootOrderSize = 0;\r
\r
+ //\r
+ // Check "BootOrder" variable firstly, this variable hold the number of boot options\r
+ //\r
BootOrder = BdsLibGetVariableAndSize (\r
L"BootOrder",\r
&gEfiGlobalVariableGuid,\r
&BootOptionSize\r
);\r
if (NULL == BootOptionVar) {\r
- gBS->FreePool (BootOrder);\r
+ SafeFreePool (BootOrder);\r
return EFI_OUT_OF_RESOURCES;\r
}\r
\r
//\r
if ((DevicePathType (OptionDevicePath) == BBS_DEVICE_PATH) &&\r
(DevicePathSubType (OptionDevicePath) == BBS_BBS_DP)) {\r
- gBS->FreePool (BootOptionVar);\r
+ SafeFreePool (BootOptionVar);\r
Index++;\r
continue;\r
}\r
BootOrder[Index] = 0xffff;\r
}\r
\r
- gBS->FreePool (BootOptionVar);\r
+ SafeFreePool (BootOptionVar);\r
Index++;\r
}\r
\r
BootOrder\r
);\r
\r
- gBS->FreePool (BootOrder);\r
+ SafeFreePool (BootOrder);\r
\r
return Status;\r
}\r
EFI_IMAGE_OPTIONAL_HEADER_UNION HdrData;\r
EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr;\r
\r
- FloppyNumber = 0;\r
- CdromNumber = 0;\r
- UsbNumber = 0;\r
- MiscNumber = 0;\r
+ FloppyNumber = 0;\r
+ CdromNumber = 0;\r
+ UsbNumber = 0;\r
+ MiscNumber = 0;\r
ZeroMem (Buffer, sizeof (Buffer));\r
+ \r
//\r
// If the boot device enumerate happened, just get the boot\r
// device from the boot order variable\r
BdsLibBuildOptionFromVar (BdsBootOptionList, L"BootOrder");\r
return EFI_SUCCESS;\r
}\r
+ \r
//\r
// Notes: this dirty code is to get the legacy boot option from the\r
// BBS table and create to variable as the EFI boot option, it should\r
// Delete invalid boot option\r
//\r
BdsDeleteAllInvalidEfiBootOption ();\r
+ \r
//\r
// Parse removable media\r
//\r
&NumberBlockIoHandles,\r
&BlockIoHandles\r
);\r
+ \r
for (Index = 0; Index < NumberBlockIoHandles; Index++) {\r
Status = gBS->HandleProtocol (\r
BlockIoHandles[Index],\r
}\r
\r
if (NumberBlockIoHandles != 0) {\r
- gBS->FreePool (BlockIoHandles);\r
+ SafeFreePool (BlockIoHandles);\r
}\r
\r
//\r
NeedDelete = TRUE;\r
Status = BdsLibGetImageHeader (\r
FileSystemHandles[Index],\r
- DEFAULT_REMOVABLE_FILE_NAME,\r
+ (CHAR16*)PcdGetPtr (PcdDefaultBootFileName),\r
&DosHeader,\r
Hdr\r
);\r
}\r
\r
if (NumberFileSystemHandles != 0) {\r
- gBS->FreePool (FileSystemHandles);\r
+ SafeFreePool (FileSystemHandles);\r
}\r
\r
//\r
}\r
\r
if (NumberSimpleNetworkHandles != 0) {\r
- gBS->FreePool (SimpleNetworkHandles);\r
+ SafeFreePool (SimpleNetworkHandles);\r
}\r
\r
//\r
}\r
\r
if (FvHandleCount != 0) {\r
- gBS->FreePool (FvHandleBuffer);\r
+ SafeFreePool (FvHandleBuffer);\r
}\r
//\r
// Make sure every boot only have one time\r
return EFI_SUCCESS;\r
}\r
\r
-\r
/**\r
Build the boot option with the handle parsed in.\r
\r
// Build the shell device path\r
//\r
EfiInitializeFwVolDevicepathNode (&ShellNode, &gEfiShellFileGuid);\r
- //\r
- //ShellNode.Header.Type = MEDIA_DEVICE_PATH;\r
- //ShellNode.Header.SubType = MEDIA_FV_FILEPATH_DP;\r
- //SetDevicePathNodeLength (&ShellNode.Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH));\r
- //CopyMem (&ShellNode.NameGuid, &gEfiShellFileGuid, sizeof (EFI_GUID));\r
- //\r
+\r
DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *) &ShellNode);\r
\r
//\r
\r
}\r
\r
-\r
/**\r
Boot from the EFI1.1 spec defined "BootNext" variable\r
\r
\r
}\r
\r
-\r
-\r
/**\r
Return the bootable media handle.\r
First, check the device is connected\r
EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr;\r
\r
UpdatedDevicePath = DevicePath;\r
+ \r
//\r
// Check whether the device is connected\r
//\r
// Fail to find the proper BlockIo and simple file protocol, maybe because device not present, we need to connect it firstly\r
//\r
UpdatedDevicePath = DevicePath;\r
- Status = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &UpdatedDevicePath, &Handle);\r
+ Status = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &UpdatedDevicePath, &Handle);\r
gBS->ConnectController (Handle, NULL, NULL, TRUE);\r
}\r
} else {\r
BlockIo->Media->BlockSize,\r
Buffer\r
);\r
- gBS->FreePool (Buffer);\r
+ SafeFreePool(Buffer);\r
}\r
}\r
\r
Hdr.Union = &HdrData;\r
Status = BdsLibGetImageHeader (\r
SimpleFileSystemHandles[Index],\r
- DEFAULT_REMOVABLE_FILE_NAME,\r
+ (CHAR16*)PcdGetPtr(PcdDefaultBootFileName),\r
&DosHeader,\r
Hdr\r
);\r
}\r
}\r
\r
- if (DupDevicePath != NULL) {\r
- SafeFreePool(DupDevicePath);\r
- }\r
- if (SimpleFileSystemHandles !=NULL ) {\r
- gBS->FreePool (SimpleFileSystemHandles);\r
- }\r
+ SafeFreePool(DupDevicePath);\r
+\r
+ SafeFreePool(SimpleFileSystemHandles);\r
\r
return ReturnHandle;\r
}\r
\r
-\r
-\r
-\r
/**\r
Check to see if the network cable is plugged in. If the DevicePath is not\r
connected it will be connected.\r
return MediaPresent;\r
}\r
\r
-\r
-\r
/**\r
For a bootable Device path, return its boot type.\r
\r
return BDS_EFI_UNSUPPORT;\r
}\r
\r
-\r
/**\r
Check whether the Device path in a boot option point to a valide bootable device,\r
And if CheckMedia is true, check the device is ready to boot now.\r
\r
- @param DevPath -- the Device path in a boot option\r
- @param CheckMedia -- if true, check the device is ready to boot now.\r
+ @param DevPath the Device path in a boot option\r
+ @param CheckMedia if true, check the device is ready to boot now.\r
\r
- @return TRUE -- the Device path is valide\r
- @return FALSE -- the Device path is invalide .\r
+ @retval TRUE the Device path is valide\r
+ @retval FALSE the Device path is invalide .\r
\r
**/\r
BOOLEAN\r
\r
TempDevicePath = DevPath;\r
LastDeviceNode = DevPath;\r
+ \r
//\r
// Check if it's a valid boot option for network boot device\r
// Only check if there is SimpleNetworkProtocol installed. If yes, that means\r
&Handle\r
);\r
}\r
+ \r
if (!EFI_ERROR (Status)) {\r
if (CheckMedia) {\r
//\r
return TRUE;\r
} else {\r
if (Status == EFI_SUCCESS) {\r
- gBS->FreePool (TempDevicePath); \r
+ SafeFreePool (TempDevicePath); \r
}\r
return FALSE;\r
}\r
Status = gBS->LocateDevicePath (&gEfiBlockIoProtocolGuid, &TempDevicePath, &Handle);\r
}\r
}\r
+ \r
if (!EFI_ERROR (Status)) {\r
Status = gBS->HandleProtocol (Handle, &gEfiBlockIoProtocolGuid, (VOID **)&BlockIo);\r
if (!EFI_ERROR (Status)) {\r
EFIAPI\r
BdsLibUpdateFvFileDevicePath (\r
IN OUT EFI_DEVICE_PATH_PROTOCOL ** DevicePath,\r
- IN EFI_GUID *FileGuid\r
+ IN EFI_GUID *FileGuid\r
)\r
{\r
EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;\r
if (FileGuid == NULL) {\r
return EFI_INVALID_PARAMETER;\r
}\r
+ \r
//\r
// Check whether the device path point to the default the input Fv file\r
//\r
FoundFvHandle = FvHandleBuffer[Index];\r
break;\r
}\r
- if (FvHandleBuffer !=NULL ) {\r
- FreePool (FvHandleBuffer); \r
- }\r
+ \r
+ SafeFreePool (FvHandleBuffer); \r
}\r
\r
if (FindFvFile) {\r
have. After this we should get all the device work and console avariable\r
if the system have console device.\r
\r
- None\r
-\r
- @return None\r
-\r
**/\r
VOID\r
BdsLibGenericConnectAll (\r
} while (DevicePath != NULL);\r
\r
if (CopyOfDevicePath != NULL) {\r
- gBS->FreePool (CopyOfDevicePath);\r
+ SafeFreePool (CopyOfDevicePath);\r
}\r
//\r
// All handle with DevicePath exists in the handle database\r
Status = gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);\r
}\r
\r
- gBS->FreePool (HandleBuffer);\r
+ SafeFreePool (HandleBuffer);\r
\r
return EFI_SUCCESS;\r
}\r
Status = gBS->DisconnectController (HandleBuffer[Index], NULL, NULL);\r
}\r
\r
- gBS->FreePool (HandleBuffer);\r
+ SafeFreePool (HandleBuffer);\r
\r
return EFI_SUCCESS;\r
}\r
Ptr++;\r
}\r
\r
- if ((*(Ptr-3) == 'D') && (*(Ptr-2) == 'e') && (*(Ptr-1) == 'v')) {\r
+ if ((*(Ptr - 3) == 'D') && (*(Ptr - 2) == 'e') && (*(Ptr - 1) == 'v')) {\r
return FALSE;\r
} else {\r
return TRUE;\r
SafeFreePool(Instance);\r
} while (CopyOfDevicePath != NULL);\r
\r
- gBS->FreePool (StartDevicePath);\r
+ SafeFreePool (StartDevicePath);\r
\r
if (!DeviceExist) {\r
return EFI_NOT_FOUND;\r
\r
}\r
\r
-\r
/**\r
This function will connect console device base on the console\r
device variable ConIn, ConOut and ErrOut.\r
#define MAX_STRING_LEN 200\r
\r
BOOLEAN mFeaturerSwitch = TRUE;\r
-BOOLEAN mResetRequired = FALSE;\r
+BOOLEAN mResetRequired = FALSE;\r
\r
extern UINT16 gPlatformBootTimeOutDefault;\r
\r
return Timeout;\r
}\r
\r
-\r
/**\r
The function will go through the driver optoin link list, load and start\r
every driver the driver optoin device path point to.\r
//\r
for (Link = BdsDriverLists->ForwardLink; Link != BdsDriverLists; Link = Link->ForwardLink) {\r
Option = CR (Link, BDS_COMMON_OPTION, Link, BDS_LOAD_OPTION_SIGNATURE);\r
+ \r
//\r
// If a load option is not marked as LOAD_OPTION_ACTIVE,\r
// the boot manager will not automatically load the option.\r
if (!IS_LOAD_OPTION_TYPE (Option->Attribute, LOAD_OPTION_ACTIVE)) {\r
continue;\r
}\r
+ \r
//\r
// If a driver load option is marked as LOAD_OPTION_FORCE_RECONNECT,\r
// then all of the EFI drivers in the system will be disconnected and\r
if (IS_LOAD_OPTION_TYPE (Option->Attribute, LOAD_OPTION_FORCE_RECONNECT)) {\r
ReconnectAll = TRUE;\r
}\r
+ \r
//\r
// Make sure the driver path is connected.\r
//\r
gBS->SetWatchdogTimer (0x0000, 0x0000, 0x0000, NULL);\r
}\r
}\r
+ \r
//\r
// Process the LOAD_OPTION_FORCE_RECONNECT driver option\r
//\r
\r
}\r
\r
-\r
/**\r
Get the Option Number that does not used.\r
Try to locate the specific option variable one by one untile find a free number.\r
IN CHAR16 *VariableName\r
)\r
{\r
- UINT16 Number;\r
UINTN Index;\r
CHAR16 StrTemp[10];\r
UINT16 *OptionBuffer;\r
// try if the option number is used\r
//\r
OptionBuffer = BdsLibGetVariableAndSize (\r
- StrTemp,\r
- &gEfiGlobalVariableGuid,\r
- &OptionSize\r
- );\r
+ StrTemp,\r
+ &gEfiGlobalVariableGuid,\r
+ &OptionSize\r
+ );\r
if (OptionBuffer == NULL) {\r
break;\r
}\r
- Index++;\r
- } while (1);\r
+ Index ++;\r
+ } while (TRUE);\r
\r
- Number = (UINT16) Index;\r
- return Number;\r
+ return ((UINT16) Index);\r
}\r
\r
\r
Description = NULL;\r
OptionOrderPtr = NULL;\r
UpdateDescription = FALSE;\r
+ Status = EFI_SUCCESS;\r
ZeroMem (OptionName, sizeof (OptionName));\r
\r
TempOptionSize = 0;\r
if (OptionPtr == NULL) {\r
continue;\r
}\r
- TempPtr = OptionPtr;\r
- TempPtr += sizeof (UINT32) + sizeof (UINT16);\r
- Description = (CHAR16 *) TempPtr;\r
- TempPtr += StrSize ((CHAR16 *) TempPtr);\r
- OptionDevicePath = (EFI_DEVICE_PATH_PROTOCOL *) TempPtr;\r
+ TempPtr = OptionPtr;\r
+ TempPtr += sizeof (UINT32) + sizeof (UINT16);\r
+ Description = (CHAR16 *) TempPtr;\r
+ TempPtr += StrSize ((CHAR16 *) TempPtr);\r
+ OptionDevicePath = (EFI_DEVICE_PATH_PROTOCOL *) TempPtr;\r
\r
//\r
// Notes: the description may will change base on the GetStringToken\r
//\r
// Got the option, so just return\r
//\r
- gBS->FreePool (OptionPtr);\r
- gBS->FreePool (TempOptionPtr);\r
+ SafeFreePool (OptionPtr);\r
+ SafeFreePool (TempOptionPtr);\r
return EFI_SUCCESS;\r
} else {\r
//\r
// Option description changed, need update.\r
//\r
UpdateDescription = TRUE;\r
- gBS->FreePool (OptionPtr);\r
+ SafeFreePool (OptionPtr);\r
break;\r
}\r
}\r
\r
- gBS->FreePool (OptionPtr);\r
+ SafeFreePool (OptionPtr);\r
}\r
\r
OptionSize = sizeof (UINT32) + sizeof (UINT16) + StrSize (String);\r
- OptionSize += GetDevicePathSize (DevicePath);\r
+ OptionSize += GetDevicePathSize (DevicePath);\r
OptionPtr = AllocateZeroPool (OptionSize);\r
TempPtr = OptionPtr;\r
*(UINT32 *) TempPtr = LOAD_OPTION_ACTIVE;\r
- TempPtr += sizeof (UINT32);\r
+ TempPtr += sizeof (UINT32);\r
*(UINT16 *) TempPtr = (UINT16) GetDevicePathSize (DevicePath);\r
- TempPtr += sizeof (UINT16);\r
+ TempPtr += sizeof (UINT16);\r
CopyMem (TempPtr, String, StrSize (String));\r
- TempPtr += StrSize (String);\r
+ TempPtr += StrSize (String);\r
CopyMem (TempPtr, DevicePath, GetDevicePathSize (DevicePath));\r
\r
if (UpdateDescription) {\r
// Return if only need to update a changed description or fail to set option.\r
//\r
if (EFI_ERROR (Status) || UpdateDescription) {\r
- gBS->FreePool (OptionPtr);\r
- gBS->FreePool (TempOptionPtr);\r
+ SafeFreePool (OptionPtr);\r
+ SafeFreePool (TempOptionPtr);\r
return Status;\r
}\r
\r
- gBS->FreePool (OptionPtr);\r
+ SafeFreePool (OptionPtr);\r
\r
//\r
// Update the option order variable\r
sizeof (UINT16),\r
&BootOrderEntry\r
);\r
- if (EFI_ERROR (Status)) {\r
- gBS->FreePool (TempOptionPtr);\r
- return Status;\r
- }\r
- return EFI_SUCCESS;\r
+ SafeFreePool (TempOptionPtr);\r
+ return Status;\r
}\r
\r
//\r
OrderItemNum * sizeof (UINT16),\r
OptionOrderPtr\r
);\r
- if (EFI_ERROR (Status)) {\r
- gBS->FreePool (TempOptionPtr);\r
- gBS->FreePool (OptionOrderPtr);\r
- return Status;\r
- }\r
+ SafeFreePool (TempOptionPtr);\r
+ SafeFreePool (OptionOrderPtr);\r
\r
- gBS->FreePool (TempOptionPtr);\r
- gBS->FreePool (OptionOrderPtr);\r
-\r
- return EFI_SUCCESS;\r
+ return Status;\r
}\r
\r
\r
//\r
// Get the option attribute\r
//\r
- TempPtr = Variable;\r
- Attribute = *(UINT32 *) Variable;\r
- TempPtr += sizeof (UINT32);\r
+ TempPtr = Variable;\r
+ Attribute = *(UINT32 *) Variable;\r
+ TempPtr += sizeof (UINT32);\r
\r
//\r
// Get the option's device path size\r
//\r
- FilePathSize = *(UINT16 *) TempPtr;\r
- TempPtr += sizeof (UINT16);\r
+ FilePathSize = *(UINT16 *) TempPtr;\r
+ TempPtr += sizeof (UINT16);\r
\r
//\r
// Get the option's description string\r
//\r
// Get the option's description string size\r
//\r
- TempPtr += StrSize ((CHAR16 *) TempPtr);\r
+ TempPtr += StrSize ((CHAR16 *) TempPtr);\r
\r
//\r
// Get the option's device path\r
//\r
- DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) TempPtr;\r
- TempPtr += FilePathSize;\r
+ DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) TempPtr;\r
+ TempPtr += FilePathSize;\r
\r
LoadOptions = TempPtr;\r
LoadOptionsSize = (UINT32) (VariableSize - (UINTN) (TempPtr - Variable));\r
//\r
if ((Option->Attribute & LOAD_OPTION_ACTIVE) == LOAD_OPTION_ACTIVE) {\r
InsertTailList (BdsCommonOptionList, &Option->Link);\r
- gBS->FreePool (Variable);\r
+ SafeFreePool (Variable);\r
return Option;\r
}\r
\r
- gBS->FreePool (Variable);\r
- gBS->FreePool (Option);\r
+ SafeFreePool (Variable);\r
+ SafeFreePool (Option);\r
return NULL;\r
\r
}\r
\r
-\r
/**\r
Process BootOrder, or DriverOrder variables, by calling\r
BdsLibVariableToOption () for each UINT16 in the variables.\r
\r
}\r
\r
- gBS->FreePool (OptionOrder);\r
+ SafeFreePool (OptionOrder);\r
\r
return EFI_SUCCESS;\r
}\r
\r
-\r
/**\r
Get boot mode by looking up configuration table and parsing HOB list\r
\r
return EFI_SUCCESS;\r
}\r
\r
-\r
/**\r
Read the EFI variable (VendorGuid/Name) and return a dynamically allocated\r
buffer, and the size of the buffer. If failure return NULL.\r
return Buffer;\r
}\r
\r
-\r
/**\r
Delete the instance in Multi which matches partly with Single instance\r
\r
return NewDevicePath;\r
}\r
\r
-\r
/**\r
Function compares a device path data structure to that of all the nodes of a\r
second device path instance.\r
// return success\r
//\r
if (CompareMem (Single, DevicePathInst, Size) == 0) {\r
- gBS->FreePool (DevicePathInst);\r
+ SafeFreePool (DevicePathInst);\r
return TRUE;\r
}\r
\r
- gBS->FreePool (DevicePathInst);\r
+ SafeFreePool (DevicePathInst);\r
DevicePathInst = GetNextDevicePathInstance (&DevicePath, &Size);\r
}\r
\r
return FALSE;\r
}\r
\r
-\r
/**\r
This function prints a series of strings.\r
\r
IfrLibCreatePopUp (2, &Key, StringBuffer1, StringBuffer2);\r
} while ((Key.ScanCode != SCAN_ESC) && (Key.UnicodeChar != CHAR_CARRIAGE_RETURN));\r
\r
- gBS->FreePool (StringBuffer1);\r
- gBS->FreePool (StringBuffer2);\r
+ SafeFreePool (StringBuffer1);\r
+ SafeFreePool (StringBuffer2);\r
//\r
// If the user hits the YES Response key, reset\r
//\r
}\r
}\r
\r
-\r
/**\r
Get the headers (dos, image, optional header) from an image.\r
\r
if (Status != EFI_BUFFER_TOO_SMALL) {\r
goto Done;\r
}\r
- gBS->FreePool (Info);\r
+ SafeFreePool (Info);\r
} while (TRUE);\r
\r
FileSize = Info->FileSize;\r
- gBS->FreePool (Info);\r
+ SafeFreePool (Info);\r
\r
//\r
// Read dos header\r
@param Event The event that triggered this notification function.\r
@param Context Pointer to the notification functions context.\r
\r
- EDES_TODO: Incomplete Descriptions None.\r
-\r
**/\r
VOID\r
EFIAPI\r
return;\r
}\r
\r
-\r
/**\r
This routine register a function to adjust the different type memory page number just before booting\r
and save the updated info into the variable for next boot to use.\r
\r
#include "InternalBdsLib.h"\r
\r
-\r
-EFI_GUID mEfiDevicePathMessagingUartFlowControlGuid = DEVICE_PATH_MESSAGING_UART_FLOW_CONTROL;\r
-\r
-EFI_GUID mEfiDevicePathMessagingSASGuid = DEVICE_PATH_MESSAGING_SAS;\r
-\r
-\r
/**\r
\r
Adjusts the size of a previously allocated buffer.\r
\r
-\r
@param OldPool A pointer to the buffer whose size is being adjusted.\r
@param OldSize The size of the current buffer.\r
@param NewSize The size of the new buffer.\r
CopyMem (NewPool, OldPool, OldSize < NewSize ? OldSize : NewSize);\r
}\r
\r
- gBS->FreePool (OldPool);\r
+ SafeFreePool (OldPool);\r
}\r
\r
return NewPool;\r
}\r
\r
-\r
/**\r
Concatenates a formatted unicode string to allocated pool.\r
The caller must free the resulting buffer.\r
Str->len = StringSize - sizeof (UINT16);\r
}\r
\r
- gBS->FreePool (AppendStr);\r
+ SafeFreePool (AppendStr);\r
return Str->str;\r
}\r
\r
switch (DevicePathType (&Vendor->Header)) {\r
case HARDWARE_DEVICE_PATH:\r
Type = L"Hw";\r
-// bugbug: nt 32 specific definition\r
-#if 0\r
- //\r
- // If the device is a winntbus device, we will give it a readable device name.\r
- //\r
- if (CompareGuid (&Vendor->Guid, &mEfiWinNtThunkProtocolGuid)) {\r
- CatPrint (Str, L"%s", L"WinNtBus");\r
- return ;\r
- } else if (CompareGuid (&Vendor->Guid, &mEfiWinNtGopGuid)) {\r
- CatPrint (Str, L"%s", L"GOP");\r
- return ;\r
- } else if (CompareGuid (&Vendor->Guid, &mEfiWinNtSerialPortGuid)) {\r
- CatPrint (Str, L"%s", L"Serial");\r
- return ;\r
- }\r
-#endif\r
break;\r
\r
case MESSAGING_DEVICE_PATH:\r
} else if (CompareGuid (&Vendor->Guid, &gEfiVTUTF8Guid)) {\r
CatPrint (Str, L"VenUft8()");\r
return ;\r
- } else if (CompareGuid (&Vendor->Guid, &mEfiDevicePathMessagingUartFlowControlGuid)) {\r
+ } else if (CompareGuid (&Vendor->Guid, &gEfiUartDevicePathGuid )) {\r
FlowControlMap = (((UART_FLOW_CONTROL_DEVICE_PATH *) Vendor)->FlowControlMap);\r
switch (FlowControlMap & 0x00000003) {\r
case 0:\r
\r
return ;\r
\r
- } else if (CompareGuid (&Vendor->Guid, &mEfiDevicePathMessagingSASGuid)) {\r
+ } else if (CompareGuid (&Vendor->Guid, &gEfiSasDevicePathGuid)) {\r
CatPrint (\r
Str,\r
L"SAS(%lx,%lx,%x,",\r
CatPrint (Str, L")");\r
}\r
\r
-\r
/**\r
Convert Device Path to a Unicode string for printing.\r
\r
)\r
{\r
ACPI_EXTENDED_HID_DEVICE_PATH *ExtendedAcpi;\r
+ \r
//\r
// Index for HID, UID and CID strings, 0 for non-exist\r
//\r
//\r
// Shrink pool used for string allocation\r
//\r
- gBS->FreePool (DevPath);\r
+ SafeFreePool (DevPath);\r
\r
Done:\r
NewSize = (Str.len + 1) * sizeof (CHAR16);\r
return Str.str;\r
}\r
\r
-\r
/**\r
Function creates a device path data structure that identically matches the\r
device path passed in.\r
+++ /dev/null
-/** @file\r
- Boot Manager Machine type\r
-\r
-Copyright (c) 2007 - 2008, Intel Corporation. <BR>\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#ifndef _BM_MACHINE_H_\r
-#define _BM_MACHINE_H_\r
-\r
-//\r
-// NOTE: This is not defined in UEFI spec.\r
-//\r
-#define DEFAULT_REMOVABLE_FILE_NAME L"\\EFI\\BOOT\\BOOTEBC.EFI"\r
-\r
-#endif\r
BdsBoot.c\r
InternalBdsLib.h\r
\r
-[Sources.Ia32]\r
- Ia32/BmMachine.h\r
-\r
-[Sources.X64]\r
- x64/BmMachine.h\r
-\r
[Sources.IPF]\r
Ipf/ShadowRom.c\r
- Ipf/BmMachine.h\r
-\r
-[Sources.EBC]\r
- Ebc/BmMachine.h\r
-\r
\r
[Packages]\r
MdePkg/MdePkg.dec\r
gEfiFileInfoGuid # ALWAYS_CONSUMED\r
gEfiPcAnsiGuid # ALWAYS_CONSUMED\r
gEfiGenericPlatformVariableGuid # ALWAYS_CONSUMED\r
-\r
-\r
+ gEfiUartDevicePathGuid # ALWAYS_CONSUMED\r
+ gEfiSasDevicePathGuid # ALWAYS_CONSUMED\r
+ \r
[Protocols]\r
gEfiSimpleFileSystemProtocolGuid # PROTOCOL ALWAYS_CONSUMED\r
gEfiSimpleTextOutProtocolGuid # PROTOCOL ALWAYS_CONSUMED\r
\r
[Pcd]\r
gEfiMdeModulePkgTokenSpaceGuid.PcdPlatformBootTimeOutDefault\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdDefaultBootFileName
\ No newline at end of file
+++ /dev/null
-/** @file\r
- Boot Manager Machine type\r
-\r
-Copyright (c) 2004 - 2008, Intel Corporation. <BR>\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#ifndef _BM_MACHINE_H_\r
-#define _BM_MACHINE_H_\r
-\r
-#define DEFAULT_REMOVABLE_FILE_NAME L"\\EFI\\BOOT\\BOOTIA32.EFI"\r
-\r
-#endif\r
#include <Library/GenericBdsLib.h>\r
#include <Library/TimerLib.h>\r
\r
-#include "BmMachine.h"\r
-\r
#define PERFORMANCE_SIGNATURE EFI_SIGNATURE_32 ('P', 'e', 'r', 'f')\r
#define PERF_TOKEN_SIZE 28\r
#define PERF_TOKEN_LENGTH (PERF_TOKEN_SIZE - 1)\r
+++ /dev/null
-/** @file\r
- Boot Manager Machine type\r
-\r
-Copyright (c) 2004 - 2008, Intel Corporation. <BR>\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#ifndef _BM_MACHINE_H_\r
-#define _BM_MACHINE_H_\r
-\r
-#define DEFAULT_REMOVABLE_FILE_NAME L"\\EFI\\BOOT\\BOOTIA64.EFI"\r
-\r
-#endif\r
gBS->FreePages (AcpiLowMemoryBase, 1);\r
return ;\r
}\r
+ \r
//\r
// Get DXE drivers performance\r
//\r
mPerfHeader.Signiture = PERFORMANCE_SIGNATURE;\r
\r
//\r
- // Put performance data to memory\r
+ // Put performance data to ACPI memory\r
//\r
CopyMem (\r
(UINTN *) (UINTN) AcpiLowMemoryBase,\r
+++ /dev/null
-/** @file\r
- Boot Manager Machine type\r
-\r
-Copyright (c) 2005 - 2008, Intel Corporation. <BR>\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#ifndef _BM_MACHINE_H_\r
-#define _BM_MACHINE_H_\r
-\r
-#define DEFAULT_REMOVABLE_FILE_NAME L"\\EFI\\BOOT\\BOOTX64.EFI"\r
-\r
-#endif\r
gEfiMdeModulePkgTokenSpaceGuid.PcdPlatformBootTimeOutDefault|10|UINT16|0x40000001\r
gEfiMdeModulePkgTokenSpaceGuid.PcdHardwareErrorRecordLevel|1|UINT16|0x40000002\r
\r
+[PcdsFixedAtBuild.IA32]\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdDefaultBootFileName|L"\\EFI\\BOOT\\BOOTIA32.EFI"|VOID*|0x40000003\r
+\r
+[PcdsFixedAtBuild.X64]\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdDefaultBootFileName|L"\\EFI\\BOOT\\BOOTX64.EFI"|VOID*|0x40000003\r
+\r
+[PcdsFixedAtBuild.IPF]\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdDefaultBootFileName|L"\\EFI\\BOOT\\BOOTIA64.EFI"|VOID*|0x40000003\r
+\r
+[PcdsFixedAtBuild.EBC]\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdDefaultBootFileName|L"\\EFI\\BOOT\\BOOTEBC.EFI"|VOID*|0x40000003\r
+ \r
[PcdsDynamic.common]\r
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase|0x0|UINT32|0x30000001\r
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize|0x0|UINT32|0x30000002\r