Cleanup SerailIO drivers to have a device path and use PCD settings for various stuff...
[mirror_edk2.git] / EmbeddedPkg / SerialDxe / SerialIo.c
index aa9653b..9543f1d 100644 (file)
@@ -23,6 +23,7 @@
 #include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/SerialPortLib.h>\r
+#include <Library/PcdLib.h>\r
 \r
 #include <Protocol/SerialIo.h>\r
 \r
@@ -189,7 +190,7 @@ SerialRead (
 {\r
   UINTN Count;\r
   \r
-  Count = SerialPortWrite (Buffer, *BufferSize);\r
+  Count = SerialPortRead (Buffer, *BufferSize);\r
   *BufferSize = Count;\r
   return (Count == 0) ? EFI_DEVICE_ERROR : EFI_SUCCESS;\r
 }\r
@@ -201,13 +202,13 @@ EFI_HANDLE  gHandle = NULL;
 // Template used to initailize the GDB Serial IO protocols\r
 //\r
 EFI_SERIAL_IO_MODE gSerialIoMode = {\r
-  0,      // ControlMask\r
-  0,      // Timeout\r
-  0,      // BaudRate\r
-  1,      // RceiveFifoDepth\r
-  0,      // DataBits\r
-  0,      // Parity\r
-  0       // StopBits\r
+  0,                                          // ControlMask\r
+  0,                                          // Timeout\r
+  FixedPcdGet64 (PcdUartDefaultBaudRate),     // BaudRate\r
+  1,                                          // RceiveFifoDepth\r
+  FixedPcdGet8 (PcdUartDefaultDataBits),      // DataBits\r
+  FixedPcdGet8 (PcdUartDefaultParity),        // Parity\r
+  FixedPcdGet8 (PcdUartDefaultStopBits)       // StopBits\r
 };\r
 \r
 \r
@@ -222,6 +223,28 @@ EFI_SERIAL_IO_PROTOCOL gSerialIoTemplate = {
   &gSerialIoMode\r
 };\r
   \r
+typedef struct {\r
+  VENDOR_DEVICE_PATH        Guid;\r
+  UART_DEVICE_PATH          Uart;\r
+  EFI_DEVICE_PATH_PROTOCOL  End;\r
+} SIMPLE_TEXT_OUT_DEVICE_PATH;\r
+\r
+SIMPLE_TEXT_OUT_DEVICE_PATH mDevicePath = {\r
+  {\r
+    { HARDWARE_DEVICE_PATH, HW_VENDOR_DP, sizeof (VENDOR_DEVICE_PATH), 0},\r
+    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
+    0,        // Reserved\r
+    FixedPcdGet64 (PcdUartDefaultBaudRate),   // BaudRate\r
+    FixedPcdGet8 (PcdUartDefaultDataBits),    // DataBits\r
+    FixedPcdGet8 (PcdUartDefaultParity),      // Parity (N)\r
+    FixedPcdGet8 (PcdUartDefaultStopBits)     // StopBits\r
+  },\r
+  { END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, sizeof (EFI_DEVICE_PATH_PROTOCOL), 0}\r
+};\r
+\r
 \r
 /**\r
   Initialize the state information for the Serial Io Protocol\r
@@ -248,7 +271,7 @@ SerialDxeInitialize (
   Status = gBS->InstallMultipleProtocolInterfaces (\r
                   &gHandle, \r
                   &gEfiSerialIoProtocolGuid,   &gSerialIoTemplate,\r
-                  &gEfiDevicePathProtocolGuid, NULL, // BugBug: Need a device path\r
+                  &gEfiDevicePathProtocolGuid, &mDevicePath, \r
                   NULL\r
                   );\r
   ASSERT_EFI_ERROR (Status);\r