+\r
+ //\r
+ // Make sure all parameters are valid\r
+ //\r
+ if ((BaudRate > SERIAL_PORT_MAX_BAUD_RATE) || (BaudRate < SERIAL_PORT_MIN_BAUD_RATE)) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ //\r
+ //The lower baud rate supported by the serial device will be selected without exceeding the unsupported BaudRate parameter\r
+ // \r
+ \r
+ for (Index = 1; Index < (sizeof (mBaudRateCurrentSupport) / sizeof (mBaudRateCurrentSupport[0])); Index++) {\r
+ if (BaudRate < mBaudRateCurrentSupport[Index]) {\r
+ BaudRate = mBaudRateCurrentSupport[Index-1];\r
+ break;\r
+ }\r
+ }\r
+ \r
+ if ((ReceiveFifoDepth < 1) || (ReceiveFifoDepth > SERIAL_PORT_MAX_RECEIVE_FIFO_DEPTH)) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ if ((Timeout < SERIAL_PORT_MIN_TIMEOUT) || (Timeout > SERIAL_PORT_MAX_TIMEOUT)) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ if ((Parity < NoParity) || (Parity > SpaceParity)) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ if ((StopBits < OneStopBit) || (StopBits > TwoStopBits)) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ //\r
+ // Now we only support DataBits=7,8.\r
+ //\r
+ if ((DataBits < 7) || (DataBits > 8)) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+ \r
+ //\r
+ // Now we only support DataBits=7,8.\r
+ // for DataBits = 6,7,8, StopBits can not set OneFiveStopBits.\r
+ //\r
+ if (StopBits == OneFiveStopBits) {\r
+ return EFI_INVALID_PARAMETER;\r
+ } \r
+ \r