Hi Folks,

In SerialRead function in MdeModulePkg/Universal/SerialDxe/SerialIo.c, it seems the timeout processing in SerialRead is not consistent.

Since SerialPortPoll only checks the status of serial port and returns immediately, and SerialPortRead does not really implement a time out mechanism and will always wait for enough input, it will cause below results:

1. If there is no serial input at all, this interface will return timeout immediately without any waiting;

2. If there is A characters in serial port FIFO, and caller requires A+1 characters, it will wait until a new input is coming and timeout will not really occur.

As SerialPortLib is a simple library implementation, I think it is better to improve SerialIoDxe driver instead of SerialPortLib.

Please let me know your comments about this.

Thanks and regards,

Gary (Heyi Guo)

EFI_STATUS
EFIAPI
SerialRead (
  IN EFI_SERIAL_IO_PROTOCOL *This,
  IN OUT UINTN              *BufferSize,
  OUT VOID                  *Buffer
  )
{
  UINTN Count;

  Count = 0;

  if (SerialPortPoll ()) {
    Count = SerialPortRead (Buffer, *BufferSize);
  }

  if (Count != *BufferSize) {
    *BufferSize = Count;
    return EFI_TIMEOUT;
  }

  return EFI_SUCCESS;
}

_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to