summaryrefslogtreecommitdiff
path: root/Nt32Pkg/WinNtSerialIoDxe
diff options
context:
space:
mode:
Diffstat (limited to 'Nt32Pkg/WinNtSerialIoDxe')
-rw-r--r--Nt32Pkg/WinNtSerialIoDxe/WinNtSerialIo.c70
-rw-r--r--Nt32Pkg/WinNtSerialIoDxe/WinNtSerialIo.h6
2 files changed, 73 insertions, 3 deletions
diff --git a/Nt32Pkg/WinNtSerialIoDxe/WinNtSerialIo.c b/Nt32Pkg/WinNtSerialIoDxe/WinNtSerialIo.c
index 44bbf5765c..c0692eaa52 100644
--- a/Nt32Pkg/WinNtSerialIoDxe/WinNtSerialIo.c
+++ b/Nt32Pkg/WinNtSerialIoDxe/WinNtSerialIo.c
@@ -56,6 +56,11 @@ EFI_DRIVER_BINDING_PROTOCOL gWinNtSerialIoDriverBinding = {
NULL
};
+//
+// List of supported baud rate
+//
+UINT64 mBaudRateCurrentSupport[] = {50, 75, 110, 134, 150, 300, 600, 1200, 1800, 2000, 2400, 3600, 4800, 7200, 9600, 19200, 38400, 57600, 115200, SERIAL_PORT_MAX_BAUD_RATE + 1};
+
/**
The user Entry Point for module WinNtSerialIo. The user code starts with this function.
@@ -739,6 +744,7 @@ Returns:
// TODO: EFI_SUCCESS - add return value to function comment
{
EFI_STATUS Status;
+ UINTN Index;
WIN_NT_SERIAL_IO_PRIVATE_DATA *Private;
COMMTIMEOUTS PortTimeOuts;
DWORD ConvertedTime;
@@ -746,8 +752,6 @@ Returns:
EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;
EFI_TPL Tpl;
- Tpl = gBS->RaiseTPL (TPL_NOTIFY);
-
Private = WIN_NT_SERIAL_IO_PRIVATE_DATA_FROM_THIS (This);
//
@@ -777,6 +781,56 @@ Returns:
if (StopBits == DefaultStopBits) {
StopBits = (EFI_STOP_BITS_TYPE) FixedPcdGet8 (PcdUartDefaultStopBits);
}
+
+ //
+ // Make sure all parameters are valid
+ //
+ if ((BaudRate > SERIAL_PORT_MAX_BAUD_RATE) || (BaudRate < SERIAL_PORT_MIN_BAUD_RATE)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ //The lower baud rate supported by the serial device will be selected without exceeding the unsupported BaudRate parameter
+ //
+
+ for (Index = 1; Index < (sizeof (mBaudRateCurrentSupport) / sizeof (mBaudRateCurrentSupport[0])); Index++) {
+ if (BaudRate < mBaudRateCurrentSupport[Index]) {
+ BaudRate = mBaudRateCurrentSupport[Index-1];
+ break;
+ }
+ }
+
+ if ((ReceiveFifoDepth < 1) || (ReceiveFifoDepth > SERIAL_PORT_MAX_RECEIVE_FIFO_DEPTH)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((Timeout < SERIAL_PORT_MIN_TIMEOUT) || (Timeout > SERIAL_PORT_MAX_TIMEOUT)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((Parity < NoParity) || (Parity > SpaceParity)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((StopBits < OneStopBit) || (StopBits > TwoStopBits)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Now we only support DataBits=7,8.
+ //
+ if ((DataBits < 7) || (DataBits > 8)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Now we only support DataBits=7,8.
+ // for DataBits = 6,7,8, StopBits can not set OneFiveStopBits.
+ //
+ if (StopBits == OneFiveStopBits) {
+ return EFI_INVALID_PARAMETER;
+ }
+
//
// See if the new attributes already match the current attributes
//
@@ -786,10 +840,11 @@ Returns:
Private->UartDevicePath.StopBits == StopBits &&
Private->SerialIoMode.ReceiveFifoDepth == ReceiveFifoDepth &&
Private->SerialIoMode.Timeout == Timeout ) {
- gBS->RestoreTPL(Tpl);
return EFI_SUCCESS;
}
+ Tpl = gBS->RaiseTPL (TPL_NOTIFY);
+
//
// Get current values from NT
//
@@ -943,6 +998,15 @@ Returns:
DCB Dcb;
EFI_TPL Tpl;
+ //
+ // first determine the parameter is invalid
+ //
+ if (Control & (~(EFI_SERIAL_REQUEST_TO_SEND | EFI_SERIAL_DATA_TERMINAL_READY |
+ EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE | EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE |
+ EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE))) {
+ return EFI_UNSUPPORTED;
+ }
+
Tpl = gBS->RaiseTPL (TPL_NOTIFY);
Private = WIN_NT_SERIAL_IO_PRIVATE_DATA_FROM_THIS (This);
diff --git a/Nt32Pkg/WinNtSerialIoDxe/WinNtSerialIo.h b/Nt32Pkg/WinNtSerialIoDxe/WinNtSerialIo.h
index affc392b51..d844aa05f2 100644
--- a/Nt32Pkg/WinNtSerialIoDxe/WinNtSerialIo.h
+++ b/Nt32Pkg/WinNtSerialIoDxe/WinNtSerialIo.h
@@ -154,6 +154,12 @@ extern EFI_COMPONENT_NAME_PROTOCOL gWinNtSerialIoComponentName;
//
#define SERIAL_PORT_MAX_BAUD_RATE 115400
+#define SERIAL_PORT_MIN_BAUD_RATE 50
+#define SERIAL_PORT_MAX_RECEIVE_FIFO_DEPTH 16
+
+#define SERIAL_PORT_MIN_TIMEOUT 1 // 1 uS
+#define SERIAL_PORT_MAX_TIMEOUT 100000000 // 100 seconds
+
//
// Function Prototypes
//