]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EmbeddedPkg/SerialDxe/SerialIo.c
EmbeddedPkg/MmcDxe: Add 'This' pointer attribute to protocol function
[mirror_edk2.git] / EmbeddedPkg / SerialDxe / SerialIo.c
index e61338836701795d9c6f82290d079bef7db36f42..59d904c192a583f1cd4fe2e72cb0e4bcfb2b5bb0 100644 (file)
@@ -1,8 +1,8 @@
 /** @file\r
   Serial IO Abstraction for GDB stub. This allows an EFI consoles that shows up on the system \r
-  running GDB. One consle for error information and another console for user input/output.\r
+  running GDB. One console for error information and another console for user input/output.\r
   \r
-  Basic packet format is $packet-data#checksum. So every comand has 4 bytes of overhead: $, \r
+  Basic packet format is $packet-data#checksum. So every command has 4 bytes of overhead: $,\r
   #, 0, 0. The 0 and 0 are the ascii characters for the checksum. \r
   \r
 \r
@@ -48,15 +48,15 @@ SerialReset (
 \r
 \r
 /**\r
-  Sets the baud rate, receive FIFO depth, transmit/receice time out, parity, \r
+  Sets the baud rate, receive FIFO depth, transmit/receive time out, parity,\r
   data buts, and stop bits on a serial device.\r
 \r
   @param  This             Protocol instance pointer.\r
   @param  BaudRate         The requested baud rate. A BaudRate value of 0 will use the the\r
                            device's default interface speed.\r
-  @param  ReveiveFifoDepth The requested depth of the FIFO on the receive side of the\r
+  @param  ReceiveFifoDepth The requested depth of the FIFO on the receive side of the\r
                            serial interface. A ReceiveFifoDepth value of 0 will use\r
-                           the device's dfault FIFO depth.\r
+                           the device's default FIFO depth.\r
   @param  Timeout          The requested time out for a single character in microseconds.\r
                            This timeout applies to both the transmit and receive side of the\r
                            interface. A Timeout value of 0 will use the device's default time\r
@@ -64,7 +64,7 @@ SerialReset (
   @param  Parity           The type of parity to use on this serial device. A Parity value of\r
                            DefaultParity will use the device's default parity value.\r
   @param  DataBits         The number of data bits to use on the serial device. A DataBits\r
-                           vaule of 0 will use the device's default data bit setting.\r
+                           value of 0 will use the device's default data bit setting.\r
   @param  StopBits         The number of stop bits to use on this serial device. A StopBits\r
                            value of DefaultStopBits will use the device's default number of\r
                            stop bits.\r
@@ -112,7 +112,7 @@ SerialSetControl (
 \r
 \r
 /**\r
-  Retrieves the status of thecontrol bits on a serial device\r
+  Retrieves the status of the control bits on a serial device\r
 \r
   @param  This              Protocol instance pointer.\r
   @param  Control           A pointer to return the current Control signals from the serial device.\r
@@ -188,24 +188,30 @@ SerialRead (
   OUT VOID                   *Buffer\r
   )\r
 {\r
-  UINTN Count;\r
+  UINTN Count = 0;\r
   \r
-  Count = SerialPortRead (Buffer, *BufferSize);\r
-  *BufferSize = Count;\r
-  return (Count == 0) ? EFI_DEVICE_ERROR : EFI_SUCCESS;\r
+  if (SerialPortPoll()) {\r
+    Count = SerialPortRead (Buffer, *BufferSize);\r
+    *BufferSize = Count;\r
+    return (Count == 0) ? EFI_DEVICE_ERROR : EFI_SUCCESS;\r
+  }\r
+  \r
+  // No data to return\r
+  *BufferSize = 0;\r
+  return EFI_SUCCESS;\r
 }\r
 \r
 \r
 EFI_HANDLE  gHandle = NULL;\r
 \r
 // \r
-// Template used to initailize the GDB Serial IO protocols\r
+// Template used to initialize the GDB Serial IO protocols\r
 //\r
 EFI_SERIAL_IO_MODE gSerialIoMode = {\r
   0,                                          // ControlMask\r
   0,                                          // Timeout\r
   FixedPcdGet64 (PcdUartDefaultBaudRate),     // BaudRate\r
-  1,                                          // RceiveFifoDepth\r
+  1,                                          // ReceiveFifoDepth\r
   FixedPcdGet8 (PcdUartDefaultDataBits),      // DataBits\r
   FixedPcdGet8 (PcdUartDefaultParity),        // Parity\r
   FixedPcdGet8 (PcdUartDefaultStopBits)       // StopBits\r
@@ -235,7 +241,7 @@ SIMPLE_TEXT_OUT_DEVICE_PATH mDevicePath = {
     EFI_CALLER_ID_GUID // Use the drivers GUID\r
   },\r
   {\r
-    { END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, sizeof (UART_DEVICE_PATH), 0},\r
+    { MESSAGING_DEVICE_PATH, MSG_UART_DP, sizeof (UART_DEVICE_PATH), 0},\r
     0,        // Reserved\r
     FixedPcdGet64 (PcdUartDefaultBaudRate),   // BaudRate\r
     FixedPcdGet8 (PcdUartDefaultDataBits),    // DataBits\r