diff options
author | Michael Kubacki <michael.kubacki@microsoft.com> | 2021-12-05 14:54:09 -0800 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2021-12-07 17:24:28 +0000 |
commit | ac0a286f4d747a4c6c603a7b225917293cbe1e9f (patch) | |
tree | 32654f2b35755afc961e2c97296b2dec5762da75 /OvmfPkg/Library/QemuBootOrderLib | |
parent | d1050b9dff1cace252aff86630bfdb59dff5f507 (diff) | |
download | edk2-ac0a286f4d747a4c6c603a7b225917293cbe1e9f.tar.gz edk2-ac0a286f4d747a4c6c603a7b225917293cbe1e9f.tar.bz2 edk2-ac0a286f4d747a4c6c603a7b225917293cbe1e9f.zip |
OvmfPkg: Apply uncrustify changes
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737
Apply uncrustify changes to .c/.h files in the OvmfPkg package
Cc: Andrew Fish <afish@apple.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Andrew Fish <afish@apple.com>
Diffstat (limited to 'OvmfPkg/Library/QemuBootOrderLib')
-rw-r--r-- | OvmfPkg/Library/QemuBootOrderLib/ExtraRootBusMap.c | 110 | ||||
-rw-r--r-- | OvmfPkg/Library/QemuBootOrderLib/ExtraRootBusMap.h | 10 | ||||
-rw-r--r-- | OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c | 1054 |
3 files changed, 667 insertions, 507 deletions
diff --git a/OvmfPkg/Library/QemuBootOrderLib/ExtraRootBusMap.c b/OvmfPkg/Library/QemuBootOrderLib/ExtraRootBusMap.c index 25d5494047..37d488e01c 100644 --- a/OvmfPkg/Library/QemuBootOrderLib/ExtraRootBusMap.c +++ b/OvmfPkg/Library/QemuBootOrderLib/ExtraRootBusMap.c @@ -28,11 +28,10 @@ // BusNumbers is NULL.
//
struct EXTRA_ROOT_BUS_MAP_STRUCT {
- UINT32 *BusNumbers;
- UINTN Count;
+ UINT32 *BusNumbers;
+ UINTN Count;
};
-
/**
An ORDERED_COLLECTION_USER_COMPARE function that compares root bridge
protocol device paths based on UID.
@@ -51,12 +50,12 @@ STATIC INTN
EFIAPI
RootBridgePathCompare (
- IN CONST VOID *UserStruct1,
- IN CONST VOID *UserStruct2
+ IN CONST VOID *UserStruct1,
+ IN CONST VOID *UserStruct2
)
{
- CONST ACPI_HID_DEVICE_PATH *Acpi1;
- CONST ACPI_HID_DEVICE_PATH *Acpi2;
+ CONST ACPI_HID_DEVICE_PATH *Acpi1;
+ CONST ACPI_HID_DEVICE_PATH *Acpi2;
Acpi1 = UserStruct1;
Acpi2 = UserStruct2;
@@ -66,7 +65,6 @@ RootBridgePathCompare ( 0;
}
-
/**
An ORDERED_COLLECTION_KEY_COMPARE function that compares a root bridge
protocol device path against a UID.
@@ -86,12 +84,12 @@ STATIC INTN
EFIAPI
RootBridgePathKeyCompare (
- IN CONST VOID *StandaloneKey,
- IN CONST VOID *UserStruct
+ IN CONST VOID *StandaloneKey,
+ IN CONST VOID *UserStruct
)
{
- CONST UINT32 *Uid;
- CONST ACPI_HID_DEVICE_PATH *Acpi;
+ CONST UINT32 *Uid;
+ CONST ACPI_HID_DEVICE_PATH *Acpi;
Uid = StandaloneKey;
Acpi = UserStruct;
@@ -101,7 +99,6 @@ RootBridgePathKeyCompare ( 0;
}
-
/**
Create a structure that maps the relative positions of PCI root buses to bus
numbers.
@@ -129,31 +126,37 @@ RootBridgePathKeyCompare ( **/
EFI_STATUS
CreateExtraRootBusMap (
- OUT EXTRA_ROOT_BUS_MAP **ExtraRootBusMap
+ OUT EXTRA_ROOT_BUS_MAP **ExtraRootBusMap
)
{
- EFI_STATUS Status;
- UINTN NumHandles;
- EFI_HANDLE *Handles;
- ORDERED_COLLECTION *Collection;
- EXTRA_ROOT_BUS_MAP *Map;
- UINTN Idx;
- ORDERED_COLLECTION_ENTRY *Entry, *Entry2;
+ EFI_STATUS Status;
+ UINTN NumHandles;
+ EFI_HANDLE *Handles;
+ ORDERED_COLLECTION *Collection;
+ EXTRA_ROOT_BUS_MAP *Map;
+ UINTN Idx;
+ ORDERED_COLLECTION_ENTRY *Entry, *Entry2;
//
// Handles and Collection are temporary / helper variables, while in Map we
// build the return value.
//
- Status = gBS->LocateHandleBuffer (ByProtocol,
- &gEfiPciRootBridgeIoProtocolGuid, NULL /* SearchKey */,
- &NumHandles, &Handles);
- if (EFI_ERROR (Status)) {
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiPciRootBridgeIoProtocolGuid,
+ NULL /* SearchKey */,
+ &NumHandles,
+ &Handles
+ );
+ if (EFI_ERROR (Status)) {
return Status;
}
- Collection = OrderedCollectionInit (RootBridgePathCompare,
- RootBridgePathKeyCompare);
+ Collection = OrderedCollectionInit (
+ RootBridgePathCompare,
+ RootBridgePathKeyCompare
+ );
if (Collection == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto FreeHandles;
@@ -169,10 +172,13 @@ CreateExtraRootBusMap ( // Collect the ACPI device path protocols of the root bridges.
//
for (Idx = 0; Idx < NumHandles; ++Idx) {
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- Status = gBS->HandleProtocol (Handles[Idx], &gEfiDevicePathProtocolGuid,
- (VOID**)&DevicePath);
+ Status = gBS->HandleProtocol (
+ Handles[Idx],
+ &gEfiDevicePathProtocolGuid,
+ (VOID **)&DevicePath
+ );
if (EFI_ERROR (Status)) {
goto FreeMap;
}
@@ -182,14 +188,16 @@ CreateExtraRootBusMap ( // nonzero (ie. the root bridge that the bus number belongs to is "extra",
// not the main one). In that case, link the device path into Collection.
//
- if (DevicePathType (DevicePath) == ACPI_DEVICE_PATH &&
- DevicePathSubType (DevicePath) == ACPI_DP &&
- ((ACPI_HID_DEVICE_PATH *)DevicePath)->HID == EISA_PNP_ID(0x0A03) &&
- ((ACPI_HID_DEVICE_PATH *)DevicePath)->UID > 0) {
+ if ((DevicePathType (DevicePath) == ACPI_DEVICE_PATH) &&
+ (DevicePathSubType (DevicePath) == ACPI_DP) &&
+ (((ACPI_HID_DEVICE_PATH *)DevicePath)->HID == EISA_PNP_ID (0x0A03)) &&
+ (((ACPI_HID_DEVICE_PATH *)DevicePath)->UID > 0))
+ {
Status = OrderedCollectionInsert (Collection, NULL, DevicePath);
if (EFI_ERROR (Status)) {
goto FreeMap;
}
+
++Map->Count;
}
}
@@ -208,24 +216,29 @@ CreateExtraRootBusMap ( //
// Now collect the bus numbers of the extra PCI root buses into Map.
//
- Idx = 0;
+ Idx = 0;
Entry = OrderedCollectionMin (Collection);
while (Idx < Map->Count) {
- ACPI_HID_DEVICE_PATH *Acpi;
+ ACPI_HID_DEVICE_PATH *Acpi;
ASSERT (Entry != NULL);
- Acpi = OrderedCollectionUserStruct (Entry);
+ Acpi = OrderedCollectionUserStruct (Entry);
Map->BusNumbers[Idx] = Acpi->UID;
- DEBUG ((DEBUG_VERBOSE,
+ DEBUG ((
+ DEBUG_VERBOSE,
"%a: extra bus position 0x%Lx maps to bus number (UID) 0x%x\n",
- __FUNCTION__, (UINT64)(Idx + 1), Acpi->UID));
+ __FUNCTION__,
+ (UINT64)(Idx + 1),
+ Acpi->UID
+ ));
++Idx;
Entry = OrderedCollectionNext (Entry);
}
+
ASSERT (Entry == NULL);
*ExtraRootBusMap = Map;
- Status = EFI_SUCCESS;
+ Status = EFI_SUCCESS;
//
// Fall through in order to release temporaries.
@@ -236,15 +249,18 @@ FreeMap: if (Map->BusNumbers != NULL) {
FreePool (Map->BusNumbers);
}
+
FreePool (Map);
}
FreeCollection:
for (Entry = OrderedCollectionMin (Collection); Entry != NULL;
- Entry = Entry2) {
+ Entry = Entry2)
+ {
Entry2 = OrderedCollectionNext (Entry);
OrderedCollectionDelete (Collection, Entry, NULL);
}
+
OrderedCollectionUninit (Collection);
FreeHandles:
@@ -253,7 +269,6 @@ FreeHandles: return Status;
}
-
/**
Release a map created with CreateExtraRootBusMap().
@@ -261,12 +276,13 @@ FreeHandles: */
VOID
DestroyExtraRootBusMap (
- IN EXTRA_ROOT_BUS_MAP *ExtraRootBusMap
+ IN EXTRA_ROOT_BUS_MAP *ExtraRootBusMap
)
{
if (ExtraRootBusMap->BusNumbers != NULL) {
FreePool (ExtraRootBusMap->BusNumbers);
}
+
FreePool (ExtraRootBusMap);
}
@@ -291,17 +307,19 @@ DestroyExtraRootBusMap ( **/
EFI_STATUS
MapRootBusPosToBusNr (
- IN CONST EXTRA_ROOT_BUS_MAP *ExtraRootBusMap,
- IN UINT64 RootBusPos,
- OUT UINT32 *RootBusNr
+ IN CONST EXTRA_ROOT_BUS_MAP *ExtraRootBusMap,
+ IN UINT64 RootBusPos,
+ OUT UINT32 *RootBusNr
)
{
if (RootBusPos == 0) {
return EFI_INVALID_PARAMETER;
}
+
if (RootBusPos > ExtraRootBusMap->Count) {
return EFI_NOT_FOUND;
}
+
*RootBusNr = ExtraRootBusMap->BusNumbers[(UINTN)RootBusPos - 1];
return EFI_SUCCESS;
}
diff --git a/OvmfPkg/Library/QemuBootOrderLib/ExtraRootBusMap.h b/OvmfPkg/Library/QemuBootOrderLib/ExtraRootBusMap.h index 3b79fbdc7f..7c4a338693 100644 --- a/OvmfPkg/Library/QemuBootOrderLib/ExtraRootBusMap.h +++ b/OvmfPkg/Library/QemuBootOrderLib/ExtraRootBusMap.h @@ -16,19 +16,19 @@ typedef struct EXTRA_ROOT_BUS_MAP_STRUCT EXTRA_ROOT_BUS_MAP; EFI_STATUS
CreateExtraRootBusMap (
- OUT EXTRA_ROOT_BUS_MAP **ExtraRootBusMap
+ OUT EXTRA_ROOT_BUS_MAP **ExtraRootBusMap
);
VOID
DestroyExtraRootBusMap (
- IN EXTRA_ROOT_BUS_MAP *ExtraRootBusMap
+ IN EXTRA_ROOT_BUS_MAP *ExtraRootBusMap
);
EFI_STATUS
MapRootBusPosToBusNr (
- IN CONST EXTRA_ROOT_BUS_MAP *ExtraRootBusMap,
- IN UINT64 RootBusPos,
- OUT UINT32 *RootBusNr
+ IN CONST EXTRA_ROOT_BUS_MAP *ExtraRootBusMap,
+ IN UINT64 RootBusPos,
+ OUT UINT32 *RootBusNr
);
#endif
diff --git a/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c b/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c index ceffb17fa6..b5768285d8 100644 --- a/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c +++ b/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c @@ -26,21 +26,20 @@ /**
OpenFirmware to UEFI device path translation output buffer size in CHAR16's.
**/
-#define TRANSLATION_OUTPUT_SIZE 0x100
+#define TRANSLATION_OUTPUT_SIZE 0x100
/**
Output buffer size for OpenFirmware to UEFI device path fragment translation,
in CHAR16's, for a sequence of PCI bridges.
**/
-#define BRIDGE_TRANSLATION_OUTPUT_SIZE 0x40
+#define BRIDGE_TRANSLATION_OUTPUT_SIZE 0x40
/**
Numbers of nodes in OpenFirmware device paths that are required and examined.
**/
-#define REQUIRED_PCI_OFW_NODES 2
-#define REQUIRED_MMIO_OFW_NODES 1
-#define EXAMINED_OFW_NODES 6
-
+#define REQUIRED_PCI_OFW_NODES 2
+#define REQUIRED_MMIO_OFW_NODES 1
+#define EXAMINED_OFW_NODES 6
/**
Simple character classification routines, corresponding to POSIX class names
@@ -49,7 +48,7 @@ STATIC
BOOLEAN
IsAlnum (
- IN CHAR8 Chr
+ IN CHAR8 Chr
)
{
return (('0' <= Chr && Chr <= '9') ||
@@ -58,11 +57,10 @@ IsAlnum ( );
}
-
STATIC
BOOLEAN
IsDriverNamePunct (
- IN CHAR8 Chr
+ IN CHAR8 Chr
)
{
return (Chr == ',' || Chr == '.' || Chr == '_' ||
@@ -70,27 +68,24 @@ IsDriverNamePunct ( );
}
-
STATIC
BOOLEAN
IsPrintNotDelim (
- IN CHAR8 Chr
+ IN CHAR8 Chr
)
{
return (32 <= Chr && Chr <= 126 &&
Chr != '/' && Chr != '@' && Chr != ':');
}
-
/**
Utility types and functions.
**/
typedef struct {
- CONST CHAR8 *Ptr; // not necessarily NUL-terminated
- UINTN Len; // number of non-NUL characters
+ CONST CHAR8 *Ptr; // not necessarily NUL-terminated
+ UINTN Len; // number of non-NUL characters
} SUBSTRING;
-
/**
Check if Substring and String have identical contents.
@@ -109,12 +104,12 @@ typedef struct { STATIC
BOOLEAN
SubstringEq (
- IN SUBSTRING Substring,
- IN CONST CHAR8 *String
+ IN SUBSTRING Substring,
+ IN CONST CHAR8 *String
)
{
- UINTN Pos;
- CONST CHAR8 *Chr;
+ UINTN Pos;
+ CONST CHAR8 *Chr;
Pos = 0;
Chr = String;
@@ -127,7 +122,6 @@ SubstringEq ( return (BOOLEAN)(Pos == Substring.Len && *Chr == '\0');
}
-
/**
Parse a comma-separated list of hexadecimal integers into the elements of an
@@ -175,38 +169,41 @@ ParseUnitAddressHexList ( IN OUT UINTN *NumResults
)
{
- UINTN Entry; // number of entry currently being parsed
- UINT64 EntryVal; // value being constructed for current entry
- CHAR8 PrevChr; // UnitAddress character previously checked
- UINTN Pos; // current position within UnitAddress
- RETURN_STATUS Status;
+ UINTN Entry; // number of entry currently being parsed
+ UINT64 EntryVal; // value being constructed for current entry
+ CHAR8 PrevChr; // UnitAddress character previously checked
+ UINTN Pos; // current position within UnitAddress
+ RETURN_STATUS Status;
Entry = 0;
EntryVal = 0;
PrevChr = ',';
for (Pos = 0; Pos < UnitAddress.Len; ++Pos) {
- CHAR8 Chr;
- INT8 Val;
+ CHAR8 Chr;
+ INT8 Val;
Chr = UnitAddress.Ptr[Pos];
Val = ('a' <= Chr && Chr <= 'f') ? (Chr - 'a' + 10) :
('A' <= Chr && Chr <= 'F') ? (Chr - 'A' + 10) :
- ('0' <= Chr && Chr <= '9') ? (Chr - '0' ) :
+ ('0' <= Chr && Chr <= '9') ? (Chr - '0') :
-1;
if (Val >= 0) {
if (EntryVal > 0xFFFFFFFFFFFFFFFull) {
return RETURN_INVALID_PARAMETER;
}
+
EntryVal = LShiftU64 (EntryVal, 4) | Val;
} else if (Chr == ',') {
if (PrevChr == ',') {
return RETURN_INVALID_PARAMETER;
}
+
if (Entry < *NumResults) {
Result[Entry] = EntryVal;
}
+
++Entry;
EntryVal = 0;
} else {
@@ -219,41 +216,40 @@ ParseUnitAddressHexList ( if (PrevChr == ',') {
return RETURN_INVALID_PARAMETER;
}
+
if (Entry < *NumResults) {
Result[Entry] = EntryVal;
- Status = RETURN_SUCCESS;
+ Status = RETURN_SUCCESS;
} else {
Status = RETURN_BUFFER_TOO_SMALL;
}
+
++Entry;
*NumResults = Entry;
return Status;
}
-
/**
A simple array of Boot Option ID's.
**/
typedef struct {
- UINT16 *Data;
- UINTN Allocated;
- UINTN Produced;
+ UINT16 *Data;
+ UINTN Allocated;
+ UINTN Produced;
} BOOT_ORDER;
-
/**
Array element tracking an enumerated boot option that has the
LOAD_OPTION_ACTIVE attribute.
**/
typedef struct {
- CONST EFI_BOOT_MANAGER_LOAD_OPTION *BootOption; // reference only, no
- // ownership
- BOOLEAN Appended; // has been added to a
- // BOOT_ORDER?
+ CONST EFI_BOOT_MANAGER_LOAD_OPTION *BootOption; // reference only, no
+ // ownership
+ BOOLEAN Appended; // has been added to a
+ // BOOT_ORDER?
} ACTIVE_OPTION;
-
/**
Append an active boot option to BootOrder, reallocating the latter if needed.
@@ -273,35 +269,35 @@ typedef struct { STATIC
RETURN_STATUS
BootOrderAppend (
- IN OUT BOOT_ORDER *BootOrder,
- IN OUT ACTIVE_OPTION *ActiveOption
+ IN OUT BOOT_ORDER *BootOrder,
+ IN OUT ACTIVE_OPTION *ActiveOption
)
{
if (BootOrder->Produced == BootOrder->Allocated) {
- UINTN AllocatedNew;
- UINT16 *DataNew;
+ UINTN AllocatedNew;
+ UINT16 *DataNew;
ASSERT (BootOrder->Allocated > 0);
AllocatedNew = BootOrder->Allocated * 2;
- DataNew = ReallocatePool (
- BootOrder->Allocated * sizeof (*BootOrder->Data),
- AllocatedNew * sizeof (*DataNew),
- BootOrder->Data
- );
+ DataNew = ReallocatePool (
+ BootOrder->Allocated * sizeof (*BootOrder->Data),
+ AllocatedNew * sizeof (*DataNew),
+ BootOrder->Data
+ );
if (DataNew == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
+
BootOrder->Allocated = AllocatedNew;
BootOrder->Data = DataNew;
}
BootOrder->Data[BootOrder->Produced++] =
- (UINT16) ActiveOption->BootOption->OptionNumber;
+ (UINT16)ActiveOption->BootOption->OptionNumber;
ActiveOption->Appended = TRUE;
return RETURN_SUCCESS;
}
-
/**
Create an array of ACTIVE_OPTION elements for a boot option array.
@@ -330,14 +326,14 @@ BootOrderAppend ( STATIC
RETURN_STATUS
CollectActiveOptions (
- IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions,
- IN UINTN BootOptionCount,
- OUT ACTIVE_OPTION **ActiveOption,
- OUT UINTN *Count
+ IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions,
+ IN UINTN BootOptionCount,
+ OUT ACTIVE_OPTION **ActiveOption,
+ OUT UINTN *Count
)
{
- UINTN Index;
- UINTN ScanMode;
+ UINTN Index;
+ UINTN ScanMode;
*ActiveOption = NULL;
@@ -354,6 +350,7 @@ CollectActiveOptions ( (*ActiveOption)[*Count].BootOption = &BootOptions[Index];
(*ActiveOption)[*Count].Appended = FALSE;
}
+
++*Count;
}
}
@@ -362,26 +359,26 @@ CollectActiveOptions ( if (*Count == 0) {
return RETURN_NOT_FOUND;
}
+
*ActiveOption = AllocatePool (*Count * sizeof **ActiveOption);
if (*ActiveOption == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
}
}
+
return RETURN_SUCCESS;
}
-
/**
OpenFirmware device path node
**/
typedef struct {
- SUBSTRING DriverName;
- SUBSTRING UnitAddress;
- SUBSTRING DeviceArguments;
+ SUBSTRING DriverName;
+ SUBSTRING UnitAddress;
+ SUBSTRING DeviceArguments;
} OFW_NODE;
-
/**
Parse an OpenFirmware device path node into the caller-allocated OFW_NODE
@@ -430,24 +427,24 @@ typedef struct { STATIC
RETURN_STATUS
ParseOfwNode (
- IN OUT CONST CHAR8 **Ptr,
- OUT OFW_NODE *OfwNode,
- OUT BOOLEAN *IsFinal
+ IN OUT CONST CHAR8 **Ptr,
+ OUT OFW_NODE *OfwNode,
+ OUT BOOLEAN *IsFinal
)
{
//
// A leading slash is expected. End of string is tolerated.
//
switch (**Ptr) {
- case '\0':
- return RETURN_NOT_FOUND;
+ case '\0':
+ return RETURN_NOT_FOUND;
- case '/':
- ++*Ptr;
- break;
+ case '/':
+ ++*Ptr;
+ break;
- default:
- return RETURN_INVALID_PARAMETER;
+ default:
+ return RETURN_INVALID_PARAMETER;
}
//
@@ -457,22 +454,23 @@ ParseOfwNode ( OfwNode->DriverName.Len = 0;
while (OfwNode->DriverName.Len < 32 &&
(IsAlnum (**Ptr) || IsDriverNamePunct (**Ptr))
- ) {
+ )
+ {
++*Ptr;
++OfwNode->DriverName.Len;
}
- if (OfwNode->DriverName.Len == 0 || OfwNode->DriverName.Len == 32) {
+ if ((OfwNode->DriverName.Len == 0) || (OfwNode->DriverName.Len == 32)) {
return RETURN_INVALID_PARAMETER;
}
-
//
// unit-address
//
if (**Ptr != '@') {
return RETURN_INVALID_PARAMETER;
}
+
++*Ptr;
OfwNode->UnitAddress.Ptr = *Ptr;
@@ -486,7 +484,6 @@ ParseOfwNode ( return RETURN_INVALID_PARAMETER;
}
-
//
// device-arguments, may be omitted
//
@@ -503,43 +500,43 @@ ParseOfwNode ( if (OfwNode->DeviceArguments.Len == 0) {
return RETURN_INVALID_PARAMETER;
}
- }
- else {
+ } else {
OfwNode->DeviceArguments.Ptr = NULL;
}
switch (**Ptr) {
- case '\n':
- ++*Ptr;
+ case '\n':
+ ++*Ptr;
//
// fall through
//
- case '\0':
- *IsFinal = TRUE;
- break;
+ case '\0':
+ *IsFinal = TRUE;
+ break;
- case '/':
- *IsFinal = FALSE;
- break;
+ case '/':
+ *IsFinal = FALSE;
+ break;
- default:
- return RETURN_INVALID_PARAMETER;
+ default:
+ return RETURN_INVALID_PARAMETER;
}
DEBUG ((
DEBUG_VERBOSE,
"%a: DriverName=\"%.*a\" UnitAddress=\"%.*a\" DeviceArguments=\"%.*a\"\n",
__FUNCTION__,
- OfwNode->DriverName.Len, OfwNode->DriverName.Ptr,
- OfwNode->UnitAddress.Len, OfwNode->UnitAddress.Ptr,
+ OfwNode->DriverName.Len,
+ OfwNode->DriverName.Ptr,
+ OfwNode->UnitAddress.Len,
+ OfwNode->UnitAddress.Ptr,
OfwNode->DeviceArguments.Len,
OfwNode->DeviceArguments.Ptr == NULL ? "" : OfwNode->DeviceArguments.Ptr
));
return RETURN_SUCCESS;
}
-
/**
Translate a PCI-like array of OpenFirmware device nodes to a UEFI device path
@@ -584,21 +581,21 @@ ParseOfwNode ( STATIC
RETURN_STATUS
TranslatePciOfwNodes (
- IN CONST OFW_NODE *OfwNode,
- IN UINTN NumNodes,
- IN CONST EXTRA_ROOT_BUS_MAP *ExtraPciRoots,
- OUT CHAR16 *Translated,
- IN OUT UINTN *TranslatedSize
+ IN CONST OFW_NODE *OfwNode,
+ IN UINTN NumNodes,
+ IN CONST EXTRA_ROOT_BUS_MAP *ExtraPciRoots,
+ OUT CHAR16 *Translated,
+ IN OUT UINTN *TranslatedSize
)
{
- UINT32 PciRoot;
- CHAR8 *Comma;
- UINTN FirstNonBridge;
- CHAR16 Bridges[BRIDGE_TRANSLATION_OUTPUT_SIZE];
- UINTN BridgesLen;
- UINT64 PciDevFun[2];
- UINTN NumEntries;
- UINTN Written;
+ UINT32 PciRoot;
+ CHAR8 *Comma;
+ UINTN FirstNonBridge;
+ CHAR16 Bridges[BRIDGE_TRANSLATION_OUTPUT_SIZE];
+ UINTN BridgesLen;
+ UINT64 PciDevFun[2];
+ UINTN NumEntries;
+ UINTN Written;
//
// Resolve the PCI root bus number.
@@ -613,18 +610,22 @@ TranslatePciOfwNodes ( // ^
// root bus serial number (not PCI bus number)
//
- if (NumNodes < REQUIRED_PCI_OFW_NODES ||
+ if ((NumNodes < REQUIRED_PCI_OFW_NODES) ||
!SubstringEq (OfwNode[0].DriverName, "pci")
- ) {
+ )
+ {
return RETURN_UNSUPPORTED;
}
PciRoot = 0;
- Comma = ScanMem8 (OfwNode[0].UnitAddress.Ptr, OfwNode[0].UnitAddress.Len,
- ',');
+ Comma = ScanMem8 (
+ OfwNode[0].UnitAddress.Ptr,
+ OfwNode[0].UnitAddress.Len,
+ ','
+ );
if (Comma != NULL) {
- SUBSTRING PciRootSerialSubString;
- UINT64 PciRootSerial;
+ SUBSTRING PciRootSerialSubString;
+ UINT64 PciRootSerial;
//
// Parse the root bus serial number from the unit address after the comma.
@@ -634,16 +635,28 @@ TranslatePciOfwNodes ( (PciRootSerialSubString.Ptr -
OfwNode[0].UnitAddress.Ptr);
NumEntries = 1;
- if (RETURN_ERROR (ParseUnitAddressHexList (PciRootSerialSubString,
- &PciRootSerial, &NumEntries))) {
+ if (RETURN_ERROR (
+ ParseUnitAddressHexList (
+ PciRootSerialSubString,
+ &PciRootSerial,
+ &NumEntries
+ )
+ ))
+ {
return RETURN_UNSUPPORTED;
}
//
// Map the extra root bus's serial number to its actual bus number.
//
- if (EFI_ERROR (MapRootBusPosToBusNr (ExtraPciRoots, PciRootSerial,
- &PciRoot))) {
+ if (EFI_ERROR (
+ MapRootBusPosToBusNr (
+ ExtraPciRoots,
+ PciRootSerial,
+ &PciRoot
+ )
+ ))
+ {
return RETURN_PROTOCOL_ERROR;
}
}
@@ -660,26 +673,35 @@ TranslatePciOfwNodes ( // Pci(0x1E,0x0)
//
FirstNonBridge = 1;
- Bridges[0] = L'\0';
- BridgesLen = 0;
+ Bridges[0] = L'\0';
+ BridgesLen = 0;
do {
- UINT64 BridgeDevFun[2];
- UINTN BridgesFreeBytes;
+ UINT64 BridgeDevFun[2];
+ UINTN BridgesFreeBytes;
if (!SubstringEq (OfwNode[FirstNonBridge].DriverName, "pci-bridge")) {
break;
}
BridgeDevFun[1] = 0;
- NumEntries = sizeof BridgeDevFun / sizeof BridgeDevFun[0];
- if (ParseUnitAddressHexList (OfwNode[FirstNonBridge].UnitAddress,
- BridgeDevFun, &NumEntries) != RETURN_SUCCESS) {
+ NumEntries = sizeof BridgeDevFun / sizeof BridgeDevFun[0];
+ if (ParseUnitAddressHexList (
+ OfwNode[FirstNonBridge].UnitAddress,
+ BridgeDevFun,
+ &NumEntries
+ ) != RETURN_SUCCESS)
+ {
return RETURN_UNSUPPORTED;
}
BridgesFreeBytes = sizeof Bridges - BridgesLen * sizeof Bridges[0];
- Written = UnicodeSPrintAsciiFormat (Bridges + BridgesLen, BridgesFreeBytes,
- "/Pci(0x%Lx,0x%Lx)", BridgeDevFun[0], BridgeDevFun[1]);
+ Written = UnicodeSPrintAsciiFormat (
+ Bridges + BridgesLen,
+ BridgesFreeBytes,
+ "/Pci(0x%Lx,0x%Lx)",
+ BridgeDevFun[0],
+ BridgeDevFun[1]
+ );
BridgesLen += Written;
//
@@ -701,21 +723,23 @@ TranslatePciOfwNodes ( // Parse the OFW nodes starting with the first non-bridge node.
//
PciDevFun[1] = 0;
- NumEntries = ARRAY_SIZE (PciDevFun);
+ NumEntries = ARRAY_SIZE (PciDevFun);
if (ParseUnitAddressHexList (
OfwNode[FirstNonBridge].UnitAddress,
PciDevFun,
&NumEntries
) != RETURN_SUCCESS
- ) {
+ )
+ {
return RETURN_UNSUPPORTED;
}
- if (NumNodes >= FirstNonBridge + 3 &&
+ if ((NumNodes >= FirstNonBridge + 3) &&
SubstringEq (OfwNode[FirstNonBridge + 0].DriverName, "ide") &&
SubstringEq (OfwNode[FirstNonBridge + 1].DriverName, "drive") &&
SubstringEq (OfwNode[FirstNonBridge + 2].DriverName, "disk")
- ) {
+ )
+ {
//
// OpenFirmware device path (IDE disk, IDE CD-ROM):
//
@@ -732,42 +756,44 @@ TranslatePciOfwNodes ( // ^
// fixed LUN
//
- UINT64 Secondary;
- UINT64 Slave;
+ UINT64 Secondary;
+ UINT64 Slave;
NumEntries = 1;
- if (ParseUnitAddressHexList (
- OfwNode[FirstNonBridge + 1].UnitAddress,
- &Secondary,
- &NumEntries
- ) != RETURN_SUCCESS ||
- Secondary > 1 ||
- ParseUnitAddressHexList (
- OfwNode[FirstNonBridge + 2].UnitAddress,
- &Slave,
- &NumEntries // reuse after previous single-element call
- ) != RETURN_SUCCESS ||
- Slave > 1
- ) {
+ if ((ParseUnitAddressHexList (
+ OfwNode[FirstNonBridge + 1].UnitAddress,
+ &Secondary,
+ &NumEntries
+ ) != RETURN_SUCCESS) ||
+ (Secondary > 1) ||
+ (ParseUnitAddressHexList (
+ OfwNode[FirstNonBridge + 2].UnitAddress,
+ &Slave,
+ &NumEntries // reuse after previous single-element call
+ ) != RETURN_SUCCESS) ||
+ (Slave > 1)
+ )
+ {
return RETURN_UNSUPPORTED;
}
Written = UnicodeSPrintAsciiFormat (
- Translated,
- *TranslatedSize * sizeof (*Translated), // BufferSize in bytes
- "PciRoot(0x%x)%s/Pci(0x%Lx,0x%Lx)/Ata(%a,%a,0x0)",
- PciRoot,
- Bridges,
- PciDevFun[0],
- PciDevFun[1],
- Secondary ? "Secondary" : "Primary",
- Slave ? "Slave" : "Master"
- );
- } else if (NumNodes >= FirstNonBridge + 3 &&
- SubstringEq (OfwNode[FirstNonBridge + 0].DriverName, "pci8086,2922") &&
- SubstringEq (OfwNode[FirstNonBridge + 1].DriverName, "drive") &&
- SubstringEq (OfwNode[FirstNonBridge + 2].DriverName, "disk")
- ) {
+ Translated,
+ *TranslatedSize * sizeof (*Translated), // BufferSize in bytes
+ "PciRoot(0x%x)%s/Pci(0x%Lx,0x%Lx)/Ata(%a,%a,0x0)",
+ PciRoot,
+ Bridges,
+ PciDevFun[0],
+ PciDevFun[1],
+ Secondary ? "Secondary" : "Primary",
+ Slave ? "Slave" : "Master"
+ );
+ } else if ((NumNodes >= FirstNonBridge + 3) &&
+ SubstringEq (OfwNode[FirstNonBridge + 0].DriverName, "pci8086,2922") &&
+ SubstringEq (OfwNode[FirstNonBridge + 1].DriverName, "drive") &&
+ SubstringEq (OfwNode[FirstNonBridge + 2].DriverName, "disk")
+ )
+ {
//
// OpenFirmware device path (Q35 SATA disk and CD-ROM):
//
@@ -787,30 +813,36 @@ TranslatePciOfwNodes ( // | always 0xFFFF on Q35
// channel (port) number
//
- UINT64 Channel;
+ UINT64 Channel;
NumEntries = 1;
- if (RETURN_ERROR (ParseUnitAddressHexList (
- OfwNode[FirstNonBridge + 1].UnitAddress, &Channel,
- &NumEntries))) {
+ if (RETURN_ERROR (
+ ParseUnitAddressHexList (
+ OfwNode[FirstNonBridge + 1].UnitAddress,
+ &Channel,
+ &NumEntries
+ )
+ ))
+ {
return RETURN_UNSUPPORTED;
}
Written = UnicodeSPrintAsciiFormat (
- Translated,
- *TranslatedSize * sizeof (*Translated), // BufferSize in bytes
- "PciRoot(0x%x)%s/Pci(0x%Lx,0x%Lx)/Sata(0x%Lx,0xFFFF,0x0)",
- PciRoot,
- Bridges,
- PciDevFun[0],
- PciDevFun[1],
- Channel
- );
- } else if (NumNodes >= FirstNonBridge + 3 &&
+ Translated,
+ *TranslatedSize * sizeof (*Translated), // BufferSize in bytes
+ "PciRoot(0x%x)%s/Pci(0x%Lx,0x%Lx)/Sata(0x%Lx,0xFFFF,0x0)",
+ PciRoot,
+ Bridges,
+ PciDevFun[0],
+ PciDevFun[1],
+ Channel
+ );
+ } else if ((NumNodes >= FirstNonBridge + 3) &&
SubstringEq (OfwNode[FirstNonBridge + 0].DriverName, "isa") &&
SubstringEq (OfwNode[FirstNonBridge + 1].DriverName, "fdc") &&
SubstringEq (OfwNode[FirstNonBridge + 2].DriverName, "floppy")
- ) {
+ )
+ {
//
// OpenFirmware device path (floppy disk):
//
@@ -827,33 +859,35 @@ TranslatePciOfwNodes ( // ^
// ACPI UID
//
- UINT64 AcpiUid;
+ UINT64 AcpiUid;
NumEntries = 1;
- if (ParseUnitAddressHexList (
- OfwNode[FirstNonBridge + 2].UnitAddress,
- &AcpiUid,
- &NumEntries
- ) != RETURN_SUCCESS ||
- AcpiUid > 1
- ) {
+ if ((ParseUnitAddressHexList (
+ OfwNode[FirstNonBridge + 2].UnitAddress,
+ &AcpiUid,
+ &NumEntries
+ ) != RETURN_SUCCESS) ||
+ (AcpiUid > 1)
+ )
+ {
return RETURN_UNSUPPORTED;
}
Written = UnicodeSPrintAsciiFormat (
- Translated,
- *TranslatedSize * sizeof (*Translated), // BufferSize in bytes
- "PciRoot(0x%x)%s/Pci(0x%Lx,0x%Lx)/Floppy(0x%Lx)",
- PciRoot,
- Bridges,
- PciDevFun[0],
- PciDevFun[1],
- AcpiUid
- );
- } else if (NumNodes >= FirstNonBridge + 2 &&
+ Translated,
+ *TranslatedSize * sizeof (*Translated), // BufferSize in bytes
+ "PciRoot(0x%x)%s/Pci(0x%Lx,0x%Lx)/Floppy(0x%Lx)",
+ PciRoot,
+ Bridges,
+ PciDevFun[0],
+ PciDevFun[1],
+ AcpiUid
+ );
+ } else if ((NumNodes >= FirstNonBridge + 2) &&
SubstringEq (OfwNode[FirstNonBridge + 0].DriverName, "scsi") &&
SubstringEq (OfwNode[FirstNonBridge + 1].DriverName, "disk")
- ) {
+ )
+ {
//
// OpenFirmware device path (virtio-blk disk):
//
@@ -870,19 +904,20 @@ TranslatePciOfwNodes ( // PciRoot(0x0)/Pci(0x6,0x3) -- if PCI function is present and nonzero
//
Written = UnicodeSPrintAsciiFormat (
- Translated,
- *TranslatedSize * sizeof (*Translated), // BufferSize in bytes
- "PciRoot(0x%x)%s/Pci(0x%Lx,0x%Lx)",
- PciRoot,
- Bridges,
- PciDevFun[0],
- PciDevFun[1]
- );
- } else if (NumNodes >= FirstNonBridge + 3 &&
+ Translated,
+ *TranslatedSize * sizeof (*Translated), // BufferSize in bytes
+ "PciRoot(0x%x)%s/Pci(0x%Lx,0x%Lx)",
+ PciRoot,
+ Bridges,
+ PciDevFun[0],
+ PciDevFun[1]
+ );
+ } else if ((NumNodes >= FirstNonBridge + 3) &&
SubstringEq (OfwNode[FirstNonBridge + 0].DriverName, "scsi") &&
SubstringEq (OfwNode[FirstNonBridge + 1].DriverName, "channel") &&
SubstringEq (OfwNode[FirstNonBridge + 2].DriverName, "disk")
- ) {
+ )
+ {
//
// OpenFirmware device path (virtio-scsi disk):
//
@@ -901,34 +936,36 @@ TranslatePciOfwNodes ( // PciRoot(0x0)/Pci(0x7,0x3)/Scsi(0x2,0x3)
// -- if PCI function is present and nonzero
//
- UINT64 TargetLun[2];
+ UINT64 TargetLun[2];
TargetLun[1] = 0;
- NumEntries = ARRAY_SIZE (TargetLun);
+ NumEntries = ARRAY_SIZE (TargetLun);
if (ParseUnitAddressHexList (
OfwNode[FirstNonBridge + 2].UnitAddress,
TargetLun,
&NumEntries
) != RETURN_SUCCESS
- ) {
+ )
+ {
return RETURN_UNSUPPORTED;
}
Written = UnicodeSPrintAsciiFormat (
- Translated,
- *TranslatedSize * sizeof (*Translated), // BufferSize in bytes
- "PciRoot(0x%x)%s/Pci(0x%Lx,0x%Lx)/Scsi(0x%Lx,0x%Lx)",
- PciRoot,
- Bridges,
- PciDevFun[0],
- PciDevFun[1],
- TargetLun[0],
- TargetLun[1]
- );
- } else if (NumNodes >= FirstNonBridge + 2 &&
- SubstringEq (OfwNode[FirstNonBridge + 0].DriverName, "pci8086,5845") &&
- SubstringEq (OfwNode[FirstNonBridge + 1].DriverName, "namespace")
- ) {
+ Translated,
+ *TranslatedSize * sizeof (*Translated), // BufferSize in bytes
+ "PciRoot(0x%x)%s/Pci(0x%Lx,0x%Lx)/Scsi(0x%Lx,0x%Lx)",
+ PciRoot,
+ Bridges,
+ PciDevFun[0],
+ PciDevFun[1],
+ TargetLun[0],
+ TargetLun[1]
+ );
+ } else if ((NumNodes >= FirstNonBridge + 2) &&
+ SubstringEq (OfwNode[FirstNonBridge + 0].DriverName, "pci8086,5845") &&
+ SubstringEq (OfwNode[FirstNonBridge + 1].DriverName, "namespace")
+ )
+ {
//
// OpenFirmware device path (NVMe device):
//
@@ -948,41 +985,49 @@ TranslatePciOfwNodes ( // | in address order
// namespace ID
//
- UINT64 Namespace[2];
- UINTN RequiredEntries;
- UINT8 *Eui64;
+ UINT64 Namespace[2];
+ UINTN RequiredEntries;
+ UINT8 *Eui64;
RequiredEntries = ARRAY_SIZE (Namespace);
- NumEntries = RequiredEntries;
- if (ParseUnitAddressHexList (
- OfwNode[FirstNonBridge + 1].UnitAddress,
- Namespace,
- &NumEntries
- ) != RETURN_SUCCESS ||
- NumEntries != RequiredEntries ||
- Namespace[0] == 0 ||
- Namespace[0] >= MAX_UINT32
- ) {
+ NumEntries = RequiredEntries;
+ if ((ParseUnitAddressHexList (
+ OfwNode[FirstNonBridge + 1].UnitAddress,
+ Namespace,
+ &NumEntries
+ ) != RETURN_SUCCESS) ||
+ (NumEntries != RequiredEntries) ||
+ (Namespace[0] == 0) ||
+ (Namespace[0] >= MAX_UINT32)
+ )
+ {
return RETURN_UNSUPPORTED;
}
- Eui64 = (UINT8 *)&Namespace[1];
+ Eui64 = (UINT8 *)&Namespace[1];
Written = UnicodeSPrintAsciiFormat (
- Translated,
- *TranslatedSize * sizeof (*Translated), // BufferSize in bytes
- "PciRoot(0x%x)%s/Pci(0x%Lx,0x%Lx)/"
- "NVMe(0x%Lx,%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x)",
- PciRoot,
- Bridges,
- PciDevFun[0],
- PciDevFun[1],
- Namespace[0],
- Eui64[7], Eui64[6], Eui64[5], Eui64[4],
- Eui64[3], Eui64[2], Eui64[1], Eui64[0]
- );
- } else if (NumNodes >= FirstNonBridge + 2 &&
+ Translated,
+ *TranslatedSize * sizeof (*Translated), // BufferSize in bytes
+ "PciRoot(0x%x)%s/Pci(0x%Lx,0x%Lx)/"
+ "NVMe(0x%Lx,%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x)",
+ PciRoot,
+ Bridges,
+ PciDevFun[0],
+ PciDevFun[1],
+ Namespace[0],
+ Eui64[7],
+ Eui64[6],
+ Eui64[5],
+ Eui64[4],
+ Eui64[3],
+ Eui64[2],
+ Eui64[1],
+ Eui64[0]
+ );
+ } else if ((NumNodes >= FirstNonBridge + 2) &&
SubstringEq (OfwNode[FirstNonBridge + 0].DriverName, "usb") &&
- SubstringEq (OfwNode[FirstNonBridge + 1].DriverName, "storage")) {
+ SubstringEq (OfwNode[FirstNonBridge + 1].DriverName, "storage"))
+ {
//
// OpenFirmware device path (usb-storage device in XHCI port):
//
@@ -1001,16 +1046,16 @@ TranslatePciOfwNodes ( // | XHCI port number in 0-based notation
// 0x0 if PCI function is 0, or absent from OFW
//
- RETURN_STATUS ParseStatus;
- UINT64 OneBasedXhciPort;
+ RETURN_STATUS ParseStatus;
+ UINT64 OneBasedXhciPort;
- NumEntries = 1;
+ NumEntries = 1;
ParseStatus = ParseUnitAddressHexList (
OfwNode[FirstNonBridge + 1].UnitAddress,
&OneBasedXhciPort,
&NumEntries
);
- if (RETURN_ERROR (ParseStatus) || OneBasedXhciPort == 0) {
+ if (RETURN_ERROR (ParseStatus) || (OneBasedXhciPort == 0)) {
return RETURN_UNSUPPORTED;
}
@@ -1039,14 +1084,14 @@ TranslatePciOfwNodes ( // PciRoot(0x0)/Pci(0x3,0x2)
//
Written = UnicodeSPrintAsciiFormat (
- Translated,
- *TranslatedSize * sizeof (*Translated), // BufferSize in bytes
- "PciRoot(0x%x)%s/Pci(0x%Lx,0x%Lx)",
- PciRoot,
- Bridges,
- PciDevFun[0],
- PciDevFun[1]
- );
+ Translated,
+ *TranslatedSize * sizeof (*Translated), // BufferSize in bytes
+ "PciRoot(0x%x)%s/Pci(0x%Lx,0x%Lx)",
+ PciRoot,
+ Bridges,
+ PciDevFun[0],
+ PciDevFun[1]
+ );
}
//
@@ -1062,17 +1107,15 @@ TranslatePciOfwNodes ( return RETURN_BUFFER_TOO_SMALL;
}
-
//
// A type providing easy raw access to the base address of a virtio-mmio
// transport.
//
typedef union {
- UINT64 Uint64;
- UINT8 Raw[8];
+ UINT64 Uint64;
+ UINT8 Raw[8];
} VIRTIO_MMIO_BASE_ADDRESS;
-
/**
Translate an MMIO-like array of OpenFirmware device nodes to a UEFI device
@@ -1108,43 +1151,56 @@ typedef union { STATIC
RETURN_STATUS
TranslateMmioOfwNodes (
- IN CONST OFW_NODE *OfwNode,
- IN UINTN NumNodes,
- OUT CHAR16 *Translated,
- IN OUT UINTN *TranslatedSize
+ IN CONST OFW_NODE *OfwNode,
+ IN UINTN NumNodes,
+ OUT CHAR16 *Translated,
+ IN OUT UINTN *TranslatedSize
)
{
- VIRTIO_MMIO_BASE_ADDRESS VirtioMmioBase;
- CHAR16 VenHwString[60 + 1];
- UINTN NumEntries;
- UINTN Written;
+ VIRTIO_MMIO_BASE_ADDRESS VirtioMmioBase;
+ CHAR16 VenHwString[60 + 1];
+ UINTN NumEntries;
+ UINTN Written;
//
// Get the base address of the virtio-mmio transport.
//
- if (NumNodes < REQUIRED_MMIO_OFW_NODES ||
+ if ((NumNodes < REQUIRED_MMIO_OFW_NODES) ||
!SubstringEq (OfwNode[0].DriverName, "virtio-mmio")
- ) {
+ )
+ {
return RETURN_UNSUPPORTED;
}
+
NumEntries = 1;
if (ParseUnitAddressHexList (
OfwNode[0].UnitAddress,
&VirtioMmioBase.Uint64,
&NumEntries
) != RETURN_SUCCESS
- ) {
+ )
+ {
return RETURN_UNSUPPORTED;
}
- UnicodeSPrintAsciiFormat (VenHwString, sizeof VenHwString,
- "VenHw(%g,%02X%02X%02X%02X%02X%02X%02X%02X)", &gVirtioMmioTransportGuid,
- VirtioMmioBase.Raw[0], VirtioMmioBase.Raw[1], VirtioMmioBase.Raw[2],
- VirtioMmioBase.Raw[3], VirtioMmioBase.Raw[4], VirtioMmioBase.Raw[5],
- VirtioMmioBase.Raw[6], VirtioMmioBase.Raw[7]);
-
- if (NumNodes >= 2 &&
- SubstringEq (OfwNode[1].DriverName, "disk")) {
+ UnicodeSPrintAsciiFormat (
+ VenHwString,
+ sizeof VenHwString,
+ "VenHw(%g,%02X%02X%02X%02X%02X%02X%02X%02X)",
+ &gVirtioMmioTransportGuid,
+ VirtioMmioBase.Raw[0],
+ VirtioMmioBase.Raw[1],
+ VirtioMmioBase.Raw[2],
+ VirtioMmioBase.Raw[3],
+ VirtioMmioBase.Raw[4],
+ VirtioMmioBase.Raw[5],
+ VirtioMmioBase.Raw[6],
+ VirtioMmioBase.Raw[7]
+ );
+
+ if ((NumNodes >= 2) &&
+ SubstringEq (OfwNode[1].DriverName, "disk"))
+ {
//
// OpenFirmware device path (virtio-blk disk):
//
@@ -1163,9 +1219,10 @@ TranslateMmioOfwNodes ( "%s",
VenHwString
);
- } else if (NumNodes >= 3 &&
+ } else if ((NumNodes >= 3) &&
SubstringEq (OfwNode[1].DriverName, "channel") &&
- SubstringEq (OfwNode[2].DriverName, "disk")) {
+ SubstringEq (OfwNode[2].DriverName, "disk"))
+ {
//
// OpenFirmware device path (virtio-scsi disk):
//
@@ -1180,16 +1237,17 @@ TranslateMmioOfwNodes ( //
// <VenHwString>/Scsi(0x2,0x3)
//
- UINT64 TargetLun[2];
+ UINT64 TargetLun[2];
TargetLun[1] = 0;
- NumEntries = ARRAY_SIZE (TargetLun);
+ NumEntries = ARRAY_SIZE (TargetLun);
if (ParseUnitAddressHexList (
OfwNode[2].UnitAddress,
TargetLun,
&NumEntries
) != RETURN_SUCCESS
- ) {
+ )
+ {
return RETURN_UNSUPPORTED;
}
@@ -1201,8 +1259,9 @@ TranslateMmioOfwNodes ( TargetLun[0],
TargetLun[1]
);
- } else if (NumNodes >= 2 &&
- SubstringEq (OfwNode[1].DriverName, "ethernet-phy")) {
+ } else if ((NumNodes >= 2) &&
+ SubstringEq (OfwNode[1].DriverName, "ethernet-phy"))
+ {
//
// OpenFirmware device path (virtio-net NIC):
//
@@ -1238,7 +1297,6 @@ TranslateMmioOfwNodes ( return RETURN_BUFFER_TOO_SMALL;
}
-
/**
Translate an array of OpenFirmware device nodes to a UEFI device path
@@ -1283,26 +1341,38 @@ TranslateMmioOfwNodes ( STATIC
RETURN_STATUS
TranslateOfwNodes (
- IN CONST OFW_NODE *OfwNode,
- IN UINTN NumNodes,
- IN CONST EXTRA_ROOT_BUS_MAP *ExtraPciRoots,
- OUT CHAR16 *Translated,
- IN OUT UINTN *TranslatedSize
+ IN CONST OFW_NODE *OfwNode,
+ IN UINTN NumNodes,
+ IN CONST EXTRA_ROOT_BUS_MAP *ExtraPciRoots,
+ OUT CHAR16 *Translated,
+ IN OUT UINTN *TranslatedSize
)
{
- RETURN_STATUS Status;
+ RETURN_STATUS Status;
Status = RETURN_UNSUPPORTED;
if (FeaturePcdGet (PcdQemuBootOrderPciTranslation)) {
- Status = TranslatePciOfwNodes (OfwNode, NumNodes, ExtraPciRoots,
- Translated, TranslatedSize);
+ Status = TranslatePciOfwNodes (
+ OfwNode,
+ NumNodes,
+ ExtraPciRoots,
+ Translated,
+ TranslatedSize
+ );
}
- if (Status == RETURN_UNSUPPORTED &&
- FeaturePcdGet (PcdQemuBootOrderMmioTranslation)) {
- Status = TranslateMmioOfwNodes (OfwNode, NumNodes, Translated,
- TranslatedSize);
+
+ if ((Status == RETURN_UNSUPPORTED) &&
+ FeaturePcdGet (PcdQemuBootOrderMmioTranslation))
+ {
+ Status = TranslateMmioOfwNodes (
+ OfwNode,
+ NumNodes,
+ Translated,
+ TranslatedSize
+ );
}
+
return Status;
}
@@ -1368,22 +1438,22 @@ TranslateOfwNodes ( STATIC
RETURN_STATUS
TranslateOfwPath (
- IN OUT CONST CHAR8 **Ptr,
- IN CONST EXTRA_ROOT_BUS_MAP *ExtraPciRoots,
- OUT CHAR16 *Translated,
- IN OUT UINTN *TranslatedSize
+ IN OUT CONST CHAR8 **Ptr,
+ IN CONST EXTRA_ROOT_BUS_MAP *ExtraPciRoots,
+ OUT CHAR16 *Translated,
+ IN OUT UINTN *TranslatedSize
)
{
- UINTN NumNodes;
- RETURN_STATUS Status;
- OFW_NODE Node[EXAMINED_OFW_NODES];
- BOOLEAN IsFinal;
- OFW_NODE Skip;
+ UINTN NumNodes;
+ RETURN_STATUS Status;
+ OFW_NODE Node[EXAMINED_OFW_NODES];
+ BOOLEAN IsFinal;
+ OFW_NODE Skip;
- IsFinal = FALSE;
+ IsFinal = FALSE;
NumNodes = 0;
if (AsciiStrCmp (*Ptr, "HALT") == 0) {
- *Ptr += 4;
+ *Ptr += 4;
Status = RETURN_NOT_FOUND;
} else {
Status = ParseOfwNode (Ptr, &Node[NumNodes], &IsFinal);
@@ -1404,16 +1474,16 @@ TranslateOfwPath ( }
switch (Status) {
- case RETURN_SUCCESS:
- ++NumNodes;
- break;
+ case RETURN_SUCCESS:
+ ++NumNodes;
+ break;
- case RETURN_INVALID_PARAMETER:
- DEBUG ((DEBUG_VERBOSE, "%a: parse error\n", __FUNCTION__));
- return RETURN_INVALID_PARAMETER;
+ case RETURN_INVALID_PARAMETER:
+ DEBUG ((DEBUG_VERBOSE, "%a: parse error\n", __FUNCTION__));
+ return RETURN_INVALID_PARAMETER;
- default:
- ASSERT (0);
+ default:
+ ASSERT (0);
}
Status = TranslateOfwNodes (
@@ -1421,32 +1491,36 @@ TranslateOfwPath ( NumNodes < EXAMINED_OFW_NODES ? NumNodes : EXAMINED_OFW_NODES,
ExtraPciRoots,
Translated,
- TranslatedSize);
+ TranslatedSize
+ );
switch (Status) {
- case RETURN_SUCCESS:
- DEBUG ((DEBUG_VERBOSE, "%a: success: \"%s\"\n", __FUNCTION__, Translated));
- break;
+ case RETURN_SUCCESS:
+ DEBUG ((DEBUG_VERBOSE, "%a: success: \"%s\"\n", __FUNCTION__, Translated));
+ break;
- case RETURN_BUFFER_TOO_SMALL:
- DEBUG ((DEBUG_VERBOSE, "%a: buffer too small\n", __FUNCTION__));
- break;
+ case RETURN_BUFFER_TOO_SMALL:
+ DEBUG ((DEBUG_VERBOSE, "%a: buffer too small\n", __FUNCTION__));
+ break;
- case RETURN_UNSUPPORTED:
- DEBUG ((DEBUG_VERBOSE, "%a: unsupported\n", __FUNCTION__));
- break;
+ case RETURN_UNSUPPORTED:
+ DEBUG ((DEBUG_VERBOSE, "%a: unsupported\n", __FUNCTION__));
+ break;
- case RETURN_PROTOCOL_ERROR:
- DEBUG ((DEBUG_VERBOSE, "%a: logic error / system state mismatch\n",
- __FUNCTION__));
- break;
+ case RETURN_PROTOCOL_ERROR:
+ DEBUG ((
+ DEBUG_VERBOSE,
+ "%a: logic error / system state mismatch\n",
+ __FUNCTION__
+ ));
+ break;
- default:
- ASSERT (0);
+ default:
+ ASSERT (0);
}
+
return Status;
}
-
/**
Connect devices based on the boot order retrieved from QEMU.
@@ -1481,16 +1555,16 @@ ConnectDevicesFromQemu ( VOID
)
{
- RETURN_STATUS Status;
- FIRMWARE_CONFIG_ITEM FwCfgItem;
- UINTN FwCfgSize;
- CHAR8 *FwCfg;
- EFI_STATUS EfiStatus;
- EXTRA_ROOT_BUS_MAP *ExtraPciRoots;
- CONST CHAR8 *FwCfgPtr;
- UINTN NumConnected;
- UINTN TranslatedSize;
- CHAR16 Translated[TRANSLATION_OUTPUT_SIZE];
+ RETURN_STATUS Status;
+ FIRMWARE_CONFIG_ITEM FwCfgItem;
+ UINTN FwCfgSize;
+ CHAR8 *FwCfg;
+ EFI_STATUS EfiStatus;
+ EXTRA_ROOT_BUS_MAP *ExtraPciRoots;
+ CONST CHAR8 *FwCfgPtr;
+ UINTN NumConnected;
+ UINTN TranslatedSize;
+ CHAR16 Translated[TRANSLATION_OUTPUT_SIZE];
Status = QemuFwCfgFindFile ("bootorder", &FwCfgItem, &FwCfgSize);
if (RETURN_ERROR (Status)) {
@@ -1512,6 +1586,7 @@ ConnectDevicesFromQemu ( Status = RETURN_INVALID_PARAMETER;
goto FreeFwCfg;
}
+
DEBUG ((DEBUG_VERBOSE, "%a: FwCfg:\n", __FUNCTION__));
DEBUG ((DEBUG_VERBOSE, "%a\n", FwCfg));
DEBUG ((DEBUG_VERBOSE, "%a: FwCfg: <end>\n", __FUNCTION__));
@@ -1529,14 +1604,18 @@ ConnectDevicesFromQemu ( //
// Translate each OpenFirmware path to a UEFI devpath prefix.
//
- FwCfgPtr = FwCfg;
- NumConnected = 0;
+ FwCfgPtr = FwCfg;
+ NumConnected = 0;
TranslatedSize = ARRAY_SIZE (Translated);
- Status = TranslateOfwPath (&FwCfgPtr, ExtraPciRoots, Translated,
- &TranslatedSize);
+ Status = TranslateOfwPath (
+ &FwCfgPtr,
+ ExtraPciRoots,
+ Translated,
+ &TranslatedSize
+ );
while (!RETURN_ERROR (Status)) {
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- EFI_HANDLE Controller;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_HANDLE Controller;
//
// Convert the UEFI devpath prefix to binary representation.
@@ -1547,6 +1626,7 @@ ConnectDevicesFromQemu ( Status = RETURN_OUT_OF_RESOURCES;
goto FreeExtraPciRoots;
}
+
//
// Advance along DevicePath, connecting the nodes individually, and asking
// drivers not to produce sibling nodes. Retrieve the controller handle
@@ -1559,6 +1639,7 @@ ConnectDevicesFromQemu ( Status = (RETURN_STATUS)EfiStatus;
goto FreeExtraPciRoots;
}
+
//
// Because QEMU's OFW devpaths have lesser expressive power than UEFI
// devpaths (i.e., DevicePath is considered a prefix), connect the tree
@@ -1566,22 +1647,31 @@ ConnectDevicesFromQemu ( // (EFI_NOT_FOUND), that's OK.
//
EfiStatus = gBS->ConnectController (Controller, NULL, NULL, TRUE);
- if (EFI_ERROR (EfiStatus) && EfiStatus != EFI_NOT_FOUND) {
+ if (EFI_ERROR (EfiStatus) && (EfiStatus != EFI_NOT_FOUND)) {
Status = (RETURN_STATUS)EfiStatus;
goto FreeExtraPciRoots;
}
+
++NumConnected;
//
// Move to the next OFW devpath.
//
TranslatedSize = ARRAY_SIZE (Translated);
- Status = TranslateOfwPath (&FwCfgPtr, ExtraPciRoots, Translated,
- &TranslatedSize);
+ Status = TranslateOfwPath (
+ &FwCfgPtr,
+ ExtraPciRoots,
+ Translated,
+ &TranslatedSize
+ );
}
- if (Status == RETURN_NOT_FOUND && NumConnected > 0) {
- DEBUG ((DEBUG_INFO, "%a: %Lu OpenFirmware device path(s) connected\n",
- __FUNCTION__, (UINT64)NumConnected));
+ if ((Status == RETURN_NOT_FOUND) && (NumConnected > 0)) {
+ DEBUG ((
+ DEBUG_INFO,
+ "%a: %Lu OpenFirmware device path(s) connected\n",
+ __FUNCTION__,
+ (UINT64)NumConnected
+ ));
Status = RETURN_SUCCESS;
}
@@ -1596,7 +1686,6 @@ FreeFwCfg: return Status;
}
-
/**
Convert the UEFI DevicePath to full text representation with DevPathToText,
@@ -1623,19 +1712,19 @@ FreeFwCfg: STATIC
BOOLEAN
Match (
- IN CONST CHAR16 *Translated,
- IN UINTN TranslatedLength,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ IN CONST CHAR16 *Translated,
+ IN UINTN TranslatedLength,
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
)
{
- CHAR16 *Converted;
- BOOLEAN Result;
- VOID *FileBuffer;
- UINTN FileSize;
- EFI_DEVICE_PATH_PROTOCOL *AbsDevicePath;
- CHAR16 *AbsConverted;
- BOOLEAN Shortform;
- EFI_DEVICE_PATH_PROTOCOL *Node;
+ CHAR16 *Converted;
+ BOOLEAN Result;
+ VOID *FileBuffer;
+ UINTN FileSize;
+ EFI_DEVICE_PATH_PROTOCOL *AbsDevicePath;
+ CHAR16 *AbsConverted;
+ BOOLEAN Shortform;
+ EFI_DEVICE_PATH_PROTOCOL *Node;
Converted = ConvertDevicePathToText (
DevicePath,
@@ -1646,37 +1735,42 @@ Match ( return FALSE;
}
- Result = FALSE;
+ Result = FALSE;
Shortform = FALSE;
//
// Expand the short-form device path to full device path
//
if ((DevicePathType (DevicePath) == MEDIA_DEVICE_PATH) &&
- (DevicePathSubType (DevicePath) == MEDIA_HARDDRIVE_DP)) {
+ (DevicePathSubType (DevicePath) == MEDIA_HARDDRIVE_DP))
+ {
//
// Harddrive shortform device path
//
Shortform = TRUE;
} else if ((DevicePathType (DevicePath) == MEDIA_DEVICE_PATH) &&
- (DevicePathSubType (DevicePath) == MEDIA_FILEPATH_DP)) {
+ (DevicePathSubType (DevicePath) == MEDIA_FILEPATH_DP))
+ {
//
// File-path shortform device path
//
Shortform = TRUE;
} else if ((DevicePathType (DevicePath) == MESSAGING_DEVICE_PATH) &&
- (DevicePathSubType (DevicePath) == MSG_URI_DP)) {
+ (DevicePathSubType (DevicePath) == MSG_URI_DP))
+ {
//
// URI shortform device path
//
Shortform = TRUE;
} else {
for ( Node = DevicePath
- ; !IsDevicePathEnd (Node)
- ; Node = NextDevicePathNode (Node)
- ) {
+ ; !IsDevicePathEnd (Node)
+ ; Node = NextDevicePathNode (Node)
+ )
+ {
if ((DevicePathType (Node) == MESSAGING_DEVICE_PATH) &&
((DevicePathSubType (Node) == MSG_USB_CLASS_DP) ||
- (DevicePathSubType (Node) == MSG_USB_WWID_DP))) {
+ (DevicePathSubType (Node) == MSG_USB_WWID_DP)))
+ {
Shortform = TRUE;
break;
}
@@ -1689,20 +1783,27 @@ Match ( //
if (Shortform) {
FileBuffer = EfiBootManagerGetLoadOptionBuffer (
- DevicePath, &AbsDevicePath, &FileSize
+ DevicePath,
+ &AbsDevicePath,
+ &FileSize
);
if (FileBuffer == NULL) {
goto Exit;
}
+
FreePool (FileBuffer);
AbsConverted = ConvertDevicePathToText (AbsDevicePath, FALSE, FALSE);
FreePool (AbsDevicePath);
if (AbsConverted == NULL) {
goto Exit;
}
- DEBUG ((DEBUG_VERBOSE,
+
+ DEBUG ((
+ DEBUG_VERBOSE,
"%a: expanded relative device path \"%s\" for prefix matching\n",
- __FUNCTION__, Converted));
+ __FUNCTION__,
+ Converted
+ ));
FreePool (Converted);
Converted = AbsConverted;
}
@@ -1723,7 +1824,6 @@ Exit: return Result;
}
-
/**
Append some of the unselected active boot options to the boot order.
@@ -1753,27 +1853,27 @@ Exit: STATIC
RETURN_STATUS
BootOrderComplete (
- IN OUT BOOT_ORDER *BootOrder,
- IN OUT ACTIVE_OPTION *ActiveOption,
- IN UINTN ActiveCount
+ IN OUT BOOT_ORDER *BootOrder,
+ IN OUT ACTIVE_OPTION *ActiveOption,
+ IN UINTN ActiveCount
)
{
- RETURN_STATUS Status;
- UINTN Idx;
+ RETURN_STATUS Status;
+ UINTN Idx;
Status = RETURN_SUCCESS;
- Idx = 0;
+ Idx = 0;
while (!RETURN_ERROR (Status) && Idx < ActiveCount) {
if (!ActiveOption[Idx].Appended) {
- CONST EFI_BOOT_MANAGER_LOAD_OPTION *Current;
- CONST EFI_DEVICE_PATH_PROTOCOL *FirstNode;
+ CONST EFI_BOOT_MANAGER_LOAD_OPTION *Current;
+ CONST EFI_DEVICE_PATH_PROTOCOL *FirstNode;
- Current = ActiveOption[Idx].BootOption;
+ Current = ActiveOption[Idx].BootOption;
FirstNode = Current->FilePath;
if (FirstNode != NULL) {
- CHAR16 *Converted;
- STATIC CHAR16 ConvFallBack[] = L"<unable to convert>";
- BOOLEAN Keep;
+ CHAR16 *Converted;
+ STATIC CHAR16 ConvFallBack[] = L"<unable to convert>";
+ BOOLEAN Keep;
Converted = ConvertDevicePathToText (FirstNode, FALSE, FALSE);
if (Converted == NULL) {
@@ -1781,19 +1881,22 @@ BootOrderComplete ( }
Keep = TRUE;
- if (DevicePathType(FirstNode) == MEDIA_DEVICE_PATH &&
- DevicePathSubType(FirstNode) == MEDIA_HARDDRIVE_DP) {
+ if ((DevicePathType (FirstNode) == MEDIA_DEVICE_PATH) &&
+ (DevicePathSubType (FirstNode) == MEDIA_HARDDRIVE_DP))
+ {
//
// drop HD()
//
Keep = FALSE;
- } else if (DevicePathType(FirstNode) == ACPI_DEVICE_PATH &&
- DevicePathSubType(FirstNode) == ACPI_DP) {
- ACPI_HID_DEVICE_PATH *Acpi;
-
- Acpi = (ACPI_HID_DEVICE_PATH *) FirstNode;
- if ((Acpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST &&
- EISA_ID_TO_NUM (Acpi->HID) == 0x0a03) {
+ } else if ((DevicePathType (FirstNode) == ACPI_DEVICE_PATH) &&
+ (DevicePathSubType (FirstNode) == ACPI_DP))
+ {
+ ACPI_HID_DEVICE_PATH *Acpi;
+
+ Acpi = (ACPI_HID_DEVICE_PATH *)FirstNode;
+ if (((Acpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) &&
+ (EISA_ID_TO_NUM (Acpi->HID) == 0x0a03))
+ {
//
// drop PciRoot() if we enabled the user to select PCI-like boot
// options, by providing translation for such OFW device path
@@ -1801,9 +1904,10 @@ BootOrderComplete ( //
Keep = !FeaturePcdGet (PcdQemuBootOrderPciTranslation);
}
- } else if (DevicePathType(FirstNode) == HARDWARE_DEVICE_PATH &&
- DevicePathSubType(FirstNode) == HW_VENDOR_DP) {
- VENDOR_DEVICE_PATH *VenHw;
+ } else if ((DevicePathType (FirstNode) == HARDWARE_DEVICE_PATH) &&
+ (DevicePathSubType (FirstNode) == HW_VENDOR_DP))
+ {
+ VENDOR_DEVICE_PATH *VenHw;
VenHw = (VENDOR_DEVICE_PATH *)FirstNode;
if (CompareGuid (&VenHw->Guid, &gVirtioMmioTransportGuid)) {
@@ -1818,12 +1922,20 @@ BootOrderComplete ( if (Keep) {
Status = BootOrderAppend (BootOrder, &ActiveOption[Idx]);
if (!RETURN_ERROR (Status)) {
- DEBUG ((DEBUG_VERBOSE, "%a: keeping \"%s\"\n", __FUNCTION__,
- Converted));
+ DEBUG ((
+ DEBUG_VERBOSE,
+ "%a: keeping \"%s\"\n",
+ __FUNCTION__,
+ Converted
+ ));
}
} else {
- DEBUG ((DEBUG_VERBOSE, "%a: dropping \"%s\"\n", __FUNCTION__,
- Converted));
+ DEBUG ((
+ DEBUG_VERBOSE,
+ "%a: dropping \"%s\"\n",
+ __FUNCTION__,
+ Converted
+ ));
}
if (Converted != ConvFallBack) {
@@ -1831,12 +1943,13 @@ BootOrderComplete ( }
}
}
+
++Idx;
}
+
return Status;
}
-
/**
Delete Boot#### variables that stand for such active boot options that have
been dropped (ie. have not been selected by either matching or "survival
@@ -1851,24 +1964,30 @@ BootOrderComplete ( STATIC
VOID
PruneBootVariables (
- IN CONST ACTIVE_OPTION *ActiveOption,
- IN UINTN ActiveCount
+ IN CONST ACTIVE_OPTION *ActiveOption,
+ IN UINTN ActiveCount
)
{
- UINTN Idx;
+ UINTN Idx;
for (Idx = 0; Idx < ActiveCount; ++Idx) {
if (!ActiveOption[Idx].Appended) {
- CHAR16 VariableName[9];
+ CHAR16 VariableName[9];
- UnicodeSPrintAsciiFormat (VariableName, sizeof VariableName, "Boot%04x",
- ActiveOption[Idx].BootOption->OptionNumber);
+ UnicodeSPrintAsciiFormat (
+ VariableName,
+ sizeof VariableName,
+ "Boot%04x",
+ ActiveOption[Idx].BootOption->OptionNumber
+ );
//
// "The space consumed by the deleted variable may not be available until
// the next power cycle", but that's good enough.
//
- gRT->SetVariable (VariableName, &gEfiGlobalVariableGuid,
+ gRT->SetVariable (
+ VariableName,
+ &gEfiGlobalVariableGuid,
0, // Attributes, 0 means deletion
0, // DataSize, 0 means deletion
NULL // Data
@@ -1877,7 +1996,6 @@ PruneBootVariables ( }
}
-
/**
Set the boot order based on configuration retrieved from QEMU.
@@ -1912,22 +2030,22 @@ SetBootOrderFromQemu ( VOID
)
{
- RETURN_STATUS Status;
- FIRMWARE_CONFIG_ITEM FwCfgItem;
- UINTN FwCfgSize;
- CHAR8 *FwCfg;
- CONST CHAR8 *FwCfgPtr;
+ RETURN_STATUS Status;
+ FIRMWARE_CONFIG_ITEM FwCfgItem;
+ UINTN FwCfgSize;
+ CHAR8 *FwCfg;
+ CONST CHAR8 *FwCfgPtr;
- BOOT_ORDER BootOrder;
- ACTIVE_OPTION *ActiveOption;
- UINTN ActiveCount;
+ BOOT_ORDER BootOrder;
+ ACTIVE_OPTION *ActiveOption;
+ UINTN ActiveCount;
- EXTRA_ROOT_BUS_MAP *ExtraPciRoots;
+ EXTRA_ROOT_BUS_MAP *ExtraPciRoots;
- UINTN TranslatedSize;
- CHAR16 Translated[TRANSLATION_OUTPUT_SIZE];
- EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
- UINTN BootOptionCount;
+ UINTN TranslatedSize;
+ CHAR16 Translated[TRANSLATION_OUTPUT_SIZE];
+ EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
+ UINTN BootOptionCount;
Status = QemuFwCfgFindFile ("bootorder", &FwCfgItem, &FwCfgSize);
if (Status != RETURN_SUCCESS) {
@@ -1957,16 +2075,17 @@ SetBootOrderFromQemu ( BootOrder.Produced = 0;
BootOrder.Allocated = 1;
- BootOrder.Data = AllocatePool (
- BootOrder.Allocated * sizeof (*BootOrder.Data)
- );
+ BootOrder.Data = AllocatePool (
+ BootOrder.Allocated * sizeof (*BootOrder.Data)
+ );
if (BootOrder.Data == NULL) {
Status = RETURN_OUT_OF_RESOURCES;
goto ErrorFreeFwCfg;
}
BootOptions = EfiBootManagerGetLoadOptions (
- &BootOptionCount, LoadOptionTypeBoot
+ &BootOptionCount,
+ LoadOptionTypeBoot
);
if (BootOptions == NULL) {
Status = RETURN_NOT_FOUND;
@@ -1974,7 +2093,10 @@ SetBootOrderFromQemu ( }
Status = CollectActiveOptions (
- BootOptions, BootOptionCount, &ActiveOption, &ActiveCount
+ BootOptions,
+ BootOptionCount,
+ &ActiveOption,
+ &ActiveCount
);
if (RETURN_ERROR (Status)) {
goto ErrorFreeBootOptions;
@@ -1993,14 +2115,19 @@ SetBootOrderFromQemu ( // translate each OpenFirmware path
//
TranslatedSize = ARRAY_SIZE (Translated);
- Status = TranslateOfwPath (&FwCfgPtr, ExtraPciRoots, Translated,
- &TranslatedSize);
+ Status = TranslateOfwPath (
+ &FwCfgPtr,
+ ExtraPciRoots,
+ Translated,
+ &TranslatedSize
+ );
while (Status == RETURN_SUCCESS ||
Status == RETURN_UNSUPPORTED ||
Status == RETURN_PROTOCOL_ERROR ||
- Status == RETURN_BUFFER_TOO_SMALL) {
+ Status == RETURN_BUFFER_TOO_SMALL)
+ {
if (Status == RETURN_SUCCESS) {
- UINTN Idx;
+ UINTN Idx;
//
// match translated OpenFirmware path against all active boot options
@@ -2012,7 +2139,8 @@ SetBootOrderFromQemu ( TranslatedSize, // contains length, not size, in CHAR16's here
ActiveOption[Idx].BootOption->FilePath
)
- ) {
+ )
+ {
//
// match found, store ID and continue with next OpenFirmware path
//
@@ -2025,11 +2153,15 @@ SetBootOrderFromQemu ( } // translation successful
TranslatedSize = ARRAY_SIZE (Translated);
- Status = TranslateOfwPath (&FwCfgPtr, ExtraPciRoots, Translated,
- &TranslatedSize);
+ Status = TranslateOfwPath (
+ &FwCfgPtr,
+ ExtraPciRoots,
+ Translated,
+ &TranslatedSize
+ );
} // scanning of OpenFirmware paths done
- if (Status == RETURN_NOT_FOUND && BootOrder.Produced > 0) {
+ if ((Status == RETURN_NOT_FOUND) && (BootOrder.Produced > 0)) {
//
// No more OpenFirmware paths, some matches found: rewrite BootOrder NvVar.
// Some of the active boot options that have not been selected over fw_cfg
@@ -2048,14 +2180,18 @@ SetBootOrderFromQemu ( L"BootOrder",
&gEfiGlobalVariableGuid,
EFI_VARIABLE_NON_VOLATILE |
- EFI_VARIABLE_BOOTSERVICE_ACCESS |
- EFI_VARIABLE_RUNTIME_ACCESS,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS |
+ EFI_VARIABLE_RUNTIME_ACCESS,
BootOrder.Produced * sizeof (*BootOrder.Data),
BootOrder.Data
);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a: setting BootOrder: %r\n", __FUNCTION__,
- Status));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: setting BootOrder: %r\n",
+ __FUNCTION__,
+ Status
+ ));
goto ErrorFreeExtraPciRoots;
}
@@ -2083,7 +2219,6 @@ ErrorFreeFwCfg: return Status;
}
-
/**
Calculate the number of seconds we should be showing the FrontPage progress
bar for.
@@ -2096,8 +2231,8 @@ GetFrontPageTimeoutFromQemu ( VOID
)
{
- FIRMWARE_CONFIG_ITEM BootMenuWaitItem;
- UINTN BootMenuWaitSize;
+ FIRMWARE_CONFIG_ITEM BootMenuWaitItem;
+ UINTN BootMenuWaitSize;
QemuFwCfgSelectItem (QemuFwCfgItemBootMenu);
if (QemuFwCfgRead16 () == 0) {
@@ -2108,20 +2243,27 @@ GetFrontPageTimeoutFromQemu ( return PcdGet16 (PcdPlatformBootTimeOut);
}
- if (RETURN_ERROR (QemuFwCfgFindFile ("etc/boot-menu-wait", &BootMenuWaitItem,
- &BootMenuWaitSize)) ||
- BootMenuWaitSize != sizeof (UINT16)) {
+ if (RETURN_ERROR (
+ QemuFwCfgFindFile (
+ "etc/boot-menu-wait",
+ &BootMenuWaitItem,
+ &BootMenuWaitSize
+ )
+ ) ||
+ (BootMenuWaitSize != sizeof (UINT16)))
+ {
//
// "-boot menu=on" was specified without "splash-time=N". In this case,
// return three seconds if the platform default would cause us to skip the
// front page, and return the platform default otherwise.
//
- UINT16 Timeout;
+ UINT16 Timeout;
Timeout = PcdGet16 (PcdPlatformBootTimeOut);
if (Timeout == 0) {
Timeout = 3;
}
+
return Timeout;
}
|