mirror of https://github.com/acidanthera/audk.git
updated WinNtSerialIoDxe driver 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 efiWinNtIoProtocolGuid 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@9256 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
3831f3e9a9
commit
f22911b49e
|
@ -1,6 +1,6 @@
|
||||||
/**@file
|
/**@file
|
||||||
|
|
||||||
Copyright (c) 2006 - 2007, Intel Corporation
|
Copyright (c) 2006 - 2009, Intel Corporation
|
||||||
All rights reserved. This program and the accompanying materials
|
All rights reserved. This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -127,65 +127,20 @@ Returns:
|
||||||
UART_DEVICE_PATH *UartNode;
|
UART_DEVICE_PATH *UartNode;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Open the IO Abstraction(s) needed to perform the supported test
|
// Check RemainingDevicePath validation
|
||||||
//
|
//
|
||||||
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,
|
|
||||||
&gEfiWinNtIoProtocolGuid,
|
|
||||||
(VOID **) &WinNtIo,
|
|
||||||
This->DriverBindingHandle,
|
|
||||||
Handle,
|
|
||||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
|
||||||
);
|
|
||||||
if (Status == EFI_ALREADY_STARTED) {
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Make sure that the WinNt Thunk Protocol is valid
|
|
||||||
//
|
|
||||||
if (WinNtIo->WinNtThunk->Signature != EFI_WIN_NT_THUNK_PROTOCOL_SIGNATURE) {
|
|
||||||
Status = EFI_UNSUPPORTED;
|
|
||||||
goto Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Check the GUID to see if this is a handle type the driver supports
|
|
||||||
//
|
|
||||||
if (!CompareGuid (WinNtIo->TypeGuid, &gEfiWinNtSerialPortGuid)) {
|
|
||||||
Status = EFI_UNSUPPORTED;
|
|
||||||
goto Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (RemainingDevicePath != NULL) {
|
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;
|
Status = EFI_UNSUPPORTED;
|
||||||
|
|
||||||
UartNode = (UART_DEVICE_PATH *) RemainingDevicePath;
|
UartNode = (UART_DEVICE_PATH *) RemainingDevicePath;
|
||||||
if (UartNode->Header.Type != MESSAGING_DEVICE_PATH ||
|
if (UartNode->Header.Type != MESSAGING_DEVICE_PATH ||
|
||||||
UartNode->Header.SubType != MSG_UART_DP ||
|
UartNode->Header.SubType != MSG_UART_DP ||
|
||||||
|
@ -210,12 +165,30 @@ Returns:
|
||||||
if ((UartNode->DataBits >= 6) && (UartNode->DataBits <= 8) && (UartNode->StopBits == OneFiveStopBits)) {
|
if ((UartNode->DataBits >= 6) && (UartNode->DataBits <= 8) && (UartNode->StopBits == OneFiveStopBits)) {
|
||||||
goto Error;
|
goto Error;
|
||||||
}
|
}
|
||||||
Status = EFI_SUCCESS;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Error:
|
|
||||||
//
|
//
|
||||||
// Close the I/O Abstraction(s) used to perform the supported test
|
// Open the IO Abstraction(s) needed to perform the supported test
|
||||||
|
//
|
||||||
|
Status = gBS->OpenProtocol (
|
||||||
|
Handle,
|
||||||
|
&gEfiWinNtIoProtocolGuid,
|
||||||
|
(VOID **) &WinNtIo,
|
||||||
|
This->DriverBindingHandle,
|
||||||
|
Handle,
|
||||||
|
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||||
|
);
|
||||||
|
if (Status == EFI_ALREADY_STARTED) {
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// If protocols were opened normally, closed it
|
||||||
//
|
//
|
||||||
gBS->CloseProtocol (
|
gBS->CloseProtocol (
|
||||||
Handle,
|
Handle,
|
||||||
|
@ -224,6 +197,54 @@ Error:
|
||||||
Handle
|
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 WinNt Thunk Protocol is valid
|
||||||
|
//
|
||||||
|
if (WinNtIo->WinNtThunk->Signature != EFI_WIN_NT_THUNK_PROTOCOL_SIGNATURE) {
|
||||||
|
Status = EFI_UNSUPPORTED;
|
||||||
|
goto Error;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check the GUID to see if this is a handle type the driver supports
|
||||||
|
//
|
||||||
|
if (!CompareGuid (WinNtIo->TypeGuid, &gEfiWinNtSerialPortGuid)) {
|
||||||
|
Status = EFI_UNSUPPORTED;
|
||||||
|
goto Error;
|
||||||
|
}
|
||||||
|
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
|
||||||
|
Error:
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,6 +282,7 @@ Returns:
|
||||||
UINTN EntryCount;
|
UINTN EntryCount;
|
||||||
UINTN Index;
|
UINTN Index;
|
||||||
EFI_SERIAL_IO_PROTOCOL *SerialIo;
|
EFI_SERIAL_IO_PROTOCOL *SerialIo;
|
||||||
|
UART_DEVICE_PATH *UartNode;
|
||||||
|
|
||||||
Private = NULL;
|
Private = NULL;
|
||||||
NtHandle = INVALID_HANDLE_VALUE;
|
NtHandle = INVALID_HANDLE_VALUE;
|
||||||
|
@ -303,7 +325,10 @@ Returns:
|
||||||
|
|
||||||
if (Status == EFI_ALREADY_STARTED) {
|
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;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,24 +358,64 @@ Returns:
|
||||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||||
);
|
);
|
||||||
if (!EFI_ERROR (Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
CopyMem (&Node, RemainingDevicePath, sizeof (UART_DEVICE_PATH));
|
UartNode = (UART_DEVICE_PATH *) RemainingDevicePath;
|
||||||
Status = SerialIo->SetAttributes (
|
Status = SerialIo->SetAttributes (
|
||||||
SerialIo,
|
SerialIo,
|
||||||
Node.BaudRate,
|
UartNode->BaudRate,
|
||||||
SerialIo->Mode->ReceiveFifoDepth,
|
SerialIo->Mode->ReceiveFifoDepth,
|
||||||
SerialIo->Mode->Timeout,
|
SerialIo->Mode->Timeout,
|
||||||
(EFI_PARITY_TYPE)Node.Parity,
|
(EFI_PARITY_TYPE)UartNode->Parity,
|
||||||
Node.DataBits,
|
UartNode->DataBits,
|
||||||
(EFI_STOP_BITS_TYPE)Node.StopBits
|
(EFI_STOP_BITS_TYPE)UartNode->StopBits
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FreePool (OpenInfoBuffer);
|
FreePool (OpenInfoBuffer);
|
||||||
|
|
||||||
|
if (Index < EntryCount) {
|
||||||
|
//
|
||||||
|
// If gEfiWinNtIoProtocolGuid is opened by one child device, return
|
||||||
|
//
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
//
|
||||||
|
// If gEfiWinNtIoProtocolGuid 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 WinNtIo 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;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Check to see if we can access the hardware device. If it's Open in NT we
|
// Check to see if we can access the hardware device. If it's Open in NT we
|
||||||
|
@ -396,6 +461,8 @@ Returns:
|
||||||
Private->Fifo.Last = 0;
|
Private->Fifo.Last = 0;
|
||||||
Private->Fifo.Surplus = SERIAL_MAX_BUFFER_SIZE;
|
Private->Fifo.Surplus = SERIAL_MAX_BUFFER_SIZE;
|
||||||
|
|
||||||
|
CopyMem (&Private->UartDevicePath, &Node, sizeof (UART_DEVICE_PATH));
|
||||||
|
|
||||||
AddUnicodeString2 (
|
AddUnicodeString2 (
|
||||||
"eng",
|
"eng",
|
||||||
gWinNtSerialIoComponentName.SupportedLanguages,
|
gWinNtSerialIoComponentName.SupportedLanguages,
|
||||||
|
@ -421,25 +488,6 @@ Returns:
|
||||||
Private->SerialIo.Read = WinNtSerialIoRead;
|
Private->SerialIo.Read = WinNtSerialIoRead;
|
||||||
Private->SerialIo.Mode = &Private->SerialIoMode;
|
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 WinNtIo 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
|
// Build the device path by appending the UART node to the ParentDevicePath
|
||||||
// from the WinNtIo handle. The Uart setings are zero here, since
|
// from the WinNtIo handle. The Uart setings are zero here, since
|
||||||
|
|
Loading…
Reference in New Issue