+++ /dev/null
-/*++\r
-\r
-Copyright (c) 2006, Intel Corporation \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
-Module Name:\r
-\r
- BdsBoot.c\r
-\r
-Abstract:\r
-\r
- BDS Lib functions which relate with create or process the boot\r
- option.\r
-\r
---*/\r
-#include "Performance.h"\r
-\r
-BOOLEAN mEnumBootDevice = FALSE;\r
-\r
-EFI_STATUS\r
-BdsLibDoLegacyBoot (\r
- IN BDS_COMMON_OPTION *Option\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- \r
- Boot the legacy system with the boot option\r
-\r
-Arguments:\r
-\r
- Option - The legacy boot option which have BBS device path\r
-\r
-Returns:\r
-\r
- EFI_UNSUPPORTED - There is no legacybios protocol, do not support\r
- legacy boot.\r
- \r
- EFI_STATUS - Return the status of LegacyBios->LegacyBoot ().\r
-\r
---*/\r
-{\r
- EFI_STATUS Status;\r
- EFI_LEGACY_BIOS_PROTOCOL *LegacyBios;\r
-\r
- Status = gBS->LocateProtocol (&gEfiLegacyBiosProtocolGuid, NULL,
- (void **)&LegacyBios);\r
- if (EFI_ERROR (Status)) {\r
- //\r
- // If no LegacyBios protocol we do not support legacy boot\r
- //\r
- return EFI_UNSUPPORTED;\r
- }\r
- //\r
- // Notes: if we seperate the int 19, then we don't need to refresh BBS\r
- //\r
- BdsRefreshBbsTableForBoot (Option);\r
-\r
- //\r
- // Write boot to OS performance data to a file\r
- //\r
- PERF_CODE (\r
- WriteBootToOsPerformanceData ();\r
- );\r
-\r
-\r
- DEBUG ((EFI_D_INFO | EFI_D_LOAD, "Legacy Boot: %S\n", Option->Description));\r
- return LegacyBios->LegacyBoot (\r
- LegacyBios,\r
- (BBS_BBS_DEVICE_PATH *) Option->DevicePath,\r
- Option->LoadOptionsSize,\r
- Option->LoadOptions\r
- );\r
-}\r
-\r
-EFI_STATUS\r
-BdsLibBootViaBootOption (\r
- IN BDS_COMMON_OPTION * Option,\r
- IN EFI_DEVICE_PATH_PROTOCOL * DevicePath,\r
- OUT UINTN *ExitDataSize,\r
- OUT CHAR16 **ExitData OPTIONAL\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Process the boot option follow the EFI 1.1 specification and \r
- special treat the legacy boot option with BBS_DEVICE_PATH.\r
-\r
-Arguments:\r
-\r
- Option - The boot option need to be processed\r
- \r
- DevicePath - The device path which describe where to load \r
- the boot image or the legcy BBS device path \r
- to boot the legacy OS\r
-\r
- ExitDataSize - Returned directly from gBS->StartImage ()\r
-\r
- ExitData - Returned directly from gBS->StartImage ()\r
-\r
-Returns:\r
-\r
- EFI_SUCCESS - Status from gBS->StartImage (),\r
- or BdsBootByDiskSignatureAndPartition ()\r
-\r
- EFI_NOT_FOUND - If the Device Path is not found in the system\r
-\r
---*/\r
-{\r
- EFI_STATUS Status;\r
- EFI_HANDLE Handle;\r
- EFI_HANDLE ImageHandle;\r
- EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;\r
- EFI_DEVICE_PATH_PROTOCOL *FilePath;\r
- EFI_LOADED_IMAGE_PROTOCOL *ImageInfo;\r
- EFI_ACPI_S3_SAVE_PROTOCOL *AcpiS3Save;\r
-\r
- *ExitDataSize = 0;\r
- *ExitData = NULL;\r
-\r
- //\r
- // Notes: put EFI64 ROM Shadow Solution\r
- //\r
- EFI64_SHADOW_ALL_LEGACY_ROM ();\r
-\r
- //\r
- // Notes: this code can be remove after the s3 script table\r
- // hook on the event EFI_EVENT_SIGNAL_READY_TO_BOOT or\r
- // EFI_EVENT_SIGNAL_LEGACY_BOOT\r
- //\r
- Status = gBS->LocateProtocol (&gEfiAcpiS3SaveProtocolGuid, NULL,
- (VOID **)&AcpiS3Save);\r
- if (!EFI_ERROR (Status)) {\r
- AcpiS3Save->S3Save (AcpiS3Save, NULL);\r
- }\r
- //\r
- // If it's Device Path that starts with a hard drive path,\r
- // this routine will do the booting.\r
- //\r
- Status = BdsBootByDiskSignatureAndPartition (\r
- Option,\r
- (HARDDRIVE_DEVICE_PATH *) DevicePath,\r
- Option->LoadOptionsSize,\r
- Option->LoadOptions,\r
- ExitDataSize,\r
- ExitData\r
- );\r
- if (!EFI_ERROR (Status)) {\r
- //\r
- // If we found a disk signature and partition device path return success\r
- //\r
- return EFI_SUCCESS;\r
- }\r
-\r
- EfiSignalEventReadyToBoot ();\r
-\r
- //\r
- // Set Boot Current\r
- //\r
- gRT->SetVariable (\r
- L"BootCurrent",\r
- &gEfiGlobalVariableGuid,\r
- EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
- sizeof (UINT16),\r
- &Option->BootCurrent\r
- );\r
-\r
- if ((DevicePathType (Option->DevicePath) == BBS_DEVICE_PATH) &&\r
- (DevicePathSubType (Option->DevicePath) == BBS_BBS_DP)\r
- ) {\r
- //\r
- // Check to see if we should legacy BOOT. If yes then do the legacy boot\r
- //\r
- return BdsLibDoLegacyBoot (Option);\r
- }\r
-\r
- DEBUG ((EFI_D_INFO | EFI_D_LOAD, "Booting EFI 1.1 way %S\n", Option->Description));\r
-\r
- Status = gBS->LoadImage (\r
- TRUE,\r
- mBdsImageHandle,\r
- DevicePath,\r
- NULL,\r
- 0,\r
- &ImageHandle\r
- );\r
-\r
- //\r
- // If we didn't find an image, we may need to load the default\r
- // boot behavior for the device.\r
- //\r
- if (EFI_ERROR (Status)) {\r
- //\r
- // Find a Simple File System protocol on the device path. If the remaining\r
- // device path is set to end then no Files are being specified, so try\r
- // the removable media file name.\r
- //\r
- TempDevicePath = DevicePath;\r
- Status = gBS->LocateDevicePath (\r
- &gEfiSimpleFileSystemProtocolGuid,\r
- &TempDevicePath,\r
- &Handle\r
- );\r
- if (!EFI_ERROR (Status) && IsDevicePathEnd (TempDevicePath)) {\r
- FilePath = FileDevicePath (Handle, EFI_REMOVABLE_MEDIA_FILE_NAME);\r
- if (FilePath) {\r
- Status = gBS->LoadImage (\r
- TRUE,\r
- mBdsImageHandle,\r
- FilePath,\r
- NULL,\r
- 0,\r
- &ImageHandle\r
- );\r
- if (EFI_ERROR (Status)) {\r
- //\r
- // The DevicePath failed, and it's not a valid\r
- // removable media device.\r
- //\r
- goto Done;\r
- }\r
- }\r
- } else {\r
- Status = EFI_NOT_FOUND;\r
- }\r
- }\r
-\r
- if (EFI_ERROR (Status)) {\r
- //\r
- // It there is any error from the Boot attempt exit now.\r
- //\r
- goto Done;\r
- }\r
- //\r
- // Provide the image with it's load options\r
- //\r
- Status = gBS->HandleProtocol (ImageHandle, &gEfiLoadedImageProtocolGuid,
- (VOID **) &ImageInfo);\r
- ASSERT_EFI_ERROR (Status);\r
-\r
- if (Option->LoadOptionsSize != 0) {\r
- ImageInfo->LoadOptionsSize = Option->LoadOptionsSize;\r
- ImageInfo->LoadOptions = Option->LoadOptions;\r
- }\r
- //\r
- // Before calling the image, enable the Watchdog Timer for\r
- // the 5 Minute period\r
- //\r
- gBS->SetWatchdogTimer (5 * 60, 0x0000, 0x00, NULL);\r
-\r
- Status = gBS->StartImage (ImageHandle, ExitDataSize, ExitData);\r
- DEBUG ((EFI_D_INFO | EFI_D_LOAD, "Image Return Status = %r\n", Status));\r
-\r
- //\r
- // Clear the Watchdog Timer after the image returns\r
- //\r
- gBS->SetWatchdogTimer (0x0000, 0x0000, 0x0000, NULL);\r
-\r
-Done:\r
- //\r
- // Clear Boot Current\r
- //\r
- gRT->SetVariable (\r
- L"BootCurrent",\r
- &gEfiGlobalVariableGuid,\r
- EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
- 0,\r
- &Option->BootCurrent\r
- );\r
-\r
- return Status;\r
-}\r
-\r
-EFI_STATUS\r
-BdsBootByDiskSignatureAndPartition (\r
- IN BDS_COMMON_OPTION * Option,\r
- IN HARDDRIVE_DEVICE_PATH * HardDriveDevicePath,\r
- IN UINT32 LoadOptionsSize,\r
- IN VOID *LoadOptions,\r
- OUT UINTN *ExitDataSize,\r
- OUT CHAR16 **ExitData OPTIONAL\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Check to see if a hard ware device path was passed in. If it was then search\r
- all the block IO devices for the passed in hard drive device path. \r
- \r
-Arguments:\r
-\r
- Option - The current processing boot option.\r
-\r
- HardDriveDevicePath - EFI Device Path to boot, if it starts with a hard\r
- drive device path.\r
-\r
- LoadOptionsSize - Passed into gBS->StartImage ()\r
- via the loaded image protocol.\r
-\r
- LoadOptions - Passed into gBS->StartImage ()\r
- via the loaded image protocol.\r
-\r
- ExitDataSize - returned directly from gBS->StartImage ()\r
-\r
- ExitData - returned directly from gBS->StartImage ()\r
-\r
-Returns:\r
-\r
- EFI_SUCCESS - Status from gBS->StartImage (),\r
- or BootByDiskSignatureAndPartition ()\r
- \r
- EFI_NOT_FOUND - If the Device Path is not found in the system\r
-\r
---*/\r
-{\r
- EFI_STATUS Status;\r
- UINTN BlockIoHandleCount;\r
- EFI_HANDLE *BlockIoBuffer;\r
- EFI_DEVICE_PATH_PROTOCOL *BlockIoDevicePath;\r
- EFI_DEVICE_PATH_PROTOCOL *BlockIoHdDevicePath;\r
- HARDDRIVE_DEVICE_PATH *TmpHdPath;\r
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
- EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;\r
- UINTN Index;\r
- BOOLEAN DevicePathMatch;\r
- HARDDRIVE_DEVICE_PATH *TempPath;\r
-\r
- *ExitDataSize = 0;\r
- *ExitData = NULL;\r
-\r
- if ( !((DevicePathType (&HardDriveDevicePath->Header) == MEDIA_DEVICE_PATH) &&\r
- (DevicePathSubType (&HardDriveDevicePath->Header) == MEDIA_HARDDRIVE_DP))\r
- ) {\r
- //\r
- // If the HardDriveDevicePath does not start with a Hard Drive Device Path\r
- // exit.\r
- //\r
- return EFI_NOT_FOUND;\r
- }\r
- //\r
- // The boot device have already been connected\r
- //\r
- Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiBlockIoProtocolGuid, NULL, &BlockIoHandleCount, &BlockIoBuffer);\r
- if (EFI_ERROR (Status) || BlockIoHandleCount == 0) {\r
- //\r
- // If there was an error or there are no device handles that support\r
- // the BLOCK_IO Protocol, then return.\r
- //\r
- return EFI_NOT_FOUND;\r
- }\r
- //\r
- // Loop through all the device handles that support the BLOCK_IO Protocol\r
- //\r
- for (Index = 0; Index < BlockIoHandleCount; Index++) {\r
-\r
- Status = gBS->HandleProtocol (BlockIoBuffer[Index], &gEfiDevicePathProtocolGuid, (VOID *) &BlockIoDevicePath);\r
- if (EFI_ERROR (Status) || BlockIoDevicePath == NULL) {\r
- continue;\r
- }\r
- //\r
- // Make PreviousDevicePath == the device path node before the end node\r
- //\r
- DevicePath = BlockIoDevicePath;\r
- BlockIoHdDevicePath = NULL;\r
-\r
- //\r
- // find HardDriver device path node\r
- //\r
- while (!IsDevicePathEnd (DevicePath)) {\r
- if ((DevicePathType (DevicePath) == MEDIA_DEVICE_PATH) && \r
- (DevicePathSubType (DevicePath) == MEDIA_HARDDRIVE_DP)\r
- ) {\r
- BlockIoHdDevicePath = DevicePath;\r
- break;\r
- }\r
-\r
- DevicePath = NextDevicePathNode (DevicePath);\r
- }\r
-\r
- if (BlockIoHdDevicePath == NULL) {\r
- continue;\r
- }\r
- //\r
- // See if the harddrive device path in blockio matches the orig Hard Drive Node\r
- //\r
- DevicePathMatch = FALSE;\r
-\r
- TmpHdPath = (HARDDRIVE_DEVICE_PATH *) BlockIoHdDevicePath;\r
- TempPath = (HARDDRIVE_DEVICE_PATH *) BdsLibUnpackDevicePath ((EFI_DEVICE_PATH_PROTOCOL *) HardDriveDevicePath);\r
-\r
- //\r
- // Only several fields will be checked. NOT whole NODE\r
- //\r
- if ( TmpHdPath->PartitionNumber == TempPath->PartitionNumber &&\r
- TmpHdPath->MBRType == TempPath->MBRType &&\r
- TmpHdPath->SignatureType == TempPath->SignatureType &&\r
- CompareGuid ((EFI_GUID *) TmpHdPath->Signature, (EFI_GUID *) TempPath->Signature)) {\r
- //\r
- // Get the matched device path\r
- //\r
- DevicePathMatch = TRUE;\r
- }\r
- //\r
- // Only do the boot, when devicepath match\r
- //\r
- if (DevicePathMatch) {\r
- //\r
- // Combine the Block IO and Hard Drive Device path together and try\r
- // to boot from it.\r
- //\r
- DevicePath = NextDevicePathNode ((EFI_DEVICE_PATH_PROTOCOL *) HardDriveDevicePath);\r
- NewDevicePath = AppendDevicePath (BlockIoDevicePath, DevicePath);\r
-\r
- //\r
- // Recursive boot with new device path\r
- //\r
- Status = BdsLibBootViaBootOption (Option, NewDevicePath, ExitDataSize, ExitData);\r
- if (!EFI_ERROR (Status)) {\r
- break;\r
- }\r
- }\r
- }\r
-\r
- gBS->FreePool (BlockIoBuffer);\r
- return Status;\r
-}\r
-\r
-EFI_STATUS\r
-BdsLibEnumerateAllBootOption (\r
- IN OUT LIST_ENTRY *BdsBootOptionList\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- This function will enumerate all possible boot device in the system,\r
- it will only excute once of every boot.\r
-\r
-Arguments:\r
-\r
- BdsBootOptionList - The header of the link list which indexed all\r
- current boot options\r
-\r
-Returns:\r
-\r
- EFI_SUCCESS - Finished all the boot device enumerate and create\r
- the boot option base on that boot device\r
-\r
---*/\r
-{\r
- EFI_STATUS Status;\r
- UINT16 BootOptionNumber;\r
- UINTN NumberFileSystemHandles;\r
- EFI_HANDLE *FileSystemHandles;\r
- UINTN NumberBlkIoHandles;\r
- EFI_HANDLE *BlkIoHandles;\r
- EFI_BLOCK_IO_PROTOCOL *BlkIo;\r
- UINTN Index;\r
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
- UINTN NumberLoadFileHandles;\r
- EFI_HANDLE *LoadFileHandles;\r
- VOID *ProtocolInstance;\r
- EFI_FIRMWARE_VOLUME_PROTOCOL *Fv;\r
- UINTN FvHandleCount;\r
- EFI_HANDLE *FvHandleBuffer;\r
- EFI_FV_FILETYPE Type;\r
- UINTN Size;\r
- EFI_FV_FILE_ATTRIBUTES Attributes;\r
- UINT32 AuthenticationStatus;\r
-\r
- BootOptionNumber = 0;\r
-\r
- //\r
- // If the boot device enumerate happened, just get the boot\r
- // device from the boot order variable\r
- //\r
- if (mEnumBootDevice) {\r
- BdsLibBuildOptionFromVar (BdsBootOptionList, L"BootOrder");\r
- return EFI_SUCCESS;\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
- // be removed after the CSM can provide legacy boot option directly\r
- //\r
- REFRESH_LEGACY_BOOT_OPTIONS;\r
-\r
- //\r
- // Check all the block IO to create boot option\r
- //\r
- gBS->LocateHandleBuffer (\r
- ByProtocol,\r
- &gEfiBlockIoProtocolGuid,\r
- NULL,\r
- &NumberBlkIoHandles,\r
- &BlkIoHandles\r
- );\r
- for (Index = 0; Index < NumberBlkIoHandles; Index++) {\r
- Status = gBS->HandleProtocol (\r
- BlkIoHandles[Index],\r
- &gEfiBlockIoProtocolGuid,\r
- (VOID **) &BlkIo\r
- );\r
- if (EFI_ERROR (Status)) {\r
- continue;\r
- }\r
-\r
- if (!BlkIo->Media->RemovableMedia) {\r
- //\r
- // Skip fixed Media device on first loop interration\r
- //\r
- continue;\r
- }\r
-\r
- DevicePath = DevicePathFromHandle (BlkIoHandles[Index]);\r
- if ((DevicePathType (DevicePath) == MEDIA_DEVICE_PATH) && \r
- (DevicePathSubType (DevicePath) == MEDIA_HARDDRIVE_DP)\r
- ) {\r
- //\r
- // Build the boot option\r
- //\r
- BdsLibBuildOptionFromHandle (BlkIoHandles[Index], BdsBootOptionList);\r
- BootOptionNumber++;\r
- }\r
- }\r
-\r
- if (NumberBlkIoHandles) {\r
- gBS->FreePool (BlkIoHandles);\r
- }\r
- //\r
- // Parse Fixed Disk Devices.\r
- //\r
- gBS->LocateHandleBuffer (\r
- ByProtocol,\r
- &gEfiSimpleFileSystemProtocolGuid,\r
- NULL,\r
- &NumberFileSystemHandles,\r
- &FileSystemHandles\r
- );\r
- for (Index = 0; Index < NumberFileSystemHandles; Index++) {\r
- Status = gBS->HandleProtocol (\r
- FileSystemHandles[Index],\r
- &gEfiBlockIoProtocolGuid,\r
- (VOID **) &BlkIo\r
- );\r
- if (!EFI_ERROR (Status)) {\r
- if (BlkIo->Media->RemovableMedia) {\r
- //\r
- // If the file system handle supports a BlkIo protocol,\r
- // skip the removable media devices\r
- //\r
- continue;\r
- }\r
- }\r
-\r
- DevicePath = DevicePathFromHandle (FileSystemHandles[Index]);\r
- if ((DevicePathType (DevicePath) == MEDIA_DEVICE_PATH) && \r
- (DevicePathSubType (DevicePath) == MEDIA_HARDDRIVE_DP)\r
- ) {\r
- //\r
- // If the FileSystem protocol does not contain a BlkIo protocol,\r
- // then build it\r
- //\r
- BdsLibBuildOptionFromHandle (FileSystemHandles[Index], BdsBootOptionList);\r
- BootOptionNumber++;\r
- }\r
- }\r
-\r
- if (NumberFileSystemHandles) {\r
- gBS->FreePool (FileSystemHandles);\r
- }\r
- //\r
- // Parse Network Boot Device\r
- //\r
- gBS->LocateHandleBuffer (\r
- ByProtocol,\r
- &gEfiSimpleNetworkProtocolGuid,\r
- NULL,\r
- &NumberLoadFileHandles,\r
- &LoadFileHandles\r
- );\r
- for (Index = 0; Index < NumberLoadFileHandles; Index++) {\r
- Status = gBS->HandleProtocol (\r
- LoadFileHandles[Index],\r
- &gEfiLoadFileProtocolGuid,\r
- (VOID **) &ProtocolInstance\r
- );\r
- if (EFI_ERROR (Status)) {\r
- continue;\r
- }\r
-\r
- BdsLibBuildOptionFromHandle (LoadFileHandles[Index], BdsBootOptionList);\r
- BootOptionNumber++;\r
- }\r
-\r
- if (NumberLoadFileHandles) {\r
- gBS->FreePool (LoadFileHandles);\r
- }\r
- //\r
- // Check if we have on flash shell\r
- //\r
- gBS->LocateHandleBuffer (\r
- ByProtocol,\r
- &gEfiFirmwareVolumeProtocolGuid,\r
- NULL,\r
- &FvHandleCount,\r
- &FvHandleBuffer\r
- );\r
- for (Index = 0; Index < FvHandleCount; Index++) {\r
- gBS->HandleProtocol (\r
- FvHandleBuffer[Index],\r
- &gEfiFirmwareVolumeProtocolGuid,\r
- (VOID **) &Fv\r
- );\r
-\r
- Status = Fv->ReadFile (\r
- Fv,\r
- &gEfiShellFileGuid,\r
- NULL,\r
- &Size,\r
- &Type,\r
- &Attributes,\r
- &AuthenticationStatus\r
- );\r
- if (EFI_ERROR (Status)) {\r
- //\r
- // Skip if no shell file in the FV\r
- //\r
- continue;\r
- }\r
- //\r
- // Build the shell boot option\r
- //\r
- BdsLibBuildOptionFromShell (FvHandleBuffer[Index], BdsBootOptionList);\r
- BootOptionNumber++;\r
- }\r
-\r
- if (FvHandleCount) {\r
- gBS->FreePool (FvHandleBuffer);\r
- }\r
- //\r
- // Make sure every boot only have one time\r
- // boot device enumerate\r
- //\r
- BdsLibBuildOptionFromVar (BdsBootOptionList, L"BootOrder");\r
- mEnumBootDevice = TRUE;\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-VOID\r
-BdsLibBuildOptionFromHandle (\r
- IN EFI_HANDLE Handle,\r
- IN LIST_ENTRY *BdsBootOptionList\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- \r
- Build the boot option with the handle parsed in\r
- \r
-Arguments:\r
-\r
- Handle - The handle which present the device path to create boot option\r
- \r
- BdsBootOptionList - The header of the link list which indexed all current\r
- boot options\r
-\r
-Returns:\r
-\r
- VOID\r
-\r
---*/\r
-{\r
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
- CHAR16 *TempString;\r
-\r
- DevicePath = DevicePathFromHandle (Handle);\r
- TempString = DevicePathToStr (DevicePath);\r
-\r
- //\r
- // Create and register new boot option\r
- //\r
- BdsLibRegisterNewOption (BdsBootOptionList, DevicePath, TempString, L"BootOrder");\r
-}\r
-\r
-VOID\r
-BdsLibBuildOptionFromShell (\r
- IN EFI_HANDLE Handle,\r
- IN OUT LIST_ENTRY *BdsBootOptionList\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- \r
- Build the on flash shell boot option with the handle parsed in\r
- \r
-Arguments:\r
-\r
- Handle - The handle which present the device path to create on flash shell\r
- boot option\r
- \r
- BdsBootOptionList - The header of the link list which indexed all current\r
- boot options\r
-\r
-Returns:\r
-\r
- None\r
-\r
---*/\r
-{\r
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
- MEDIA_FW_VOL_FILEPATH_DEVICE_PATH ShellNode;\r
-\r
- DevicePath = DevicePathFromHandle (Handle);\r
-\r
- //\r
- // Build the shell device path\r
- //\r
- EfiInitializeFwVolDevicepathNode (&ShellNode, &gEfiShellFileGuid);\r
- DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *) &ShellNode);\r
-\r
- //\r
- // Create and register the shell boot option\r
- //\r
- BdsLibRegisterNewOption (BdsBootOptionList, DevicePath, L"Internal EFI Shell", L"BootOrder");\r
-\r
-}\r
-\r
-VOID\r
-BdsLibBootNext (\r
- VOID\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- \r
- Boot from the EFI1.1 spec defined "BootNext" variable\r
- \r
-Arguments:\r
-\r
- None\r
- \r
-Returns:\r
-\r
- None\r
-\r
---*/\r
-{\r
- UINT16 *BootNext;\r
- UINTN BootNextSize;\r
- CHAR16 Buffer[20];\r
- BDS_COMMON_OPTION *BootOption;\r
- LIST_ENTRY TempList;\r
- UINTN ExitDataSize;\r
- CHAR16 *ExitData;\r
-\r
- //\r
- // Init the boot option name buffer and temp link list\r
- //\r
- InitializeListHead (&TempList);\r
- ZeroMem (Buffer, sizeof (Buffer));\r
-\r
- BootNext = BdsLibGetVariableAndSize (\r
- L"BootNext",\r
- &gEfiGlobalVariableGuid,\r
- &BootNextSize\r
- );\r
-\r
- //\r
- // Clear the boot next variable first\r
- //\r
- if (BootNext != NULL) {\r
- gRT->SetVariable (\r
- L"BootNext",\r
- &gEfiGlobalVariableGuid,\r
- EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
- 0,\r
- BootNext\r
- );\r
-\r
- //\r
- // Start to build the boot option and try to boot\r
- //\r
- UnicodeSPrint (Buffer, sizeof (Buffer), L"Boot%04x", *BootNext);\r
- BootOption = BdsLibVariableToOption (&TempList, Buffer);\r
- BdsLibConnectDevicePath (BootOption->DevicePath);\r
- BdsLibBootViaBootOption (BootOption, BootOption->DevicePath, &ExitDataSize, &ExitData);\r
- }\r
-\r
-}\r