#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
//\r
Size = sizeof (UINT16);\r
Status = gRT->GetVariable (L"Timeout", &gEfiGlobalVariableGuid, NULL, &Size, &Timeout);\r
- if (!EFI_ERROR (Status)) {\r
- return Timeout;\r
+ if (EFI_ERROR (Status)) {\r
+ //\r
+ // According to UEFI 2.0 spec, it should treat the Timeout value as 0xffff\r
+ // (default value PcdPlatformBootTimeOutDefault) when L"Timeout" variable is not present.\r
+ // To make the current EFI Automatic-Test activity possible, platform can choose other value\r
+ // for automatic boot when the variable is not present.\r
+ //\r
+ Timeout = PcdGet16 (PcdPlatformBootTimeOutDefault);\r
}\r
- //\r
- // To make the current EFI Automatic-Test activity possible, just add\r
- // following code to make AutoBoot enabled when this variable is not\r
- // present.\r
- // This code should be removed later.\r
- //\r
- Timeout = PcdGet16 (PcdPlatformBootTimeOutDefault);\r
\r
- //\r
- // Notes: Platform should set default variable if non exists on all error cases!!!\r
- //\r
- Status = gRT->SetVariable (\r
- L"Timeout",\r
- &gEfiGlobalVariableGuid,\r
- EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
- sizeof (UINT16),\r
- &Timeout\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
+ FreePool (OptionPtr);\r
+ FreePool (TempOptionPtr);\r
return EFI_SUCCESS;\r
} else {\r
//\r
// Option description changed, need update.\r
//\r
UpdateDescription = TRUE;\r
- gBS->FreePool (OptionPtr);\r
+ FreePool (OptionPtr);\r
break;\r
}\r
}\r
\r
- gBS->FreePool (OptionPtr);\r
+ FreePool (OptionPtr);\r
}\r
\r
OptionSize = sizeof (UINT32) + sizeof (UINT16) + StrSize (String);\r
- OptionSize += GetDevicePathSize (DevicePath);\r
+ OptionSize += GetDevicePathSize (DevicePath);\r
OptionPtr = AllocateZeroPool (OptionSize);\r
+ ASSERT (OptionPtr != NULL);\r
+ \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
+ FreePool (OptionPtr);\r
+ if (TempOptionPtr != NULL) {\r
+ FreePool (TempOptionPtr);\r
+ }\r
return Status;\r
}\r
\r
- gBS->FreePool (OptionPtr);\r
+ FreePool (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
+ if (TempOptionPtr != NULL) {\r
+ FreePool (TempOptionPtr);\r
}\r
- return EFI_SUCCESS;\r
+ return Status;\r
}\r
\r
//\r
//\r
OrderItemNum = (TempOptionSize / sizeof (UINT16)) + 1 ;\r
OptionOrderPtr = AllocateZeroPool ( OrderItemNum * sizeof (UINT16));\r
+ ASSERT (OptionOrderPtr!= NULL);\r
+ \r
CopyMem (OptionOrderPtr, TempOptionPtr, (OrderItemNum - 1) * sizeof (UINT16));\r
\r
OptionOrderPtr[Index] = RegisterOptionNumber;\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
+ FreePool (TempOptionPtr);\r
+ FreePool (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
+ FreePool (Variable);\r
return Option;\r
}\r
\r
- gBS->FreePool (Variable);\r
- gBS->FreePool (Option);\r
+ FreePool (Variable);\r
+ FreePool (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
+ FreePool (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
//\r
TempNewDevicePath = NewDevicePath;\r
NewDevicePath = AppendDevicePathInstance (NewDevicePath, Instance);\r
- SafeFreePool(TempNewDevicePath);\r
+ if (TempNewDevicePath != NULL) {\r
+ FreePool(TempNewDevicePath);\r
+ }\r
}\r
- SafeFreePool(Instance);\r
+ FreePool(Instance);\r
Instance = GetNextDevicePathInstance (&Multi, &InstanceSize);\r
InstanceSize -= END_DEVICE_PATH_LENGTH;\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
EFI_DEVICE_PATH_PROTOCOL *DevicePathInst;\r
UINTN Size;\r
\r
- if (Multi != NULL || Single != NULL) {\r
+ if (Multi == NULL || Single == NULL) {\r
return FALSE;\r
}\r
\r
// return success\r
//\r
if (CompareMem (Single, DevicePathInst, Size) == 0) {\r
- gBS->FreePool (DevicePathInst);\r
+ FreePool (DevicePathInst);\r
return TRUE;\r
}\r
\r
- gBS->FreePool (DevicePathInst);\r
+ FreePool (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
+ FreePool (StringBuffer1);\r
+ FreePool (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
&Root\r
);\r
if (EFI_ERROR (Status)) {\r
+ Root = NULL;\r
goto Done;\r
}\r
\r
break;\r
}\r
if (Status != EFI_BUFFER_TOO_SMALL) {\r
+ FreePool (Info);\r
goto Done;\r
}\r
- gBS->FreePool (Info);\r
+ FreePool (Info);\r
} while (TRUE);\r
\r
FileSize = Info->FileSize;\r
- gBS->FreePool (Info);\r
+ FreePool (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