-/**\r
- Get the index number (#### in Boot####) for the boot option pointed to a BBS legacy device type\r
- specified by DeviceType.\r
-\r
- @param DeviceType The legacy device type. It can be floppy, network, harddisk, cdrom,\r
- etc.\r
- @param OptionIndex Returns the index number (#### in Boot####).\r
- @param OptionSize Return the size of the Boot### variable.\r
-\r
-**/\r
-VOID *\r
-GetLegacyBootOptionVar (\r
- IN UINTN DeviceType,\r
- OUT UINTN *OptionIndex,\r
- OUT UINTN *OptionSize\r
- )\r
-{\r
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
- VOID *OptionBuffer;\r
- UINTN OrderSize;\r
- UINTN Index;\r
- UINT16 *OrderBuffer;\r
- CHAR16 StrTemp[100];\r
- UINT16 FilePathSize;\r
- UINT8 *Ptr;\r
- UINT8 *OptionalData;\r
-\r
- //\r
- // Get Boot Option number from the size of BootOrder\r
- //\r
- OrderBuffer = BdsLibGetVariableAndSize (\r
- L"BootOrder",\r
- &gEfiGlobalVariableGuid,\r
- &OrderSize\r
- );\r
- \r
- if (OrderBuffer == NULL) {\r
- return NULL;\r
- }\r
- \r
- for (Index = 0; Index < OrderSize / sizeof (UINT16); Index++) {\r
- UnicodeSPrint (StrTemp, 100, L"Boot%04x", OrderBuffer[Index]);\r
- OptionBuffer = BdsLibGetVariableAndSize (\r
- StrTemp,\r
- &gEfiGlobalVariableGuid,\r
- OptionSize\r
- );\r
- if (NULL == OptionBuffer) {\r
- continue;\r
- }\r
-\r
- Ptr = (UINT8 *) OptionBuffer;\r
- Ptr += sizeof (UINT32);\r
-\r
- FilePathSize = *(UINT16 *) Ptr;\r
- Ptr += sizeof (UINT16);\r
-\r
- Ptr += StrSize ((CHAR16 *) Ptr);\r
-\r
- //\r
- // Now Ptr point to Device Path\r
- //\r
- DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) Ptr;\r
- Ptr += FilePathSize;\r
-\r
- //\r
- // Now Ptr point to Optional Data\r
- //\r
- OptionalData = Ptr;\r
-\r
- if ((DeviceType == ((BBS_TABLE *) OptionalData)->DeviceType) &&\r
- (BBS_DEVICE_PATH == DevicePath->Type) &&\r
- (BBS_BBS_DP == DevicePath->SubType)\r
- ) {\r
- *OptionIndex = OrderBuffer[Index];\r
- FreePool (OrderBuffer);\r
- return OptionBuffer;\r
- } else {\r
- FreePool (OptionBuffer);\r
- }\r
- }\r
-\r
- FreePool (OrderBuffer);\r
- return NULL;\r
-}\r
-\r