mirror of https://github.com/acidanthera/audk.git
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
This commit is contained in:
parent
0cd118f779
commit
af4a63857c
|
@ -144,14 +144,91 @@ SerialControllerDriverSupported (
|
|||
EFI_STATUS Status;
|
||||
EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
|
||||
EFI_ISA_IO_PROTOCOL *IsaIo;
|
||||
UART_DEVICE_PATH UartNode;
|
||||
UART_DEVICE_PATH *UartNode;
|
||||
|
||||
//
|
||||
// Ignore the RemainingDevicePath
|
||||
// Check RemainingDevicePath validation
|
||||
//
|
||||
if (RemainingDevicePath != NULL) {
|
||||
//
|
||||
// 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
|
||||
//
|
||||
Status = EFI_UNSUPPORTED;
|
||||
|
||||
UartNode = (UART_DEVICE_PATH *) RemainingDevicePath;
|
||||
if (UartNode->Header.Type != MESSAGING_DEVICE_PATH ||
|
||||
UartNode->Header.SubType != MSG_UART_DP ||
|
||||
sizeof (UART_DEVICE_PATH) != DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) UartNode)
|
||||
) {
|
||||
goto Error;
|
||||
}
|
||||
|
||||
if (UartNode->BaudRate > SERIAL_PORT_MAX_BAUD_RATE) {
|
||||
goto Error;
|
||||
}
|
||||
|
||||
if (UartNode->Parity < NoParity || UartNode->Parity > SpaceParity) {
|
||||
goto Error;
|
||||
}
|
||||
|
||||
if (UartNode->DataBits < 5 || UartNode->DataBits > 8) {
|
||||
goto Error;
|
||||
}
|
||||
|
||||
if (UartNode->StopBits < OneStopBit || UartNode->StopBits > TwoStopBits) {
|
||||
goto Error;
|
||||
}
|
||||
|
||||
if ((UartNode->DataBits == 5) && (UartNode->StopBits == TwoStopBits)) {
|
||||
goto Error;
|
||||
}
|
||||
|
||||
if ((UartNode->DataBits >= 6) && (UartNode->DataBits <= 8) && (UartNode->StopBits == OneFiveStopBits)) {
|
||||
goto Error;
|
||||
}
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Open the IO Abstraction(s) needed to perform the supported test
|
||||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiIsaIoProtocolGuid,
|
||||
(VOID **) &IsaIo,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
);
|
||||
if (Status == EFI_ALREADY_STARTED) {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Close the I/O Abstraction(s) used to perform the supported test
|
||||
//
|
||||
gBS->CloseProtocol (
|
||||
Controller,
|
||||
&gEfiIsaIoProtocolGuid,
|
||||
This->DriverBindingHandle,
|
||||
Controller
|
||||
);
|
||||
|
||||
//
|
||||
// Open the EFI Device Path protocol needed to perform the supported test
|
||||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
|
@ -164,30 +241,6 @@ SerialControllerDriverSupported (
|
|||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
gBS->CloseProtocol (
|
||||
Controller,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
This->DriverBindingHandle,
|
||||
Controller
|
||||
);
|
||||
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiIsaIoProtocolGuid,
|
||||
(VOID **) &IsaIo,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
);
|
||||
|
||||
if (Status == EFI_ALREADY_STARTED) {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
@ -200,57 +253,14 @@ SerialControllerDriverSupported (
|
|||
Status = EFI_UNSUPPORTED;
|
||||
goto Error;
|
||||
}
|
||||
//
|
||||
// Make sure RemainingDevicePath is valid
|
||||
//
|
||||
if (RemainingDevicePath != NULL) {
|
||||
Status = EFI_UNSUPPORTED;
|
||||
CopyMem (
|
||||
&UartNode,
|
||||
(UART_DEVICE_PATH *) RemainingDevicePath,
|
||||
sizeof (UART_DEVICE_PATH)
|
||||
);
|
||||
if (UartNode.Header.Type != MESSAGING_DEVICE_PATH ||
|
||||
UartNode.Header.SubType != MSG_UART_DP ||
|
||||
sizeof (UART_DEVICE_PATH) != DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) &UartNode)
|
||||
) {
|
||||
goto Error;
|
||||
}
|
||||
|
||||
if (UartNode.BaudRate > SERIAL_PORT_MAX_BAUD_RATE) {
|
||||
goto Error;
|
||||
}
|
||||
|
||||
if (UartNode.Parity < NoParity || UartNode.Parity > SpaceParity) {
|
||||
goto Error;
|
||||
}
|
||||
|
||||
if (UartNode.DataBits < 5 || UartNode.DataBits > 8) {
|
||||
goto Error;
|
||||
}
|
||||
|
||||
if (UartNode.StopBits < OneStopBit || UartNode.StopBits > TwoStopBits) {
|
||||
goto Error;
|
||||
}
|
||||
|
||||
if ((UartNode.DataBits == 5) && (UartNode.StopBits == TwoStopBits)) {
|
||||
goto Error;
|
||||
}
|
||||
|
||||
if ((UartNode.DataBits >= 6) && (UartNode.DataBits <= 8) && (UartNode.StopBits == OneFiveStopBits)) {
|
||||
goto Error;
|
||||
}
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
}
|
||||
|
||||
Error:
|
||||
//
|
||||
// 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,
|
||||
&gEfiIsaIoProtocolGuid,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
This->DriverBindingHandle,
|
||||
Controller
|
||||
);
|
||||
|
@ -281,11 +291,11 @@ SerialControllerDriverStart (
|
|||
EFI_ISA_IO_PROTOCOL *IsaIo;
|
||||
SERIAL_DEV *SerialDevice;
|
||||
UINTN Index;
|
||||
UART_DEVICE_PATH Node;
|
||||
EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
|
||||
EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfoBuffer;
|
||||
UINTN EntryCount;
|
||||
EFI_SERIAL_IO_PROTOCOL *SerialIo;
|
||||
UART_DEVICE_PATH *UartNode;
|
||||
|
||||
SerialDevice = NULL;
|
||||
//
|
||||
|
@ -328,9 +338,13 @@ SerialControllerDriverStart (
|
|||
|
||||
if (Status == EFI_ALREADY_STARTED) {
|
||||
|
||||
if (RemainingDevicePath == NULL) {
|
||||
if (RemainingDevicePath == NULL || IsDevicePathEnd (RemainingDevicePath)) {
|
||||
//
|
||||
// If RemainingDevicePath is NULL or is the End of Device Path Node
|
||||
//
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
// Make sure a child handle does not already exist. This driver can only
|
||||
// produce one child per serial port.
|
||||
|
@ -357,24 +371,44 @@ SerialControllerDriverStart (
|
|||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
CopyMem (&Node, RemainingDevicePath, sizeof (UART_DEVICE_PATH));
|
||||
UartNode = (UART_DEVICE_PATH *) RemainingDevicePath;
|
||||
Status = SerialIo->SetAttributes (
|
||||
SerialIo,
|
||||
Node.BaudRate,
|
||||
UartNode->BaudRate,
|
||||
SerialIo->Mode->ReceiveFifoDepth,
|
||||
SerialIo->Mode->Timeout,
|
||||
(EFI_PARITY_TYPE) Node.Parity,
|
||||
Node.DataBits,
|
||||
(EFI_STOP_BITS_TYPE) Node.StopBits
|
||||
(EFI_PARITY_TYPE) UartNode->Parity,
|
||||
UartNode->DataBits,
|
||||
(EFI_STOP_BITS_TYPE) UartNode->StopBits
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
FreePool (OpenInfoBuffer);
|
||||
|
||||
gBS->FreePool (OpenInfoBuffer);
|
||||
return Status;
|
||||
if (Index < EntryCount) {
|
||||
//
|
||||
// If gEfiSerialIoProtocolGuid is opened by one child device, return
|
||||
//
|
||||
return Status;
|
||||
}
|
||||
//
|
||||
// If gEfiSerialIoProtocolGuid is not opened by any child device,
|
||||
// go further to create child device handle based on RemainingDevicePath
|
||||
//
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Initialize the serial device instance
|
||||
//
|
||||
|
@ -388,6 +422,21 @@ SerialControllerDriverStart (
|
|||
SerialDevice->IsaIo = IsaIo;
|
||||
SerialDevice->ParentDevicePath = ParentDevicePath;
|
||||
|
||||
//
|
||||
// Check if RemainingDevicePath is NULL,
|
||||
// if yes, use the values from the gSerialDevTempate as no remaining device path was
|
||||
// passed in.
|
||||
//
|
||||
if (RemainingDevicePath != NULL) {
|
||||
//
|
||||
// If RemainingDevicePath isn't NULL,
|
||||
// match the configuration of the RemainingDevicePath. IsHandleSupported()
|
||||
// already checked to make sure the RemainingDevicePath contains settings
|
||||
// that we can support.
|
||||
//
|
||||
CopyMem (&SerialDevice->UartDevicePath, RemainingDevicePath, sizeof (UART_DEVICE_PATH));
|
||||
}
|
||||
|
||||
AddName (SerialDevice, IsaIo);
|
||||
|
||||
for (Index = 0; SerialDevice->IsaIo->ResourceList->ResourceItem[Index].Type != EfiIsaAcpiResourceEndOfList; Index++) {
|
||||
|
@ -414,19 +463,6 @@ SerialControllerDriverStart (
|
|||
goto Error;
|
||||
}
|
||||
|
||||
if (RemainingDevicePath != NULL) {
|
||||
//
|
||||
// Match the configuration of the RemainingDevicePath. IsHandleSupported()
|
||||
// already checked to make sure the RemainingDevicePath contains settings
|
||||
// that we can support.
|
||||
//
|
||||
CopyMem (&SerialDevice->UartDevicePath, RemainingDevicePath, sizeof (UART_DEVICE_PATH));
|
||||
} else {
|
||||
//
|
||||
// Use the values from the gSerialDevTempate as no remaining device path was
|
||||
// passed in.
|
||||
//
|
||||
}
|
||||
//
|
||||
// Build the device path by appending the UART node to the ParentDevicePath.
|
||||
//The Uart setings are zero here, since SetAttribute() will update them to match
|
||||
|
|
|
@ -194,7 +194,7 @@ IDEBusDriverBindingSupported (
|
|||
}
|
||||
|
||||
//
|
||||
// If protocols were opened normally, closed it
|
||||
// Close the I/O Abstraction(s) used to perform the supported test
|
||||
//
|
||||
gBS->CloseProtocol (
|
||||
Controller,
|
||||
|
@ -428,7 +428,7 @@ IDEBusDriverBindingStart (
|
|||
if (EnumAll || RemainingDevicePath == NULL) {
|
||||
//
|
||||
// If IdeInit->EnumAll is TRUE or RemainingDevicePath is NULL,
|
||||
// must enumerate all IDE device anyway
|
||||
// must enumerate all IDE devices anyway
|
||||
//
|
||||
BeginningIdeChannel = IdePrimary;
|
||||
EndIdeChannel = IdeSecondary;
|
||||
|
@ -437,8 +437,8 @@ IDEBusDriverBindingStart (
|
|||
|
||||
} else if (!IsDevicePathEnd (RemainingDevicePath)) {
|
||||
//
|
||||
// RemainingDevicePath is the End of Device Path Node,
|
||||
// only scan the specified device by RemainingDevicePath.
|
||||
// If RemainingDevicePath isn't the End of Device Path Node,
|
||||
// only scan the specified device by RemainingDevicePath
|
||||
//
|
||||
Node = (EFI_DEV_PATH *) RemainingDevicePath;
|
||||
BeginningIdeChannel = Node->Atapi.PrimarySecondary;
|
||||
|
@ -456,7 +456,7 @@ IDEBusDriverBindingStart (
|
|||
|
||||
} else {
|
||||
//
|
||||
// If RemainingDevicePath is not the End of Device Path Node,
|
||||
// If RemainingDevicePath is the End of Device Path Node,
|
||||
// skip enumerate any device and return EFI_SUCESSS
|
||||
//
|
||||
BeginningIdeChannel = IdeMaxChannel;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
//
|
||||
// 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
|
||||
)) {
|
||||
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;
|
||||
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)) {
|
||||
gBS->CloseProtocol (
|
||||
Controller,
|
||||
&gEfiUsb2HcProtocolGuid,
|
||||
This->DriverBindingHandle,
|
||||
Controller
|
||||
);
|
||||
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;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
if (EFI_ERROR (Status)) {
|
||||
return 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)) {
|
||||
//
|
||||
// Close the USB_HC used to perform the supported test
|
||||
//
|
||||
gBS->CloseProtocol (
|
||||
Controller,
|
||||
&gEfiUsbHcProtocolGuid,
|
||||
This->DriverBindingHandle,
|
||||
Controller
|
||||
);
|
||||
|
||||
} else {
|
||||
|
||||
//
|
||||
// Close the USB_HC2 used to perform the supported test
|
||||
//
|
||||
gBS->CloseProtocol (
|
||||
Controller,
|
||||
&gEfiUsb2HcProtocolGuid,
|
||||
This->DriverBindingHandle,
|
||||
Controller
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Open the EFI Device Path protocol needed to perform the supported test
|
||||
//
|
||||
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)) {
|
||||
//
|
||||
// Close protocol, don't use device path protocol in the Support() function
|
||||
//
|
||||
gBS->CloseProtocol (
|
||||
Controller,
|
||||
&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));
|
||||
//
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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,54 +124,38 @@ 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)) {
|
||||
if (!IsDevicePathEnd (RemainingDevicePath)) {
|
||||
//
|
||||
// If RemainingDevicePath isn't the End of Device Path Node,
|
||||
// check its validation
|
||||
//
|
||||
Node = (VENDOR_DEVICE_PATH *) RemainingDevicePath;
|
||||
|
||||
return EFI_UNSUPPORTED;
|
||||
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
|
||||
//
|
||||
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
|
||||
);
|
||||
|
||||
//
|
||||
// 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.
|
||||
|
@ -191,6 +175,7 @@ TerminalDriverBindingSupported (
|
|||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Close the I/O Abstraction(s) used to perform the supported test
|
||||
//
|
||||
|
@ -201,6 +186,35 @@ TerminalDriverBindingSupported (
|
|||
Controller
|
||||
);
|
||||
|
||||
//
|
||||
// Open the EFI Device Path protocol needed to perform the supported test
|
||||
//
|
||||
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;
|
||||
}
|
||||
|
||||
//
|
||||
// Close protocol, don't use device path protocol in the Support() function
|
||||
//
|
||||
gBS->CloseProtocol (
|
||||
Controller,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
This->DriverBindingHandle,
|
||||
Controller
|
||||
);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**@file
|
||||
|
||||
Copyright (c) 2006 - 2007, Intel Corporation
|
||||
Copyright (c) 2006 - 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
|
||||
|
@ -239,20 +239,30 @@ Returns:
|
|||
// it is a legal Device Path Node for this bus driver's children.
|
||||
//
|
||||
if (RemainingDevicePath != NULL) {
|
||||
if (RemainingDevicePath->Type != HARDWARE_DEVICE_PATH ||
|
||||
RemainingDevicePath->SubType != HW_VENDOR_DP ||
|
||||
DevicePathNodeLength(RemainingDevicePath) != sizeof(WIN_NT_VENDOR_DEVICE_PATH_NODE)) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
for (Index = 0; Index < NT_PCD_ARRAY_SIZE; Index++) {
|
||||
if (CompareGuid (&((VENDOR_DEVICE_PATH *) RemainingDevicePath)->Guid, mPcdEnvironment[Index].DevicePathGuid)) {
|
||||
break;
|
||||
//
|
||||
// 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
|
||||
//
|
||||
if (RemainingDevicePath->Type != HARDWARE_DEVICE_PATH ||
|
||||
RemainingDevicePath->SubType != HW_VENDOR_DP ||
|
||||
DevicePathNodeLength(RemainingDevicePath) != sizeof(WIN_NT_VENDOR_DEVICE_PATH_NODE)) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
if (Index >= NT_PCD_ARRAY_SIZE) {
|
||||
return EFI_UNSUPPORTED;
|
||||
for (Index = 0; Index < NT_PCD_ARRAY_SIZE; Index++) {
|
||||
if (CompareGuid (&((VENDOR_DEVICE_PATH *) RemainingDevicePath)->Guid, mPcdEnvironment[Index].DevicePathGuid)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Index >= NT_PCD_ARRAY_SIZE) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -261,8 +271,8 @@ Returns:
|
|||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
(VOID **) &ParentDevicePath,
|
||||
&gEfiWinNtThunkProtocolGuid,
|
||||
(VOID **) &WinNtThunk,
|
||||
This->DriverBindingHandle,
|
||||
ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
|
@ -275,17 +285,23 @@ Returns:
|
|||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Close the I/O Abstraction(s) used to perform the supported test
|
||||
//
|
||||
gBS->CloseProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
&gEfiWinNtThunkProtocolGuid,
|
||||
This->DriverBindingHandle,
|
||||
ControllerHandle
|
||||
);
|
||||
|
||||
//
|
||||
// Open the EFI Device Path protocol needed to perform the supported test
|
||||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiWinNtThunkProtocolGuid,
|
||||
(VOID **) &WinNtThunk,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
(VOID **) &ParentDevicePath,
|
||||
This->DriverBindingHandle,
|
||||
ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
|
@ -307,11 +323,11 @@ Returns:
|
|||
}
|
||||
|
||||
//
|
||||
// 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 (
|
||||
ControllerHandle,
|
||||
&gEfiWinNtThunkProtocolGuid,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
This->DriverBindingHandle,
|
||||
ControllerHandle
|
||||
);
|
||||
|
@ -470,15 +486,25 @@ Returns:
|
|||
CreateDevice = TRUE;
|
||||
if (RemainingDevicePath != NULL) {
|
||||
CreateDevice = FALSE;
|
||||
Node = (WIN_NT_VENDOR_DEVICE_PATH_NODE *) RemainingDevicePath;
|
||||
if (Node->VendorDevicePath.Header.Type == HARDWARE_DEVICE_PATH &&
|
||||
Node->VendorDevicePath.Header.SubType == HW_VENDOR_DP &&
|
||||
DevicePathNodeLength (&Node->VendorDevicePath.Header) == sizeof (WIN_NT_VENDOR_DEVICE_PATH_NODE)
|
||||
) {
|
||||
if (CompareGuid (&Node->VendorDevicePath.Guid, mPcdEnvironment[Index].DevicePathGuid) &&
|
||||
Node->Instance == Count
|
||||
//
|
||||
// Check if RemainingDevicePath is the End of Device Path Node,
|
||||
// if yes, don't create any child device
|
||||
//
|
||||
if (!IsDevicePathEnd (RemainingDevicePath)) {
|
||||
//
|
||||
// If RemainingDevicePath isn't the End of Device Path Node,
|
||||
// check its validation
|
||||
//
|
||||
Node = (WIN_NT_VENDOR_DEVICE_PATH_NODE *) RemainingDevicePath;
|
||||
if (Node->VendorDevicePath.Header.Type == HARDWARE_DEVICE_PATH &&
|
||||
Node->VendorDevicePath.Header.SubType == HW_VENDOR_DP &&
|
||||
DevicePathNodeLength (&Node->VendorDevicePath.Header) == sizeof (WIN_NT_VENDOR_DEVICE_PATH_NODE)
|
||||
) {
|
||||
CreateDevice = TRUE;
|
||||
if (CompareGuid (&Node->VendorDevicePath.Guid, mPcdEnvironment[Index].DevicePathGuid) &&
|
||||
Node->Instance == Count
|
||||
) {
|
||||
CreateDevice = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -188,7 +188,7 @@ Returns:
|
|||
}
|
||||
|
||||
//
|
||||
// If protocols were opened normally, closed it
|
||||
// Close the I/O Abstraction(s) used to perform the supported test
|
||||
//
|
||||
gBS->CloseProtocol (
|
||||
Handle,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*+++
|
||||
|
||||
Copyright (c) 2006, Intel Corporation
|
||||
Copyright (c) 2006 - 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
|
||||
|
@ -186,20 +186,30 @@ Returns:
|
|||
// it is a legal Device Path Node for this bus driver's children.
|
||||
//
|
||||
if (RemainingDevicePath != NULL) {
|
||||
if (RemainingDevicePath->Type != HARDWARE_DEVICE_PATH ||
|
||||
RemainingDevicePath->SubType != HW_VENDOR_DP ||
|
||||
DevicePathNodeLength(RemainingDevicePath) != sizeof(UNIX_VENDOR_DEVICE_PATH_NODE)) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
for (Index = 0; Index < UNIX_PCD_ARRAY_SIZE; Index++) {
|
||||
if (CompareGuid (&((VENDOR_DEVICE_PATH *) RemainingDevicePath)->Guid, mPcdEnvironment[Index].DevicePathGuid)) {
|
||||
break;
|
||||
//
|
||||
// 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
|
||||
//
|
||||
if (RemainingDevicePath->Type != HARDWARE_DEVICE_PATH ||
|
||||
RemainingDevicePath->SubType != HW_VENDOR_DP ||
|
||||
DevicePathNodeLength(RemainingDevicePath) != sizeof(UNIX_VENDOR_DEVICE_PATH_NODE)) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
if (Index >= UNIX_PCD_ARRAY_SIZE) {
|
||||
return EFI_UNSUPPORTED;
|
||||
for (Index = 0; Index < UNIX_PCD_ARRAY_SIZE; Index++) {
|
||||
if (CompareGuid (&((VENDOR_DEVICE_PATH *) RemainingDevicePath)->Guid, mPcdEnvironment[Index].DevicePathGuid)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Index >= UNIX_PCD_ARRAY_SIZE) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -208,8 +218,8 @@ Returns:
|
|||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
(VOID **)&ParentDevicePath,
|
||||
&gEfiUnixThunkProtocolGuid,
|
||||
(VOID **)&UnixThunk,
|
||||
This->DriverBindingHandle,
|
||||
ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
|
@ -222,17 +232,23 @@ Returns:
|
|||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Close the I/O Abstraction(s) used to perform the supported test
|
||||
//
|
||||
gBS->CloseProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
&gEfiUnixThunkProtocolGuid,
|
||||
This->DriverBindingHandle,
|
||||
ControllerHandle
|
||||
);
|
||||
|
||||
//
|
||||
// Open the EFI Device Path protocol needed to perform the supported test
|
||||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiUnixThunkProtocolGuid,
|
||||
(VOID **)&UnixThunk,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
(VOID **)&ParentDevicePath,
|
||||
This->DriverBindingHandle,
|
||||
ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
|
@ -253,12 +269,12 @@ Returns:
|
|||
Status = EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
//
|
||||
// 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 (
|
||||
ControllerHandle,
|
||||
&gEfiUnixThunkProtocolGuid,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
This->DriverBindingHandle,
|
||||
ControllerHandle
|
||||
);
|
||||
|
@ -414,15 +430,25 @@ Returns:
|
|||
CreateDevice = TRUE;
|
||||
if (RemainingDevicePath != NULL) {
|
||||
CreateDevice = FALSE;
|
||||
Node = (UNIX_VENDOR_DEVICE_PATH_NODE *) RemainingDevicePath;
|
||||
if (Node->VendorDevicePath.Header.Type == HARDWARE_DEVICE_PATH &&
|
||||
Node->VendorDevicePath.Header.SubType == HW_VENDOR_DP &&
|
||||
DevicePathNodeLength (&Node->VendorDevicePath.Header) == sizeof (UNIX_VENDOR_DEVICE_PATH_NODE)
|
||||
) {
|
||||
if (CompareGuid (&Node->VendorDevicePath.Guid, mPcdEnvironment[Index].DevicePathGuid) &&
|
||||
Node->Instance == Count
|
||||
//
|
||||
// Check if RemainingDevicePath is the End of Device Path Node,
|
||||
// if yes, don't create any child device
|
||||
//
|
||||
if (!IsDevicePathEnd (RemainingDevicePath)) {
|
||||
//
|
||||
// If RemainingDevicePath isn't the End of Device Path Node,
|
||||
// check its validation
|
||||
//
|
||||
Node = (UNIX_VENDOR_DEVICE_PATH_NODE *) RemainingDevicePath;
|
||||
if (Node->VendorDevicePath.Header.Type == HARDWARE_DEVICE_PATH &&
|
||||
Node->VendorDevicePath.Header.SubType == HW_VENDOR_DP &&
|
||||
DevicePathNodeLength (&Node->VendorDevicePath.Header) == sizeof (UNIX_VENDOR_DEVICE_PATH_NODE)
|
||||
) {
|
||||
CreateDevice = TRUE;
|
||||
if (CompareGuid (&Node->VendorDevicePath.Guid, mPcdEnvironment[Index].DevicePathGuid) &&
|
||||
Node->Instance == Count
|
||||
) {
|
||||
CreateDevice = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -222,32 +222,50 @@ Returns:
|
|||
EFI_UNIX_IO_PROTOCOL *UnixIo;
|
||||
UART_DEVICE_PATH *UartNode;
|
||||
|
||||
//
|
||||
// Check RemainingDevicePath validation
|
||||
//
|
||||
if (RemainingDevicePath != NULL) {
|
||||
//
|
||||
// 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
|
||||
//
|
||||
Status = EFI_UNSUPPORTED;
|
||||
UartNode = (UART_DEVICE_PATH *) RemainingDevicePath;
|
||||
if (UartNode->Header.Type != MESSAGING_DEVICE_PATH ||
|
||||
UartNode->Header.SubType != MSG_UART_DP ||
|
||||
DevicePathNodeLength((EFI_DEVICE_PATH_PROTOCOL *)UartNode) != sizeof(UART_DEVICE_PATH)) {
|
||||
goto Error;
|
||||
}
|
||||
if (UartNode->BaudRate < 0 || UartNode->BaudRate > SERIAL_PORT_MAX_BAUD_RATE) {
|
||||
goto Error;
|
||||
}
|
||||
if (UartNode->Parity < NoParity || UartNode->Parity > SpaceParity) {
|
||||
goto Error;
|
||||
}
|
||||
if (UartNode->DataBits < 5 || UartNode->DataBits > 8) {
|
||||
goto Error;
|
||||
}
|
||||
if (UartNode->StopBits < OneStopBit || UartNode->StopBits > TwoStopBits) {
|
||||
goto Error;
|
||||
}
|
||||
if ((UartNode->DataBits == 5) && (UartNode->StopBits == TwoStopBits)) {
|
||||
goto Error;
|
||||
}
|
||||
if ((UartNode->DataBits >= 6) && (UartNode->DataBits <= 8) && (UartNode->StopBits == OneFiveStopBits)) {
|
||||
goto Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Open the IO Abstraction(s) needed to perform the supported test
|
||||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
Handle,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
(VOID**)&ParentDevicePath,
|
||||
This->DriverBindingHandle,
|
||||
Handle,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
);
|
||||
if (Status == EFI_ALREADY_STARTED) {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
gBS->CloseProtocol (
|
||||
Handle,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
This->DriverBindingHandle,
|
||||
Handle
|
||||
);
|
||||
|
||||
Status = gBS->OpenProtocol (
|
||||
Handle,
|
||||
&gEfiUnixIoProtocolGuid,
|
||||
|
@ -264,6 +282,45 @@ Returns:
|
|||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Close the I/O Abstraction(s) used to perform the supported test
|
||||
//
|
||||
gBS->CloseProtocol (
|
||||
Handle,
|
||||
&gEfiUnixIoProtocolGuid,
|
||||
This->DriverBindingHandle,
|
||||
Handle
|
||||
);
|
||||
|
||||
//
|
||||
// Open the EFI Device Path protocol needed to perform the supported test
|
||||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
Handle,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
(VOID**)&ParentDevicePath,
|
||||
This->DriverBindingHandle,
|
||||
Handle,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
);
|
||||
if (Status == EFI_ALREADY_STARTED) {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Close protocol, don't use device path protocol in the Support() function
|
||||
//
|
||||
gBS->CloseProtocol (
|
||||
Handle,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
This->DriverBindingHandle,
|
||||
Handle
|
||||
);
|
||||
|
||||
//
|
||||
// Make sure that the Unix Thunk Protocol is valid
|
||||
//
|
||||
|
@ -280,46 +337,9 @@ Returns:
|
|||
goto Error;
|
||||
}
|
||||
|
||||
if (RemainingDevicePath != NULL) {
|
||||
Status = EFI_UNSUPPORTED;
|
||||
UartNode = (UART_DEVICE_PATH *) RemainingDevicePath;
|
||||
if (UartNode->Header.Type != MESSAGING_DEVICE_PATH ||
|
||||
UartNode->Header.SubType != MSG_UART_DP ||
|
||||
DevicePathNodeLength((EFI_DEVICE_PATH_PROTOCOL *)UartNode) != sizeof(UART_DEVICE_PATH)) {
|
||||
goto Error;
|
||||
}
|
||||
if (UartNode->BaudRate < 0 || UartNode->BaudRate > SERIAL_PORT_MAX_BAUD_RATE) {
|
||||
goto Error;
|
||||
}
|
||||
if (UartNode->Parity < NoParity || UartNode->Parity > SpaceParity) {
|
||||
goto Error;
|
||||
}
|
||||
if (UartNode->DataBits < 5 || UartNode->DataBits > 8) {
|
||||
goto Error;
|
||||
}
|
||||
if (UartNode->StopBits < OneStopBit || UartNode->StopBits > TwoStopBits) {
|
||||
goto Error;
|
||||
}
|
||||
if ((UartNode->DataBits == 5) && (UartNode->StopBits == TwoStopBits)) {
|
||||
goto Error;
|
||||
}
|
||||
if ((UartNode->DataBits >= 6) && (UartNode->DataBits <= 8) && (UartNode->StopBits == OneFiveStopBits)) {
|
||||
goto Error;
|
||||
}
|
||||
Status = EFI_SUCCESS;
|
||||
}
|
||||
return EFI_SUCCESS;
|
||||
|
||||
Error:
|
||||
//
|
||||
// Close the I/O Abstraction(s) used to perform the supported test
|
||||
//
|
||||
gBS->CloseProtocol (
|
||||
Handle,
|
||||
&gEfiUnixIoProtocolGuid,
|
||||
This->DriverBindingHandle,
|
||||
Handle
|
||||
);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -353,6 +373,7 @@ Returns:
|
|||
UINTN Index;
|
||||
EFI_SERIAL_IO_PROTOCOL *SerialIo;
|
||||
CHAR8 AsciiDevName[1024];
|
||||
UART_DEVICE_PATH *UartNode;
|
||||
|
||||
DEBUG ((EFI_D_INFO, "SerialIo drive binding start!\r\n"));
|
||||
Private = NULL;
|
||||
|
@ -396,7 +417,10 @@ Returns:
|
|||
|
||||
if (Status == EFI_ALREADY_STARTED) {
|
||||
|
||||
if (RemainingDevicePath == NULL) {
|
||||
if (RemainingDevicePath == NULL || IsDevicePathEnd (RemainingDevicePath)) {
|
||||
//
|
||||
// If RemainingDevicePath is NULL or is the End of Device Path Node
|
||||
//
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -426,15 +450,15 @@ Returns:
|
|||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
CopyMem (&Node, RemainingDevicePath, sizeof (UART_DEVICE_PATH));
|
||||
UartNode = (UART_DEVICE_PATH *) RemainingDevicePath;
|
||||
Status = SerialIo->SetAttributes (
|
||||
SerialIo,
|
||||
Node.BaudRate,
|
||||
UartNode->BaudRate,
|
||||
SerialIo->Mode->ReceiveFifoDepth,
|
||||
SerialIo->Mode->Timeout,
|
||||
Node.Parity,
|
||||
Node.DataBits,
|
||||
Node.StopBits
|
||||
UartNode->Parity,
|
||||
UartNode->DataBits,
|
||||
UartNode->StopBits
|
||||
);
|
||||
}
|
||||
break;
|
||||
|
@ -442,7 +466,47 @@ Returns:
|
|||
}
|
||||
|
||||
FreePool (OpenInfoBuffer);
|
||||
return Status;
|
||||
if (Index < EntryCount) {
|
||||
//
|
||||
// If gEfiUnixIoProtocolGuid is opened by one child device, return
|
||||
//
|
||||
return Status;
|
||||
}
|
||||
//
|
||||
// If gEfiUnixIoProtocolGuid is not opened by any child device,
|
||||
// go further to create child device handle based on RemainingDevicePath
|
||||
//
|
||||
}
|
||||
|
||||
if (RemainingDevicePath == NULL) {
|
||||
//
|
||||
// Build the device path by appending the UART node to the ParentDevicePath
|
||||
// from the UnixIo handle. The Uart setings are zero here, since
|
||||
// SetAttribute() will update them to match the default setings.
|
||||
//
|
||||
ZeroMem (&Node, sizeof (UART_DEVICE_PATH));
|
||||
Node.Header.Type = MESSAGING_DEVICE_PATH;
|
||||
Node.Header.SubType = MSG_UART_DP;
|
||||
SetDevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) &Node, sizeof (UART_DEVICE_PATH));
|
||||
|
||||
} else if (!IsDevicePathEnd (RemainingDevicePath)) {
|
||||
//
|
||||
// If RemainingDevicePath isn't the End of Device Path Node,
|
||||
// only scan the specified device by RemainingDevicePath
|
||||
//
|
||||
//
|
||||
// Match the configuration of the RemainingDevicePath. IsHandleSupported()
|
||||
// already checked to make sure the RemainingDevicePath contains settings
|
||||
// that we can support.
|
||||
//
|
||||
CopyMem (&Node, RemainingDevicePath, sizeof (UART_DEVICE_PATH));
|
||||
|
||||
} else {
|
||||
//
|
||||
// If RemainingDevicePath is the End of Device Path Node,
|
||||
// skip enumerate any device and return EFI_SUCESSS
|
||||
//
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -486,6 +550,8 @@ Returns:
|
|||
Private->Fifo.Last = 0;
|
||||
Private->Fifo.Surplus = SERIAL_MAX_BUFFER_SIZE;
|
||||
|
||||
CopyMem (&Private->UartDevicePath, &Node, sizeof (UART_DEVICE_PATH));
|
||||
|
||||
AddUnicodeString (
|
||||
"eng",
|
||||
gUnixSerialIoComponentName.SupportedLanguages,
|
||||
|
@ -502,24 +568,7 @@ Returns:
|
|||
Private->SerialIo.Read = UnixSerialIoRead;
|
||||
Private->SerialIo.Mode = &Private->SerialIoMode;
|
||||
|
||||
if (RemainingDevicePath != NULL) {
|
||||
//
|
||||
// Match the configuration of the RemainingDevicePath. IsHandleSupported()
|
||||
// already checked to make sure the RemainingDevicePath contains settings
|
||||
// that we can support.
|
||||
//
|
||||
CopyMem (&Private->UartDevicePath, RemainingDevicePath, sizeof (UART_DEVICE_PATH));
|
||||
} else {
|
||||
//
|
||||
// Build the device path by appending the UART node to the ParentDevicePath
|
||||
// from the UnixIo handle. The Uart setings are zero here, since
|
||||
// SetAttribute() will update them to match the default setings.
|
||||
//
|
||||
ZeroMem (&Private->UartDevicePath, sizeof (UART_DEVICE_PATH));
|
||||
Private->UartDevicePath.Header.Type = MESSAGING_DEVICE_PATH;
|
||||
Private->UartDevicePath.Header.SubType = MSG_UART_DP;
|
||||
SetDevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) &Private->UartDevicePath, sizeof (UART_DEVICE_PATH));
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Build the device path by appending the UART node to the ParentDevicePath
|
||||
|
|
Loading…
Reference in New Issue