summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg/Library/NonDiscoverableDeviceRegistrationLib/NonDiscoverableDeviceRegistrationLib.c
diff options
context:
space:
mode:
Diffstat (limited to 'MdeModulePkg/Library/NonDiscoverableDeviceRegistrationLib/NonDiscoverableDeviceRegistrationLib.c')
-rw-r--r--MdeModulePkg/Library/NonDiscoverableDeviceRegistrationLib/NonDiscoverableDeviceRegistrationLib.c114
1 files changed, 62 insertions, 52 deletions
diff --git a/MdeModulePkg/Library/NonDiscoverableDeviceRegistrationLib/NonDiscoverableDeviceRegistrationLib.c b/MdeModulePkg/Library/NonDiscoverableDeviceRegistrationLib/NonDiscoverableDeviceRegistrationLib.c
index 8074268986..a68612dd76 100644
--- a/MdeModulePkg/Library/NonDiscoverableDeviceRegistrationLib/NonDiscoverableDeviceRegistrationLib.c
+++ b/MdeModulePkg/Library/NonDiscoverableDeviceRegistrationLib/NonDiscoverableDeviceRegistrationLib.c
@@ -34,44 +34,44 @@ GetGuidFromType (
)
{
switch (Type) {
- case NonDiscoverableDeviceTypeAhci:
- return &gEdkiiNonDiscoverableAhciDeviceGuid;
+ case NonDiscoverableDeviceTypeAhci:
+ return &gEdkiiNonDiscoverableAhciDeviceGuid;
- case NonDiscoverableDeviceTypeAmba:
- return &gEdkiiNonDiscoverableAmbaDeviceGuid;
+ case NonDiscoverableDeviceTypeAmba:
+ return &gEdkiiNonDiscoverableAmbaDeviceGuid;
- case NonDiscoverableDeviceTypeEhci:
- return &gEdkiiNonDiscoverableEhciDeviceGuid;
+ case NonDiscoverableDeviceTypeEhci:
+ return &gEdkiiNonDiscoverableEhciDeviceGuid;
- case NonDiscoverableDeviceTypeNvme:
- return &gEdkiiNonDiscoverableNvmeDeviceGuid;
+ case NonDiscoverableDeviceTypeNvme:
+ return &gEdkiiNonDiscoverableNvmeDeviceGuid;
- case NonDiscoverableDeviceTypeOhci:
- return &gEdkiiNonDiscoverableOhciDeviceGuid;
+ case NonDiscoverableDeviceTypeOhci:
+ return &gEdkiiNonDiscoverableOhciDeviceGuid;
- case NonDiscoverableDeviceTypeSdhci:
- return &gEdkiiNonDiscoverableSdhciDeviceGuid;
+ case NonDiscoverableDeviceTypeSdhci:
+ return &gEdkiiNonDiscoverableSdhciDeviceGuid;
- case NonDiscoverableDeviceTypeUfs:
- return &gEdkiiNonDiscoverableUfsDeviceGuid;
+ case NonDiscoverableDeviceTypeUfs:
+ return &gEdkiiNonDiscoverableUfsDeviceGuid;
- case NonDiscoverableDeviceTypeUhci:
- return &gEdkiiNonDiscoverableUhciDeviceGuid;
+ case NonDiscoverableDeviceTypeUhci:
+ return &gEdkiiNonDiscoverableUhciDeviceGuid;
- case NonDiscoverableDeviceTypeXhci:
- return &gEdkiiNonDiscoverableXhciDeviceGuid;
+ case NonDiscoverableDeviceTypeXhci:
+ return &gEdkiiNonDiscoverableXhciDeviceGuid;
- default:
- return NULL;
+ default:
+ return NULL;
}
}
#pragma pack (1)
typedef struct {
- VENDOR_DEVICE_PATH Vendor;
- UINT64 BaseAddress;
- UINT8 ResourceType;
- EFI_DEVICE_PATH_PROTOCOL End;
+ VENDOR_DEVICE_PATH Vendor;
+ UINT64 BaseAddress;
+ UINT8 ResourceType;
+ EFI_DEVICE_PATH_PROTOCOL End;
} NON_DISCOVERABLE_DEVICE_PATH;
#pragma pack ()
@@ -108,25 +108,26 @@ RegisterNonDiscoverableMmioDevice (
...
)
{
- NON_DISCOVERABLE_DEVICE *Device;
- NON_DISCOVERABLE_DEVICE_PATH *DevicePath;
- EFI_HANDLE LocalHandle;
- EFI_STATUS Status;
- UINTN AllocSize;
- UINTN Index;
- VA_LIST Args;
- EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Desc;
- EFI_ACPI_END_TAG_DESCRIPTOR *End;
- UINTN Base, Size;
-
- if (Type >= NonDiscoverableDeviceTypeMax ||
- DmaType >= NonDiscoverableDeviceDmaTypeMax ||
- NumMmioResources == 0) {
+ NON_DISCOVERABLE_DEVICE *Device;
+ NON_DISCOVERABLE_DEVICE_PATH *DevicePath;
+ EFI_HANDLE LocalHandle;
+ EFI_STATUS Status;
+ UINTN AllocSize;
+ UINTN Index;
+ VA_LIST Args;
+ EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Desc;
+ EFI_ACPI_END_TAG_DESCRIPTOR *End;
+ UINTN Base, Size;
+
+ if ((Type >= NonDiscoverableDeviceTypeMax) ||
+ (DmaType >= NonDiscoverableDeviceDmaTypeMax) ||
+ (NumMmioResources == 0))
+ {
return EFI_INVALID_PARAMETER;
}
if (Handle == NULL) {
- Handle = &LocalHandle;
+ Handle = &LocalHandle;
LocalHandle = NULL;
}
@@ -141,13 +142,13 @@ RegisterNonDiscoverableMmioDevice (
Device->Type = GetGuidFromType (Type);
ASSERT (Device->Type != NULL);
- Device->DmaType = DmaType;
+ Device->DmaType = DmaType;
Device->Initialize = InitFunc;
- Device->Resources = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *)(Device + 1);
+ Device->Resources = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *)(Device + 1);
VA_START (Args, NumMmioResources);
for (Index = 0; Index < NumMmioResources; Index++) {
- Desc = &Device->Resources [Index];
+ Desc = &Device->Resources[Index];
Base = VA_ARG (Args, UINTN);
Size = VA_ARG (Args, UINTN);
@@ -160,9 +161,10 @@ RegisterNonDiscoverableMmioDevice (
Desc->AddrSpaceGranularity = ((EFI_PHYSICAL_ADDRESS)Base + Size > SIZE_4GB) ? 64 : 32;
Desc->AddrTranslationOffset = 0;
}
+
VA_END (Args);
- End = (EFI_ACPI_END_TAG_DESCRIPTOR *)&Device->Resources [NumMmioResources];
+ End = (EFI_ACPI_END_TAG_DESCRIPTOR *)&Device->Resources[NumMmioResources];
End->Desc = ACPI_END_TAG_DESCRIPTOR;
End->Checksum = 0;
@@ -170,7 +172,8 @@ RegisterNonDiscoverableMmioDevice (
DevicePath = (NON_DISCOVERABLE_DEVICE_PATH *)CreateDeviceNode (
HARDWARE_DEVICE_PATH,
HW_VENDOR_DP,
- sizeof (*DevicePath));
+ sizeof (*DevicePath)
+ );
if (DevicePath == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto FreeDevice;
@@ -182,20 +185,27 @@ RegisterNonDiscoverableMmioDevice (
// Use the base address and type of the first region to
// make the device path unique
//
- DevicePath->BaseAddress = Device->Resources [0].AddrRangeMin;
- DevicePath->ResourceType = Device->Resources [0].ResType;
+ DevicePath->BaseAddress = Device->Resources[0].AddrRangeMin;
+ DevicePath->ResourceType = Device->Resources[0].ResType;
- SetDevicePathNodeLength (&DevicePath->Vendor,
- sizeof (*DevicePath) - sizeof (DevicePath->End));
+ SetDevicePathNodeLength (
+ &DevicePath->Vendor,
+ sizeof (*DevicePath) - sizeof (DevicePath->End)
+ );
SetDevicePathEndNode (&DevicePath->End);
- Status = gBS->InstallMultipleProtocolInterfaces (Handle,
- &gEdkiiNonDiscoverableDeviceProtocolGuid, Device,
- &gEfiDevicePathProtocolGuid, DevicePath,
- NULL);
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ Handle,
+ &gEdkiiNonDiscoverableDeviceProtocolGuid,
+ Device,
+ &gEfiDevicePathProtocolGuid,
+ DevicePath,
+ NULL
+ );
if (EFI_ERROR (Status)) {
goto FreeDevicePath;
}
+
return EFI_SUCCESS;
FreeDevicePath: