summaryrefslogtreecommitdiff
path: root/EmbeddedPkg
diff options
context:
space:
mode:
authorandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>2010-02-15 20:40:51 +0000
committerandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>2010-02-15 20:40:51 +0000
commit026e30c4bb80a73ac7c5c286711ae07b1c51108b (patch)
tree84fbc585ed86e924d54382baebef00ac7870e891 /EmbeddedPkg
parent95572bd1b8b55fff0b714b3e3a5f923f38eae460 (diff)
downloadedk2-platforms-026e30c4bb80a73ac7c5c286711ae07b1c51108b.tar.xz
Cleanup SerailIO drivers to have a device path and use PCD settings for various stuff. Also clean up a few coding convention items.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10009 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EmbeddedPkg')
-rw-r--r--EmbeddedPkg/SerialDxe/SerialDxe.inf10
-rw-r--r--EmbeddedPkg/SerialDxe/SerialIo.c41
-rw-r--r--EmbeddedPkg/SimpleTextInOutSerial/SimpleTextInOut.c34
-rw-r--r--EmbeddedPkg/SimpleTextInOutSerial/SimpleTextInOutSerial.inf7
4 files changed, 79 insertions, 13 deletions
diff --git a/EmbeddedPkg/SerialDxe/SerialDxe.inf b/EmbeddedPkg/SerialDxe/SerialDxe.inf
index e2f46ecf1b..23139bddde 100644
--- a/EmbeddedPkg/SerialDxe/SerialDxe.inf
+++ b/EmbeddedPkg/SerialDxe/SerialDxe.inf
@@ -1,6 +1,6 @@
#/** @file
#
-# Component discription file for Bds module
+# Convert SerialLib into SerialIo protocol
#
# Copyright (c) 2008, Intel Corporation. <BR>
# All rights reserved. This program and the accompanying materials
@@ -47,7 +47,13 @@
[Protocols]
gEfiSerialIoProtocolGuid
gEfiDevicePathProtocolGuid
-
+[FixedPcd]
+ gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate
+ gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits
+ gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity
+ gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits
+
+
[Depex]
TRUE
diff --git a/EmbeddedPkg/SerialDxe/SerialIo.c b/EmbeddedPkg/SerialDxe/SerialIo.c
index aa9653bcf3..9543f1d1ec 100644
--- a/EmbeddedPkg/SerialDxe/SerialIo.c
+++ b/EmbeddedPkg/SerialDxe/SerialIo.c
@@ -23,6 +23,7 @@
#include <Library/UefiBootServicesTableLib.h>
#include <Library/DebugLib.h>
#include <Library/SerialPortLib.h>
+#include <Library/PcdLib.h>
#include <Protocol/SerialIo.h>
@@ -189,7 +190,7 @@ SerialRead (
{
UINTN Count;
- Count = SerialPortWrite (Buffer, *BufferSize);
+ Count = SerialPortRead (Buffer, *BufferSize);
*BufferSize = Count;
return (Count == 0) ? EFI_DEVICE_ERROR : EFI_SUCCESS;
}
@@ -201,13 +202,13 @@ EFI_HANDLE gHandle = NULL;
// Template used to initailize the GDB Serial IO protocols
//
EFI_SERIAL_IO_MODE gSerialIoMode = {
- 0, // ControlMask
- 0, // Timeout
- 0, // BaudRate
- 1, // RceiveFifoDepth
- 0, // DataBits
- 0, // Parity
- 0 // StopBits
+ 0, // ControlMask
+ 0, // Timeout
+ FixedPcdGet64 (PcdUartDefaultBaudRate), // BaudRate
+ 1, // RceiveFifoDepth
+ FixedPcdGet8 (PcdUartDefaultDataBits), // DataBits
+ FixedPcdGet8 (PcdUartDefaultParity), // Parity
+ FixedPcdGet8 (PcdUartDefaultStopBits) // StopBits
};
@@ -222,6 +223,28 @@ EFI_SERIAL_IO_PROTOCOL gSerialIoTemplate = {
&gSerialIoMode
};
+typedef struct {
+ VENDOR_DEVICE_PATH Guid;
+ UART_DEVICE_PATH Uart;
+ EFI_DEVICE_PATH_PROTOCOL End;
+} SIMPLE_TEXT_OUT_DEVICE_PATH;
+
+SIMPLE_TEXT_OUT_DEVICE_PATH mDevicePath = {
+ {
+ { HARDWARE_DEVICE_PATH, HW_VENDOR_DP, sizeof (VENDOR_DEVICE_PATH), 0},
+ EFI_CALLER_ID_GUID // Use the drivers GUID
+ },
+ {
+ { END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, sizeof (UART_DEVICE_PATH), 0},
+ 0, // Reserved
+ FixedPcdGet64 (PcdUartDefaultBaudRate), // BaudRate
+ FixedPcdGet8 (PcdUartDefaultDataBits), // DataBits
+ FixedPcdGet8 (PcdUartDefaultParity), // Parity (N)
+ FixedPcdGet8 (PcdUartDefaultStopBits) // StopBits
+ },
+ { END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, sizeof (EFI_DEVICE_PATH_PROTOCOL), 0}
+};
+
/**
Initialize the state information for the Serial Io Protocol
@@ -248,7 +271,7 @@ SerialDxeInitialize (
Status = gBS->InstallMultipleProtocolInterfaces (
&gHandle,
&gEfiSerialIoProtocolGuid, &gSerialIoTemplate,
- &gEfiDevicePathProtocolGuid, NULL, // BugBug: Need a device path
+ &gEfiDevicePathProtocolGuid, &mDevicePath,
NULL
);
ASSERT_EFI_ERROR (Status);
diff --git a/EmbeddedPkg/SimpleTextInOutSerial/SimpleTextInOut.c b/EmbeddedPkg/SimpleTextInOutSerial/SimpleTextInOut.c
index f491de6e95..bdc67fbda0 100644
--- a/EmbeddedPkg/SimpleTextInOutSerial/SimpleTextInOut.c
+++ b/EmbeddedPkg/SimpleTextInOutSerial/SimpleTextInOut.c
@@ -64,10 +64,12 @@
#include <Library/MemoryAllocationLib.h>
#include <Library/DebugLib.h>
#include <Library/SerialPortLib.h>
+#include <Library/PcdLib.h>
#include <Protocol/SerialIo.h>
#include <Protocol/SimpleTextIn.h>
#include <Protocol/SimpleTextOut.h>
+#include <Protocol/DevicePath.h>
#define MODE0_COLUMN_COUNT 80
@@ -198,7 +200,30 @@ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL mSimpleTextOut = {
&mSimpleTextOutMode
};
- EFI_HANDLE mInstallHandle = NULL;
+EFI_HANDLE mInstallHandle = NULL;
+
+typedef struct {
+ VENDOR_DEVICE_PATH Guid;
+ UART_DEVICE_PATH Uart;
+ EFI_DEVICE_PATH_PROTOCOL End;
+} SIMPLE_TEXT_OUT_DEVICE_PATH;
+
+SIMPLE_TEXT_OUT_DEVICE_PATH mDevicePath = {
+ {
+ { HARDWARE_DEVICE_PATH, HW_VENDOR_DP, sizeof (VENDOR_DEVICE_PATH), 0},
+ EFI_CALLER_ID_GUID
+ },
+ {
+ { END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, sizeof (UART_DEVICE_PATH), 0},
+ 0, // Reserved
+ FixedPcdGet64 (PcdUartDefaultBaudRate), // BaudRate
+ FixedPcdGet8 (PcdUartDefaultDataBits), // DataBits
+ FixedPcdGet8 (PcdUartDefaultParity), // Parity (N)
+ FixedPcdGet8 (PcdUartDefaultStopBits) // StopBits
+ },
+ { END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, sizeof (EFI_DEVICE_PATH_PROTOCOL), 0}
+};
+
@@ -271,6 +296,10 @@ ReadKeyStroke (
{
CHAR8 Char;
+ if (!SerialPortPoll ()) {
+ return EFI_NOT_READY;
+ }
+
SerialPortRead ((UINT8 *)&Char, 1);
//
@@ -660,7 +689,8 @@ SimpleTextInOutEntryPoint (
&mInstallHandle,
&gEfiSimpleTextInProtocolGuid, &mSimpleTextIn,
&gEfiSimpleTextOutProtocolGuid, &mSimpleTextOut,
- NULL
+ &gEfiDevicePathProtocolGuid, &mDevicePath,
+ NULL
);
if (!EFI_ERROR (Status)) {
gST->ConOut = &mSimpleTextOut;
diff --git a/EmbeddedPkg/SimpleTextInOutSerial/SimpleTextInOutSerial.inf b/EmbeddedPkg/SimpleTextInOutSerial/SimpleTextInOutSerial.inf
index 9799d550c3..e06a83d4e7 100644
--- a/EmbeddedPkg/SimpleTextInOutSerial/SimpleTextInOutSerial.inf
+++ b/EmbeddedPkg/SimpleTextInOutSerial/SimpleTextInOutSerial.inf
@@ -51,5 +51,12 @@
gEfiSerialIoProtocolGuid
gEfiDevicePathProtocolGuid
+[FixedPcd]
+ gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate
+ gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits
+ gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity
+ gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits
+
+
[depex]
TRUE