//\r
InitializeListHead (&TempBootLists);\r
BdsLibRegisterNewOption (&TempBootLists, DevicePath, L"EFI Internal Shell", L"BootOrder");\r
+ //\r
+ // free the temporary device path created by BdsLibUpdateFvFileDevicePath()\r
+ //\r
+ gBS->FreePool (DevicePath); \r
+ DevicePath = Option->DevicePath;\r
}\r
\r
//\r
break;\r
case MESSAGING_DEVICE_PATH:\r
//\r
- // if the device path not only point to driver device, it is not a messaging device path.\r
+ // Get the last device path node\r
//\r
LastDeviceNode = NextDevicePathNode (TempDevicePath);\r
+ if (DevicePathSubType(LastDeviceNode) == MSG_DEVICE_LOGICAL_UNIT_DP) {\r
+ //\r
+ // if the next node type is Device Logical Unit, which specify the Logical Unit Number (LUN),\r
+ // skit it\r
+ //\r
+ LastDeviceNode = NextDevicePathNode (LastDeviceNode);\r
+ }\r
+ //\r
+ // if the device path not only point to driver device, it is not a messaging device path,\r
+ //\r
if (!IsDevicePathEndType (LastDeviceNode)) {\r
- break;\r
+ break; \r
}\r
\r
if (DevicePathSubType(TempDevicePath) == MSG_ATAPI_DP) {\r
}\r
\r
//\r
- // If the boot option point to a internal Shell, it is a valid EFI boot option,\r
- // and assume it is ready to boot now\r
+ // Check if it's a valid boot option for internal Shell\r
//\r
if (EfiGetNameGuidFromFwVolDevicePathNode ((MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) LastDeviceNode) != NULL) {\r
- return TRUE;\r
+ //\r
+ // If the boot option point to Internal FV shell, make sure it is valid\r
+ //\r
+ TempDevicePath = DevPath; \r
+ Status = BdsLibUpdateFvFileDevicePath (&TempDevicePath, &gEfiShellFileGuid);\r
+ if (Status == EFI_ALREADY_STARTED) {\r
+ return TRUE;\r
+ } else {\r
+ if (Status == EFI_SUCCESS) {\r
+ gBS->FreePool (TempDevicePath); \r
+ }\r
+ return FALSE;\r
+ }\r
}\r
-\r
+ \r
//\r
// If the boot option point to a blockIO device, no matter whether or not it is a removeable device, it is a valid EFI boot option\r
//\r
// Second, if fail to find, try to enumerate all FV\r
//\r
if (!FindFvFile) {\r
+ FvHandleBuffer = NULL;\r
gBS->LocateHandleBuffer (\r
ByProtocol,\r
&gEfiFirmwareVolume2ProtocolGuid,\r
FoundFvHandle = FvHandleBuffer[Index];\r
break;\r
}\r
+ if (FvHandleBuffer !=NULL ) {\r
+ FreePool (FvHandleBuffer); \r
+ }\r
}\r
\r
if (FindFvFile) {\r