summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg
diff options
context:
space:
mode:
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2009-09-14 08:55:03 +0000
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2009-09-14 08:55:03 +0000
commitaf4a63857cd189964cc2c6b53b54483efaba78a3 (patch)
tree791e8df39b79520e7e3c7cbb9bb33bc2d0bb89c5 /MdeModulePkg
parent0cd118f7799602a88a5feb8ff1ef3e011a04b8ad (diff)
downloadedk2-af4a63857cd189964cc2c6b53b54483efaba78a3.tar.gz
edk2-af4a63857cd189964cc2c6b53b54483efaba78a3.tar.bz2
edk2-af4a63857cd189964cc2c6b53b54483efaba78a3.zip
updated the Bus Driver that is able to create all or one of its child handles on each call to Start() not to create new child handle if RemainingDeviepath is the End of Device Path Node, per UEFI 2.3.
The others changes include: 1. Check RemainingDevicePath at beginning of Supported(), make sure it has been verified before Start() is called. 2. Check IO protocol firstly rather than EfiDevicePathProtocolGuid, reduce the times entering into Start() function because EfiDevicePathProtocolGuid existed on most of handle. 3. If no any child device is created on last time, and RemainingDevicePath is valid Uart Devcie path, go on creating child device handle based on this RemainingDevicePath. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9262 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg')
-rw-r--r--MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBus.c50
-rw-r--r--MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c119
-rw-r--r--MdeModulePkg/Bus/Usb/UsbBusDxe/UsbUtility.c17
-rw-r--r--MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c79
4 files changed, 182 insertions, 83 deletions
diff --git a/MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBus.c b/MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBus.c
index 2325b645ed..d53fdc8eb3 100644
--- a/MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBus.c
+++ b/MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBus.c
@@ -2,7 +2,7 @@
SCSI Bus driver that layers on every SCSI Pass Thru and
Extended SCSI Pass Thru protocol in the system.
-Copyright (c) 2006 - 2008, Intel Corporation. <BR>
+Copyright (c) 2006 - 2009, Intel Corporation. <BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -142,9 +142,30 @@ SCSIBusDriverBindingSupported (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
- EFI_STATUS Status;
- EFI_SCSI_PASS_THRU_PROTOCOL *PassThru;
+ EFI_STATUS Status;
+ EFI_SCSI_PASS_THRU_PROTOCOL *PassThru;
EFI_EXT_SCSI_PASS_THRU_PROTOCOL *ExtPassThru;
+ EFI_DEV_PATH *Node;
+
+ if (RemainingDevicePath != NULL) {
+ Node = (EFI_DEV_PATH *) RemainingDevicePath;
+ //
+ // Check if RemainingDevicePath is the End of Device Path Node,
+ // if yes, go on checking other conditions
+ //
+ if (!IsDevicePathEnd (Node)) {
+ //
+ // If RemainingDevicePath isn't the End of Device Path Node,
+ // check its validation
+ //
+ if (Node->DevPath.Type != MESSAGING_DEVICE_PATH ||
+ Node->DevPath.SubType != MSG_SCSI_DP ||
+ DevicePathNodeLength(&Node->DevPath) != sizeof(ATAPI_DEVICE_PATH)) {
+ return EFI_UNSUPPORTED;
+ }
+ }
+ }
+
//
// Check for the existence of Extended SCSI Pass Thru Protocol and SCSI Pass Thru Protocol
//
@@ -188,6 +209,9 @@ SCSIBusDriverBindingSupported (
return EFI_SUCCESS;
}
+ //
+ // Close the I/O Abstraction(s) used to perform the supported test
+ //
gBS->CloseProtocol (
Controller,
&gEfiExtScsiPassThruProtocolGuid,
@@ -377,16 +401,32 @@ SCSIBusDriverBindingStart (
ScsiBusDev = SCSI_BUS_CONTROLLER_DEVICE_FROM_THIS (BusIdentify);
}
+ Lun = 0;
if (RemainingDevicePath == NULL) {
+ //
+ // If RemainingDevicePath is NULL,
+ // must enumerate all SCSI devices anyway
+ //
SetMem (ScsiTargetId, TARGET_MAX_BYTES,0xFF);
- Lun = 0;
FromFirstTarget = TRUE;
- } else {
+
+ } else if (!IsDevicePathEnd (RemainingDevicePath)) {
+ //
+ // If RemainingDevicePath isn't the End of Device Path Node,
+ // only scan the specified device by RemainingDevicePath
+ //
if (ScsiBusDev->ExtScsiSupport) {
ScsiBusDev->ExtScsiInterface->GetTargetLun (ScsiBusDev->ExtScsiInterface, RemainingDevicePath, &TargetId, &Lun);
} else {
ScsiBusDev->ScsiInterface->GetTargetLun (ScsiBusDev->ScsiInterface, RemainingDevicePath, &ScsiTargetId->ScsiId.Scsi, &Lun);
}
+
+ } else {
+ //
+ // If RemainingDevicePath is the End of Device Path Node,
+ // skip enumerate any device and return EFI_SUCESSS
+ //
+ ScanOtherPuns = FALSE;
}
while(ScanOtherPuns) {
diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c
index d0def777bd..b2f5fdbc75 100644
--- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c
+++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c
@@ -2,7 +2,7 @@
Usb Bus Driver Binding and Bus IO Protocol.
-Copyright (c) 2004 - 2007, Intel Corporation
+Copyright (c) 2004 - 2009, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -1124,42 +1124,28 @@ UsbBusControllerDriverSupported (
// Check whether device path is valid
//
if (RemainingDevicePath != NULL) {
- DevicePathNode.DevPath = RemainingDevicePath;
-
- if ((DevicePathNode.DevPath->Type != MESSAGING_DEVICE_PATH) ||
- (DevicePathNode.DevPath->SubType != MSG_USB_DP &&
- DevicePathNode.DevPath->SubType != MSG_USB_CLASS_DP
- && DevicePathNode.DevPath->SubType != MSG_USB_WWID_DP
- )) {
-
- return EFI_UNSUPPORTED;
+ //
+ // Check if RemainingDevicePath is the End of Device Path Node,
+ // if yes, go on checking other conditions
+ //
+ if (!IsDevicePathEnd (RemainingDevicePath)) {
+ //
+ // If RemainingDevicePath isn't the End of Device Path Node,
+ // check its validation
+ //
+ DevicePathNode.DevPath = RemainingDevicePath;
+
+ if ((DevicePathNode.DevPath->Type != MESSAGING_DEVICE_PATH) ||
+ (DevicePathNode.DevPath->SubType != MSG_USB_DP &&
+ DevicePathNode.DevPath->SubType != MSG_USB_CLASS_DP
+ && DevicePathNode.DevPath->SubType != MSG_USB_WWID_DP
+ )) {
+
+ return EFI_UNSUPPORTED;
+ }
}
}
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- (VOID **) &ParentDevicePath,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
-
- if (Status == EFI_ALREADY_STARTED) {
- return EFI_SUCCESS;
- }
-
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- gBS->CloseProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
-
//
// Check whether USB_HC2 protocol is installed
//
@@ -1171,45 +1157,80 @@ UsbBusControllerDriverSupported (
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
-
if (Status == EFI_ALREADY_STARTED) {
return EFI_SUCCESS;
}
- if (!EFI_ERROR (Status)) {
+ if (EFI_ERROR (Status)) {
+ //
+ // If failed to open USB_HC2, fall back to USB_HC
+ //
+ Status = gBS->OpenProtocol (
+ Controller,
+ &gEfiUsbHcProtocolGuid,
+ (VOID **) &UsbHc,
+ This->DriverBindingHandle,
+ Controller,
+ EFI_OPEN_PROTOCOL_BY_DRIVER
+ );
+ if (Status == EFI_ALREADY_STARTED) {
+ return EFI_SUCCESS;
+ }
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Close the USB_HC used to perform the supported test
+ //
gBS->CloseProtocol (
Controller,
- &gEfiUsb2HcProtocolGuid,
+ &gEfiUsbHcProtocolGuid,
This->DriverBindingHandle,
Controller
);
- return EFI_SUCCESS;
- }
+ } else {
+ //
+ // Close the USB_HC2 used to perform the supported test
+ //
+ gBS->CloseProtocol (
+ Controller,
+ &gEfiUsb2HcProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
+ }
+
//
- // If failed to open USB_HC2, fall back to USB_HC
+ // Open the EFI Device Path protocol needed to perform the supported test
//
Status = gBS->OpenProtocol (
Controller,
- &gEfiUsbHcProtocolGuid,
- (VOID **) &UsbHc,
+ &gEfiDevicePathProtocolGuid,
+ (VOID **) &ParentDevicePath,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
-
if (Status == EFI_ALREADY_STARTED) {
return EFI_SUCCESS;
}
if (!EFI_ERROR (Status)) {
+ //
+ // Close protocol, don't use device path protocol in the Support() function
+ //
gBS->CloseProtocol (
Controller,
- &gEfiUsbHcProtocolGuid,
+ &gEfiDevicePathProtocolGuid,
This->DriverBindingHandle,
Controller
);
+
+ return EFI_SUCCESS;
}
return Status;
@@ -1283,6 +1304,16 @@ UsbBusControllerDriverStart (
//
// Save the passed in RemainingDevicePath this time
//
+ if (RemainingDevicePath != NULL) {
+ if (IsDevicePathEnd (RemainingDevicePath)) {
+ //
+ // If RemainingDevicePath is the End of Device Path Node,
+ // skip enumerate any device and return EFI_SUCESSS
+ //
+ return EFI_SUCCESS;
+ }
+ }
+
Status = UsbBusAddWantedUsbIoDP (UsbBusId, RemainingDevicePath);
ASSERT (!EFI_ERROR (Status));
//
diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbUtility.c b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbUtility.c
index c59565fd1e..2275d6efc9 100644
--- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbUtility.c
+++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbUtility.c
@@ -2,7 +2,7 @@
Wrapper function for usb host controller interface.
-Copyright (c) 2007, Intel Corporation
+Copyright (c) 2007 - 2009, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -1109,7 +1109,7 @@ UsbBusAddWantedUsbIoDP (
//
// Check whether remaining device path is valid
//
- if (RemainingDevicePath != NULL) {
+ if (RemainingDevicePath != NULL && !IsDevicePathEnd (RemainingDevicePath)) {
if ((RemainingDevicePath->Type != MESSAGING_DEVICE_PATH) ||
(RemainingDevicePath->SubType != MSG_USB_DP &&
RemainingDevicePath->SubType != MSG_USB_CLASS_DP
@@ -1127,24 +1127,31 @@ UsbBusAddWantedUsbIoDP (
if (RemainingDevicePath == NULL) {
//
- // RemainingDevicePath== NULL means all Usb devices in this bus are wanted.
+ // RemainingDevicePath == NULL means all Usb devices in this bus are wanted.
// Here use a Usb class Device Path in WantedUsbIoDPList to indicate all Usb devices
// are wanted Usb devices
//
Status = UsbBusFreeUsbDPList (&Bus->WantedUsbIoDPList);
ASSERT (!EFI_ERROR (Status));
DevicePathPtr = DuplicateDevicePath ((EFI_DEVICE_PATH_PROTOCOL *) &mAllUsbClassDevicePath);
- } else {
+ } else if (!IsDevicePathEnd (RemainingDevicePath)) {
//
+ // If RemainingDevicePath isn't the End of Device Path Node,
// Create new Usb device path according to the usb part in remaining device path
//
DevicePathPtr = GetUsbDPFromFullDP (RemainingDevicePath);
+ } else {
+ //
+ // If RemainingDevicePath is the End of Device Path Node,
+ // skip enumerate any device and return EFI_SUCESSS
+ //
+ return EFI_SUCCESS;
}
ASSERT (DevicePathPtr != NULL);
Status = AddUsbDPToList (DevicePathPtr, &Bus->WantedUsbIoDPList);
ASSERT (!EFI_ERROR (Status));
- gBS->FreePool (DevicePathPtr);
+ FreePool (DevicePathPtr);
return EFI_SUCCESS;
}
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
index 5e3b689a18..b68d45f7a4 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
@@ -2,7 +2,7 @@
Produces Simple Text Input Protocol, Simple Text Input Extended Protocol and
Simple Text Output Protocol upon Serial IO Protocol.
-Copyright (c) 2006 - 2008, Intel Corporation. <BR>
+Copyright (c) 2006 - 2009, Intel Corporation. <BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -124,34 +124,46 @@ TerminalDriverBindingSupported (
// device path that describes a terminal communications protocol.
//
if (RemainingDevicePath != NULL) {
-
- Node = (VENDOR_DEVICE_PATH *) RemainingDevicePath;
-
- if (Node->Header.Type != MESSAGING_DEVICE_PATH ||
- Node->Header.SubType != MSG_VENDOR_DP ||
- DevicePathNodeLength(&Node->Header) != sizeof(VENDOR_DEVICE_PATH)) {
-
- return EFI_UNSUPPORTED;
-
- }
//
- // only supports PC ANSI, VT100, VT100+ and VT-UTF8 terminal types
+ // Check if RemainingDevicePath is the End of Device Path Node,
+ // if yes, go on checking other conditions
//
- if (!CompareGuid (&Node->Guid, &gEfiPcAnsiGuid) &&
- !CompareGuid (&Node->Guid, &gEfiVT100Guid) &&
- !CompareGuid (&Node->Guid, &gEfiVT100PlusGuid) &&
- !CompareGuid (&Node->Guid, &gEfiVTUTF8Guid)) {
-
- return EFI_UNSUPPORTED;
+ if (!IsDevicePathEnd (RemainingDevicePath)) {
+ //
+ // If RemainingDevicePath isn't the End of Device Path Node,
+ // check its validation
+ //
+ Node = (VENDOR_DEVICE_PATH *) RemainingDevicePath;
+
+ if (Node->Header.Type != MESSAGING_DEVICE_PATH ||
+ Node->Header.SubType != MSG_VENDOR_DP ||
+ DevicePathNodeLength(&Node->Header) != sizeof(VENDOR_DEVICE_PATH)) {
+
+ return EFI_UNSUPPORTED;
+
+ }
+ //
+ // only supports PC ANSI, VT100, VT100+ and VT-UTF8 terminal types
+ //
+ if (!CompareGuid (&Node->Guid, &gEfiPcAnsiGuid) &&
+ !CompareGuid (&Node->Guid, &gEfiVT100Guid) &&
+ !CompareGuid (&Node->Guid, &gEfiVT100PlusGuid) &&
+ !CompareGuid (&Node->Guid, &gEfiVTUTF8Guid)) {
+
+ return EFI_UNSUPPORTED;
+ }
}
}
//
// Open the IO Abstraction(s) needed to perform the supported test
+ // The Controller must support the Serial I/O Protocol.
+ // This driver is a bus driver with at most 1 child device, so it is
+ // ok for it to be already started.
//
Status = gBS->OpenProtocol (
Controller,
- &gEfiDevicePathProtocolGuid,
- (VOID **) &ParentDevicePath,
+ &gEfiSerialIoProtocolGuid,
+ (VOID **) &SerialIo,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -164,22 +176,23 @@ TerminalDriverBindingSupported (
return Status;
}
+ //
+ // Close the I/O Abstraction(s) used to perform the supported test
+ //
gBS->CloseProtocol (
Controller,
- &gEfiDevicePathProtocolGuid,
+ &gEfiSerialIoProtocolGuid,
This->DriverBindingHandle,
Controller
);
//
- // The Controller must support the Serial I/O Protocol.
- // This driver is a bus driver with at most 1 child device, so it is
- // ok for it to be already started.
+ // Open the EFI Device Path protocol needed to perform the supported test
//
Status = gBS->OpenProtocol (
Controller,
- &gEfiSerialIoProtocolGuid,
- (VOID **) &SerialIo,
+ &gEfiDevicePathProtocolGuid,
+ (VOID **) &ParentDevicePath,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -191,12 +204,13 @@ TerminalDriverBindingSupported (
if (EFI_ERROR (Status)) {
return Status;
}
+
//
- // Close the I/O Abstraction(s) used to perform the supported test
+ // Close protocol, don't use device path protocol in the Support() function
//
gBS->CloseProtocol (
Controller,
- &gEfiSerialIoProtocolGuid,
+ &gEfiDevicePathProtocolGuid,
This->DriverBindingHandle,
Controller
);
@@ -353,8 +367,9 @@ TerminalDriverBindingStart (
CopyMem (&DefaultNode->Guid, gTerminalType[TerminalType], sizeof (EFI_GUID));
RemainingDevicePath = (EFI_DEVICE_PATH_PROTOCOL *) DefaultNode;
- } else {
+ } else if (!IsDevicePathEnd (RemainingDevicePath)) {
//
+ // If RemainingDevicePath isn't the End of Device Path Node,
// Use the RemainingDevicePath to determine the terminal type
//
Node = (VENDOR_DEVICE_PATH *)RemainingDevicePath;
@@ -369,6 +384,12 @@ TerminalDriverBindingStart (
} else {
goto Error;
}
+ } else {
+ //
+ // If RemainingDevicePath is the End of Device Path Node,
+ // skip enumerate any device and return EFI_SUCESSS
+ //
+ return EFI_SUCCESS;
}
//