summaryrefslogtreecommitdiff
path: root/OvmfPkg/QemuVideoDxe
diff options
context:
space:
mode:
authorLaszlo Ersek <lersek@redhat.com>2014-03-03 08:40:28 +0000
committerjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>2014-03-03 08:40:28 +0000
commit42d0cad751d610a8e6680ffd468fc40c970e96c0 (patch)
treee4fe9e5a83bb363d6e7942e5cfedb1668a977d87 /OvmfPkg/QemuVideoDxe
parentd89186bc869bfedd9f83f8e52f995dfd04691521 (diff)
downloadedk2-platforms-42d0cad751d610a8e6680ffd468fc40c970e96c0.tar.xz
OvmfPkg: QemuVideoDxe: simplify UEFI driver model use in Supported() / Start()
A bus driver is allowed to ignore the actual value of RemainingDevicePath in Supported() and Start(), and to produce all child handles at once. This in effect means the following invariants for QemuVideoDxe: - (RemainingDevicePath == NULL), and - (Private->GopDevicePath != NULL) Simplify Supported() and Start() by substituting constant TRUE and FALSE (as appropriate) in expressions that check RemainingDevicePath and/or Private->GopDevicePath. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Jordan Justen <jordan.l.justen@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15283 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'OvmfPkg/QemuVideoDxe')
-rw-r--r--OvmfPkg/QemuVideoDxe/Driver.c110
1 files changed, 24 insertions, 86 deletions
diff --git a/OvmfPkg/QemuVideoDxe/Driver.c b/OvmfPkg/QemuVideoDxe/Driver.c
index d7716ce6a9..508e1acb10 100644
--- a/OvmfPkg/QemuVideoDxe/Driver.c
+++ b/OvmfPkg/QemuVideoDxe/Driver.c
@@ -97,7 +97,6 @@ QemuVideoControllerDriverSupported (
EFI_STATUS Status;
EFI_PCI_IO_PROTOCOL *PciIo;
PCI_TYPE00 Pci;
- EFI_DEV_PATH *Node;
QEMU_VIDEO_CARD *Card;
//
@@ -130,40 +129,10 @@ QemuVideoControllerDriverSupported (
}
Status = EFI_UNSUPPORTED;
- //
- // See if the I/O enable is on. Most systems only allow one VGA device to be turned on
- // at a time, so see if this is one that is turned on.
- //
- // if (((Pci.Hdr.Command & 0x01) == 0x01)) {
- //
- // See if this is a Cirrus Logic PCI controller
- //
Card = QemuVideoDetect(Pci.Hdr.VendorId, Pci.Hdr.DeviceId);
if (Card != NULL) {
DEBUG ((EFI_D_INFO, "QemuVideo: %s detected\n", Card->Name));
Status = EFI_SUCCESS;
- //
- // If this is an Intel 945 graphics controller,
- // go further check RemainingDevicePath validation
- //
- if (RemainingDevicePath != NULL) {
- Node = (EFI_DEV_PATH *) RemainingDevicePath;
- //
- // Check if RemainingDevicePath is the End of Device Path Node,
- // if yes, return EFI_SUCCESS
- //
- if (!IsDevicePathEnd (Node)) {
- //
- // If RemainingDevicePath isn't the End of Device Path Node,
- // check its validation
- //
- if (Node->DevPath.Type != ACPI_DEVICE_PATH ||
- Node->DevPath.SubType != ACPI_ADR_DP ||
- DevicePathNodeLength(&Node->DevPath) != sizeof(ACPI_ADR_DEVICE_PATH)) {
- Status = EFI_UNSUPPORTED;
- }
- }
- }
}
Done:
@@ -204,6 +173,7 @@ QemuVideoControllerDriverStart (
EFI_STATUS Status;
QEMU_VIDEO_PRIVATE_DATA *Private;
EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
+ ACPI_ADR_DEVICE_PATH AcpiDeviceNode;
PCI_TYPE00 Pci;
QEMU_VIDEO_CARD *Card;
EFI_PCI_IO_PROTOCOL *ChildPciIo;
@@ -342,50 +312,32 @@ QemuVideoControllerDriverStart (
//
// Set Gop Device Path
//
- if (RemainingDevicePath == NULL) {
- ACPI_ADR_DEVICE_PATH AcpiDeviceNode;
-
- ZeroMem (&AcpiDeviceNode, sizeof (ACPI_ADR_DEVICE_PATH));
- AcpiDeviceNode.Header.Type = ACPI_DEVICE_PATH;
- AcpiDeviceNode.Header.SubType = ACPI_ADR_DP;
- AcpiDeviceNode.ADR = ACPI_DISPLAY_ADR (1, 0, 0, 1, 0, ACPI_ADR_DISPLAY_TYPE_VGA, 0, 0);
- SetDevicePathNodeLength (&AcpiDeviceNode.Header, sizeof (ACPI_ADR_DEVICE_PATH));
-
- Private->GopDevicePath = AppendDevicePathNode (
- ParentDevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *) &AcpiDeviceNode
- );
- if (Private->GopDevicePath == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto RestoreAttributes;
- }
- } else if (!IsDevicePathEnd (RemainingDevicePath)) {
- //
- // If RemainingDevicePath isn't the End of Device Path Node,
- // only scan the specified device by RemainingDevicePath
- //
- Private->GopDevicePath = AppendDevicePathNode (ParentDevicePath, RemainingDevicePath);
- if (Private->GopDevicePath == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto RestoreAttributes;
- }
+ ZeroMem (&AcpiDeviceNode, sizeof (ACPI_ADR_DEVICE_PATH));
+ AcpiDeviceNode.Header.Type = ACPI_DEVICE_PATH;
+ AcpiDeviceNode.Header.SubType = ACPI_ADR_DP;
+ AcpiDeviceNode.ADR = ACPI_DISPLAY_ADR (1, 0, 0, 1, 0, ACPI_ADR_DISPLAY_TYPE_VGA, 0, 0);
+ SetDevicePathNodeLength (&AcpiDeviceNode.Header, sizeof (ACPI_ADR_DEVICE_PATH));
+
+ Private->GopDevicePath = AppendDevicePathNode (
+ ParentDevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *) &AcpiDeviceNode
+ );
+ if (Private->GopDevicePath == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto RestoreAttributes;
}
//
- // Create new child handle and install the device path protocol on it only if
- // RemainingDevicePath equals NULL, or doesn't point to the End of Device
- // Path Node.
+ // Create new child handle and install the device path protocol on it.
//
- if (Private->GopDevicePath != NULL) {
- Status = gBS->InstallMultipleProtocolInterfaces (
- &Private->Handle,
- &gEfiDevicePathProtocolGuid,
- Private->GopDevicePath,
- NULL
- );
- if (EFI_ERROR (Status)) {
- goto FreeGopDevicePath;
- }
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &Private->Handle,
+ &gEfiDevicePathProtocolGuid,
+ Private->GopDevicePath,
+ NULL
+ );
+ if (EFI_ERROR (Status)) {
+ goto FreeGopDevicePath;
}
//
@@ -410,14 +362,6 @@ QemuVideoControllerDriverStart (
}
//
- // If RemainingDevicePath points to the End of Device Path Node, then we
- // haven't created a child handle, and we're done.
- //
- if (Private->GopDevicePath == NULL) {
- return EFI_SUCCESS;
- }
-
- //
// Start the GOP software stack.
//
Status = QemuVideoGraphicsOutputConstructor (Private);
@@ -463,17 +407,11 @@ FreeModeData:
FreePool (Private->ModeData);
UninstallGopDevicePath:
- //
- // Handles the case transparently when Private->Handle and
- // Private->GopDevicePath are NULL.
- //
gBS->UninstallProtocolInterface (Private->Handle,
&gEfiDevicePathProtocolGuid, Private->GopDevicePath);
FreeGopDevicePath:
- if (Private->GopDevicePath != NULL) {
- FreePool (Private->GopDevicePath);
- }
+ FreePool (Private->GopDevicePath);
RestoreAttributes:
Private->PciIo->Attributes (Private->PciIo, EfiPciIoAttributeOperationSet,