]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Import IsaSerialDxe in IntelFrameworkModulePkg.
authoryshang1 <yshang1@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 10 Jul 2007 09:38:02 +0000 (09:38 +0000)
committeryshang1 <yshang1@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 10 Jul 2007 09:38:02 +0000 (09:38 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@3170 6f19259b-4bc3-4df7-8a09-765794883524

IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/ComponentName.c [new file with mode: 0644]
IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/ComponentName.h [new file with mode: 0644]
IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerial.inf [new file with mode: 0644]
IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerial.msa [new file with mode: 0644]
IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.c [new file with mode: 0644]
IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.h [new file with mode: 0644]
IntelFrameworkModulePkg/IntelFrameworkModulePkg.dsc

diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/ComponentName.c b/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/ComponentName.c
new file mode 100644 (file)
index 0000000..2156c1a
--- /dev/null
@@ -0,0 +1,226 @@
+/*++\r
+\r
+Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved. <BR> \r
+This software and associated documentation (if any) is furnished\r
+under a license and may only be used or copied in accordance\r
+with the terms of the license. Except as permitted by such\r
+license, no part of this software or documentation may be\r
+reproduced, stored in a retrieval system, or transmitted in any\r
+form or by any means without the express written consent of\r
+Intel Corporation.\r
+\r
+\r
+Module Name:\r
+\r
+  ComponentName.c\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+#include "Serial.h"\r
+\r
+//\r
+// EFI Component Name Protocol\r
+//\r
+EFI_COMPONENT_NAME_PROTOCOL     gIsaSerialComponentName = {\r
+  IsaSerialComponentNameGetDriverName,\r
+  IsaSerialComponentNameGetControllerName,\r
+  "eng"\r
+};\r
+\r
+STATIC EFI_UNICODE_STRING_TABLE mIsaSerialDriverNameTable[] = {\r
+  {\r
+    "eng",\r
+    L"ISA Serial Driver"\r
+  },\r
+  {\r
+    NULL,\r
+    NULL\r
+  }\r
+};\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+IsaSerialComponentNameGetDriverName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
+  IN  CHAR8                        *Language,\r
+  OUT CHAR16                       **DriverName\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+  \r
+    Retrieves a Unicode string that is the user readable name of the EFI Driver.\r
+\r
+  Arguments:\r
+  \r
+    This       - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
+    Language   - A pointer to a three character ISO 639-2 language identifier.\r
+                 This is the language of the driver name that that the caller \r
+                 is requesting, and it must match one of the languages specified\r
+                 in SupportedLanguages.  The number of languages supported by a \r
+                 driver is up to the driver writer.\r
+    DriverName - A pointer to the Unicode string to return.  This Unicode string\r
+                 is the name of the driver specified by This in the language \r
+                 specified by Language.\r
+\r
+  Returns:\r
+  \r
+    EFI_SUCCESS           - The Unicode string for the Driver specified by This\r
+                            and the language specified by Language was returned \r
+                            in DriverName.\r
+    EFI_INVALID_PARAMETER - Language is NULL.\r
+    EFI_INVALID_PARAMETER - DriverName is NULL.\r
+    EFI_UNSUPPORTED       - The driver specified by This does not support the \r
+                            language specified by Language.\r
+\r
+--*/\r
+{\r
+  return LookupUnicodeString (\r
+           Language,\r
+           gIsaSerialComponentName.SupportedLanguages,\r
+           mIsaSerialDriverNameTable,\r
+           DriverName\r
+           );\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+IsaSerialComponentNameGetControllerName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
+  IN  EFI_HANDLE                                      ControllerHandle,\r
+  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
+  IN  CHAR8                                           *Language,\r
+  OUT CHAR16                                          **ControllerName\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+  \r
+    Retrieves a Unicode string that is the user readable name of the controller\r
+    that is being managed by an EFI Driver.\r
+\r
+  Arguments:\r
+  \r
+    This             - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
+    ControllerHandle - The handle of a controller that the driver specified by \r
+                       This is managing.  This handle specifies the controller \r
+                       whose name is to be returned.\r
+    ChildHandle      - The handle of the child controller to retrieve the name \r
+                       of.  This is an optional parameter that may be NULL.  It \r
+                       will be NULL for device drivers.  It will also be NULL \r
+                       for a bus drivers that wish to retrieve the name of the \r
+                       bus controller.  It will not be NULL for a bus driver \r
+                       that wishes to retrieve the name of a child controller.\r
+    Language         - A pointer to a three character ISO 639-2 language \r
+                       identifier.  This is the language of the controller name \r
+                       that that the caller is requesting, and it must match one\r
+                       of the languages specified in SupportedLanguages.  The \r
+                       number of languages supported by a driver is up to the \r
+                       driver writer.\r
+    ControllerName   - A pointer to the Unicode string to return.  This Unicode\r
+                       string is the name of the controller specified by \r
+                       ControllerHandle and ChildHandle in the language \r
+                       specified by Language from the point of view of the \r
+                       driver specified by This. \r
+\r
+  Returns:\r
+  \r
+    EFI_SUCCESS           - The Unicode string for the user readable name in the \r
+                            language specified by Language for the driver \r
+                            specified by This was returned in DriverName.\r
+    EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
+    EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid \r
+                            EFI_HANDLE.\r
+    EFI_INVALID_PARAMETER - Language is NULL.\r
+    EFI_INVALID_PARAMETER - ControllerName is NULL.\r
+    EFI_UNSUPPORTED       - The driver specified by This is not currently \r
+                            managing the controller specified by \r
+                            ControllerHandle and ChildHandle.\r
+    EFI_UNSUPPORTED       - The driver specified by This does not support the \r
+                            language specified by Language.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS              Status;\r
+  EFI_SERIAL_IO_PROTOCOL  *SerialIo;\r
+  SERIAL_DEV              *SerialDevice;\r
+\r
+  //\r
+  // This is a device driver, so ChildHandle must be NULL.\r
+  //\r
+  if (ChildHandle != NULL) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+  //\r
+  // Make sure this driver is currently managing ControllerHandle\r
+  //\r
+  Status = EfiTestManagedDevice (\r
+             ControllerHandle,\r
+             gSerialControllerDriver.DriverBindingHandle,\r
+             &gEfiIsaIoProtocolGuid\r
+             );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+  //\r
+  // Get the Block I/O Protocol on Controller\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                  &gEfiSerialIoProtocolGuid,\r
+                  (VOID **) &SerialIo,\r
+                  gSerialControllerDriver.DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+  //\r
+  // Get the Serial Controller's Device structure\r
+  //\r
+  SerialDevice = SERIAL_DEV_FROM_THIS (SerialIo);\r
+\r
+  return LookupUnicodeString (\r
+           Language,\r
+           gIsaSerialComponentName.SupportedLanguages,\r
+           SerialDevice->ControllerNameTable,\r
+           ControllerName\r
+           );\r
+}\r
+\r
+VOID\r
+AddName (\r
+  IN  SERIAL_DEV                               *SerialDevice,\r
+  IN  EFI_ISA_IO_PROTOCOL                      *IsaIo\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+  \r
+    Add the component name for the serial io device\r
+\r
+  Arguments:\r
+  \r
+    SerialDevice              - A pointer to the SERIAL_DEV instance.\r
+    IsaIo                     - A pointer to the EFI_ISA_IO_PROTOCOL or EFI_LIGHT_ISA_IO_PROTOCOL instance.\r
+    \r
+  Returns:\r
+\r
+    None\r
+    \r
+--*/\r
+{\r
+  CHAR16  SerialPortName[sizeof (SERIAL_PORT_NAME)];\r
+\r
+  StrCpy (SerialPortName, L"ISA Serial Port # ");\r
+  SerialPortName[sizeof (SERIAL_PORT_NAME) - 2] = (CHAR16) (L'0' + (UINT8) IsaIo->ResourceList->Device.UID);\r
+  AddUnicodeString (\r
+    "eng",\r
+    gIsaSerialComponentName.SupportedLanguages,\r
+    &SerialDevice->ControllerNameTable,\r
+    (CHAR16 *) SerialPortName\r
+    );\r
+}\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/ComponentName.h b/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/ComponentName.h
new file mode 100644 (file)
index 0000000..d17561a
--- /dev/null
@@ -0,0 +1,155 @@
+/*++\r
+\r
+Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.\r
+This software and associated documentation (if any) is furnished\r
+under a license and may only be used or copied in accordance\r
+with the terms of the license. Except as permitted by such\r
+license, no part of this software or documentation may be\r
+reproduced, stored in a retrieval system, or transmitted in any\r
+form or by any means without the express written consent of\r
+Intel Corporation.\r
+\r
+\r
+Module Name:\r
+\r
+  ComponentName.h\r
+\r
+Abstract:\r
+\r
+\r
+Revision History:\r
+\r
+--*/\r
+\r
+#ifndef _SERIAL_COMPONENT_NAME_H\r
+#define _SERIAL_COMPONENT_NAME_H\r
+\r
+#define SERIAL_PORT_NAME  "ISA Serial Port # "\r
+#define ADD_SERIAL_NAME(x, y)    AddName ((x), (y))\r
+\r
+extern EFI_COMPONENT_NAME_PROTOCOL  gIsaSerialComponentName;\r
+\r
+//\r
+// EFI Component Name Functions\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+IsaSerialComponentNameGetDriverName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
+  IN  CHAR8                        *Language,\r
+  OUT CHAR16                       **DriverName\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+\r
+    Retrieves a Unicode string that is the user readable name of the EFI Driver.\r
+\r
+  Arguments:\r
+\r
+    This       - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
+    Language   - A pointer to a three character ISO 639-2 language identifier.\r
+                 This is the language of the driver name that that the caller\r
+                 is requesting, and it must match one of the languages specified\r
+                 in SupportedLanguages.  The number of languages supported by a\r
+                 driver is up to the driver writer.\r
+    DriverName - A pointer to the Unicode string to return.  This Unicode string\r
+                 is the name of the driver specified by This in the language\r
+                 specified by Language.\r
+\r
+  Returns:\r
+\r
+    EFI_SUCCESS           - The Unicode string for the Driver specified by This\r
+                            and the language specified by Language was returned\r
+                            in DriverName.\r
+    EFI_INVALID_PARAMETER - Language is NULL.\r
+    EFI_INVALID_PARAMETER - DriverName is NULL.\r
+    EFI_UNSUPPORTED       - The driver specified by This does not support the\r
+                            language specified by Language.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+IsaSerialComponentNameGetControllerName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
+  IN  EFI_HANDLE                                      ControllerHandle,\r
+  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
+  IN  CHAR8                                           *Language,\r
+  OUT CHAR16                                          **ControllerName\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+\r
+    Retrieves a Unicode string that is the user readable name of the controller\r
+    that is being managed by an EFI Driver.\r
+\r
+  Arguments:\r
+\r
+    This             - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
+    ControllerHandle - The handle of a controller that the driver specified by\r
+                       This is managing.  This handle specifies the controller\r
+                       whose name is to be returned.\r
+    ChildHandle      - The handle of the child controller to retrieve the name\r
+                       of.  This is an optional parameter that may be NULL.  It\r
+                       will be NULL for device drivers.  It will also be NULL\r
+                       for a bus drivers that wish to retrieve the name of the\r
+                       bus controller.  It will not be NULL for a bus driver\r
+                       that wishes to retrieve the name of a child controller.\r
+    Language         - A pointer to a three character ISO 639-2 language\r
+                       identifier.  This is the language of the controller name\r
+                       that that the caller is requesting, and it must match one\r
+                       of the languages specified in SupportedLanguages.  The\r
+                       number of languages supported by a driver is up to the\r
+                       driver writer.\r
+    ControllerName   - A pointer to the Unicode string to return.  This Unicode\r
+                       string is the name of the controller specified by\r
+                       ControllerHandle and ChildHandle in the language\r
+                       specified by Language from the point of view of the\r
+                       driver specified by This.\r
+\r
+  Returns:\r
+\r
+    EFI_SUCCESS           - The Unicode string for the user readable name in the\r
+                            language specified by Language for the driver\r
+                            specified by This was returned in DriverName.\r
+    EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
+    EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid\r
+                            EFI_HANDLE.\r
+    EFI_INVALID_PARAMETER - Language is NULL.\r
+    EFI_INVALID_PARAMETER - ControllerName is NULL.\r
+    EFI_UNSUPPORTED       - The driver specified by This is not currently\r
+                            managing the controller specified by\r
+                            ControllerHandle and ChildHandle.\r
+    EFI_UNSUPPORTED       - The driver specified by This does not support the\r
+                            language specified by Language.\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+AddName (\r
+  IN  SERIAL_DEV                                   *SerialDevice,\r
+  IN  EFI_ISA_IO_PROTOCOL                          *IsaIo\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+\r
+    Add the component name for the serial io device\r
+\r
+  Arguments:\r
+\r
+    SerialDevice              - A pointer to the SERIAL_DEV instance.\r
+    IsaIo                     - A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
+\r
+  Returns:\r
+\r
+    None\r
+\r
+--*/\r
+;\r
+\r
+#endif\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerial.inf b/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerial.inf
new file mode 100644 (file)
index 0000000..119c9b9
--- /dev/null
@@ -0,0 +1,111 @@
+#/** @file\r
+# Component description file for IsaSerial module.\r
+#\r
+# Serial driver for standard UARTS on an ISA bus.\r
+# Copyright (c) 2006 - 2007, Intel Corporation.\r
+#\r
+#  All rights reserved.\r
+#  This software and associated documentation (if any) is furnished\r
+#  under a license and may only be used or copied in accordance\r
+#  with the terms of the license. Except as permitted by such\r
+#  license, no part of this software or documentation may be\r
+#  reproduced, stored in a retrieval system, or transmitted in any\r
+#  form or by any means without the express written consent of\r
+#  Intel Corporation.\r
+#\r
+#\r
+#**/\r
+\r
+################################################################################\r
+#\r
+# Defines Section - statements that will be processed to create a Makefile.\r
+#\r
+################################################################################\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = IsaSerial\r
+  FILE_GUID                      = 93B80003-9FB3-11d4-9A3A-0090273FC14D\r
+  MODULE_TYPE                    = DXE_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+  EDK_RELEASE_VERSION            = 0x00020000\r
+  EFI_SPECIFICATION_VERSION      = 0x00020000\r
+\r
+  ENTRY_POINT                    = InitializeIsaSerial\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+#  DRIVER_BINDING                =  gSerialControllerDriver                      \r
+#  COMPONENT_NAME                =  gIsaSerialComponentName                      \r
+#\r
+\r
+################################################################################\r
+#\r
+# Sources Section - list of files that are required for the build to succeed.\r
+#\r
+################################################################################\r
+\r
+[Sources.common]\r
+  ComponentName.c\r
+  ComponentName.h\r
+  serial.h\r
+  serial.c\r
+\r
+\r
+################################################################################\r
+#\r
+# Package Dependency Section - list of Package files that are required for\r
+#                              this module.\r
+#\r
+################################################################################\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r
+  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
+\r
+\r
+################################################################################\r
+#\r
+# Library Class Section - list of Library Classes that are required for\r
+#                         this module.\r
+#\r
+################################################################################\r
+\r
+[LibraryClasses]\r
+  PcdLib\r
+  ReportStatusCodeLib\r
+  UefiBootServicesTableLib\r
+  MemoryAllocationLib\r
+  BaseMemoryLib\r
+  DevicePathLib\r
+  UefiLib\r
+  BaseLib\r
+  UefiDriverEntryPoint\r
+  DebugLib\r
+\r
+\r
+################################################################################\r
+#\r
+# Protocol C Name Section - list of Protocol and Protocol Notify C Names\r
+#                           that this module uses or produces.\r
+#\r
+################################################################################\r
+\r
+[Protocols]\r
+  gEfiIsaIoProtocolGuid                         # PROTOCOL TO_START\r
+  gEfiSerialIoProtocolGuid                      # PROTOCOL BY_START\r
+  gEfiDevicePathProtocolGuid                    # PROTOCOL TO_START\r
+\r
+\r
+################################################################################\r
+#\r
+# Pcd FEATURE_FLAG - list of PCDs that this module is coded for.\r
+#\r
+################################################################################\r
+\r
+[PcdsFeatureFlag.common]\r
+  PcdNtEmulatorEnable|gEfiMdeModulePkgTokenSpaceGuid\r
+\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerial.msa b/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerial.msa
new file mode 100644 (file)
index 0000000..4ca5683
--- /dev/null
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0  http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd" xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
+  <MsaHeader>\r
+    <ModuleName>IsaSerial</ModuleName>\r
+    <ModuleType>DXE_DRIVER</ModuleType>\r
+    <GuidValue>93B80003-9FB3-11d4-9A3A-0090273FC14D</GuidValue>\r
+    <Version>1.0</Version>\r
+    <Abstract>Component description file for IsaSerial module.</Abstract>\r
+    <Description>Serial driver for standard UARTS on an ISA bus.</Description>\r
+    <Copyright>Copyright (c) 2006 - 2007, Intel Corporation.</Copyright>\r
+    <License>All rights reserved.
+      This software and associated documentation (if any) is furnished
+      under a license and may only be used or copied in accordance
+      with the terms of the license. Except as permitted by such
+      license, no part of this software or documentation may be
+      reproduced, stored in a retrieval system, or transmitted in any
+      form or by any means without the express written consent of
+      Intel Corporation.</License>\r
+    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
+  </MsaHeader>\r
+  <ModuleDefinitions>\r
+    <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+    <BinaryModule>false</BinaryModule>\r
+    <OutputFileBasename>IsaSerial</OutputFileBasename>\r
+  </ModuleDefinitions>\r
+  <LibraryClassDefinitions>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>DebugLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiDriverModelLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiDriverEntryPoint</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>DevicePathLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseMemoryLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>MemoryAllocationLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiBootServicesTableLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>ReportStatusCodeLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>PcdLib</Keyword>\r
+    </LibraryClass>\r
+  </LibraryClassDefinitions>\r
+  <SourceFiles>\r
+    <Filename>serial.c</Filename>\r
+    <Filename>serial.h</Filename>\r
+    <Filename>ComponentName.h</Filename>\r
+    <Filename>ComponentName.c</Filename>\r
+  </SourceFiles>\r
+  <PackageDependencies>\r
+    <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+    <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>\r
+  </PackageDependencies>\r
+  <Protocols>\r
+    <Protocol Usage="TO_START">\r
+      <ProtocolCName>gEfiDevicePathProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="BY_START">\r
+      <ProtocolCName>gEfiSerialIoProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="TO_START">\r
+      <ProtocolCName>gEfiIsaIoProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+  </Protocols>\r
+  <Externs>\r
+    <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+    <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+    <Extern>\r
+      <DriverBinding>gSerialControllerDriver</DriverBinding>\r
+      <ComponentName>gIsaSerialComponentName</ComponentName>\r
+    </Extern>\r
+  </Externs>\r
+  <PcdCoded>\r
+    <PcdEntry PcdItemType="FEATURE_FLAG" Usage="ALWAYS_CONSUMED">\r
+      <C_Name>PcdNtEmulatorEnable</C_Name>\r
+      <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <HelpText>If this PCD is set as TRUE, NT emulator will be endabled.</HelpText>\r
+    </PcdEntry>\r
+  </PcdCoded>\r
+</ModuleSurfaceArea>
\ No newline at end of file
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.c b/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.c
new file mode 100644 (file)
index 0000000..b21f635
--- /dev/null
@@ -0,0 +1,1902 @@
+/**@file\r
+       Serial driver for standard UARTS on an ISA bus.\r
+\r
+Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved. <BR>\r
+This software and associated documentation (if any) is furnished\r
+under a license and may only be used or copied in accordance\r
+with the terms of the license. Except as permitted by such\r
+license, no part of this software or documentation may be\r
+reproduced, stored in a retrieval system, or transmitted in any\r
+form or by any means without the express written consent of\r
+Intel Corporation.\r
+\r
+**/\r
+\r
+#include "Serial.h"\r
+\r
+//\r
+// ISA Serial Driver Global Variables\r
+//\r
+EFI_DRIVER_BINDING_PROTOCOL gSerialControllerDriver = {\r
+  SerialControllerDriverSupported,\r
+  SerialControllerDriverStart,\r
+  SerialControllerDriverStop,\r
+  0xa,\r
+  NULL,\r
+  NULL\r
+};\r
+\r
+\r
+/**\r
+  The user Entry Point for module IsaSerial. The user code starts with this function.\r
+\r
+  @param[in] ImageHandle    The firmware allocated handle for the EFI image.  \r
+  @param[in] SystemTable    A pointer to the EFI System Table.\r
+  \r
+  @retval EFI_SUCCESS       The entry point is executed successfully.\r
+  @retval other             Some error occurs when executing this entry point.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+InitializeIsaSerial(\r
+  IN EFI_HANDLE           ImageHandle,\r
+  IN EFI_SYSTEM_TABLE     *SystemTable\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+\r
+  //\r
+  // Install driver model protocol(s).\r
+  //\r
+  Status = EfiLibInstallAllDriverProtocols (\r
+             ImageHandle,\r
+             SystemTable,\r
+             &gSerialControllerDriver,\r
+             ImageHandle,\r
+             &gIsaSerialComponentName,\r
+             NULL,\r
+             NULL\r
+             );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+\r
+  return Status;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+SerialControllerDriverSupported (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
+  IN EFI_HANDLE                     Controller,\r
+  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+\r
+    Check to see if this driver supports the given controller\r
+\r
+  Arguments:\r
+\r
+    This - A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+    Controller - The handle of the controller to test.\r
+    RemainingDevicePath - A pointer to the remaining portion of a device path.\r
+\r
+  Returns:\r
+\r
+    EFI_SUCCESS - This driver can support the given controller\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                                Status;\r
+  EFI_DEVICE_PATH_PROTOCOL                  *ParentDevicePath;\r
+  EFI_ISA_IO_PROTOCOL                       *IsaIo;\r
+  UART_DEVICE_PATH                          UartNode;\r
+\r
+  //\r
+  // Ignore the RemainingDevicePath\r
+  //\r
+  //\r
+  // Open the IO Abstraction(s) needed to perform the supported test\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  Controller,\r
+                  &gEfiDevicePathProtocolGuid,\r
+                  (VOID **) &ParentDevicePath,\r
+                  This->DriverBindingHandle,\r
+                  Controller,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+  if (Status == EFI_ALREADY_STARTED) {\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  gBS->CloseProtocol (\r
+         Controller,\r
+         &gEfiDevicePathProtocolGuid,\r
+         This->DriverBindingHandle,\r
+         Controller\r
+         );\r
+\r
+  Status = gBS->OpenProtocol (\r
+                  Controller,\r
+                  &gEfiIsaIoProtocolGuid,\r
+                  (VOID **) &IsaIo,\r
+                  This->DriverBindingHandle,\r
+                  Controller,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+\r
+  if (Status == EFI_ALREADY_STARTED) {\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+  //\r
+  // Use the ISA I/O Protocol to see if Controller is standard ISA UART that\r
+  // can be managed by this driver.\r
+  //\r
+  Status = EFI_SUCCESS;\r
+  if (IsaIo->ResourceList->Device.HID != EISA_PNP_ID (0x501)) {\r
+    Status = EFI_UNSUPPORTED;\r
+    goto Error;\r
+  }\r
+  //\r
+  // Make sure RemainingDevicePath is valid\r
+  //\r
+  if (RemainingDevicePath != NULL) {\r
+    Status = EFI_UNSUPPORTED;\r
+    CopyMem (\r
+      &UartNode,\r
+      (UART_DEVICE_PATH *) RemainingDevicePath,\r
+      sizeof (UART_DEVICE_PATH)\r
+      );\r
+    if (UartNode.Header.Type != MESSAGING_DEVICE_PATH ||\r
+        UartNode.Header.SubType != MSG_UART_DP ||\r
+        sizeof (UART_DEVICE_PATH) != DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) &UartNode)\r
+                                      ) {\r
+      goto Error;\r
+    }\r
+\r
+    if (UartNode.BaudRate > SERIAL_PORT_MAX_BAUD_RATE) {\r
+      goto Error;\r
+    }\r
+\r
+    if (UartNode.Parity < NoParity || UartNode.Parity > SpaceParity) {\r
+      goto Error;\r
+    }\r
+\r
+    if (UartNode.DataBits < 5 || UartNode.DataBits > 8) {\r
+      goto Error;\r
+    }\r
+\r
+    if (UartNode.StopBits < OneStopBit || UartNode.StopBits > TwoStopBits) {\r
+      goto Error;\r
+    }\r
+\r
+    if ((UartNode.DataBits == 5) && (UartNode.StopBits == TwoStopBits)) {\r
+      goto Error;\r
+    }\r
+\r
+    if ((UartNode.DataBits >= 6) && (UartNode.DataBits <= 8) && (UartNode.StopBits == OneFiveStopBits)) {\r
+      goto Error;\r
+    }\r
+\r
+    Status = EFI_SUCCESS;\r
+  }\r
+\r
+Error:\r
+  //\r
+  // Close the I/O Abstraction(s) used to perform the supported test\r
+  //\r
+  gBS->CloseProtocol (\r
+         Controller,\r
+         &gEfiIsaIoProtocolGuid,\r
+         This->DriverBindingHandle,\r
+         Controller\r
+         );\r
+\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+SerialControllerDriverStart (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
+  IN EFI_HANDLE                     Controller,\r
+  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+\r
+    Start to management the controller passed in\r
+\r
+  Arguments:\r
+\r
+    This - A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+    Controller - The handle of the controller to test.\r
+    RemainingDevicePath - A pointer to the remaining portion of a device path.\r
+\r
+  Returns:\r
+\r
+    EFI_SUCCESS - Driver is started successfully\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                          Status;\r
+  EFI_ISA_IO_PROTOCOL                 *IsaIo;\r
+  SERIAL_DEV                          *SerialDevice;\r
+  UINTN                               Index;\r
+  UART_DEVICE_PATH                    Node;\r
+  EFI_DEVICE_PATH_PROTOCOL            *ParentDevicePath;\r
+  EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfoBuffer;\r
+  UINTN                               EntryCount;\r
+  EFI_SERIAL_IO_PROTOCOL              *SerialIo;\r
+\r
+  SerialDevice = NULL;\r
+  //\r
+  // Get the Parent Device Path\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  Controller,\r
+                  &gEfiDevicePathProtocolGuid,\r
+                  (VOID **) &ParentDevicePath,\r
+                  This->DriverBindingHandle,\r
+                  Controller,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+  if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {\r
+    return Status;\r
+  }\r
+  //\r
+  // Report status code enable the serial\r
+  //\r
+  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
+    EFI_PROGRESS_CODE,\r
+    EFI_P_PC_ENABLE | EFI_PERIPHERAL_SERIAL_PORT,\r
+    ParentDevicePath\r
+    );\r
+\r
+  //\r
+  // Grab the IO abstraction we need to get any work done\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  Controller,\r
+                  &gEfiIsaIoProtocolGuid,\r
+                  (VOID **) &IsaIo,\r
+                  This->DriverBindingHandle,\r
+                  Controller,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+  if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {\r
+    goto Error;\r
+  }\r
+\r
+  if (Status == EFI_ALREADY_STARTED) {\r
+\r
+    if (RemainingDevicePath == NULL) {\r
+      return EFI_SUCCESS;\r
+    }\r
+    //\r
+    // Make sure a child handle does not already exist.  This driver can only\r
+    // produce one child per serial port.\r
+    //\r
+    Status = gBS->OpenProtocolInformation (\r
+                    Controller,\r
+                    &gEfiIsaIoProtocolGuid,\r
+                    &OpenInfoBuffer,\r
+                    &EntryCount\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
+\r
+    Status = EFI_ALREADY_STARTED;\r
+    for (Index = 0; Index < EntryCount; Index++) {\r
+      if (OpenInfoBuffer[Index].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) {\r
+        Status = gBS->OpenProtocol (\r
+                        OpenInfoBuffer[Index].ControllerHandle,\r
+                        &gEfiSerialIoProtocolGuid,\r
+                        (VOID **) &SerialIo,\r
+                        This->DriverBindingHandle,\r
+                        Controller,\r
+                        EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                        );\r
+        if (!EFI_ERROR (Status)) {\r
+          CopyMem (&Node, RemainingDevicePath, sizeof (UART_DEVICE_PATH));\r
+          Status = SerialIo->SetAttributes (\r
+                               SerialIo,\r
+                               Node.BaudRate,\r
+                               SerialIo->Mode->ReceiveFifoDepth,\r
+                               SerialIo->Mode->Timeout,\r
+                               (EFI_PARITY_TYPE) Node.Parity,\r
+                               Node.DataBits,\r
+                               (EFI_STOP_BITS_TYPE) Node.StopBits\r
+                               );\r
+        }\r
+        break;\r
+      }\r
+    }\r
+\r
+    gBS->FreePool (OpenInfoBuffer);\r
+    return Status;\r
+  }\r
+  //\r
+  // Initialize the serial device instance\r
+  //\r
+  SerialDevice = AllocatePool (sizeof (SERIAL_DEV));\r
+  if (SerialDevice == NULL) {\r
+    Status = EFI_OUT_OF_RESOURCES;\r
+    goto Error;\r
+  }\r
+\r
+  ZeroMem (SerialDevice, sizeof (SERIAL_DEV));\r
+\r
+  SerialDevice->IsaIo               = IsaIo;\r
+  SerialDevice->ParentDevicePath    = ParentDevicePath;\r
+  SerialDevice->ControllerNameTable = NULL;\r
+\r
+  ADD_SERIAL_NAME (SerialDevice, IsaIo);\r
+\r
+  for (Index = 0; SerialDevice->IsaIo->ResourceList->ResourceItem[Index].Type != EfiIsaAcpiResourceEndOfList; Index++) {\r
+    if (SerialDevice->IsaIo->ResourceList->ResourceItem[Index].Type == EfiIsaAcpiResourceIo) {\r
+      SerialDevice->BaseAddress = (UINT16) SerialDevice->IsaIo->ResourceList->ResourceItem[Index].StartRange;\r
+    }\r
+  }\r
+  //\r
+  // Report status code the serial present\r
+  //\r
+  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
+    EFI_PROGRESS_CODE,\r
+    EFI_P_PC_PRESENCE_DETECT | EFI_PERIPHERAL_SERIAL_PORT,\r
+    ParentDevicePath\r
+    );\r
+\r
+  if (!IsaSerialPortPresent (SerialDevice)) {\r
+    Status = EFI_DEVICE_ERROR;\r
+    REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
+      EFI_ERROR_CODE,\r
+      EFI_P_EC_NOT_DETECTED | EFI_PERIPHERAL_SERIAL_PORT,\r
+      ParentDevicePath\r
+      );\r
+    goto Error;\r
+  }\r
+\r
+  SerialDevice->Signature               = SERIAL_DEV_SIGNATURE;\r
+  SerialDevice->Type                    = UART16550A;\r
+  SerialDevice->SoftwareLoopbackEnable  = FALSE;\r
+  SerialDevice->HardwareFlowControl     = FALSE;\r
+  SerialDevice->Handle                  = NULL;\r
+  SerialDevice->Receive.First           = 0;\r
+  SerialDevice->Receive.Last            = 0;\r
+  SerialDevice->Receive.Surplus         = SERIAL_MAX_BUFFER_SIZE;\r
+  SerialDevice->Transmit.First          = 0;\r
+  SerialDevice->Transmit.Last           = 0;\r
+  SerialDevice->Transmit.Surplus        = SERIAL_MAX_BUFFER_SIZE;\r
+\r
+  //\r
+  // Serial I/O\r
+  //\r
+  SerialDevice->SerialIo.Revision       = SERIAL_IO_INTERFACE_REVISION;\r
+  SerialDevice->SerialIo.Reset          = IsaSerialReset;\r
+  SerialDevice->SerialIo.SetAttributes  = IsaSerialSetAttributes;\r
+  SerialDevice->SerialIo.SetControl     = IsaSerialSetControl;\r
+  SerialDevice->SerialIo.GetControl     = IsaSerialGetControl;\r
+  SerialDevice->SerialIo.Write          = IsaSerialWrite;\r
+  SerialDevice->SerialIo.Read           = IsaSerialRead;\r
+  SerialDevice->SerialIo.Mode           = &(SerialDevice->SerialMode);\r
+\r
+  if (RemainingDevicePath != NULL) {\r
+    //\r
+    // Match the configuration of the RemainingDevicePath. IsHandleSupported()\r
+    // already checked to make sure the RemainingDevicePath contains settings\r
+    // that we can support.\r
+    //\r
+    CopyMem (&SerialDevice->UartDevicePath, RemainingDevicePath, sizeof (UART_DEVICE_PATH));\r
+  } else {\r
+    //\r
+    // Build the device path by appending the UART node to the ParentDevicePath\r
+    // from the WinNtIo handle. The Uart setings are zero here, since\r
+    // SetAttribute() will update them to match the default setings.\r
+    //\r
+    ZeroMem (&SerialDevice->UartDevicePath, sizeof (UART_DEVICE_PATH));\r
+    SerialDevice->UartDevicePath.Header.Type    = MESSAGING_DEVICE_PATH;\r
+    SerialDevice->UartDevicePath.Header.SubType = MSG_UART_DP;\r
+    SetDevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) &SerialDevice->UartDevicePath, sizeof (UART_DEVICE_PATH));\r
+  }\r
+  //\r
+  // Build the device path by appending the UART node to the ParentDevicePath\r
+  // from the WinNtIo handle. The Uart setings are zero here, since\r
+  // SetAttribute() will update them to match the current setings.\r
+  //\r
+  SerialDevice->DevicePath = AppendDevicePathNode (\r
+                               ParentDevicePath,\r
+                               (EFI_DEVICE_PATH_PROTOCOL *) &SerialDevice->UartDevicePath\r
+                               );\r
+\r
+  if (SerialDevice->DevicePath == NULL) {\r
+    Status = EFI_DEVICE_ERROR;\r
+    goto Error;\r
+  }\r
+  //\r
+  // Fill in Serial I/O Mode structure based on either the RemainingDevicePath or defaults.\r
+  //\r
+  SerialDevice->SerialMode.ControlMask      = SERIAL_PORT_DEFAULT_CONTROL_MASK;\r
+  SerialDevice->SerialMode.Timeout          = SERIAL_PORT_DEFAULT_TIMEOUT;\r
+  SerialDevice->SerialMode.BaudRate         = SerialDevice->UartDevicePath.BaudRate;\r
+  SerialDevice->SerialMode.ReceiveFifoDepth = SERIAL_PORT_DEFAULT_RECEIVE_FIFO_DEPTH;\r
+  SerialDevice->SerialMode.DataBits         = SerialDevice->UartDevicePath.DataBits;\r
+  SerialDevice->SerialMode.Parity           = SerialDevice->UartDevicePath.Parity;\r
+  SerialDevice->SerialMode.StopBits         = SerialDevice->UartDevicePath.StopBits;\r
+\r
+  //\r
+  // Issue a reset to initialize the COM port\r
+  //\r
+  Status = SerialDevice->SerialIo.Reset (&SerialDevice->SerialIo);\r
+  if (EFI_ERROR (Status)) {\r
+    REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
+      EFI_ERROR_CODE,\r
+      EFI_P_EC_CONTROLLER_ERROR | EFI_PERIPHERAL_SERIAL_PORT,\r
+      ParentDevicePath\r
+      );\r
+    goto Error;\r
+  }\r
+  //\r
+  // Install protocol interfaces for the serial device.\r
+  //\r
+  Status = gBS->InstallMultipleProtocolInterfaces (\r
+                  &SerialDevice->Handle,\r
+                  &gEfiDevicePathProtocolGuid,\r
+                  SerialDevice->DevicePath,\r
+                  &gEfiSerialIoProtocolGuid,\r
+                  &SerialDevice->SerialIo,\r
+                  NULL\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    goto Error;\r
+  }\r
+  //\r
+  // Open For Child Device\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  Controller,\r
+                  &gEfiIsaIoProtocolGuid,\r
+                  (VOID **) &IsaIo,\r
+                  This->DriverBindingHandle,\r
+                  SerialDevice->Handle,\r
+                  EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
+                  );\r
+\r
+Error:\r
+  if (EFI_ERROR (Status)) {\r
+    gBS->CloseProtocol (\r
+           Controller,\r
+           &gEfiDevicePathProtocolGuid,\r
+           This->DriverBindingHandle,\r
+           Controller\r
+           );\r
+    gBS->CloseProtocol (\r
+           Controller,\r
+           &gEfiIsaIoProtocolGuid,\r
+           This->DriverBindingHandle,\r
+           Controller\r
+           );\r
+    if (SerialDevice) {\r
+      if (SerialDevice->DevicePath) {\r
+        gBS->FreePool (SerialDevice->DevicePath);\r
+      }\r
+\r
+      FreeUnicodeStringTable (SerialDevice->ControllerNameTable);\r
+      gBS->FreePool (SerialDevice);\r
+    }\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+SerialControllerDriverStop (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL    *This,\r
+  IN  EFI_HANDLE                     Controller,\r
+  IN  UINTN                          NumberOfChildren,\r
+  IN  EFI_HANDLE                     *ChildHandleBuffer\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+\r
+    Disconnect this driver with the controller, uninstall related protocol instance\r
+\r
+  Arguments:\r
+\r
+    This                - A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+    Controller          - The handle of the controller to test.\r
+    NumberOfChildren    - Number of child device.\r
+    RemainingDevicePath - A pointer to the remaining portion of a device path.\r
+\r
+  Returns:\r
+\r
+    EFI_SUCCESS         - Operation successfully\r
+    EFI_DEVICE_ERROR    - Cannot stop the driver successfully\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                          Status;\r
+  UINTN                               Index;\r
+  BOOLEAN                             AllChildrenStopped;\r
+  EFI_SERIAL_IO_PROTOCOL              *SerialIo;\r
+  SERIAL_DEV                          *SerialDevice;\r
+  EFI_ISA_IO_PROTOCOL                 *IsaIo;\r
+  EFI_DEVICE_PATH_PROTOCOL            *DevicePath;\r
+\r
+  Status = gBS->HandleProtocol (\r
+                  Controller,\r
+                  &gEfiDevicePathProtocolGuid,\r
+                  (VOID **) &DevicePath\r
+                  );\r
+\r
+  //\r
+  // Report the status code disable the serial\r
+  //\r
+  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
+    EFI_PROGRESS_CODE,\r
+    EFI_P_PC_DISABLE | EFI_PERIPHERAL_SERIAL_PORT,\r
+    DevicePath\r
+    );\r
+\r
+  //\r
+  // Complete all outstanding transactions to Controller.\r
+  // Don't allow any new transaction to Controller to be started.\r
+  //\r
+  if (NumberOfChildren == 0) {\r
+    //\r
+    // Close the bus driver\r
+    //\r
+    Status = gBS->CloseProtocol (\r
+                    Controller,\r
+                    &gEfiIsaIoProtocolGuid,\r
+                    This->DriverBindingHandle,\r
+                    Controller\r
+                    );\r
+\r
+    Status = gBS->CloseProtocol (\r
+                    Controller,\r
+                    &gEfiDevicePathProtocolGuid,\r
+                    This->DriverBindingHandle,\r
+                    Controller\r
+                    );\r
+    return Status;\r
+  }\r
+\r
+  AllChildrenStopped = TRUE;\r
+\r
+  for (Index = 0; Index < NumberOfChildren; Index++) {\r
+\r
+    Status = gBS->OpenProtocol (\r
+                    ChildHandleBuffer[Index],\r
+                    &gEfiSerialIoProtocolGuid,\r
+                    (VOID **) &SerialIo,\r
+                    This->DriverBindingHandle,\r
+                    Controller,\r
+                    EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                    );\r
+    if (!EFI_ERROR (Status)) {\r
+\r
+      SerialDevice = SERIAL_DEV_FROM_THIS (SerialIo);\r
+\r
+      Status = gBS->CloseProtocol (\r
+                      Controller,\r
+                      &gEfiIsaIoProtocolGuid,\r
+                      This->DriverBindingHandle,\r
+                      ChildHandleBuffer[Index]\r
+                      );\r
+\r
+      Status = gBS->UninstallMultipleProtocolInterfaces (\r
+                      ChildHandleBuffer[Index],\r
+                      &gEfiDevicePathProtocolGuid,\r
+                      SerialDevice->DevicePath,\r
+                      &gEfiSerialIoProtocolGuid,\r
+                      &SerialDevice->SerialIo,\r
+                      NULL\r
+                      );\r
+      if (EFI_ERROR (Status)) {\r
+        gBS->OpenProtocol (\r
+               Controller,\r
+               &gEfiIsaIoProtocolGuid,\r
+               (VOID **) &IsaIo,\r
+               This->DriverBindingHandle,\r
+               ChildHandleBuffer[Index],\r
+               EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
+               );\r
+      } else {\r
+        if (SerialDevice->DevicePath) {\r
+          gBS->FreePool (SerialDevice->DevicePath);\r
+        }\r
+\r
+        FreeUnicodeStringTable (SerialDevice->ControllerNameTable);\r
+        gBS->FreePool (SerialDevice);\r
+      }\r
+    }\r
+\r
+    if (EFI_ERROR (Status)) {\r
+      AllChildrenStopped = FALSE;\r
+    }\r
+  }\r
+\r
+  if (!AllChildrenStopped) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+BOOLEAN\r
+IsaSerialFifoFull (\r
+  IN SERIAL_DEV_FIFO *Fifo\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+\r
+    Detect whether specific FIFO is full or not\r
+\r
+  Arguments:\r
+\r
+    Fifo  - A pointer to the Data Structure SERIAL_DEV_FIFO\r
+\r
+  Returns:\r
+\r
+    TRUE  - the FIFO is full\r
+    FALSE - the FIFO is not full\r
+\r
+--*/\r
+{\r
+  if (Fifo->Surplus == 0) {\r
+    return TRUE;\r
+  }\r
+\r
+  return FALSE;\r
+}\r
+\r
+BOOLEAN\r
+IsaSerialFifoEmpty (\r
+  IN SERIAL_DEV_FIFO *Fifo\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+\r
+    Detect whether specific FIFO is empty or not\r
+\r
+  Arguments:\r
+\r
+    Fifo  - A pointer to the Data Structure SERIAL_DEV_FIFO\r
+\r
+  Returns:\r
+\r
+    TRUE  - the FIFO is empty\r
+    FALSE - the FIFO is not empty\r
+\r
+--*/\r
+{\r
+  if (Fifo->Surplus == SERIAL_MAX_BUFFER_SIZE) {\r
+    return TRUE;\r
+  }\r
+\r
+  return FALSE;\r
+}\r
+\r
+EFI_STATUS\r
+IsaSerialFifoAdd (\r
+  IN SERIAL_DEV_FIFO *Fifo,\r
+  IN UINT8           Data\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+\r
+    Add data to specific FIFO\r
+\r
+  Arguments:\r
+\r
+    Fifo                - A pointer to the Data Structure SERIAL_DEV_FIFO\r
+    Data                - the data added to FIFO\r
+\r
+  Returns:\r
+\r
+    EFI_SUCCESS         - Add data to specific FIFO successfully\r
+    EFI_OUT_OF_RESOURCE - Failed to add data because FIFO is already full\r
+\r
+--*/\r
+{\r
+  //\r
+  // if FIFO full can not add data\r
+  //\r
+  if (IsaSerialFifoFull (Fifo)) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+  //\r
+  // FIFO is not full can add data\r
+  //\r
+  Fifo->Data[Fifo->Last] = Data;\r
+  Fifo->Surplus--;\r
+  Fifo->Last++;\r
+  if (Fifo->Last == SERIAL_MAX_BUFFER_SIZE) {\r
+    Fifo->Last = 0;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+IsaSerialFifoRemove (\r
+  IN  SERIAL_DEV_FIFO *Fifo,\r
+  OUT UINT8           *Data\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+\r
+    Remove data from specific FIFO\r
+\r
+  Arguments:\r
+\r
+    Fifo                - A pointer to the Data Structure SERIAL_DEV_FIFO\r
+    Data                - the data removed from FIFO\r
+\r
+  Returns:\r
+    EFI_SUCCESS         - Remove data from specific FIFO successfully\r
+    EFI_OUT_OF_RESOURCE - Failed to remove data because FIFO is empty\r
+\r
+--*/\r
+{\r
+  //\r
+  // if FIFO is empty, no data can remove\r
+  //\r
+  if (IsaSerialFifoEmpty (Fifo)) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+  //\r
+  // FIFO is not empty, can remove data\r
+  //\r
+  *Data = Fifo->Data[Fifo->First];\r
+  Fifo->Surplus++;\r
+  Fifo->First++;\r
+  if (Fifo->First == SERIAL_MAX_BUFFER_SIZE) {\r
+    Fifo->First = 0;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+IsaSerialReceiveTransmit (\r
+  IN SERIAL_DEV *SerialDevice\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+\r
+    Reads and writes all avaliable data.\r
+\r
+  Arguments:\r
+\r
+    SerialDevice        - The device to flush\r
+\r
+  Returns:\r
+\r
+    EFI_SUCCESS         - Data was read/written successfully.\r
+    EFI_OUT_OF_RESOURCE - Failed because software receive FIFO is full.  Note, when\r
+                          this happens, pending writes are not done.\r
+\r
+--*/\r
+{\r
+  SERIAL_PORT_LSR Lsr;\r
+  UINT8           Data;\r
+  BOOLEAN         ReceiveFifoFull;\r
+  SERIAL_PORT_MSR Msr;\r
+  SERIAL_PORT_MCR Mcr;\r
+  UINTN           TimeOut;\r
+\r
+  Data = 0;\r
+\r
+  //\r
+  // Begin the read or write\r
+  //\r
+  if (SerialDevice->SoftwareLoopbackEnable) {\r
+    do {\r
+      ReceiveFifoFull = IsaSerialFifoFull (&SerialDevice->Receive);\r
+      if (!IsaSerialFifoEmpty (&SerialDevice->Transmit)) {\r
+        IsaSerialFifoRemove (&SerialDevice->Transmit, &Data);\r
+        if (ReceiveFifoFull) {\r
+          return EFI_OUT_OF_RESOURCES;\r
+        }\r
+\r
+        IsaSerialFifoAdd (&SerialDevice->Receive, Data);\r
+      }\r
+    } while (!IsaSerialFifoEmpty (&SerialDevice->Transmit));\r
+  } else {\r
+    ReceiveFifoFull = IsaSerialFifoFull (&SerialDevice->Receive);\r
+    do {\r
+      Lsr.Data = READ_LSR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
+\r
+      if (FeaturePcdGet (PcdNtEmulatorEnable)) {\r
+        //\r
+        // This is required for NT to avoid a forever-spin...\r
+        // This would be better if READ_LSR was a polling operation\r
+        // that would timeout.\r
+        //\r
+        Lsr.Bits.THRE = 1;\r
+      }\r
+      //\r
+      // Flush incomming data to prevent a an overrun during a long write\r
+      //\r
+      if (Lsr.Bits.DR && !ReceiveFifoFull) {\r
+        ReceiveFifoFull = IsaSerialFifoFull (&SerialDevice->Receive);\r
+        if (!ReceiveFifoFull) {\r
+          if (Lsr.Bits.FIFOE || Lsr.Bits.OE || Lsr.Bits.PE || Lsr.Bits.FE || Lsr.Bits.BI) {\r
+            REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
+              EFI_ERROR_CODE,\r
+              EFI_P_EC_INPUT_ERROR | EFI_PERIPHERAL_SERIAL_PORT,\r
+              SerialDevice->DevicePath\r
+              );\r
+            if (Lsr.Bits.FIFOE || Lsr.Bits.PE || Lsr.Bits.FE || Lsr.Bits.BI) {\r
+              Data = READ_RBR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
+              continue;\r
+            }\r
+          }\r
+          //\r
+          // Make sure the receive data will not be missed, Assert DTR\r
+          //\r
+          if (SerialDevice->HardwareFlowControl) {\r
+            Mcr.Data = READ_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
+            Mcr.Bits.DTRC &= 0;\r
+            WRITE_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Mcr.Data);\r
+          }\r
+\r
+          Data = READ_RBR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
+\r
+          //\r
+          // Deassert DTR\r
+          //\r
+          if (SerialDevice->HardwareFlowControl) {\r
+            Mcr.Data = READ_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
+            Mcr.Bits.DTRC |= 1;\r
+            WRITE_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Mcr.Data);\r
+          }\r
+\r
+          IsaSerialFifoAdd (&SerialDevice->Receive, Data);\r
+\r
+          continue;\r
+        } else {\r
+          REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
+            EFI_PROGRESS_CODE,\r
+            EFI_P_SERIAL_PORT_PC_CLEAR_BUFFER | EFI_PERIPHERAL_SERIAL_PORT,\r
+            SerialDevice->DevicePath\r
+            );\r
+        }\r
+      }\r
+      //\r
+      // Do the write\r
+      //\r
+      if (Lsr.Bits.THRE && !IsaSerialFifoEmpty (&SerialDevice->Transmit)) {\r
+        //\r
+        // Make sure the transmit data will not be missed\r
+        //\r
+        if (SerialDevice->HardwareFlowControl) {\r
+          //\r
+          // Send RTS\r
+          //\r
+          Mcr.Data = READ_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
+          Mcr.Bits.RTS |= 1;\r
+          WRITE_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Mcr.Data);\r
+          //\r
+          // Wait for CTS\r
+          //\r
+          TimeOut   = 0;\r
+          Msr.Data  = READ_MSR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
+          while (!Msr.Bits.CTS) {\r
+            gBS->Stall (TIMEOUT_STALL_INTERVAL);\r
+            TimeOut++;\r
+            if (TimeOut > 5) {\r
+              break;\r
+            }\r
+\r
+            Msr.Data = READ_MSR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
+          }\r
+\r
+          if (Msr.Bits.CTS) {\r
+            IsaSerialFifoRemove (&SerialDevice->Transmit, &Data);\r
+            WRITE_THR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Data);\r
+          }\r
+        }\r
+        //\r
+        // write the data out\r
+        //\r
+        if (!SerialDevice->HardwareFlowControl) {\r
+          IsaSerialFifoRemove (&SerialDevice->Transmit, &Data);\r
+          WRITE_THR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Data);\r
+        }\r
+        //\r
+        // Make sure the transmit data will not be missed\r
+        //\r
+        if (SerialDevice->HardwareFlowControl) {\r
+          //\r
+          // Assert RTS\r
+          //\r
+          Mcr.Data = READ_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
+          Mcr.Bits.RTS &= 0;\r
+          WRITE_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Mcr.Data);\r
+        }\r
+      }\r
+    } while (Lsr.Bits.THRE && !IsaSerialFifoEmpty (&SerialDevice->Transmit));\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+//\r
+// Interface Functions\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+IsaSerialReset (\r
+  IN EFI_SERIAL_IO_PROTOCOL  *This\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+\r
+    Reset serial device\r
+\r
+  Arguments:\r
+\r
+    This             - Pointer to EFI_SERIAL_IO_PROTOCOL\r
+\r
+  Returns:\r
+\r
+    EFI_SUCCESS      - Reset successfully\r
+    EFI_DEVICE_ERROR - Failed to reset\r
+\r
+--*/\r
+{\r
+  EFI_STATUS      Status;\r
+  SERIAL_DEV      *SerialDevice;\r
+  SERIAL_PORT_LCR Lcr;\r
+  SERIAL_PORT_IER Ier;\r
+  SERIAL_PORT_MCR Mcr;\r
+  SERIAL_PORT_FCR Fcr;\r
+  EFI_TPL         Tpl;\r
+\r
+  SerialDevice = SERIAL_DEV_FROM_THIS (This);\r
+\r
+  //\r
+  // Report the status code reset the serial\r
+  //\r
+  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
+    EFI_PROGRESS_CODE,\r
+    EFI_P_PC_RESET | EFI_PERIPHERAL_SERIAL_PORT,\r
+    SerialDevice->DevicePath\r
+    );\r
+\r
+  Tpl = gBS->RaiseTPL (TPL_NOTIFY);\r
+\r
+  //\r
+  // Make sure DLAB is 0.\r
+  //\r
+  Lcr.Data      = READ_LCR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
+  Lcr.Bits.DLAB = 0;\r
+  WRITE_LCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Lcr.Data);\r
+\r
+  //\r
+  // Turn off all interrupts\r
+  //\r
+  Ier.Data        = READ_IER (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
+  Ier.Bits.RAVIE  = 0;\r
+  Ier.Bits.THEIE  = 0;\r
+  Ier.Bits.RIE    = 0;\r
+  Ier.Bits.MIE    = 0;\r
+  WRITE_IER (SerialDevice->IsaIo, SerialDevice->BaseAddress, Ier.Data);\r
+\r
+  //\r
+  // Disable the FIFO.\r
+  //\r
+  Fcr.Bits.TRFIFOE = 0;\r
+  WRITE_FCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Fcr.Data);\r
+\r
+  //\r
+  // Turn off loopback and disable device interrupt.\r
+  //\r
+  Mcr.Data      = READ_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
+  Mcr.Bits.OUT1 = 0;\r
+  Mcr.Bits.OUT2 = 0;\r
+  Mcr.Bits.LME  = 0;\r
+  WRITE_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Mcr.Data);\r
+\r
+  //\r
+  // Clear the scratch pad register\r
+  //\r
+  WRITE_SCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, 0);\r
+\r
+  //\r
+  // Go set the current attributes\r
+  //\r
+  Status = This->SetAttributes (\r
+                   This,\r
+                   This->Mode->BaudRate,\r
+                   This->Mode->ReceiveFifoDepth,\r
+                   This->Mode->Timeout,\r
+                   (EFI_PARITY_TYPE) This->Mode->Parity,\r
+                   (UINT8) This->Mode->DataBits,\r
+                   (EFI_STOP_BITS_TYPE) This->Mode->StopBits\r
+                   );\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    gBS->RestoreTPL (Tpl);\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+  //\r
+  // Go set the current control bits\r
+  //\r
+  Status = This->SetControl (\r
+                   This,\r
+                   This->Mode->ControlMask\r
+                   );\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    gBS->RestoreTPL (Tpl);\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+  //\r
+  // for 16550A enable FIFO, 16550 disable FIFO\r
+  //\r
+  Fcr.Bits.TRFIFOE  = 1;\r
+  Fcr.Bits.RESETRF  = 1;\r
+  Fcr.Bits.RESETTF  = 1;\r
+  WRITE_FCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Fcr.Data);\r
+\r
+  //\r
+  // Reset the software FIFO\r
+  //\r
+  SerialDevice->Receive.First     = 0;\r
+  SerialDevice->Receive.Last      = 0;\r
+  SerialDevice->Receive.Surplus   = SERIAL_MAX_BUFFER_SIZE;\r
+  SerialDevice->Transmit.First    = 0;\r
+  SerialDevice->Transmit.Last     = 0;\r
+  SerialDevice->Transmit.Surplus  = SERIAL_MAX_BUFFER_SIZE;\r
+\r
+  gBS->RestoreTPL (Tpl);\r
+\r
+  //\r
+  // Device reset is complete\r
+  //\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+IsaSerialSetAttributes (\r
+  IN EFI_SERIAL_IO_PROTOCOL  *This,\r
+  IN UINT64                  BaudRate,\r
+  IN UINT32                  ReceiveFifoDepth,\r
+  IN UINT32                  Timeout,\r
+  IN EFI_PARITY_TYPE         Parity,\r
+  IN UINT8                   DataBits,\r
+  IN EFI_STOP_BITS_TYPE      StopBits\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+\r
+    Set new attributes to a serial device\r
+\r
+  Arguments:\r
+\r
+    This                   - Pointer to EFI_SERIAL_IO_PROTOCOL\r
+    BaudRate               - The baudrate of the serial device\r
+    ReceiveFifoDepth       - The depth of receive FIFO buffer\r
+    Timeout                - The request timeout for a single char\r
+    Parity                 - The type of parity used in serial device\r
+    DataBits               - Number of databits used in serial device\r
+    StopBits               - Number of stopbits used in serial device\r
+\r
+  Returns:\r
+\r
+    EFI_SUCCESS            - The new attributes were set\r
+    EFI_INVALID_PARAMETERS - One or more attributes have an unsupported value\r
+    EFI_UNSUPPORTED        - Data Bits can not set to 5 or 6\r
+    EFI_DEVICE_ERROR       - The serial device is not functioning correctly (no return)\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                Status;\r
+  SERIAL_DEV                *SerialDevice;\r
+  UINT32                    Divisor;\r
+  UINT32                    Remained;\r
+  SERIAL_PORT_LCR           Lcr;\r
+  EFI_DEVICE_PATH_PROTOCOL  *NewDevicePath;\r
+  EFI_TPL                   Tpl;\r
+\r
+  SerialDevice = SERIAL_DEV_FROM_THIS (This);\r
+\r
+  //\r
+  // Check for default settings and fill in actual values.\r
+  //\r
+  if (BaudRate == 0) {\r
+    BaudRate = SERIAL_PORT_DEFAULT_BAUD_RATE;\r
+  }\r
+\r
+  if (ReceiveFifoDepth == 0) {\r
+    ReceiveFifoDepth = SERIAL_PORT_DEFAULT_RECEIVE_FIFO_DEPTH;\r
+  }\r
+\r
+  if (Timeout == 0) {\r
+    Timeout = SERIAL_PORT_DEFAULT_TIMEOUT;\r
+  }\r
+\r
+  if (Parity == DefaultParity) {\r
+    Parity = SERIAL_PORT_DEFAULT_PARITY;\r
+  }\r
+\r
+  if (DataBits == 0) {\r
+    DataBits = SERIAL_PORT_DEFAULT_DATA_BITS;\r
+  }\r
+\r
+  if (StopBits == DefaultStopBits) {\r
+    StopBits = (EFI_STOP_BITS_TYPE) SERIAL_PORT_DEFAULT_STOP_BITS;\r
+  }\r
+  //\r
+  // 5 and 6 data bits can not be verified on a 16550A UART\r
+  // Return EFI_INVALID_PARAMETER if an attempt is made to use these settings.\r
+  //\r
+  if ((DataBits == 5) || (DataBits == 6)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\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
+  // 50,75,110,134,150,300,600,1200,1800,2000,2400,3600,4800,7200,9600,19200,\r
+  // 38400,57600,115200\r
+  //\r
+  if (BaudRate < 75) {\r
+    BaudRate = 50;\r
+  } else if (BaudRate < 110) {\r
+    BaudRate = 75;\r
+  } else if (BaudRate < 134) {\r
+    BaudRate = 110;\r
+  } else if (BaudRate < 150) {\r
+    BaudRate = 134;\r
+  } else if (BaudRate < 300) {\r
+    BaudRate = 150;\r
+  } else if (BaudRate < 600) {\r
+    BaudRate = 300;\r
+  } else if (BaudRate < 1200) {\r
+    BaudRate = 600;\r
+  } else if (BaudRate < 1800) {\r
+    BaudRate = 1200;\r
+  } else if (BaudRate < 2000) {\r
+    BaudRate = 1800;\r
+  } else if (BaudRate < 2400) {\r
+    BaudRate = 2000;\r
+  } else if (BaudRate < 3600) {\r
+    BaudRate = 2400;\r
+  } else if (BaudRate < 4800) {\r
+    BaudRate = 3600;\r
+  } else if (BaudRate < 7200) {\r
+    BaudRate = 4800;\r
+  } else if (BaudRate < 9600) {\r
+    BaudRate = 7200;\r
+  } else if (BaudRate < 19200) {\r
+    BaudRate = 9600;\r
+  } else if (BaudRate < 38400) {\r
+    BaudRate = 19200;\r
+  } else if (BaudRate < 57600) {\r
+    BaudRate = 38400;\r
+  } else if (BaudRate < 115200) {\r
+    BaudRate = 57600;\r
+  } else if (BaudRate <= SERIAL_PORT_MAX_BAUD_RATE) {\r
+    BaudRate = 115200;\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 ((DataBits < 5) || (DataBits > 8)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if ((StopBits < OneStopBit) || (StopBits > TwoStopBits)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // for DataBits = 5, StopBits can not set TwoStopBits\r
+  //\r
+  // if ((DataBits == 5) && (StopBits == TwoStopBits)) {\r
+  //  return EFI_INVALID_PARAMETER;\r
+  // }\r
+  //\r
+  // for DataBits = 6,7,8, StopBits can not set OneFiveStopBits\r
+  //\r
+  if ((DataBits >= 6) && (DataBits <= 8) && (StopBits == OneFiveStopBits)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  //\r
+  // Compute divisor use to program the baud rate using a round determination\r
+  //\r
+  Divisor = (UINT32) DivU64x32Remainder (\r
+                       SERIAL_PORT_INPUT_CLOCK,\r
+                       ((UINT32) BaudRate * 16),\r
+                       &Remained\r
+                       );\r
+  if (Remained) {\r
+    Divisor += 1;\r
+  }\r
+\r
+  if ((Divisor == 0) || (Divisor & 0xffff0000)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Tpl = gBS->RaiseTPL (TPL_NOTIFY);\r
+\r
+  //\r
+  // Compute the actual baud rate that the serial port will be programmed for.\r
+  //\r
+  BaudRate = SERIAL_PORT_INPUT_CLOCK / Divisor / 16;\r
+\r
+  //\r
+  // Put serial port on Divisor Latch Mode\r
+  //\r
+  Lcr.Data      = READ_LCR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
+  Lcr.Bits.DLAB = 1;\r
+  WRITE_LCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Lcr.Data);\r
+\r
+  //\r
+  // Write the divisor to the serial port\r
+  //\r
+  WRITE_DLL (SerialDevice->IsaIo, SerialDevice->BaseAddress, (UINT8) (Divisor & 0xff));\r
+  WRITE_DLM (SerialDevice->IsaIo, SerialDevice->BaseAddress, (UINT8) ((Divisor >> 8) & 0xff));\r
+\r
+  //\r
+  // Put serial port back in normal mode and set remaining attributes.\r
+  //\r
+  Lcr.Bits.DLAB = 0;\r
+\r
+  switch (Parity) {\r
+  case NoParity:\r
+    Lcr.Bits.PAREN    = 0;\r
+    Lcr.Bits.EVENPAR  = 0;\r
+    Lcr.Bits.STICPAR  = 0;\r
+    break;\r
+\r
+  case EvenParity:\r
+    Lcr.Bits.PAREN    = 1;\r
+    Lcr.Bits.EVENPAR  = 1;\r
+    Lcr.Bits.STICPAR  = 0;\r
+    break;\r
+\r
+  case OddParity:\r
+    Lcr.Bits.PAREN    = 1;\r
+    Lcr.Bits.EVENPAR  = 0;\r
+    Lcr.Bits.STICPAR  = 0;\r
+    break;\r
+\r
+  case SpaceParity:\r
+    Lcr.Bits.PAREN    = 1;\r
+    Lcr.Bits.EVENPAR  = 1;\r
+    Lcr.Bits.STICPAR  = 1;\r
+    break;\r
+\r
+  case MarkParity:\r
+    Lcr.Bits.PAREN    = 1;\r
+    Lcr.Bits.EVENPAR  = 0;\r
+    Lcr.Bits.STICPAR  = 1;\r
+    break;\r
+\r
+  default:\r
+    break;\r
+  }\r
+\r
+  switch (StopBits) {\r
+  case OneStopBit:\r
+    Lcr.Bits.STOPB = 0;\r
+    break;\r
+\r
+  case OneFiveStopBits:\r
+  case TwoStopBits:\r
+    Lcr.Bits.STOPB = 1;\r
+    break;\r
+\r
+  default:\r
+    break;\r
+  }\r
+  //\r
+  // DataBits\r
+  //\r
+  Lcr.Bits.SERIALDB = (UINT8) ((DataBits - 5) & 0x03);\r
+  WRITE_LCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Lcr.Data);\r
+\r
+  //\r
+  // Set the Serial I/O mode\r
+  //\r
+  This->Mode->BaudRate          = BaudRate;\r
+  This->Mode->ReceiveFifoDepth  = ReceiveFifoDepth;\r
+  This->Mode->Timeout           = Timeout;\r
+  This->Mode->Parity            = Parity;\r
+  This->Mode->DataBits          = DataBits;\r
+  This->Mode->StopBits          = StopBits;\r
+\r
+  //\r
+  // See if Device Path Node has actually changed\r
+  //\r
+  if (SerialDevice->UartDevicePath.BaudRate == BaudRate &&\r
+      SerialDevice->UartDevicePath.DataBits == DataBits &&\r
+      SerialDevice->UartDevicePath.Parity == Parity &&\r
+      SerialDevice->UartDevicePath.StopBits == StopBits\r
+      ) {\r
+    gBS->RestoreTPL (Tpl);\r
+    return EFI_SUCCESS;\r
+  }\r
+  //\r
+  // Update the device path\r
+  //\r
+  SerialDevice->UartDevicePath.BaudRate = BaudRate;\r
+  SerialDevice->UartDevicePath.DataBits = DataBits;\r
+  SerialDevice->UartDevicePath.Parity   = (UINT8) Parity;\r
+  SerialDevice->UartDevicePath.StopBits = (UINT8) StopBits;\r
+\r
+  NewDevicePath = AppendDevicePathNode (\r
+                    SerialDevice->ParentDevicePath,\r
+                    (EFI_DEVICE_PATH_PROTOCOL *) &SerialDevice->UartDevicePath\r
+                    );\r
+  if (NewDevicePath == NULL) {\r
+    gBS->RestoreTPL (Tpl);\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+\r
+  if (SerialDevice->Handle != NULL) {\r
+    Status = gBS->ReinstallProtocolInterface (\r
+                    SerialDevice->Handle,\r
+                    &gEfiDevicePathProtocolGuid,\r
+                    SerialDevice->DevicePath,\r
+                    NewDevicePath\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      gBS->RestoreTPL (Tpl);\r
+      return Status;\r
+    }\r
+  }\r
+\r
+  if (SerialDevice->DevicePath) {\r
+    gBS->FreePool (SerialDevice->DevicePath);\r
+  }\r
+\r
+  SerialDevice->DevicePath = NewDevicePath;\r
+\r
+  gBS->RestoreTPL (Tpl);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+IsaSerialSetControl (\r
+  IN EFI_SERIAL_IO_PROTOCOL  *This,\r
+  IN UINT32                  Control\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+\r
+    Set Control Bits\r
+\r
+  Arguments:\r
+\r
+    This            - Pointer to EFI_SERIAL_IO_PROTOCOL\r
+    Control         - Control bits that can be settable\r
+\r
+  Returns:\r
+\r
+    EFI_SUCCESS     - New Control bits were set successfully\r
+    EFI_UNSUPPORTED - The Control bits wanted to set are not supported\r
+\r
+--*/\r
+{\r
+  SERIAL_DEV      *SerialDevice;\r
+  SERIAL_PORT_MCR Mcr;\r
+  EFI_TPL         Tpl;\r
+\r
+  //\r
+  // The control bits that can be set are :\r
+  //     EFI_SERIAL_DATA_TERMINAL_READY: 0x0001  // WO\r
+  //     EFI_SERIAL_REQUEST_TO_SEND: 0x0002  // WO\r
+  //     EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE: 0x1000  // RW\r
+  //     EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE: 0x2000  // RW\r
+  //\r
+  SerialDevice = SERIAL_DEV_FROM_THIS (This);\r
+\r
+  //\r
+  // first determine the parameter is invalid\r
+  //\r
+  if (Control & 0xffff8ffc) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  Tpl = gBS->RaiseTPL (TPL_NOTIFY);\r
+\r
+  Mcr.Data = READ_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
+  Mcr.Bits.DTRC = 0;\r
+  Mcr.Bits.RTS = 0;\r
+  Mcr.Bits.LME = 0;\r
+  SerialDevice->SoftwareLoopbackEnable = FALSE;\r
+  SerialDevice->HardwareFlowControl = FALSE;\r
+\r
+  if (Control & EFI_SERIAL_DATA_TERMINAL_READY) {\r
+    Mcr.Bits.DTRC = 1;\r
+  }\r
+\r
+  if (Control & EFI_SERIAL_REQUEST_TO_SEND) {\r
+    Mcr.Bits.RTS = 1;\r
+  }\r
+\r
+  if (Control & EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE) {\r
+    Mcr.Bits.LME = 1;\r
+  }\r
+\r
+  if (Control & EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE) {\r
+    SerialDevice->HardwareFlowControl = TRUE;\r
+  }\r
+\r
+  WRITE_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Mcr.Data);\r
+\r
+  if (Control & EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE) {\r
+    SerialDevice->SoftwareLoopbackEnable = TRUE;\r
+  }\r
+\r
+  gBS->RestoreTPL (Tpl);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+IsaSerialGetControl (\r
+  IN EFI_SERIAL_IO_PROTOCOL  *This,\r
+  OUT UINT32                 *Control\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+\r
+    Get ControlBits\r
+\r
+  Arguments:\r
+\r
+    This        - Pointer to EFI_SERIAL_IO_PROTOCOL\r
+    Control     - Control signals of the serial device\r
+\r
+  Returns:\r
+\r
+    EFI_SUCCESS - Get Control signals successfully\r
+\r
+--*/\r
+{\r
+  SERIAL_DEV      *SerialDevice;\r
+  SERIAL_PORT_MSR Msr;\r
+  SERIAL_PORT_MCR Mcr;\r
+  EFI_TPL         Tpl;\r
+\r
+  Tpl           = gBS->RaiseTPL (TPL_NOTIFY);\r
+\r
+  SerialDevice  = SERIAL_DEV_FROM_THIS (This);\r
+\r
+  *Control      = 0;\r
+\r
+  //\r
+  // Read the Modem Status Register\r
+  //\r
+  Msr.Data = READ_MSR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
+\r
+  if (Msr.Bits.CTS) {\r
+    *Control |= EFI_SERIAL_CLEAR_TO_SEND;\r
+  }\r
+\r
+  if (Msr.Bits.DSR) {\r
+    *Control |= EFI_SERIAL_DATA_SET_READY;\r
+  }\r
+\r
+  if (Msr.Bits.RI) {\r
+    *Control |= EFI_SERIAL_RING_INDICATE;\r
+  }\r
+\r
+  if (Msr.Bits.DCD) {\r
+    *Control |= EFI_SERIAL_CARRIER_DETECT;\r
+  }\r
+  //\r
+  // Read the Modem Control Register\r
+  //\r
+  Mcr.Data = READ_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
+\r
+  if (Mcr.Bits.DTRC) {\r
+    *Control |= EFI_SERIAL_DATA_TERMINAL_READY;\r
+  }\r
+\r
+  if (Mcr.Bits.RTS) {\r
+    *Control |= EFI_SERIAL_REQUEST_TO_SEND;\r
+  }\r
+\r
+  if (Mcr.Bits.LME) {\r
+    *Control |= EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE;\r
+  }\r
+\r
+  if (SerialDevice->HardwareFlowControl) {\r
+    *Control |= EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE;\r
+  }\r
+  //\r
+  // See if the Transmit FIFO is empty\r
+  //\r
+  IsaSerialReceiveTransmit (SerialDevice);\r
+\r
+  if (IsaSerialFifoEmpty (&SerialDevice->Transmit)) {\r
+    *Control |= EFI_SERIAL_OUTPUT_BUFFER_EMPTY;\r
+  }\r
+  //\r
+  // See if the Receive FIFO is empty.\r
+  //\r
+  IsaSerialReceiveTransmit (SerialDevice);\r
+\r
+  if (IsaSerialFifoEmpty (&SerialDevice->Receive)) {\r
+    *Control |= EFI_SERIAL_INPUT_BUFFER_EMPTY;\r
+  }\r
+\r
+  if (SerialDevice->SoftwareLoopbackEnable) {\r
+    *Control |= EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE;\r
+  }\r
+\r
+  gBS->RestoreTPL (Tpl);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+IsaSerialWrite (\r
+  IN EFI_SERIAL_IO_PROTOCOL  *This,\r
+  IN OUT UINTN               *BufferSize,\r
+  IN VOID                    *Buffer\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+\r
+    Write the specified number of bytes to serial device\r
+\r
+  Arguments:\r
+\r
+    This             - Pointer to EFI_SERIAL_IO_PROTOCOL\r
+    BufferSize       - On input the size of Buffer, on output the amount of\r
+                       data actually written\r
+    Buffer           - The buffer of data to write\r
+\r
+  Returns:\r
+\r
+    EFI_SUCCESS      - The data were written successfully\r
+    EFI_DEVICE_ERROR - The device reported an error\r
+    EFI_TIMEOUT      - The write operation was stopped due to timeout\r
+\r
+--*/\r
+{\r
+  SERIAL_DEV  *SerialDevice;\r
+  UINT8       *CharBuffer;\r
+  UINT32      Index;\r
+  UINTN       Elapsed;\r
+  UINTN       ActualWrite;\r
+  EFI_TPL     Tpl;\r
+\r
+  SerialDevice  = SERIAL_DEV_FROM_THIS (This);\r
+  Elapsed       = 0;\r
+  ActualWrite   = 0;\r
+\r
+  if (*BufferSize == 0) {\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  if (!Buffer) {\r
+    REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
+      EFI_ERROR_CODE,\r
+      EFI_P_EC_OUTPUT_ERROR | EFI_PERIPHERAL_SERIAL_PORT,\r
+      SerialDevice->DevicePath\r
+      );\r
+\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+\r
+  Tpl         = gBS->RaiseTPL (TPL_NOTIFY);\r
+\r
+  CharBuffer  = (UINT8 *) Buffer;\r
+\r
+  for (Index = 0; Index < *BufferSize; Index++) {\r
+    IsaSerialFifoAdd (&SerialDevice->Transmit, CharBuffer[Index]);\r
+\r
+    while (IsaSerialReceiveTransmit (SerialDevice) != EFI_SUCCESS || !IsaSerialFifoEmpty (&SerialDevice->Transmit)) {\r
+      //\r
+      //  Unsuccessful write so check if timeout has expired, if not,\r
+      //  stall for a bit, increment time elapsed, and try again\r
+      //\r
+      if (Elapsed >= This->Mode->Timeout) {\r
+        *BufferSize = ActualWrite;\r
+        gBS->RestoreTPL (Tpl);\r
+        return EFI_TIMEOUT;\r
+      }\r
+\r
+      gBS->Stall (TIMEOUT_STALL_INTERVAL);\r
+\r
+      Elapsed += TIMEOUT_STALL_INTERVAL;\r
+    }\r
+\r
+    ActualWrite++;\r
+    //\r
+    //  Successful write so reset timeout\r
+    //\r
+    Elapsed = 0;\r
+  }\r
+\r
+  gBS->RestoreTPL (Tpl);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+IsaSerialRead (\r
+  IN EFI_SERIAL_IO_PROTOCOL  *This,\r
+  IN OUT UINTN               *BufferSize,\r
+  OUT VOID                   *Buffer\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+\r
+    Read the specified number of bytes from serial device\r
+\r
+  Arguments:\r
+\r
+    This             - Pointer to EFI_SERIAL_IO_PROTOCOL\r
+    BufferSize       - On input the size of Buffer, on output the amount of\r
+                       data returned in buffer\r
+    Buffer           -  The buffer to return the data into\r
+\r
+  Returns:\r
+\r
+    EFI_SUCCESS      - The data were read successfully\r
+    EFI_DEVICE_ERROR - The device reported an error\r
+    EFI_TIMEOUT      - The read operation was stopped due to timeout\r
+\r
+--*/\r
+{\r
+  SERIAL_DEV  *SerialDevice;\r
+  UINT32      Index;\r
+  UINT8       *CharBuffer;\r
+  UINTN       Elapsed;\r
+  EFI_STATUS  Status;\r
+  EFI_TPL     Tpl;\r
+\r
+  SerialDevice  = SERIAL_DEV_FROM_THIS (This);\r
+  Elapsed       = 0;\r
+\r
+  if (*BufferSize == 0) {\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  if (!Buffer) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+\r
+  Tpl     = gBS->RaiseTPL (TPL_NOTIFY);\r
+\r
+  Status  = IsaSerialReceiveTransmit (SerialDevice);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    *BufferSize = 0;\r
+\r
+    REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
+      EFI_ERROR_CODE,\r
+      EFI_P_EC_INPUT_ERROR | EFI_PERIPHERAL_SERIAL_PORT,\r
+      SerialDevice->DevicePath\r
+      );\r
+\r
+    gBS->RestoreTPL (Tpl);\r
+\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+\r
+  CharBuffer = (UINT8 *) Buffer;\r
+  for (Index = 0; Index < *BufferSize; Index++) {\r
+    while (IsaSerialFifoRemove (&SerialDevice->Receive, &(CharBuffer[Index])) != EFI_SUCCESS) {\r
+      //\r
+      //  Unsuccessful read so check if timeout has expired, if not,\r
+      //  stall for a bit, increment time elapsed, and try again\r
+      //  Need this time out to get conspliter to work.\r
+      //\r
+      if (Elapsed >= This->Mode->Timeout) {\r
+        *BufferSize = Index;\r
+        gBS->RestoreTPL (Tpl);\r
+        return EFI_TIMEOUT;\r
+      }\r
+\r
+      gBS->Stall (TIMEOUT_STALL_INTERVAL);\r
+      Elapsed += TIMEOUT_STALL_INTERVAL;\r
+\r
+      Status = IsaSerialReceiveTransmit (SerialDevice);\r
+      if (Status == EFI_DEVICE_ERROR) {\r
+        *BufferSize = Index;\r
+        gBS->RestoreTPL (Tpl);\r
+        return EFI_DEVICE_ERROR;\r
+      }\r
+    }\r
+    //\r
+    //  Successful read so reset timeout\r
+    //\r
+    Elapsed = 0;\r
+  }\r
+\r
+  IsaSerialReceiveTransmit (SerialDevice);\r
+\r
+  gBS->RestoreTPL (Tpl);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+BOOLEAN\r
+IsaSerialPortPresent (\r
+  IN SERIAL_DEV *SerialDevice\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+\r
+    Use scratchpad register to test if this serial port is present\r
+\r
+  Arguments:\r
+\r
+    SerialDevice - Pointer to serial device structure\r
+\r
+  Returns:\r
+\r
+    TRUE         - The serial port is present\r
+    FALSE        - The serial port is NOT present\r
+\r
+--*/\r
+{\r
+  UINT8   Temp;\r
+  BOOLEAN Status;\r
+\r
+  Status = TRUE;\r
+\r
+  //\r
+  // Save SCR reg\r
+  //\r
+  Temp = READ_SCR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
+  WRITE_SCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, 0xAA);\r
+\r
+  if (READ_SCR (SerialDevice->IsaIo, SerialDevice->BaseAddress) != 0xAA)\r
+  {\r
+    if (!FeaturePcdGet (PcdNtEmulatorEnable)) {\r
+      Status = FALSE;\r
+    }\r
+  }\r
+\r
+  WRITE_SCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, 0x55);\r
+\r
+  if (READ_SCR (SerialDevice->IsaIo, SerialDevice->BaseAddress) != 0x55)\r
+  {\r
+    if (!FeaturePcdGet (PcdNtEmulatorEnable)) {\r
+      Status = FALSE;\r
+    }\r
+  }\r
+  //\r
+  // Restore SCR\r
+  //\r
+  WRITE_SCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Temp);\r
+  return Status;\r
+}\r
+\r
+UINT8\r
+IsaSerialReadPort (\r
+  IN EFI_ISA_IO_PROTOCOL                   *IsaIo,\r
+  IN UINT16                                BaseAddress,\r
+  IN UINT32                                Offset\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+\r
+    Use IsaIo protocol to read serial port\r
+\r
+  Arguments:\r
+\r
+    IsaIo       - Pointer to EFI_ISA_IO_PROTOCOL instance\r
+    BaseAddress - Serial port register group base address\r
+    Offset      - Offset in register group\r
+\r
+  Returns:\r
+\r
+    Data read from serial port\r
+\r
+--*/\r
+{\r
+  UINT8 Data;\r
+\r
+  //\r
+  // Use IsaIo to access IO\r
+  //\r
+  IsaIo->Io.Read (\r
+             IsaIo,\r
+             EfiIsaIoWidthUint8,\r
+             BaseAddress + Offset,\r
+             1,\r
+             &Data\r
+             );\r
+  return Data;\r
+}\r
+\r
+VOID\r
+IsaSerialWritePort (\r
+  IN EFI_ISA_IO_PROTOCOL                 *IsaIo,\r
+  IN UINT16                              BaseAddress,\r
+  IN UINT32                              Offset,\r
+  IN UINT8                               Data\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+\r
+    Use IsaIo protocol to write serial port\r
+\r
+  Arguments:\r
+\r
+    IsaIo       - Pointer to EFI_ISA_IO_PROTOCOL instance\r
+    BaseAddress - Serial port register group base address\r
+    Offset      - Offset in register group\r
+    Data        - data which is to be written to some serial port register\r
+\r
+  Returns:\r
+\r
+    None\r
+\r
+--*/\r
+{\r
+  //\r
+  // Use IsaIo to access IO\r
+  //\r
+  IsaIo->Io.Write (\r
+             IsaIo,\r
+             EfiIsaIoWidthUint8,\r
+             BaseAddress + Offset,\r
+             1,\r
+             &Data\r
+             );\r
+}\r
+\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.h b/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.h
new file mode 100644 (file)
index 0000000..d06f728
--- /dev/null
@@ -0,0 +1,577 @@
+/*++\r
+\r
+Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.\r
+This software and associated documentation (if any) is furnished\r
+under a license and may only be used or copied in accordance\r
+with the terms of the license. Except as permitted by such\r
+license, no part of this software or documentation may be\r
+reproduced, stored in a retrieval system, or transmitted in any\r
+form or by any means without the express written consent of\r
+Intel Corporation.\r
+\r
+\r
+Module Name:\r
+\r
+  serial.h\r
+\r
+Abstract:\r
+\r
+  Include for Serial Driver\r
+\r
+Revision History:\r
+\r
+--*/\r
+\r
+#ifndef _SERIAL_H\r
+#define _SERIAL_H\r
+\r
+//\r
+// The package level header files this module uses\r
+//\r
+#include <PiDxe.h>\r
+#include <FrameworkPei.h>\r
+//\r
+// The protocols, PPI and GUID defintions for this module\r
+//\r
+#include <Protocol/IsaIo.h>\r
+#include <Protocol/SerialIo.h>\r
+#include <Protocol/DevicePath.h>\r
+//\r
+// The Library classes this module consumes\r
+//\r
+#include <Library/DebugLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/DevicePathLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/ReportStatusCodeLib.h>\r
+#include <Library/PcdLib.h>\r
+//\r
+// Driver Binding Externs\r
+//\r
+extern EFI_DRIVER_BINDING_PROTOCOL gSerialControllerDriver;\r
+extern EFI_COMPONENT_NAME_PROTOCOL gIsaSerialComponentName;\r
+\r
+//\r
+// Internal Data Structures\r
+//\r
+#define SERIAL_DEV_SIGNATURE    EFI_SIGNATURE_32 ('s', 'e', 'r', 'd')\r
+#define SERIAL_MAX_BUFFER_SIZE  16\r
+#define TIMEOUT_STALL_INTERVAL  10\r
+\r
+//\r
+//  Name:   SERIAL_DEV_FIFO\r
+//  Purpose:  To define Receive FIFO and Transmit FIFO\r
+//  Context:  Used by serial data transmit and receive\r
+//  Fields:\r
+//      First UINT32: The index of the first data in array Data[]\r
+//      Last  UINT32: The index, which you can put a new data into array Data[]\r
+//      Surplus UINT32: Identify how many data you can put into array Data[]\r
+//      Data[]  UINT8 : An array, which used to store data\r
+//\r
+typedef struct {\r
+  UINT32  First;\r
+  UINT32  Last;\r
+  UINT32  Surplus;\r
+  UINT8   Data[SERIAL_MAX_BUFFER_SIZE];\r
+} SERIAL_DEV_FIFO;\r
+\r
+typedef enum {\r
+  UART8250  = 0,\r
+  UART16450 = 1,\r
+  UART16550 = 2,\r
+  UART16550A= 3\r
+} EFI_UART_TYPE;\r
+\r
+//\r
+//  Name:   SERIAL_DEV\r
+//  Purpose:  To provide device specific information\r
+//  Context:\r
+//  Fields:\r
+//      Signature UINTN: The identity of the serial device\r
+//      SerialIo  SERIAL_IO_PROTOCOL: Serial I/O protocol interface\r
+//      SerialMode  SERIAL_IO_MODE:\r
+//      DevicePath  EFI_DEVICE_PATH_PROTOCOL *: Device path of the serial device\r
+//      Handle      EFI_HANDLE: The handle instance attached to serial device\r
+//      BaseAddress UINT16: The base address of specific serial device\r
+//      Receive     SERIAL_DEV_FIFO: The FIFO used to store data,\r
+//                  which is received by UART\r
+//      Transmit    SERIAL_DEV_FIFO: The FIFO used to store data,\r
+//                  which you want to transmit by UART\r
+//      SoftwareLoopbackEnable BOOLEAN:\r
+//      Type    EFI_UART_TYPE: Specify the UART type of certain serial device\r
+//\r
+typedef struct {\r
+  UINTN                                  Signature;\r
+\r
+  EFI_HANDLE                             Handle;\r
+  EFI_SERIAL_IO_PROTOCOL                 SerialIo;\r
+  EFI_SERIAL_IO_MODE                     SerialMode;\r
+  EFI_DEVICE_PATH_PROTOCOL               *DevicePath;\r
+\r
+  EFI_DEVICE_PATH_PROTOCOL               *ParentDevicePath;\r
+  UART_DEVICE_PATH                       UartDevicePath;\r
+  EFI_ISA_IO_PROTOCOL                    *IsaIo;\r
+\r
+  UINT16                                 BaseAddress;\r
+  SERIAL_DEV_FIFO                        Receive;\r
+  SERIAL_DEV_FIFO                        Transmit;\r
+  BOOLEAN                                SoftwareLoopbackEnable;\r
+  BOOLEAN                                HardwareFlowControl;\r
+  EFI_UART_TYPE                          Type;\r
+  EFI_UNICODE_STRING_TABLE               *ControllerNameTable;\r
+} SERIAL_DEV;\r
+\r
+#include "ComponentName.h"\r
+\r
+#define SERIAL_DEV_FROM_THIS(a) CR (a, SERIAL_DEV, SerialIo, SERIAL_DEV_SIGNATURE)\r
+\r
+//\r
+// Globale Variables\r
+//\r
+extern EFI_DRIVER_BINDING_PROTOCOL  gSerialControllerDriver;\r
+\r
+//\r
+// Serial Driver Defaults\r
+//\r
+#define SERIAL_PORT_DEFAULT_BAUD_RATE           115200\r
+#define SERIAL_PORT_DEFAULT_RECEIVE_FIFO_DEPTH  1\r
+#define SERIAL_PORT_DEFAULT_TIMEOUT             1000000\r
+#define SERIAL_PORT_DEFAULT_PARITY              NoParity\r
+#define SERIAL_PORT_DEFAULT_DATA_BITS           8\r
+#define SERIAL_PORT_DEFAULT_STOP_BITS           1\r
+#define SERIAL_PORT_DEFAULT_CONTROL_MASK        0\r
+\r
+//\r
+// (24000000/13)MHz input clock\r
+//\r
+#define SERIAL_PORT_INPUT_CLOCK 1843200\r
+\r
+//\r
+// 115200 baud with rounding errors\r
+//\r
+#define SERIAL_PORT_MAX_BAUD_RATE           115400\r
+#define SERIAL_PORT_MIN_BAUD_RATE           50\r
+\r
+#define SERIAL_PORT_MAX_RECEIVE_FIFO_DEPTH  16\r
+#define SERIAL_PORT_MIN_TIMEOUT             1         // 1 uS\r
+#define SERIAL_PORT_MAX_TIMEOUT             100000000 // 100 seconds\r
+//\r
+// UART Registers\r
+//\r
+#define SERIAL_REGISTER_THR 0 // WO   Transmit Holding Register\r
+#define SERIAL_REGISTER_RBR 0 // RO   Receive Buffer Register\r
+#define SERIAL_REGISTER_DLL 0 // R/W  Divisor Latch LSB\r
+#define SERIAL_REGISTER_DLM 1 // R/W  Divisor Latch MSB\r
+#define SERIAL_REGISTER_IER 1 // R/W  Interrupt Enable Register\r
+#define SERIAL_REGISTER_IIR 2 // RO   Interrupt Identification Register\r
+#define SERIAL_REGISTER_FCR 2 // WO   FIFO Cotrol Register\r
+#define SERIAL_REGISTER_LCR 3 // R/W  Line Control Register\r
+#define SERIAL_REGISTER_MCR 4 // R/W  Modem Control Register\r
+#define SERIAL_REGISTER_LSR 5 // R/W  Line Status Register\r
+#define SERIAL_REGISTER_MSR 6 // R/W  Modem Status Register\r
+#define SERIAL_REGISTER_SCR 7 // R/W  Scratch Pad Register\r
+#pragma pack(1)\r
+//\r
+//  Name:   SERIAL_PORT_IER_BITS\r
+//  Purpose:  Define each bit in Interrupt Enable Register\r
+//  Context:\r
+//  Fields:\r
+//     RAVIE  Bit0: Receiver Data Available Interrupt Enable\r
+//     THEIE  Bit1: Transmistter Holding Register Empty Interrupt Enable\r
+//     RIE      Bit2: Receiver Interrupt Enable\r
+//     MIE      Bit3: Modem Interrupt Enable\r
+//     Reserved Bit4-Bit7: Reserved\r
+//\r
+typedef struct {\r
+  UINT8 RAVIE : 1;\r
+  UINT8 THEIE : 1;\r
+  UINT8 RIE : 1;\r
+  UINT8 MIE : 1;\r
+  UINT8 Reserved : 4;\r
+} SERIAL_PORT_IER_BITS;\r
+\r
+//\r
+//  Name:   SERIAL_PORT_IER\r
+//  Purpose:\r
+//  Context:\r
+//  Fields:\r
+//      Bits    SERIAL_PORT_IER_BITS:  Bits of the IER\r
+//      Data    UINT8: the value of the IER\r
+//\r
+typedef union {\r
+  SERIAL_PORT_IER_BITS  Bits;\r
+  UINT8                 Data;\r
+} SERIAL_PORT_IER;\r
+\r
+//\r
+//  Name:   SERIAL_PORT_IIR_BITS\r
+//  Purpose:  Define each bit in Interrupt Identification Register\r
+//  Context:\r
+//  Fields:\r
+//      IPS    Bit0: Interrupt Pending Status\r
+//      IIB    Bit1-Bit3: Interrupt ID Bits\r
+//      Reserved Bit4-Bit5: Reserved\r
+//      FIFOES   Bit6-Bit7: FIFO Mode Enable Status\r
+//\r
+typedef struct {\r
+  UINT8 IPS : 1;\r
+  UINT8 IIB : 3;\r
+  UINT8 Reserved : 2;\r
+  UINT8 FIFOES : 2;\r
+} SERIAL_PORT_IIR_BITS;\r
+\r
+//\r
+//  Name:   SERIAL_PORT_IIR\r
+//  Purpose:\r
+//  Context:\r
+//  Fields:\r
+//      Bits    SERIAL_PORT_IIR_BITS:  Bits of the IIR\r
+//      Data    UINT8: the value of the IIR\r
+//\r
+typedef union {\r
+  SERIAL_PORT_IIR_BITS  Bits;\r
+  UINT8                 Data;\r
+} SERIAL_PORT_IIR;\r
+\r
+//\r
+//  Name:   SERIAL_PORT_FCR_BITS\r
+//  Purpose:  Define each bit in FIFO Control Register\r
+//  Context:\r
+//  Fields:\r
+//      TRFIFOE    Bit0: Transmit and Receive FIFO Enable\r
+//      RESETRF    Bit1: Reset Reciever FIFO\r
+//      RESETTF    Bit2: Reset Transmistter FIFO\r
+//      DMS        Bit3: DMA Mode Select\r
+//      Reserved   Bit4-Bit5: Reserved\r
+//      RTB        Bit6-Bit7: Receive Trigger Bits\r
+//\r
+typedef struct {\r
+  UINT8 TRFIFOE : 1;\r
+  UINT8 RESETRF : 1;\r
+  UINT8 RESETTF : 1;\r
+  UINT8 DMS : 1;\r
+  UINT8 Reserved : 2;\r
+  UINT8 RTB : 2;\r
+} SERIAL_PORT_FCR_BITS;\r
+\r
+//\r
+//  Name:   SERIAL_PORT_FCR\r
+//  Purpose:\r
+//  Context:\r
+//  Fields:\r
+//      Bits    SERIAL_PORT_FCR_BITS:  Bits of the FCR\r
+//      Data    UINT8: the value of the FCR\r
+//\r
+typedef union {\r
+  SERIAL_PORT_FCR_BITS  Bits;\r
+  UINT8                 Data;\r
+} SERIAL_PORT_FCR;\r
+\r
+//\r
+//  Name:   SERIAL_PORT_LCR_BITS\r
+//  Purpose:  Define each bit in Line Control Register\r
+//  Context:\r
+//  Fields:\r
+//      SERIALDB  Bit0-Bit1: Number of Serial Data Bits\r
+//      STOPB   Bit2: Number of Stop Bits\r
+//      PAREN   Bit3: Parity Enable\r
+//      EVENPAR   Bit4: Even Parity Select\r
+//      STICPAR   Bit5: Sticky Parity\r
+//      BRCON   Bit6: Break Control\r
+//      DLAB    Bit7: Divisor Latch Access Bit\r
+//\r
+typedef struct {\r
+  UINT8 SERIALDB : 2;\r
+  UINT8 STOPB : 1;\r
+  UINT8 PAREN : 1;\r
+  UINT8 EVENPAR : 1;\r
+  UINT8 STICPAR : 1;\r
+  UINT8 BRCON : 1;\r
+  UINT8 DLAB : 1;\r
+} SERIAL_PORT_LCR_BITS;\r
+\r
+//\r
+//  Name:   SERIAL_PORT_LCR\r
+//  Purpose:\r
+//  Context:\r
+//  Fields:\r
+//      Bits    SERIAL_PORT_LCR_BITS:  Bits of the LCR\r
+//      Data    UINT8: the value of the LCR\r
+//\r
+typedef union {\r
+  SERIAL_PORT_LCR_BITS  Bits;\r
+  UINT8                 Data;\r
+} SERIAL_PORT_LCR;\r
+\r
+//\r
+//  Name:   SERIAL_PORT_MCR_BITS\r
+//  Purpose:  Define each bit in Modem Control Register\r
+//  Context:\r
+//  Fields:\r
+//      DTRC     Bit0: Data Terminal Ready Control\r
+//      RTS      Bit1: Request To Send Control\r
+//      OUT1     Bit2: Output1\r
+//      OUT2     Bit3: Output2, used to disable interrupt\r
+//      LME;     Bit4: Loopback Mode Enable\r
+//      Reserved Bit5-Bit7: Reserved\r
+//\r
+typedef struct {\r
+  UINT8 DTRC : 1;\r
+  UINT8 RTS : 1;\r
+  UINT8 OUT1 : 1;\r
+  UINT8 OUT2 : 1;\r
+  UINT8 LME : 1;\r
+  UINT8 Reserved : 3;\r
+} SERIAL_PORT_MCR_BITS;\r
+\r
+//\r
+//  Name:   SERIAL_PORT_MCR\r
+//  Purpose:\r
+//  Context:\r
+//  Fields:\r
+//      Bits    SERIAL_PORT_MCR_BITS:  Bits of the MCR\r
+//      Data    UINT8: the value of the MCR\r
+//\r
+typedef union {\r
+  SERIAL_PORT_MCR_BITS  Bits;\r
+  UINT8                 Data;\r
+} SERIAL_PORT_MCR;\r
+\r
+//\r
+//  Name:   SERIAL_PORT_LSR_BITS\r
+//  Purpose:  Define each bit in Line Status Register\r
+//  Context:\r
+//  Fields:\r
+//      DR    Bit0: Receiver Data Ready Status\r
+//      OE    Bit1: Overrun Error Status\r
+//      PE    Bit2: Parity Error Status\r
+//      FE    Bit3: Framing Error Status\r
+//      BI    Bit4: Break Interrupt Status\r
+//      THRE  Bit5: Transmistter Holding Register Status\r
+//      TEMT  Bit6: Transmitter Empty Status\r
+//      FIFOE Bit7: FIFO Error Status\r
+//\r
+typedef struct {\r
+  UINT8 DR : 1;\r
+  UINT8 OE : 1;\r
+  UINT8 PE : 1;\r
+  UINT8 FE : 1;\r
+  UINT8 BI : 1;\r
+  UINT8 THRE : 1;\r
+  UINT8 TEMT : 1;\r
+  UINT8 FIFOE : 1;\r
+} SERIAL_PORT_LSR_BITS;\r
+\r
+//\r
+//  Name:   SERIAL_PORT_LSR\r
+//  Purpose:\r
+//  Context:\r
+//  Fields:\r
+//      Bits    SERIAL_PORT_LSR_BITS:  Bits of the LSR\r
+//      Data    UINT8: the value of the LSR\r
+//\r
+typedef union {\r
+  SERIAL_PORT_LSR_BITS  Bits;\r
+  UINT8                 Data;\r
+} SERIAL_PORT_LSR;\r
+\r
+//\r
+//  Name:   SERIAL_PORT_MSR_BITS\r
+//  Purpose:  Define each bit in Modem Status Register\r
+//  Context:\r
+//  Fields:\r
+//      DeltaCTS      Bit0: Delta Clear To Send Status\r
+//      DeltaDSR        Bit1: Delta Data Set Ready Status\r
+//      TrailingEdgeRI  Bit2: Trailing Edge of Ring Indicator Status\r
+//      DeltaDCD        Bit3: Delta Data Carrier Detect Status\r
+//      CTS             Bit4: Clear To Send Status\r
+//      DSR             Bit5: Data Set Ready Status\r
+//      RI              Bit6: Ring Indicator Status\r
+//      DCD             Bit7: Data Carrier Detect Status\r
+//\r
+typedef struct {\r
+  UINT8 DeltaCTS : 1;\r
+  UINT8 DeltaDSR : 1;\r
+  UINT8 TrailingEdgeRI : 1;\r
+  UINT8 DeltaDCD : 1;\r
+  UINT8 CTS : 1;\r
+  UINT8 DSR : 1;\r
+  UINT8 RI : 1;\r
+  UINT8 DCD : 1;\r
+} SERIAL_PORT_MSR_BITS;\r
+\r
+//\r
+//  Name:   SERIAL_PORT_MSR\r
+//  Purpose:\r
+//  Context:\r
+//  Fields:\r
+//      Bits    SERIAL_PORT_MSR_BITS:  Bits of the MSR\r
+//      Data    UINT8: the value of the MSR\r
+//\r
+typedef union {\r
+  SERIAL_PORT_MSR_BITS  Bits;\r
+  UINT8                 Data;\r
+} SERIAL_PORT_MSR;\r
+\r
+#pragma pack()\r
+//\r
+// Define serial register I/O macros\r
+//\r
+#define READ_RBR(IO, B)     IsaSerialReadPort (IO, B, SERIAL_REGISTER_RBR)\r
+#define READ_DLL(IO, B)     IsaSerialReadPort (IO, B, SERIAL_REGISTER_DLL)\r
+#define READ_DLM(IO, B)     IsaSerialReadPort (IO, B, SERIAL_REGISTER_DLM)\r
+#define READ_IER(IO, B)     IsaSerialReadPort (IO, B, SERIAL_REGISTER_IER)\r
+#define READ_IIR(IO, B)     IsaSerialReadPort (IO, B, SERIAL_REGISTER_IIR)\r
+#define READ_LCR(IO, B)     IsaSerialReadPort (IO, B, SERIAL_REGISTER_LCR)\r
+#define READ_MCR(IO, B)     IsaSerialReadPort (IO, B, SERIAL_REGISTER_MCR)\r
+#define READ_LSR(IO, B)     IsaSerialReadPort (IO, B, SERIAL_REGISTER_LSR)\r
+#define READ_MSR(IO, B)     IsaSerialReadPort (IO, B, SERIAL_REGISTER_MSR)\r
+#define READ_SCR(IO, B)     IsaSerialReadPort (IO, B, SERIAL_REGISTER_SCR)\r
+\r
+#define WRITE_THR(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_THR, D)\r
+#define WRITE_DLL(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_DLL, D)\r
+#define WRITE_DLM(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_DLM, D)\r
+#define WRITE_IER(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_IER, D)\r
+#define WRITE_FCR(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_FCR, D)\r
+#define WRITE_LCR(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_LCR, D)\r
+#define WRITE_MCR(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_MCR, D)\r
+#define WRITE_LSR(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_LSR, D)\r
+#define WRITE_MSR(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_MSR, D)\r
+#define WRITE_SCR(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_SCR, D)\r
+\r
+//\r
+// Prototypes\r
+// Driver model protocol interface\r
+//\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+SerialControllerDriverSupported (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
+  IN EFI_HANDLE                     Controller,\r
+  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+SerialControllerDriverStart (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
+  IN EFI_HANDLE                     Controller,\r
+  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+SerialControllerDriverStop (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL   *This,\r
+  IN  EFI_HANDLE                    Controller,\r
+  IN  UINTN                         NumberOfChildren,\r
+  IN  EFI_HANDLE                    *ChildHandleBuffer\r
+  );\r
+\r
+//\r
+// Serial I/O Protocol Interface\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+IsaSerialReset (\r
+  IN EFI_SERIAL_IO_PROTOCOL         *This\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+IsaSerialSetAttributes (\r
+  IN EFI_SERIAL_IO_PROTOCOL         *This,\r
+  IN UINT64                         BaudRate,\r
+  IN UINT32                         ReceiveFifoDepth,\r
+  IN UINT32                         Timeout,\r
+  IN EFI_PARITY_TYPE                Parity,\r
+  IN UINT8                          DataBits,\r
+  IN EFI_STOP_BITS_TYPE             StopBits\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+IsaSerialSetControl (\r
+  IN EFI_SERIAL_IO_PROTOCOL         *This,\r
+  IN UINT32                         Control\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+IsaSerialGetControl (\r
+  IN EFI_SERIAL_IO_PROTOCOL         *This,\r
+  OUT UINT32                        *Control\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+IsaSerialWrite (\r
+  IN EFI_SERIAL_IO_PROTOCOL         *This,\r
+  IN OUT UINTN                      *BufferSize,\r
+  IN VOID                           *Buffer\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+IsaSerialRead (\r
+  IN EFI_SERIAL_IO_PROTOCOL         *This,\r
+  IN OUT UINTN                      *BufferSize,\r
+  OUT VOID                          *Buffer\r
+  );\r
+\r
+//\r
+// Internal Functions\r
+//\r
+BOOLEAN\r
+IsaSerialPortPresent (\r
+  IN SERIAL_DEV                     *SerialDevice\r
+  );\r
+\r
+BOOLEAN\r
+IsaSerialFifoFull (\r
+  IN SERIAL_DEV_FIFO                *Fifo\r
+  );\r
+\r
+BOOLEAN\r
+IsaSerialFifoEmpty (\r
+  IN SERIAL_DEV_FIFO                *Fifo\r
+  );\r
+\r
+EFI_STATUS\r
+IsaSerialFifoAdd (\r
+  IN SERIAL_DEV_FIFO                *Fifo,\r
+  IN UINT8                          Data\r
+  );\r
+\r
+EFI_STATUS\r
+IsaSerialFifoRemove (\r
+  IN  SERIAL_DEV_FIFO               *Fifo,\r
+  OUT UINT8                         *Data\r
+  );\r
+\r
+EFI_STATUS\r
+IsaSerialReceiveTransmit (\r
+  IN SERIAL_DEV                     *SerialDevice\r
+  );\r
+\r
+UINT8\r
+IsaSerialReadPort (\r
+  IN EFI_ISA_IO_PROTOCOL                    *IsaIo,\r
+  IN UINT16                                 BaseAddress,\r
+  IN UINT32                                 Offset\r
+  );\r
+\r
+VOID\r
+IsaSerialWritePort (\r
+  IN EFI_ISA_IO_PROTOCOL                    *IsaIo,\r
+  IN UINT16                                 BaseAddress,\r
+  IN UINT32                                 Offset,\r
+  IN UINT8                                  Data\r
+  );\r
+\r
+#endif\r
index 300f25169ab33f71a20bfe4d4ba901a23d54a033..370b55ee6a58acf51e8b48e64d5582b32ebbf9b1 100644 (file)
   PcdIsaBusSupportDma|gEfiIntelFrameworkModulePkgTokenSpaceGuid|TRUE\r
   PcdIsaBusOnlySupportSlaveDma|gEfiIntelFrameworkModulePkgTokenSpaceGuid|FALSE\r
   PcdIsaBusSupportIsaMemory|gEfiIntelFrameworkModulePkgTokenSpaceGuid|TRUE\r
   PcdIsaBusSupportDma|gEfiIntelFrameworkModulePkgTokenSpaceGuid|TRUE\r
   PcdIsaBusOnlySupportSlaveDma|gEfiIntelFrameworkModulePkgTokenSpaceGuid|FALSE\r
   PcdIsaBusSupportIsaMemory|gEfiIntelFrameworkModulePkgTokenSpaceGuid|TRUE\r
+  PcdNtEmulatorEnable|gEfiMdeModulePkgTokenSpaceGuid|FALSE\r
 \r
 [PcdsFixedAtBuild.common]\r
   PcdMaximumUnicodeStringLength|gEfiMdePkgTokenSpaceGuid|1000000\r
 \r
 [PcdsFixedAtBuild.common]\r
   PcdMaximumUnicodeStringLength|gEfiMdePkgTokenSpaceGuid|1000000\r
   $(WORKSPACE)/IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaBus.inf\r
   $(WORKSPACE)/IntelFrameworkModulePkg/Bus/Isa/IsaFloppy/Dxe/IsaFloppy.inf\r
   $(WORKSPACE)/IntelFrameworkModulePkg/Bus/Isa/IsaFloppy/Pei/FloppyPeim.inf\r
   $(WORKSPACE)/IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaBus.inf\r
   $(WORKSPACE)/IntelFrameworkModulePkg/Bus/Isa/IsaFloppy/Dxe/IsaFloppy.inf\r
   $(WORKSPACE)/IntelFrameworkModulePkg/Bus/Isa/IsaFloppy/Pei/FloppyPeim.inf\r
+  $(WORKSPACE)/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerial.inf\r
   $(WORKSPACE)/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2keyboard.inf\r
   $(WORKSPACE)/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2Mouse.inf\r
   $(WORKSPACE)/IntelFrameworkModulePkg/Universal/DataHub/DataHub/Dxe/DataHub.inf\r
   $(WORKSPACE)/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2keyboard.inf\r
   $(WORKSPACE)/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2Mouse.inf\r
   $(WORKSPACE)/IntelFrameworkModulePkg/Universal/DataHub/DataHub/Dxe/DataHub.inf\r