Discussion:
[edk2] [Patch 0/2] Let IsaSerialDxe use dynamic PCD PcdSerialClockRate
Ruiyu Ni
2015-06-10 03:21:40 UTC
Permalink
So that for certain hardware with different serial clock rate, IsaSerialDxe can still manage it.

Ruiyu Ni (2):
MdeModulePkg: Extend PcdSerialClockRate to dynamic type
IntelFrameworkModulePkg/IsaSerialDxe: Use PcdSerialClockRate instead
of hard code value

.../Bus/Isa/IsaSerialDxe/IsaSerialDxe.inf | 12 +++++++-----
IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.c | 6 +++---
IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.h | 8 +-------
MdeModulePkg/MdeModulePkg.dec | 8 ++++----
4 files changed, 15 insertions(+), 19 deletions(-)
--
1.9.5.msysgit.1


------------------------------------------------------------------------------
Ruiyu Ni
2015-06-10 03:21:41 UTC
Permalink
So it could allow platform module to change the serial clock rate per different hardware.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <***@intel.com>
Cc: Feng Tian <***@intel.com>
---
MdeModulePkg/MdeModulePkg.dec | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 39793b8..15d351d 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -890,10 +890,6 @@
# @Prompt Memory profile memory type.
gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryProfileMemoryType|0x0|UINT64|0x30001042

- ## UART clock frequency is for the baud rate configuration.
- # @Prompt Serial Port Clock Rate.
- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate|1843200|UINT32|0x00010066
-
## PCI Serial Device Info. It is an array of Device, Function, and Power Management
# information that describes the path that contains zero or more PCI to PCI briges
# followed by a PCI serial device. Each array entry is 4-bytes in length. The
@@ -968,6 +964,10 @@
gEfiMdeModulePkgTokenSpaceGuid.PcdSetupConOutRow|25|UINT32|0x4000000e

[PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
+ ## UART clock frequency is for the baud rate configuration.
+ # @Prompt Serial Port Clock Rate.
+ gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate|1843200|UINT32|0x00010066
+
## This PCD points to the front page formset GUID
# Compare the FormsetGuid or ClassGuid with this PCD value can detect whether in front page
gEfiMdeModulePkgTokenSpaceGuid.PcdFrontPageFormSetGuid|{ 0xbc, 0x30, 0x0c, 0x9e,0x06, 0x3f, 0xa6, 0x4b, 0x82, 0x88, 0x9, 0x17, 0x9b, 0x85, 0x5d, 0xbe }|VOID*|0x0001006e
--
1.9.5.msysgit.1


------------------------------------------------------------------------------
Tian, Feng
2015-06-10 04:04:39 UTC
Permalink
Reviewed-by: Feng Tian <***@intel.com>

-----Original Message-----
From: Ni, Ruiyu
Sent: Wednesday, June 10, 2015 11:22
To: edk2-***@lists.sourceforge.net
Cc: Ni, Ruiyu; Tian, Feng
Subject: [Patch 1/2] MdeModulePkg: Extend PcdSerialClockRate to dynamic type

So it could allow platform module to change the serial clock rate per different hardware.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <***@intel.com>
Cc: Feng Tian <***@intel.com>
---
MdeModulePkg/MdeModulePkg.dec | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index 39793b8..15d351d 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -890,10 +890,6 @@
# @Prompt Memory profile memory type.
gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryProfileMemoryType|0x0|UINT64|0x30001042

- ## UART clock frequency is for the baud rate configuration.
- # @Prompt Serial Port Clock Rate.
- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate|1843200|UINT32|0x00010066
-
## PCI Serial Device Info. It is an array of Device, Function, and Power Management
# information that describes the path that contains zero or more PCI to PCI briges
# followed by a PCI serial device. Each array entry is 4-bytes in length. The @@ -968,6 +964,10 @@
gEfiMdeModulePkgTokenSpaceGuid.PcdSetupConOutRow|25|UINT32|0x4000000e

[PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
+ ## UART clock frequency is for the baud rate configuration.
+ # @Prompt Serial Port Clock Rate.
+
+ gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate|1843200|UINT32|0x000
+ 10066
+
## This PCD points to the front page formset GUID
# Compare the FormsetGuid or ClassGuid with this PCD value can detect whether in front page
gEfiMdeModulePkgTokenSpaceGuid.PcdFrontPageFormSetGuid|{ 0xbc, 0x30, 0x0c, 0x9e,0x06, 0x3f, 0xa6, 0x4b, 0x82, 0x88, 0x9, 0x17, 0x9b, 0x85, 0x5d, 0xbe }|VOID*|0x0001006e
--
1.9.5.msysgit.1


------------------------------------------------------------------------------
Ruiyu Ni
2015-06-10 03:21:42 UTC
Permalink
So that the driver can work on a certain hardware when a platform module
dynamically changes the PCD value.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <***@intel.com>
Cc: Feng Tian <***@intel.com>
---
.../Bus/Isa/IsaSerialDxe/IsaSerialDxe.inf | 12 +++++++-----
IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.c | 6 +++---
IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.h | 8 +-------
3 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerialDxe.inf b/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerialDxe.inf
index 064d4a0..4abaac9 100644
--- a/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerialDxe.inf
+++ b/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerialDxe.inf
@@ -4,7 +4,7 @@
# Produces the Serial I/O protocol for standard UARTS using ISA I/O. This driver
# supports the 8250, 16450, 16550 and 16550A UART types.
#
-# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -42,6 +42,7 @@

[Packages]
MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
IntelFrameworkPkg/IntelFrameworkPkg.dec
IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec

@@ -69,10 +70,11 @@
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdIsaBusSerialUseHalfHandshake|FALSE ## CONSUMES

[Pcd]
- gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate|115200 ## CONSUMES
- gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits|8 ## CONSUMES
- gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity|1 ## CONSUMES
- gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits|1 ## CONSUMES
+ gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate|115200 ## CONSUMES
+ gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits|8 ## CONSUMES
+ gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity|1 ## CONSUMES
+ gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits|1 ## CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate|1843200 ## CONSUMES

[UserExtensions.TianoCore."ExtraFiles"]
IsaSerialDxeExtra.uni
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.c b/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.c
index 15d2bab..57ee669 100644
--- a/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.c
+++ b/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.c
@@ -1,7 +1,7 @@
/** @file
Serial driver for standard UARTS on an ISA bus.

-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -1393,7 +1393,7 @@ IsaSerialSetAttributes (
// Compute divisor use to program the baud rate using a round determination
//
Divisor = (UINT32) DivU64x32Remainder (
- SERIAL_PORT_INPUT_CLOCK,
+ PcdGet32 (PcdSerialClockRate),
((UINT32) BaudRate * 16),
&Remained
);
@@ -1410,7 +1410,7 @@ IsaSerialSetAttributes (
//
// Compute the actual baud rate that the serial port will be programmed for.
//
- BaudRate = SERIAL_PORT_INPUT_CLOCK / Divisor / 16;
+ BaudRate = PcdGet32 (PcdSerialClockRate) / Divisor / 16;

//
// Put serial port on Divisor Latch Mode
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.h b/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.h
index c8d9cb1..9d50ca9 100644
--- a/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.h
+++ b/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.h
@@ -1,7 +1,7 @@
/** @file
Include for Serial Driver

-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -128,12 +128,6 @@ typedef struct {
EFI_SERIAL_OUTPUT_BUFFER_EMPTY | \
EFI_SERIAL_INPUT_BUFFER_EMPTY)

-
-//
-// (24000000/13)MHz input clock
-//
-#define SERIAL_PORT_INPUT_CLOCK 1843200
-
//
// 115200 baud with rounding errors
//
--
1.9.5.msysgit.1


------------------------------------------------------------------------------
Tian, Feng
2015-06-10 04:13:18 UTC
Permalink
Good to me.

Reviewed-by: Feng Tian <***@intel.com>

-----Original Message-----
From: Ni, Ruiyu
Sent: Wednesday, June 10, 2015 11:22
To: edk2-***@lists.sourceforge.net
Cc: Ni, Ruiyu; Tian, Feng
Subject: [Patch 2/2] IntelFrameworkModulePkg/IsaSerialDxe: Use PcdSerialClockRate instead of hard code value

So that the driver can work on a certain hardware when a platform module dynamically changes the PCD value.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <***@intel.com>
Cc: Feng Tian <***@intel.com>
---
.../Bus/Isa/IsaSerialDxe/IsaSerialDxe.inf | 12 +++++++-----
IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.c | 6 +++---
IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.h | 8 +-------
3 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerialDxe.inf b/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerialDxe.inf
index 064d4a0..4abaac9 100644
--- a/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerialDxe.inf
+++ b/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerialDxe.inf
@@ -4,7 +4,7 @@
# Produces the Serial I/O protocol for standard UARTS using ISA I/O. This driver # supports the 8250, 16450, 16550 and 16550A UART types.
#
-# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2015, Intel Corporation. All rights
+reserved.<BR>
#
# This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License @@ -42,6 +42,7 @@

[Packages]
MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
IntelFrameworkPkg/IntelFrameworkPkg.dec
IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec

@@ -69,10 +70,11 @@
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdIsaBusSerialUseHalfHandshake|FALSE ## CONSUMES

[Pcd]
- gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate|115200 ## CONSUMES
- gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits|8 ## CONSUMES
- gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity|1 ## CONSUMES
- gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits|1 ## CONSUMES
+ gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate|115200 ## CONSUMES
+ gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits|8 ## CONSUMES
+ gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity|1 ## CONSUMES
+ gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits|1 ## CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate|1843200 ## CONSUMES

[UserExtensions.TianoCore."ExtraFiles"]
IsaSerialDxeExtra.uni
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.c b/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.c
index 15d2bab..57ee669 100644
--- a/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.c
+++ b/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.c
@@ -1,7 +1,7 @@
/** @file
Serial driver for standard UARTS on an ISA bus.

-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -1393,7 +1393,7 @@ IsaSerialSetAttributes (
// Compute divisor use to program the baud rate using a round determination
//
Divisor = (UINT32) DivU64x32Remainder (
- SERIAL_PORT_INPUT_CLOCK,
+ PcdGet32 (PcdSerialClockRate),
((UINT32) BaudRate * 16),
&Remained
);
@@ -1410,7 +1410,7 @@ IsaSerialSetAttributes (
//
// Compute the actual baud rate that the serial port will be programmed for.
//
- BaudRate = SERIAL_PORT_INPUT_CLOCK / Divisor / 16;
+ BaudRate = PcdGet32 (PcdSerialClockRate) / Divisor / 16;

//
// Put serial port on Divisor Latch Mode diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.h b/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.h
index c8d9cb1..9d50ca9 100644
--- a/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.h
+++ b/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.h
@@ -1,7 +1,7 @@
/** @file
Include for Serial Driver

-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -128,12 +128,6 @@ typedef struct {
EFI_SERIAL_OUTPUT_BUFFER_EMPTY | \
EFI_SERIAL_INPUT_BUFFER_EMPTY)

-
-//
-// (24000000/13)MHz input clock
-//
-#define SERIAL_PORT_INPUT_CLOCK 1843200
-
//
// 115200 baud with rounding errors
//
--
1.9.5.msysgit.1


------------------------------------------------------------------------------
Loading...