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
|
||||||
|
@ -126,32 +126,51 @@ Returns:
|
||||||
EFI_WIN_NT_IO_PROTOCOL *WinNtIo;
|
EFI_WIN_NT_IO_PROTOCOL *WinNtIo;
|
||||||
UART_DEVICE_PATH *UartNode;
|
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 > 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
|
// 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 (
|
Status = gBS->OpenProtocol (
|
||||||
Handle,
|
Handle,
|
||||||
&gEfiWinNtIoProtocolGuid,
|
&gEfiWinNtIoProtocolGuid,
|
||||||
|
@ -168,6 +187,45 @@ Returns:
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// If protocols were opened normally, closed it
|
||||||
|
//
|
||||||
|
gBS->CloseProtocol (
|
||||||
|
Handle,
|
||||||
|
&gEfiWinNtIoProtocolGuid,
|
||||||
|
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 WinNt Thunk Protocol is valid
|
// Make sure that the WinNt Thunk Protocol is valid
|
||||||
//
|
//
|
||||||
|
@ -184,46 +242,9 @@ Returns:
|
||||||
goto Error;
|
goto Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RemainingDevicePath != NULL) {
|
return EFI_SUCCESS;
|
||||||
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 > 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:
|
Error:
|
||||||
//
|
|
||||||
// Close the I/O Abstraction(s) used to perform the supported test
|
|
||||||
//
|
|
||||||
gBS->CloseProtocol (
|
|
||||||
Handle,
|
|
||||||
&gEfiWinNtIoProtocolGuid,
|
|
||||||
This->DriverBindingHandle,
|
|
||||||
Handle
|
|
||||||
);
|
|
||||||
|
|
||||||
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,23 +358,63 @@ 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);
|
||||||
return Status;
|
|
||||||
|
if (Index < EntryCount) {
|
||||||
|
//
|
||||||
|
// If gEfiWinNtIoProtocolGuid is opened by one child device, return
|
||||||
|
//
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -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