public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-platforms] [PATCH 0/5] Enable Ps2 keyboard
@ 2019-11-01 19:51 Agyeman, Prince
  2019-11-01 19:51 ` [edk2-platforms] [PATCH 1/5] Platform/Intel: Add gBoardModulePkgTokenSpaceGuid Agyeman, Prince
                   ` (5 more replies)
  0 siblings, 6 replies; 16+ messages in thread
From: Agyeman, Prince @ 2019-11-01 19:51 UTC (permalink / raw)
  To: devel

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2228

This patch series enables BIOS Ps2 keyboard in GalagoPro3


What was done:
Patch 0001 adds PCDs to BoardModulePkg that will enable/disable,
describe Super I/O , Ps2 keyboard/mouse, uart1 and uart2 com ports

Patch 0002 moves the generic Super I/O driver from SimicsOpenBoardPkg to
BoardModulePkg in order for it to be shared. This driver publishes the
gEfiSioProtocolGuid consumed by edk2's MdeModulePkg/Bus/Isa/Ps2KeyboardDxe
driver to enable Ps2 keyboard functions in BIOS

Patch 0003 adds PCDs defined in patch 0001 to enable/disable devices in the
Super I/O driver added in patch 0002

Patch 0004 adds a Null Ps2 Library that adds Ps2 keyboard device path to
ConIn and ConInDev

Patch 0005 enables Ps2 keyboard in BIOS by setting Ps2 keyboard related PCDs
Prince Agyeman (5):
  Platform/Intel: Add gBoardModulePkgTokenSpaceGuid
  Platform/Intel: Move Sio Dxe Driver
  BoardModulePkg: Added Pcds Sio Driver
  KabylakeOpenBoardPkg: Add Ps2 keyboard Null Library
  KabylakeOpenBoardPkg: Add Ps2 Keyboard Support

 .../Intel/BoardModulePkg/BoardModulePkg.dec   |  25 +++
 .../Intel/BoardModulePkg/BoardModulePkg.dsc   |   1 +
 .../LegacySioDxe/ComponentName.c              |   0
 .../LegacySioDxe/ComponentName.h              |   0
 .../LegacySioDxe/LegacySioDxe.inf             |  18 +-
 .../LegacySioDxe/Register.h                   |   0
 .../LegacySioDxe/SioChip.c                    |  71 +++++-
 .../LegacySioDxe/SioChip.h                    |  18 +-
 .../LegacySioDxe/SioDriver.c                  |  42 +++-
 .../LegacySioDxe/SioDriver.h                  |   1 -
 .../LegacySioDxe/SioService.c                 |   0
 .../LegacySioDxe/SioService.h                 |   0
 .../BoardAcpiLib/DxeBoardAcpiTableLib.inf     |   3 +-
 .../DxeMultiBoardAcpiSupportLib.inf           |   3 +-
 .../GalagoPro3/Library/Ps2KbcLib/Ps2KbcLib.c  | 202 ++++++++++++++++++
 .../GalagoPro3/Library/Ps2KbcLib/Ps2KbcLib.h  |  65 ++++++
 .../Library/Ps2KbcLib/Ps2KbcLib.inf           |  39 ++++
 .../GalagoPro3/OpenBoardPkg.dsc               |   7 +
 .../GalagoPro3/OpenBoardPkg.fdf               |   2 +
 .../GalagoPro3/OpenBoardPkgPcd.dsc            |   6 +
 .../BoardAcpiLib/DxeBoardAcpiTableLib.inf     |   3 +-
 .../DxeMultiBoardAcpiSupportLib.inf           |   3 +-
 .../KabylakeRvp3/OpenBoardPkgPcd.dsc          |   5 +
 .../KabylakeOpenBoardPkg/OpenBoardPkg.dec     |   2 -
 .../BoardX58Ich10/OpenBoardPkg.dsc            |   2 +-
 .../BoardX58Ich10/OpenBoardPkg.fdf            |   2 +-
 .../BoardX58Ich10/OpenBoardPkgPcd.dsc         |   6 +
 .../WhiskeylakeOpenBoardPkg/OpenBoardPkg.dec  |   1 -
 .../WhiskeylakeURvp/OpenBoardPkgPcd.dsc       |   5 +
 29 files changed, 499 insertions(+), 33 deletions(-)
 rename Platform/Intel/{SimicsOpenBoardPkg => BoardModulePkg}/LegacySioDxe/ComponentName.c (100%)
 rename Platform/Intel/{SimicsOpenBoardPkg => BoardModulePkg}/LegacySioDxe/ComponentName.h (100%)
 rename Platform/Intel/{SimicsOpenBoardPkg => BoardModulePkg}/LegacySioDxe/LegacySioDxe.inf (63%)
 rename Platform/Intel/{SimicsOpenBoardPkg => BoardModulePkg}/LegacySioDxe/Register.h (100%)
 rename Platform/Intel/{SimicsOpenBoardPkg => BoardModulePkg}/LegacySioDxe/SioChip.c (75%)
 rename Platform/Intel/{SimicsOpenBoardPkg => BoardModulePkg}/LegacySioDxe/SioChip.h (90%)
 rename Platform/Intel/{SimicsOpenBoardPkg => BoardModulePkg}/LegacySioDxe/SioDriver.c (88%)
 rename Platform/Intel/{SimicsOpenBoardPkg => BoardModulePkg}/LegacySioDxe/SioDriver.h (95%)
 rename Platform/Intel/{SimicsOpenBoardPkg => BoardModulePkg}/LegacySioDxe/SioService.c (100%)
 rename Platform/Intel/{SimicsOpenBoardPkg => BoardModulePkg}/LegacySioDxe/SioService.h (100%)
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/Ps2KbcLib.c
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/Ps2KbcLib.h
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/Ps2KbcLib.inf

-- 
2.19.1.windows.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [edk2-platforms] [PATCH 1/5] Platform/Intel: Add gBoardModulePkgTokenSpaceGuid
  2019-11-01 19:51 [edk2-platforms] [PATCH 0/5] Enable Ps2 keyboard Agyeman, Prince
@ 2019-11-01 19:51 ` Agyeman, Prince
  2019-11-01 21:55   ` Nate DeSimone
  2019-11-01 19:51 ` [edk2-platforms] [PATCH 2/5] Platform/Intel: Move Sio Dxe Driver Agyeman, Prince
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 16+ messages in thread
From: Agyeman, Prince @ 2019-11-01 19:51 UTC (permalink / raw)
  To: devel; +Cc: Michael Kubacki, Chasel Chiu, Nate DeSimone

Added gBoardModulePkgTokenSpaceGuid to BoardModulePkg

Added ps2 keyboard and Uart enable PCDs.

Added PCDs to define IO ports for Uart1 and Uart2

Enabled KabylakeOpenBoardPkg and WhiskeylakeOpenBoardPkg
boards to use the ps2 keyboard enable PCD.

Cc: Michael Kubacki <michael.a.kubacki@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>

Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
---
 .../Intel/BoardModulePkg/BoardModulePkg.dec   | 25 +++++++++++++++++++
 .../BoardAcpiLib/DxeBoardAcpiTableLib.inf     |  3 ++-
 .../DxeMultiBoardAcpiSupportLib.inf           |  3 ++-
 .../GalagoPro3/OpenBoardPkgPcd.dsc            |  5 ++++
 .../BoardAcpiLib/DxeBoardAcpiTableLib.inf     |  3 ++-
 .../DxeMultiBoardAcpiSupportLib.inf           |  3 ++-
 .../KabylakeRvp3/OpenBoardPkgPcd.dsc          |  5 ++++
 .../KabylakeOpenBoardPkg/OpenBoardPkg.dec     |  2 --
 .../WhiskeylakeOpenBoardPkg/OpenBoardPkg.dec  |  1 -
 .../WhiskeylakeURvp/OpenBoardPkgPcd.dsc       |  5 ++++
 10 files changed, 48 insertions(+), 7 deletions(-)

diff --git a/Platform/Intel/BoardModulePkg/BoardModulePkg.dec b/Platform/Intel/BoardModulePkg/BoardModulePkg.dec
index f461cc7cab..26e662f711 100644
--- a/Platform/Intel/BoardModulePkg/BoardModulePkg.dec
+++ b/Platform/Intel/BoardModulePkg/BoardModulePkg.dec
@@ -42,3 +42,28 @@
 
   ## GUID to publish BIOS information HOB
   gBiosInfoGuid = { 0x09d0d15c, 0xe9f0, 0x4dfc, {0x9e, 0x0b, 0x39, 0x33, 0x1f, 0xca, 0x66, 0x85} }
+
+  ## {7F4EE1A3-C1F3-43E4-BA1A-39DCDE46C343}
+  gBoardModulePkgTokenSpaceGuid = { 0x7f4ee1a3, 0xc1f3, 0x43e4, { 0xba, 0x1a, 0x39, 0xdc, 0xde, 0x46, 0xc3, 0x43 } }
+
+[PcdsFixedAtBuild]
+  ## PcdPs2KbMsEnable 0x0:Disable, 0x1:Enable
+  gBoardModulePkgTokenSpaceGuid.PcdPs2KbMsEnable|0x00|UINT8|0x00000001
+
+  ## SuperIo Pci ISA Bridge info. It is an array that contains the Segment, Bus, Device and Function
+  #  information describing the PCI Device Info. The first byte is the segment number,
+  #  the second is the bus number, third byte is the device number, the fourth byte
+  #  is the Function.
+  gBoardModulePkgTokenSpaceGuid.PcdSuperIoPciIsaBridgeDevice|{0xFF, 0xFF, 0xFF, 0xFF}|VOID*|0x00000002
+
+  ## PcdUart1Enable 0x0:Disable, 0x1:Enable
+  gBoardModulePkgTokenSpaceGuid.PcdUart1Enable|0x00|UINT8|0x00000003
+  gBoardModulePkgTokenSpaceGuid.PcdUart1IrqMask|0x0010|UINT16|0x00000004
+  gBoardModulePkgTokenSpaceGuid.PcdUart1IoPort|0x03F8|UINT16|0x00000005
+  gBoardModulePkgTokenSpaceGuid.PcdUart1Length|0x08|UINT8|0x00000006
+
+  ## PcdUart2Enable 0x0:Disable, 0x1:Enable
+  gBoardModulePkgTokenSpaceGuid.PcdUart2Enable|0x00|UINT8|0x00000007
+  gBoardModulePkgTokenSpaceGuid.PcdUart2IrqMask|0x0008|UINT16|0x00000008
+  gBoardModulePkgTokenSpaceGuid.PcdUart2IoPort|0x02F8|UINT16|0x00000009
+  gBoardModulePkgTokenSpaceGuid.PcdUart2Length|0x08|UINT8|0x0000000A
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/BoardAcpiLib/DxeBoardAcpiTableLib.inf b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/BoardAcpiLib/DxeBoardAcpiTableLib.inf
index a79bdcdbc6..35cd5c8fdb 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/BoardAcpiLib/DxeBoardAcpiTableLib.inf
+++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/BoardAcpiLib/DxeBoardAcpiTableLib.inf
@@ -33,9 +33,10 @@
   MinPlatformPkg/MinPlatformPkg.dec
   KabylakeOpenBoardPkg/OpenBoardPkg.dec
   KabylakeSiliconPkg/SiPkg.dec
+  BoardModulePkg/BoardModulePkg.dec
 
 [Pcd]
-  gKabylakeOpenBoardPkgTokenSpaceGuid.PcdPs2KbMsEnable
+  gBoardModulePkgTokenSpaceGuid.PcdPs2KbMsEnable
   gMinPlatformPkgTokenSpaceGuid.PcdPciExpNative
   gMinPlatformPkgTokenSpaceGuid.PcdNativeAspmEnable
   gMinPlatformPkgTokenSpaceGuid.PcdLowPowerS0Idle
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/BoardAcpiLib/DxeMultiBoardAcpiSupportLib.inf b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/BoardAcpiLib/DxeMultiBoardAcpiSupportLib.inf
index db8ba7a822..9fe27f9fda 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/BoardAcpiLib/DxeMultiBoardAcpiSupportLib.inf
+++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/BoardAcpiLib/DxeMultiBoardAcpiSupportLib.inf
@@ -34,9 +34,10 @@
   MinPlatformPkg/MinPlatformPkg.dec
   KabylakeOpenBoardPkg/OpenBoardPkg.dec
   KabylakeSiliconPkg/SiPkg.dec
+  BoardModulePkg/BoardModulePkg.dec
 
 [Pcd]
-  gKabylakeOpenBoardPkgTokenSpaceGuid.PcdPs2KbMsEnable
+  gBoardModulePkgTokenSpaceGuid.PcdPs2KbMsEnable
   gKabylakeOpenBoardPkgTokenSpaceGuid.PcdPciExpNative
   gKabylakeOpenBoardPkgTokenSpaceGuid.PcdNativeAspmEnable
   gKabylakeOpenBoardPkgTokenSpaceGuid.PcdLowPowerS0Idle
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd.dsc b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd.dsc
index c68b8a49cf..4550a4e0b5 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd.dsc
+++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd.dsc
@@ -308,6 +308,11 @@
   gMinPlatformPkgTokenSpaceGuid.PcdTestPointIbvPlatformFeature|{0x03, 0x0F, 0x07, 0x1F, 0x1F, 0x0F, 0x0F, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
 !endif
 
+  ######################################
+  # Board Configuration
+  ######################################
+  gBoardModulePkgTokenSpaceGuid.PcdPs2KbMsEnable|1
+
 [PcdsFixedAtBuild.IA32]
   ######################################
   # Edk2 Configuration
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Library/BoardAcpiLib/DxeBoardAcpiTableLib.inf b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Library/BoardAcpiLib/DxeBoardAcpiTableLib.inf
index bfb58e868f..e0bf5823d8 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Library/BoardAcpiLib/DxeBoardAcpiTableLib.inf
+++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Library/BoardAcpiLib/DxeBoardAcpiTableLib.inf
@@ -33,9 +33,10 @@
   MinPlatformPkg/MinPlatformPkg.dec
   KabylakeOpenBoardPkg/OpenBoardPkg.dec
   KabylakeSiliconPkg/SiPkg.dec
+  BoardModulePkg/BoardModulePkg.dec
 
 [Pcd]
-  gKabylakeOpenBoardPkgTokenSpaceGuid.PcdPs2KbMsEnable
+  gBoardModulePkgTokenSpaceGuid.PcdPs2KbMsEnable
   gKabylakeOpenBoardPkgTokenSpaceGuid.PcdPciExpNative
   gKabylakeOpenBoardPkgTokenSpaceGuid.PcdNativeAspmEnable
   gKabylakeOpenBoardPkgTokenSpaceGuid.PcdLowPowerS0Idle
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Library/BoardAcpiLib/DxeMultiBoardAcpiSupportLib.inf b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Library/BoardAcpiLib/DxeMultiBoardAcpiSupportLib.inf
index 00cdbe80ce..e5de9268e7 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Library/BoardAcpiLib/DxeMultiBoardAcpiSupportLib.inf
+++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Library/BoardAcpiLib/DxeMultiBoardAcpiSupportLib.inf
@@ -34,9 +34,10 @@
   MinPlatformPkg/MinPlatformPkg.dec
   KabylakeOpenBoardPkg/OpenBoardPkg.dec
   KabylakeSiliconPkg/SiPkg.dec
+  BoardModulePkg/BoardModulePkg.dec
 
 [Pcd]
-  gKabylakeOpenBoardPkgTokenSpaceGuid.PcdPs2KbMsEnable
+  gBoardModulePkgTokenSpaceGuid.PcdPs2KbMsEnable
   gKabylakeOpenBoardPkgTokenSpaceGuid.PcdPciExpNative
   gKabylakeOpenBoardPkgTokenSpaceGuid.PcdNativeAspmEnable
   gKabylakeOpenBoardPkgTokenSpaceGuid.PcdLowPowerS0Idle
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkgPcd.dsc b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkgPcd.dsc
index 34cc731313..8728586bfd 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkgPcd.dsc
+++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkgPcd.dsc
@@ -324,6 +324,11 @@
   gMinPlatformPkgTokenSpaceGuid.PcdTestPointIbvPlatformFeature|{0x03, 0x0F, 0x07, 0x1F, 0x1F, 0x0F, 0x0F, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
 !endif
 
+  ######################################
+  # Board Configuration
+  ######################################
+  gBoardModulePkgTokenSpaceGuid.PcdPs2KbMsEnable|0
+
 [PcdsFixedAtBuild.IA32]
   ######################################
   # Edk2 Configuration
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/OpenBoardPkg.dec b/Platform/Intel/KabylakeOpenBoardPkg/OpenBoardPkg.dec
index 9680e63bad..01d6116616 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/OpenBoardPkg.dec
+++ b/Platform/Intel/KabylakeOpenBoardPkg/OpenBoardPkg.dec
@@ -288,8 +288,6 @@ gKabylakeOpenBoardPkgTokenSpaceGuid.PcdBoardUcmcGpioTableSize|0|UINT16|0x0000001
 # Misc
 gKabylakeOpenBoardPkgTokenSpaceGuid.PcdIoExpanderPresent|FALSE|BOOLEAN|0x000000EC
 
-  gKabylakeOpenBoardPkgTokenSpaceGuid.PcdPs2KbMsEnable|1|UINT8|0x40000009
-
   gKabylakeOpenBoardPkgTokenSpaceGuid.PcdAcpiSleepState|1|UINT8|0x40000002
   gKabylakeOpenBoardPkgTokenSpaceGuid.PcdAcpiHibernate|1|UINT8|0x40000003
   gKabylakeOpenBoardPkgTokenSpaceGuid.PcdLowPowerS0Idle|0|UINT8|0x40000004
diff --git a/Platform/Intel/WhiskeylakeOpenBoardPkg/OpenBoardPkg.dec b/Platform/Intel/WhiskeylakeOpenBoardPkg/OpenBoardPkg.dec
index 34494d0168..fbb9549e44 100644
--- a/Platform/Intel/WhiskeylakeOpenBoardPkg/OpenBoardPkg.dec
+++ b/Platform/Intel/WhiskeylakeOpenBoardPkg/OpenBoardPkg.dec
@@ -271,7 +271,6 @@ gWhiskeylakeOpenBoardPkgTokenSpaceGuid.PcdAcpiHibernate|1|UINT8|0x40000003
 gWhiskeylakeOpenBoardPkgTokenSpaceGuid.PcdLowPowerS0Idle|0|UINT8|0x40000004
 gWhiskeylakeOpenBoardPkgTokenSpaceGuid.PcdPciExpNative|0|UINT8|0x40000005
 gWhiskeylakeOpenBoardPkgTokenSpaceGuid.PcdNativeAspmEnable|1|UINT8|0x40000006
-gWhiskeylakeOpenBoardPkgTokenSpaceGuid.PcdPs2KbMsEnable|0|UINT8|0x40000009
 gWhiskeylakeOpenBoardPkgTokenSpaceGuid.PcdDisableActiveTripPoints|1|UINT8|0x4000000A
 gWhiskeylakeOpenBoardPkgTokenSpaceGuid.PcdDisablePassiveTripPoints|0|UINT8|0x4000000B
 gWhiskeylakeOpenBoardPkgTokenSpaceGuid.PcdDisableCriticalTripPoints|1|UINT8|0x4000000C
diff --git a/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPkgPcd.dsc b/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPkgPcd.dsc
index adbd48f6d7..805013429e 100644
--- a/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPkgPcd.dsc
+++ b/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPkgPcd.dsc
@@ -296,6 +296,11 @@
   gMinPlatformPkgTokenSpaceGuid.PcdTestPointIbvPlatformFeature|{0x03, 0x0F, 0x07, 0x1F, 0x1F, 0x0F, 0x0F, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
 !endif
 
+  ######################################
+  # Board Configuration
+  ######################################
+  gBoardModulePkgTokenSpaceGuid.PcdPs2KbMsEnable|0
+
 [PcdsFixedAtBuild.IA32]
   ######################################
   # Edk2 Configuration
-- 
2.19.1.windows.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [edk2-platforms] [PATCH 2/5] Platform/Intel: Move Sio Dxe Driver
  2019-11-01 19:51 [edk2-platforms] [PATCH 0/5] Enable Ps2 keyboard Agyeman, Prince
  2019-11-01 19:51 ` [edk2-platforms] [PATCH 1/5] Platform/Intel: Add gBoardModulePkgTokenSpaceGuid Agyeman, Prince
@ 2019-11-01 19:51 ` Agyeman, Prince
  2019-11-01 21:55   ` Nate DeSimone
  2019-11-04  9:15   ` Chiu, Chasel
  2019-11-01 19:51 ` [edk2-platforms] [PATCH 3/5] BoardModulePkg: Added Pcds Sio Driver Agyeman, Prince
                   ` (3 subsequent siblings)
  5 siblings, 2 replies; 16+ messages in thread
From: Agyeman, Prince @ 2019-11-01 19:51 UTC (permalink / raw)
  To: devel; +Cc: Michael Kubacki, Chasel Chiu, Nate DeSimone

Moved LegacySioDxe from SimicsOpenBoardPkg
to BoardModulePkg as LegacySioDxe is generic
and can be shared between open board packages

Removed unused libraries and functions in LegacySioDxe

Pointed BoardX58Ich10 to the current LegacySioDxe
location

Cc: Michael Kubacki <michael.a.kubacki@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>

Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
---
 Platform/Intel/BoardModulePkg/BoardModulePkg.dsc       |  1 +
 .../LegacySioDxe/ComponentName.c                       |  0
 .../LegacySioDxe/ComponentName.h                       |  0
 .../LegacySioDxe/LegacySioDxe.inf                      |  3 ---
 .../LegacySioDxe/Register.h                            |  0
 .../LegacySioDxe/SioChip.c                             |  2 --
 .../LegacySioDxe/SioChip.h                             | 10 ----------
 .../LegacySioDxe/SioDriver.c                           |  0
 .../LegacySioDxe/SioDriver.h                           |  1 -
 .../LegacySioDxe/SioService.c                          |  0
 .../LegacySioDxe/SioService.h                          |  0
 .../SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc  |  2 +-
 .../SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf  |  2 +-
 13 files changed, 3 insertions(+), 18 deletions(-)
 rename Platform/Intel/{SimicsOpenBoardPkg => BoardModulePkg}/LegacySioDxe/ComponentName.c (100%)
 rename Platform/Intel/{SimicsOpenBoardPkg => BoardModulePkg}/LegacySioDxe/ComponentName.h (100%)
 rename Platform/Intel/{SimicsOpenBoardPkg => BoardModulePkg}/LegacySioDxe/LegacySioDxe.inf (92%)
 rename Platform/Intel/{SimicsOpenBoardPkg => BoardModulePkg}/LegacySioDxe/Register.h (100%)
 rename Platform/Intel/{SimicsOpenBoardPkg => BoardModulePkg}/LegacySioDxe/SioChip.c (94%)
 rename Platform/Intel/{SimicsOpenBoardPkg => BoardModulePkg}/LegacySioDxe/SioChip.h (93%)
 rename Platform/Intel/{SimicsOpenBoardPkg => BoardModulePkg}/LegacySioDxe/SioDriver.c (100%)
 rename Platform/Intel/{SimicsOpenBoardPkg => BoardModulePkg}/LegacySioDxe/SioDriver.h (95%)
 rename Platform/Intel/{SimicsOpenBoardPkg => BoardModulePkg}/LegacySioDxe/SioService.c (100%)
 rename Platform/Intel/{SimicsOpenBoardPkg => BoardModulePkg}/LegacySioDxe/SioService.h (100%)

diff --git a/Platform/Intel/BoardModulePkg/BoardModulePkg.dsc b/Platform/Intel/BoardModulePkg/BoardModulePkg.dsc
index 5ec68ceebf..fffc135d75 100644
--- a/Platform/Intel/BoardModulePkg/BoardModulePkg.dsc
+++ b/Platform/Intel/BoardModulePkg/BoardModulePkg.dsc
@@ -76,6 +76,7 @@
 
 [Components]
   BoardModulePkg/FirmwareBootMediaInfo/FirmwareBootMediaInfoPei.inf
+  BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
   BoardModulePkg/Library/CmosAccessLib/CmosAccessLib.inf
   BoardModulePkg/Library/PlatformCmosAccessLibNull/PlatformCmosAccessLibNull.inf
 
diff --git a/Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/ComponentName.c b/Platform/Intel/BoardModulePkg/LegacySioDxe/ComponentName.c
similarity index 100%
rename from Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/ComponentName.c
rename to Platform/Intel/BoardModulePkg/LegacySioDxe/ComponentName.c
diff --git a/Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/ComponentName.h b/Platform/Intel/BoardModulePkg/LegacySioDxe/ComponentName.h
similarity index 100%
rename from Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/ComponentName.h
rename to Platform/Intel/BoardModulePkg/LegacySioDxe/ComponentName.h
diff --git a/Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/LegacySioDxe.inf b/Platform/Intel/BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
similarity index 92%
rename from Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/LegacySioDxe.inf
rename to Platform/Intel/BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
index 275f36ca47..d606ba43dc 100644
--- a/Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/LegacySioDxe.inf
+++ b/Platform/Intel/BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
@@ -28,11 +28,8 @@
   MemoryAllocationLib
   PcdLib
   DevicePathLib
-  IoLib
   UefiDriverEntryPoint
   UefiBootServicesTableLib
-  S3BootScriptLib
-  S3IoLib
 
 [Packages]
   MdePkg/MdePkg.dec
diff --git a/Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/Register.h b/Platform/Intel/BoardModulePkg/LegacySioDxe/Register.h
similarity index 100%
rename from Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/Register.h
rename to Platform/Intel/BoardModulePkg/LegacySioDxe/Register.h
diff --git a/Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/SioChip.c b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.c
similarity index 94%
rename from Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/SioChip.c
rename to Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.c
index b9a7b9cd24..81efe3c38b 100644
--- a/Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/SioChip.c
+++ b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.c
@@ -7,9 +7,7 @@
 **/
 
 #include "SioDriver.h"
-#include <Library/S3IoLib.h>
 
-LOCAL_IO_WRITE8    mIoWrite8         = IoWrite8;
 //
 // System configuration (setup) information
 //
diff --git a/Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/SioChip.h b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.h
similarity index 93%
rename from Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/SioChip.h
rename to Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.h
index 48e28c44b0..9322365923 100644
--- a/Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/SioChip.h
+++ b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.h
@@ -46,16 +46,6 @@ typedef struct {
   ACPI_RESOURCE_HEADER_PTR    PossibleResources;
 } DEVICE_INFO;
 
-
-/**
-  Initialize the SIO chip for S3.
-**/
-VOID
-SioInitForS3 (
-  VOID
-  );
-
-
 /**
   Return the supported devices.
 
diff --git a/Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/SioDriver.c b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioDriver.c
similarity index 100%
rename from Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/SioDriver.c
rename to Platform/Intel/BoardModulePkg/LegacySioDxe/SioDriver.c
diff --git a/Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/SioDriver.h b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioDriver.h
similarity index 95%
rename from Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/SioDriver.h
rename to Platform/Intel/BoardModulePkg/LegacySioDxe/SioDriver.h
index 2e75871f7f..8817019fbf 100644
--- a/Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/SioDriver.h
+++ b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioDriver.h
@@ -16,7 +16,6 @@
 #include <Library/BaseMemoryLib.h>
 #include <Library/DebugLib.h>
 #include <Library/IoLib.h>
-#include <Library/S3BootScriptLib.h>
 #include <Library/PciLib.h>
 #include <Library/UefiBootServicesTableLib.h>
 #include <Library/DevicePathLib.h>
diff --git a/Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/SioService.c b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioService.c
similarity index 100%
rename from Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/SioService.c
rename to Platform/Intel/BoardModulePkg/LegacySioDxe/SioService.c
diff --git a/Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/SioService.h b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioService.h
similarity index 100%
rename from Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/SioService.h
rename to Platform/Intel/BoardModulePkg/LegacySioDxe/SioService.h
diff --git a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc
index 78f1e80990..f91f71e246 100644
--- a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc
+++ b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc
@@ -280,7 +280,7 @@
   #######################################
   $(BOARD_PKG)/AcpiTables/AcpiTables.inf
   $(BOARD_PKG)/AcpiTables/MinPlatformAcpiTables/AcpiPlatform.inf
-  $(BOARD_PKG)/LegacySioDxe/LegacySioDxe.inf
+  BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
   $(BOARD_PKG)/SimicsDxe/SimicsDxe.inf
   $(BOARD_PKG)/SimicsVideoDxe/SimicsVideoDxe.inf
   $(BOARD_PKG)/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
diff --git a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf
index 39226251a7..590e01a14e 100644
--- a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf
+++ b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf
@@ -213,7 +213,7 @@ INF  MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
 INF  MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceSmm.inf
 INF  MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf
 
-INF  $(BOARD_PKG)/LegacySioDxe/LegacySioDxe.inf
+INF  BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
 INF  MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KeyboardDxe.inf
 
 INF  $(BOARD_PKG)/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
-- 
2.19.1.windows.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [edk2-platforms] [PATCH 3/5] BoardModulePkg: Added Pcds Sio Driver
  2019-11-01 19:51 [edk2-platforms] [PATCH 0/5] Enable Ps2 keyboard Agyeman, Prince
  2019-11-01 19:51 ` [edk2-platforms] [PATCH 1/5] Platform/Intel: Add gBoardModulePkgTokenSpaceGuid Agyeman, Prince
  2019-11-01 19:51 ` [edk2-platforms] [PATCH 2/5] Platform/Intel: Move Sio Dxe Driver Agyeman, Prince
@ 2019-11-01 19:51 ` Agyeman, Prince
  2019-11-01 21:55   ` [edk2-devel] " Nate DeSimone
  2019-11-04 18:19   ` Kubacki, Michael A
  2019-11-01 19:51 ` [edk2-platforms] [PATCH 4/5] KabylakeOpenBoardPkg: Add Ps2 keyboard Null Library Agyeman, Prince
                   ` (2 subsequent siblings)
  5 siblings, 2 replies; 16+ messages in thread
From: Agyeman, Prince @ 2019-11-01 19:51 UTC (permalink / raw)
  To: devel; +Cc: Michael Kubacki, Chasel Chiu, Nate DeSimone

Included PCDs to the Sio dxe driver,
to allow the enable/disable of Ps2 keyboard/mouse,
UART1 and UART2 com ports.

Renamed the Sio driver's base name

Cc: Michael Kubacki <michael.a.kubacki@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>

Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
---
 .../LegacySioDxe/LegacySioDxe.inf             | 15 +++-
 .../BoardModulePkg/LegacySioDxe/SioChip.c     | 69 +++++++++++++++++--
 .../BoardModulePkg/LegacySioDxe/SioChip.h     | 10 +++
 .../BoardModulePkg/LegacySioDxe/SioDriver.c   | 42 ++++++++++-
 .../BoardX58Ich10/OpenBoardPkgPcd.dsc         |  6 ++
 5 files changed, 133 insertions(+), 9 deletions(-)

diff --git a/Platform/Intel/BoardModulePkg/LegacySioDxe/LegacySioDxe.inf b/Platform/Intel/BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
index d606ba43dc..4ab01a6098 100644
--- a/Platform/Intel/BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
+++ b/Platform/Intel/BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
@@ -10,7 +10,7 @@
 
 [Defines]
   INF_VERSION                    = 0x00010017
-  BASE_NAME                      = HitachiH8s2113Dxe
+  BASE_NAME                      = LegacySioDxe
   FILE_GUID                      = 7807E404-8281-4FF1-8457-0B54BABE263F
   VERSION_STRING                 = 1.0
   MODULE_TYPE                    = UEFI_DRIVER
@@ -34,6 +34,7 @@
 [Packages]
   MdePkg/MdePkg.dec
   MdeModulePkg/MdeModulePkg.dec
+  BoardModulePkg/BoardModulePkg.dec
 
 [Sources]
   SioChip.c
@@ -44,6 +45,18 @@
   SioDriver.h
   ComponentName.c
 
+[Pcd]
+  gBoardModulePkgTokenSpaceGuid.PcdPs2KbMsEnable
+  gBoardModulePkgTokenSpaceGuid.PcdUart1Enable
+  gBoardModulePkgTokenSpaceGuid.PcdUart1IrqMask
+  gBoardModulePkgTokenSpaceGuid.PcdUart1IoPort
+  gBoardModulePkgTokenSpaceGuid.PcdUart1Length
+  gBoardModulePkgTokenSpaceGuid.PcdUart2Enable
+  gBoardModulePkgTokenSpaceGuid.PcdUart2IrqMask
+  gBoardModulePkgTokenSpaceGuid.PcdUart2IoPort
+  gBoardModulePkgTokenSpaceGuid.PcdUart2Length
+  gBoardModulePkgTokenSpaceGuid.PcdSuperIoPciIsaBridgeDevice
+
 [Protocols]
   gEfiPciIoProtocolGuid                         ## CONSUMES
   gEfiDevicePathProtocolGuid                    ## PRODUCES
diff --git a/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.c b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.c
index 81efe3c38b..09403a7354 100644
--- a/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.c
+++ b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.c
@@ -19,12 +19,31 @@
 ACPI_SIO_RESOURCES_IO_IRQ      mCom1Resources = {
   {
     { ACPI_FIXED_LOCATION_IO_PORT_DESCRIPTOR },
-    0x3f8,
-    8
+      FixedPcdGet16 (PcdUart1IoPort),
+      FixedPcdGet8 (PcdUart1Length)
+    },
+    {
+      { ACPI_IRQ_NOFLAG_DESCRIPTOR },
+      FixedPcdGet16 (PcdUart1IrqMask)
+    },
+    {
+      ACPI_END_TAG_DESCRIPTOR,
+      0
+    }
+};
+
+//
+// COM 2 UART Controller
+//
+ACPI_SIO_RESOURCES_IO_IRQ      mCom2Resources = {
+  {
+    { ACPI_FIXED_LOCATION_IO_PORT_DESCRIPTOR },
+    FixedPcdGet16 (PcdUart2IoPort),
+    FixedPcdGet8 (PcdUart2Length)
   },
   {
     { ACPI_IRQ_NOFLAG_DESCRIPTOR },
-    BIT4    // IRQ4
+    FixedPcdGet16 (PcdUart2IrqMask),
   },
   {
     ACPI_END_TAG_DESCRIPTOR,
@@ -70,10 +89,12 @@ ACPI_SIO_RESOURCES_IO_IRQ      mMouseResources = {
   }
 };
 
+
 //
 // Table of SIO Controllers
 //
 DEVICE_INFO    mDeviceInfo[] = {
+#if FixedPcdGet8 (PcdUart1Enable) == DEVICE_ENABLED
   {
     {
       EISA_PNP_ID(0x501),
@@ -84,6 +105,20 @@ DEVICE_INFO    mDeviceInfo[] = {
     { (ACPI_SMALL_RESOURCE_HEADER *) &mCom1Resources },
     { (ACPI_SMALL_RESOURCE_HEADER *) &mCom1Resources }
   },  // COM 1 UART Controller
+#endif
+#if FixedPcdGet8 (PcdUart2Enable) == DEVICE_ENABLED
+  {
+    {
+      EISA_PNP_ID(0x501),
+      0
+    },
+    0,
+    RESOURCE_IO | RESOURCE_IRQ,
+    { (ACPI_SMALL_RESOURCE_HEADER *) &mCom2Resources },
+    { (ACPI_SMALL_RESOURCE_HEADER *) &mCom2Resources }
+  },  // COM 2 UART Controller
+#endif
+#if FixedPcdGet8 (PcdPs2KbMsEnable) == DEVICE_ENABLED
   {
     {
       EISA_PNP_ID(0x303),
@@ -103,10 +138,28 @@ DEVICE_INFO    mDeviceInfo[] = {
     0,  // Cannot change resource
     { (ACPI_SMALL_RESOURCE_HEADER *) &mMouseResources },
     { (ACPI_SMALL_RESOURCE_HEADER *) &mMouseResources }
-  }  // PS/2 Mouse Controller
+  },  // PS/2 Mouse Controller
+#endif
+  DEVICE_INFO_END
 };
 
 
+
+/**
+  Gets the number of devices in Table of SIO Controllers mDeviceInfo
+
+  @retval     Number of enabled devices in Table of SIO Controllers.
+**/
+UINTN
+EFIAPI
+GetDeviceCount(
+  VOID
+){
+   UINTN        Count;
+   Count = ARRAY_SIZE(mDeviceInfo) - 1; // -1 to account for for the end device info
+   return Count;
+}
+
 /**
   Return the supported devices.
 
@@ -128,7 +181,7 @@ DeviceGetList (
   //
   // Allocate enough memory for simplicity
   //
-  DeviceCount =  sizeof (mDeviceInfo) / sizeof (mDeviceInfo[0]);
+  DeviceCount = GetDeviceCount();
   LocalDevices = AllocatePool (sizeof (EFI_SIO_ACPI_DEVICE_ID) * DeviceCount);
   ASSERT (LocalDevices != NULL);
   if (LocalDevices == NULL) {
@@ -157,7 +210,6 @@ SioInit (
   VOID
   )
 {
-
   return EFI_SUCCESS;
 }
 
@@ -175,8 +227,11 @@ DeviceSearch (
   )
 {
   UINTN       Index;
+  UINTN       DeviceCount;
+
+  DeviceCount = GetDeviceCount();
 
-  for (Index = 0; Index < sizeof (mDeviceInfo) / sizeof (mDeviceInfo[0]); Index++) {
+  for (Index = 0; Index < DeviceCount; Index++) {
     if (CompareMem (Device, &mDeviceInfo[Index].Device, sizeof (*Device)) == 0) {
       return &mDeviceInfo[Index];
     }
diff --git a/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.h b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.h
index 9322365923..8bd53ccdd6 100644
--- a/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.h
+++ b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.h
@@ -24,6 +24,9 @@ UINT8
 #define RESOURCE_DMA   BIT2
 #define RESOURCE_MEM   BIT3
 
+#define DEVICE_ENABLED  0x01
+#define DEVICE_INFO_END { { 0xFFFFFFFF, 0xFFFFFFFF } }
+
 #pragma pack(1)
 
 typedef struct {
@@ -46,6 +49,13 @@ typedef struct {
   ACPI_RESOURCE_HEADER_PTR    PossibleResources;
 } DEVICE_INFO;
 
+typedef struct {
+  UINT8 Segment;
+  UINT8 Bus;
+  UINT8 Device;
+  UINT8 Funtion;
+} SIO_PCI_ISA_BRIDGE_DEVICE_INFO;
+
 /**
   Return the supported devices.
 
diff --git a/Platform/Intel/BoardModulePkg/LegacySioDxe/SioDriver.c b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioDriver.c
index 408c6ff301..5ab9109ad9 100644
--- a/Platform/Intel/BoardModulePkg/LegacySioDxe/SioDriver.c
+++ b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioDriver.c
@@ -8,7 +8,6 @@
 
 #include "SioDriver.h"
 
-
 //
 // This driver is for ACPI(PNP0A03,0)/PCI(0x1f,0)
 //
@@ -106,6 +105,27 @@ SioDriverEntryPoint (
 }
 
 
+/**
+  Compares a PCI to ISA bridge device segment, bus, device and function to the
+  PcdSuperIoPciIsaBridgeDevice values.
+
+  @param[in]  CurrentDevice       The device to be compared with the PcdSuperIoPciIsaBridgeDevice information
+  @retval     TRUE                This device matches PcdSuperIoPciIsaBridgeDevice values
+  @retval     FALSE               This device does not match the PcdSuperIoPciIsaBridgeDevice values
+**/
+BOOLEAN
+EFIAPI
+SioDeviceEnabled (
+  IN SIO_PCI_ISA_BRIDGE_DEVICE_INFO *CurrentDevice
+){
+    SIO_PCI_ISA_BRIDGE_DEVICE_INFO *Device = \
+      (SIO_PCI_ISA_BRIDGE_DEVICE_INFO *) FixedPcdGetPtr (PcdSuperIoPciIsaBridgeDevice);
+    if(CompareMem (Device, CurrentDevice, sizeof (SIO_PCI_ISA_BRIDGE_DEVICE_INFO)) == 0) {
+      return TRUE;
+    }
+    return FALSE;
+}
+
 /**
   Test to see if this driver supports Controller Handle.
 
@@ -138,6 +158,7 @@ SioDriverSupported (
   UINTN                     BusNumber;
   UINTN                     DeviceNumber;
   UINTN                     FunctionNumber;
+  SIO_PCI_ISA_BRIDGE_DEVICE_INFO  SioDevice;
 
   //
   // If RemainingDevicePath is not NULL, it should verify that the first device
@@ -250,6 +271,25 @@ SioDriverSupported (
             Status = EFI_UNSUPPORTED;
           }
         }
+
+        if(!EFI_ERROR (Status)) {
+          Status = PciIo->GetLocation (
+                            PciIo,
+                            &SegmentNumber,
+                            &BusNumber,
+                            &DeviceNumber,
+                            &FunctionNumber
+                            );
+          if(!EFI_ERROR (Status)) {
+            SioDevice.Segment = (UINT8) SegmentNumber;
+            SioDevice.Bus = (UINT8) BusNumber;
+            SioDevice.Device = (UINT8) DeviceNumber;
+            SioDevice.Funtion = (UINT8) FunctionNumber;
+            if(!SioDeviceEnabled (&SioDevice)) {
+              Status = EFI_UNSUPPORTED;
+            }
+          }
+        }
       }
     }
 
diff --git a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.dsc b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.dsc
index 0298e4b12d..b85991b772 100644
--- a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.dsc
+++ b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.dsc
@@ -196,6 +196,12 @@
   gMinPlatformPkgTokenSpaceGuid.PcdMaxCpuThreadCount|4
   gMinPlatformPkgTokenSpaceGuid.PcdPcIoApicAddressBase|0xFEC01000
 
+  ######################################
+  # Board Configuration
+  ######################################
+  gBoardModulePkgTokenSpaceGuid.PcdPs2KbMsEnable|1
+  gBoardModulePkgTokenSpaceGuid.PcdSuperIoPciIsaBridgeDevice|{0x00,0x00,0x1F,0x00}
+
 [PcdsFixedAtBuild.X64]
   ######################################
   # Edk2 Configuration
-- 
2.19.1.windows.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [edk2-platforms] [PATCH 4/5] KabylakeOpenBoardPkg: Add Ps2 keyboard Null Library
  2019-11-01 19:51 [edk2-platforms] [PATCH 0/5] Enable Ps2 keyboard Agyeman, Prince
                   ` (2 preceding siblings ...)
  2019-11-01 19:51 ` [edk2-platforms] [PATCH 3/5] BoardModulePkg: Added Pcds Sio Driver Agyeman, Prince
@ 2019-11-01 19:51 ` Agyeman, Prince
  2019-11-01 21:55   ` Nate DeSimone
  2019-11-04  9:03   ` Chiu, Chasel
  2019-11-01 19:51 ` [edk2-platforms] [PATCH 5/5] KabylakeOpenBoardPkg: Add Ps2 Keyboard Support Agyeman, Prince
  2019-11-04 18:18 ` [edk2-devel] [edk2-platforms] [PATCH 0/5] Enable Ps2 keyboard Kubacki, Michael A
  5 siblings, 2 replies; 16+ messages in thread
From: Agyeman, Prince @ 2019-11-01 19:51 UTC (permalink / raw)
  To: devel; +Cc: Michael Kubacki, Chasel Chiu, Nate DeSimone

Added GalagoPro3 board ps2 keyboard library
that adds ps2 device path to ConIn and ConInDev
Uefi variables

Cc: Michael Kubacki <michael.a.kubacki@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>

Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
---
 .../GalagoPro3/Library/Ps2KbcLib/Ps2KbcLib.c  | 202 ++++++++++++++++++
 .../GalagoPro3/Library/Ps2KbcLib/Ps2KbcLib.h  |  65 ++++++
 .../Library/Ps2KbcLib/Ps2KbcLib.inf           |  39 ++++
 3 files changed, 306 insertions(+)
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/Ps2KbcLib.c
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/Ps2KbcLib.h
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/Ps2KbcLib.inf

diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/Ps2KbcLib.c b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/Ps2KbcLib.c
new file mode 100644
index 0000000000..ac1563d3cd
--- /dev/null
+++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/Ps2KbcLib.c
@@ -0,0 +1,202 @@
+/** @file
+  Main file for NULL named library for Ps2 keyboard controller librarr.
+
+  Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "Ps2KbcLib.h"
+
+GLOBAL_REMOVE_IF_UNREFERENCED PLATFORM_KEYBOARD_DEVICE_PATH  gKeyboardDevicePath = {
+  gPciRootBridge,
+  {
+    {
+      HARDWARE_DEVICE_PATH,
+      HW_PCI_DP,
+      {
+        (UINT8) (sizeof (PCI_DEVICE_PATH)),
+        (UINT8) ((sizeof (PCI_DEVICE_PATH)) >> 8)
+      }
+    },
+    0, // Function, patched in EnumPs2Keyboard
+    0  // Device, patched in EnumPs2Keyboard
+  },
+  {
+    {
+      ACPI_DEVICE_PATH,
+      ACPI_DP,
+      {
+        (UINT8) (sizeof (ACPI_HID_DEVICE_PATH)),
+        (UINT8) ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8)
+      }
+    },
+    EISA_PNP_ID(0x0303),
+    0
+  },
+  gEndEntire
+};
+
+/**
+  Check if PS2 keyboard is conntected, by sending ECHO command.
+  @retval                       TRUE if connected FALSE otherwise
+**/
+BOOLEAN
+DetectPs2Keyboard (
+  VOID
+  )
+{
+  UINT32                TimeOut;
+  UINT32                RegEmptied;
+  UINT8                 Data;
+  UINT32                SumTimeOut;
+  BOOLEAN               FoundPs2Kbc;
+
+  TimeOut     = 0;
+  RegEmptied  = 0;
+  FoundPs2Kbc       = FALSE;
+
+  //
+  // Wait for input buffer empty
+  //
+  for (TimeOut = 0; TimeOut < PS2_KEYBOARD_TIMEOUT; TimeOut += 30) {
+    if ((IoRead8 (KEYBOARD_8042_STATUS_REGISTER) & 0x02) == 0) {
+      FoundPs2Kbc = TRUE;
+      break;
+    }
+    MicroSecondDelay (30);
+  }
+
+  if (FoundPs2Kbc == FALSE) {
+    return FALSE;
+  }
+
+  //
+  // Send echo command
+  //
+  IoWrite8 (KEYBOARD_8042_DATA_REGISTER, KBC_INPBUF_VIA60_KBECHO);
+
+  //
+  // Init variables
+  //
+  FoundPs2Kbc       = FALSE;
+  TimeOut     = 0;
+  SumTimeOut  = 0;
+  Data = 0;
+
+  //
+  // Read from 8042 (multiple times if needed)
+  // until the expected value appears
+  // use SumTimeOut to control the iteration
+  //
+  while (1) {
+    //
+    // Perform a read
+    //
+    for (TimeOut = 0; TimeOut < PS2_KEYBOARD_TIMEOUT; TimeOut += 30) {
+      if (IoRead8 (KEYBOARD_8042_STATUS_REGISTER) & 0x01) {
+        Data = IoRead8 (KEYBOARD_8042_DATA_REGISTER);
+        break;
+      }
+      MicroSecondDelay (30);
+    }
+
+    SumTimeOut += TimeOut;
+
+    if (Data == KBC_INPBUF_VIA60_KBECHO) {
+      FoundPs2Kbc = TRUE;
+      break;
+    }
+
+    if (SumTimeOut >= PS2_KEYBOARD_WAITFORVALUE_TIMEOUT) {
+      break;
+    }
+  }
+  return FoundPs2Kbc;
+}
+
+/**
+  Check if PS2 keyboard is conntected. If the result of first time is
+  error, it will retry again.
+  @retval                       TRUE if connected FALSE otherwise
+**/
+BOOLEAN
+IsPs2KeyboardConnected (
+  VOID
+  )
+{
+  BOOLEAN Result;
+  Result = DetectPs2Keyboard ();
+
+  if (Result == FALSE) {
+    //
+    // If there is no ps2 keyboard detected for the 1st time, retry again.
+    //
+    Result = DetectPs2Keyboard ();
+  }
+  return Result;
+}
+
+
+/**
+  Updates the ConIn variable with Ps2 Keyboard device path,
+  if it doesn't already exists in ConIn and ConInDev
+**/
+VOID
+AddPs2Keyboard (
+  VOID
+  )
+{
+  SIO_PCI_ISA_BRIDGE_DEVICE_INFO *SioIsaInfo;
+
+  DEBUG ((DEBUG_INFO, "[AddPs2Keyboard]\n"));
+
+  SioIsaInfo = (SIO_PCI_ISA_BRIDGE_DEVICE_INFO*) FixedPcdGetPtr (PcdSuperIoPciIsaBridgeDevice);
+
+  //
+  // patch IsaBridge device and and function
+  //
+  gKeyboardDevicePath.IsaBridge.Device = SioIsaInfo->Device;
+  gKeyboardDevicePath.IsaBridge.Function = SioIsaInfo->Funtion;
+
+  //
+  // Append Ps2 Keyboard into "ConIn"
+  //
+  EfiBootManagerUpdateConsoleVariable (ConIn, (EFI_DEVICE_PATH_PROTOCOL *) &gKeyboardDevicePath, NULL);
+
+  //
+  // Append Ps2 Keyboard into "ConInDev"
+  //
+  EfiBootManagerUpdateConsoleVariable (ConInDev, (EFI_DEVICE_PATH_PROTOCOL *) &gKeyboardDevicePath, NULL);
+}
+
+
+/**
+  Constructor for the Ps2 keyboard controller library.
+
+  @param ImageHandle    the image handle of the process
+  @param SystemTable    the EFI System Table pointer
+
+  @retval EFI_SUCCESS        the shell command handlers were installed sucessfully
+  @retval EFI_UNSUPPORTED    the shell level required was not found.
+**/
+EFI_STATUS
+EFIAPI
+Ps2KbcLibConstructor (
+  IN EFI_HANDLE        ImageHandle,
+  IN EFI_SYSTEM_TABLE  *SystemTable
+  )
+{
+  UINT8                               Ps2KbMsEnable;
+
+  Ps2KbMsEnable = PcdGet8 (PcdPs2KbMsEnable);
+
+  if (Ps2KbMsEnable == 0x1
+    && IsPs2KeyboardConnected())
+  {
+      // add ps2 device path to ConIn and ConInDev
+      AddPs2Keyboard ();
+  }
+
+  return EFI_SUCCESS;
+}
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/Ps2KbcLib.h b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/Ps2KbcLib.h
new file mode 100644
index 0000000000..60bba122d6
--- /dev/null
+++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/Ps2KbcLib.h
@@ -0,0 +1,65 @@
+/** @file
+  Header file for NULL named library for Ps2 keyboard controller library.
+
+  Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _PS2_KBC_LIB_H
+#define _PS2_KBC_LIB_H
+
+#include <Uefi.h>
+#include <Library/UefiLib.h>
+#include <Library/DevicePathLib.h>
+#include <Library/DebugLib.h>
+#include <Library/IoLib.h>
+#include <Library/TimerLib.h>
+#include <Library/UefiBootManagerLib.h>
+
+//
+// Below is the platform console device path
+//
+typedef struct {
+  ACPI_HID_DEVICE_PATH      PciRootBridge;
+  PCI_DEVICE_PATH           IsaBridge;
+  ACPI_HID_DEVICE_PATH      Keyboard;
+  EFI_DEVICE_PATH_PROTOCOL  End;
+} PLATFORM_KEYBOARD_DEVICE_PATH;
+
+typedef struct {
+  UINT8 Segment;
+  UINT8 Bus;
+  UINT8 Device;
+  UINT8 Funtion;
+} SIO_PCI_ISA_BRIDGE_DEVICE_INFO;
+
+#define gPciRootBridge \
+  { \
+    { \
+      ACPI_DEVICE_PATH, \
+      ACPI_DP, \
+      { \
+        (UINT8) (sizeof (ACPI_HID_DEVICE_PATH)), \
+        (UINT8) ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) \
+      }, \
+    }, \
+    EISA_PNP_ID (0x0A03), \
+    0 \
+  }
+
+#define gEndEntire \
+  { \
+    END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, { END_DEVICE_PATH_LENGTH, 0 } \
+  }
+
+#define KBC_INPBUF_VIA60_KBECHO             0xEE
+#define KEYBOARD_8042_DATA_REGISTER         0x60
+#define KEYBOARD_8042_STATUS_REGISTER       0x64
+
+#define PS2_KEYBOARD_TIMEOUT                65536   // 0.07s
+#define PS2_KEYBOARD_WAITFORVALUE_TIMEOUT   1000000 // 1s
+#define PS2_KEYBOARD_KBEN                   0xF4
+#define PS2_KEYBOARD_CMDECHO_ACK            0xFA
+
+#endif
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/Ps2KbcLib.inf b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/Ps2KbcLib.inf
new file mode 100644
index 0000000000..7ab1b628e3
--- /dev/null
+++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/Ps2KbcLib.inf
@@ -0,0 +1,39 @@
+## @file
+# Component information file for PEI GalagoPro3 Board Init Pre-Mem Library
+#
+# Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+[Defines]
+  INF_VERSION                    = 0x00010006
+  BASE_NAME                      = Ps2KbcLib
+  FILE_GUID                      = E94EA52E-E84C-42E7-B863-EA1327EFA265
+  MODULE_TYPE                    = UEFI_DRIVER
+  VERSION_STRING                 = 1.2
+  LIBRARY_CLASS                  = NULL|UEFI_DRIVER
+  CONSTRUCTOR                    = Ps2KbcLibConstructor
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  KabylakeOpenBoardPkg/OpenBoardPkg.dec
+  BoardModulePkg/BoardModulePkg.dec
+
+[Sources]
+  Ps2KbcLib.c
+  Ps2KbcLib.h
+
+[LibraryClasses]
+  DevicePathLib
+  DebugLib
+  IoLib
+  UefiDriverEntryPoint
+  UefiBootManagerLib
+  UefiLib
+  TimerLib
+
+[Pcd]
+  gBoardModulePkgTokenSpaceGuid.PcdPs2KbMsEnable
+  gBoardModulePkgTokenSpaceGuid.PcdSuperIoPciIsaBridgeDevice
-- 
2.19.1.windows.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [edk2-platforms] [PATCH 5/5] KabylakeOpenBoardPkg: Add Ps2 Keyboard Support
  2019-11-01 19:51 [edk2-platforms] [PATCH 0/5] Enable Ps2 keyboard Agyeman, Prince
                   ` (3 preceding siblings ...)
  2019-11-01 19:51 ` [edk2-platforms] [PATCH 4/5] KabylakeOpenBoardPkg: Add Ps2 keyboard Null Library Agyeman, Prince
@ 2019-11-01 19:51 ` Agyeman, Prince
  2019-11-01 21:54   ` [edk2-devel] " Nate DeSimone
  2019-11-04 18:18 ` [edk2-devel] [edk2-platforms] [PATCH 0/5] Enable Ps2 keyboard Kubacki, Michael A
  5 siblings, 1 reply; 16+ messages in thread
From: Agyeman, Prince @ 2019-11-01 19:51 UTC (permalink / raw)
  To: devel

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2228

Added Ps2Keyboard DXE driver.

Added Sio dxe driver to publish the SIO protocol
needed by the Ps2Keyboard DXE driver.

Included a Ps2 null Library to BdsDxe driver
to add the Ps2 device path to ConIn and ConInDev
variables

Configured the Super I/O Pci to Isa bridge bus,
device, function device info PCD. This will help the Super I/O
driver identify which bridge the Super I/O is connected to.

Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
---
 .../Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc | 7 +++++++
 .../Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.fdf | 2 ++
 .../KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd.dsc    | 1 +
 3 files changed, 10 insertions(+)

diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc
index f59248bba4..c6a0749458 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc
+++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc
@@ -311,6 +311,11 @@
   MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf
   MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf
   MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutputDxe.inf
+  MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KeyboardDxe.inf
+  MdeModulePkg/Universal/BdsDxe/BdsDxe.inf{
+    <LibraryClasses>
+      NULL|$(PROJECT)/Library/Ps2KbcLib/Ps2KbcLib.inf
+  }
   UefiCpuPkg/CpuDxe/CpuDxe.inf
 
   ShellPkg/Application/Shell/Shell.inf {
@@ -408,3 +413,5 @@
       !endif
   }
 !endif
+
+  BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.fdf b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.fdf
index 80efab1aad..d58466d390 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.fdf
+++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.fdf
@@ -335,6 +335,8 @@ INF  MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
 INF  MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
 INF  MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutputDxe.inf
 INF  MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf
+INF  BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
+INF  MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KeyboardDxe.inf
 
 INF  ShellPkg/Application/Shell/Shell.inf
 
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd.dsc b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd.dsc
index 4550a4e0b5..c6f5ae7534 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd.dsc
+++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd.dsc
@@ -312,6 +312,7 @@
   # Board Configuration
   ######################################
   gBoardModulePkgTokenSpaceGuid.PcdPs2KbMsEnable|1
+  gBoardModulePkgTokenSpaceGuid.PcdSuperIoPciIsaBridgeDevice|{0x00, 0x00, 0x1F, 0x00}
 
 [PcdsFixedAtBuild.IA32]
   ######################################
-- 
2.19.1.windows.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [edk2-devel] [edk2-platforms] [PATCH 5/5] KabylakeOpenBoardPkg: Add Ps2 Keyboard Support
  2019-11-01 19:51 ` [edk2-platforms] [PATCH 5/5] KabylakeOpenBoardPkg: Add Ps2 Keyboard Support Agyeman, Prince
@ 2019-11-01 21:54   ` Nate DeSimone
  0 siblings, 0 replies; 16+ messages in thread
From: Nate DeSimone @ 2019-11-01 21:54 UTC (permalink / raw)
  To: devel@edk2.groups.io, Agyeman, Prince

Please implement a patch 6 and 7 adding the same changes you made here for GalagoPro3 to KabylakeRvp3 and WhiskeyLakeURvp. Both of those boards have PS/2 keyboard connectors and your change is valuable there too.

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Agyeman, Prince
Sent: Friday, November 1, 2019 12:51 PM
To: devel@edk2.groups.io
Subject: [edk2-devel] [edk2-platforms] [PATCH 5/5] KabylakeOpenBoardPkg: Add Ps2 Keyboard Support

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2228

Added Ps2Keyboard DXE driver.

Added Sio dxe driver to publish the SIO protocol needed by the Ps2Keyboard DXE driver.

Included a Ps2 null Library to BdsDxe driver to add the Ps2 device path to ConIn and ConInDev variables

Configured the Super I/O Pci to Isa bridge bus, device, function device info PCD. This will help the Super I/O driver identify which bridge the Super I/O is connected to.

Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
---
 .../Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc | 7 +++++++  .../Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.fdf | 2 ++
 .../KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd.dsc    | 1 +
 3 files changed, 10 insertions(+)

diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc
index f59248bba4..c6a0749458 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc
+++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc
@@ -311,6 +311,11 @@
   MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf
   MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf
   MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutputDxe.inf
+  MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KeyboardDxe.inf
+  MdeModulePkg/Universal/BdsDxe/BdsDxe.inf{
+    <LibraryClasses>
+      NULL|$(PROJECT)/Library/Ps2KbcLib/Ps2KbcLib.inf
+  }
   UefiCpuPkg/CpuDxe/CpuDxe.inf
 
   ShellPkg/Application/Shell/Shell.inf { @@ -408,3 +413,5 @@
       !endif
   }
 !endif
+
+  BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.fdf b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.fdf
index 80efab1aad..d58466d390 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.fdf
+++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.fdf
@@ -335,6 +335,8 @@ INF  MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
 INF  MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
 INF  MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutputDxe.inf
 INF  MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf
+INF  BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
+INF  MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KeyboardDxe.inf
 
 INF  ShellPkg/Application/Shell/Shell.inf
 
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd.dsc b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd.dsc
index 4550a4e0b5..c6f5ae7534 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd.dsc
+++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd.dsc
@@ -312,6 +312,7 @@
   # Board Configuration
   ######################################
   gBoardModulePkgTokenSpaceGuid.PcdPs2KbMsEnable|1
+  gBoardModulePkgTokenSpaceGuid.PcdSuperIoPciIsaBridgeDevice|{0x00, 
+ 0x00, 0x1F, 0x00}
 
 [PcdsFixedAtBuild.IA32]
   ######################################
--
2.19.1.windows.1





^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [edk2-platforms] [PATCH 4/5] KabylakeOpenBoardPkg: Add Ps2 keyboard Null Library
  2019-11-01 19:51 ` [edk2-platforms] [PATCH 4/5] KabylakeOpenBoardPkg: Add Ps2 keyboard Null Library Agyeman, Prince
@ 2019-11-01 21:55   ` Nate DeSimone
  2019-11-04  9:03   ` Chiu, Chasel
  1 sibling, 0 replies; 16+ messages in thread
From: Nate DeSimone @ 2019-11-01 21:55 UTC (permalink / raw)
  To: Agyeman, Prince, devel@edk2.groups.io; +Cc: Kubacki, Michael A, Chiu, Chasel

This is actually a really generic library. Please move it to BoardModulePkg and rename it to BdsPs2KeyboardLib.

This isn't really a "null library" please update your commit message. I'd recommend "Add BdsPs2KeyboardLib".

-----Original Message-----
From: Agyeman, Prince <prince.agyeman@intel.com> 
Sent: Friday, November 1, 2019 12:51 PM
To: devel@edk2.groups.io
Cc: Kubacki, Michael A <michael.a.kubacki@intel.com>; Chiu, Chasel <chasel.chiu@intel.com>; Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>
Subject: [edk2-platforms] [PATCH 4/5] KabylakeOpenBoardPkg: Add Ps2 keyboard Null Library

Added GalagoPro3 board ps2 keyboard library that adds ps2 device path to ConIn and ConInDev Uefi variables

Cc: Michael Kubacki <michael.a.kubacki@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>

Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
---
 .../GalagoPro3/Library/Ps2KbcLib/Ps2KbcLib.c  | 202 ++++++++++++++++++  .../GalagoPro3/Library/Ps2KbcLib/Ps2KbcLib.h  |  65 ++++++
 .../Library/Ps2KbcLib/Ps2KbcLib.inf           |  39 ++++
 3 files changed, 306 insertions(+)
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/Ps2KbcLib.c
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/Ps2KbcLib.h
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/Ps2KbcLib.inf

diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/Ps2KbcLib.c b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/Ps2KbcLib.c
new file mode 100644
index 0000000000..ac1563d3cd
--- /dev/null
+++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/P
+++ s2KbcLib.c
@@ -0,0 +1,202 @@
+/** @file
+  Main file for NULL named library for Ps2 keyboard controller librarr.
+
+  Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "Ps2KbcLib.h"
+
+GLOBAL_REMOVE_IF_UNREFERENCED PLATFORM_KEYBOARD_DEVICE_PATH  
+gKeyboardDevicePath = {
+  gPciRootBridge,
+  {
+    {
+      HARDWARE_DEVICE_PATH,
+      HW_PCI_DP,
+      {
+        (UINT8) (sizeof (PCI_DEVICE_PATH)),
+        (UINT8) ((sizeof (PCI_DEVICE_PATH)) >> 8)
+      }
+    },
+    0, // Function, patched in EnumPs2Keyboard
+    0  // Device, patched in EnumPs2Keyboard
+  },
+  {
+    {
+      ACPI_DEVICE_PATH,
+      ACPI_DP,
+      {
+        (UINT8) (sizeof (ACPI_HID_DEVICE_PATH)),
+        (UINT8) ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8)
+      }
+    },
+    EISA_PNP_ID(0x0303),
+    0
+  },
+  gEndEntire
+};
+
+/**
+  Check if PS2 keyboard is conntected, by sending ECHO command.
+  @retval                       TRUE if connected FALSE otherwise
+**/
+BOOLEAN
+DetectPs2Keyboard (
+  VOID
+  )
+{
+  UINT32                TimeOut;
+  UINT32                RegEmptied;
+  UINT8                 Data;
+  UINT32                SumTimeOut;
+  BOOLEAN               FoundPs2Kbc;
+
+  TimeOut     = 0;
+  RegEmptied  = 0;
+  FoundPs2Kbc       = FALSE;
+
+  //
+  // Wait for input buffer empty
+  //
+  for (TimeOut = 0; TimeOut < PS2_KEYBOARD_TIMEOUT; TimeOut += 30) {
+    if ((IoRead8 (KEYBOARD_8042_STATUS_REGISTER) & 0x02) == 0) {
+      FoundPs2Kbc = TRUE;
+      break;
+    }
+    MicroSecondDelay (30);
+  }
+
+  if (FoundPs2Kbc == FALSE) {
+    return FALSE;
+  }
+
+  //
+  // Send echo command
+  //
+  IoWrite8 (KEYBOARD_8042_DATA_REGISTER, KBC_INPBUF_VIA60_KBECHO);
+
+  //
+  // Init variables
+  //
+  FoundPs2Kbc       = FALSE;
+  TimeOut     = 0;
+  SumTimeOut  = 0;
+  Data = 0;
+
+  //
+  // Read from 8042 (multiple times if needed)  // until the expected 
+ value appears  // use SumTimeOut to control the iteration  //  while 
+ (1) {
+    //
+    // Perform a read
+    //
+    for (TimeOut = 0; TimeOut < PS2_KEYBOARD_TIMEOUT; TimeOut += 30) {
+      if (IoRead8 (KEYBOARD_8042_STATUS_REGISTER) & 0x01) {
+        Data = IoRead8 (KEYBOARD_8042_DATA_REGISTER);
+        break;
+      }
+      MicroSecondDelay (30);
+    }
+
+    SumTimeOut += TimeOut;
+
+    if (Data == KBC_INPBUF_VIA60_KBECHO) {
+      FoundPs2Kbc = TRUE;
+      break;
+    }
+
+    if (SumTimeOut >= PS2_KEYBOARD_WAITFORVALUE_TIMEOUT) {
+      break;
+    }
+  }
+  return FoundPs2Kbc;
+}
+
+/**
+  Check if PS2 keyboard is conntected. If the result of first time is
+  error, it will retry again.
+  @retval                       TRUE if connected FALSE otherwise
+**/
+BOOLEAN
+IsPs2KeyboardConnected (
+  VOID
+  )
+{
+  BOOLEAN Result;
+  Result = DetectPs2Keyboard ();
+
+  if (Result == FALSE) {
+    //
+    // If there is no ps2 keyboard detected for the 1st time, retry again.
+    //
+    Result = DetectPs2Keyboard ();
+  }
+  return Result;
+}
+
+
+/**
+  Updates the ConIn variable with Ps2 Keyboard device path,
+  if it doesn't already exists in ConIn and ConInDev **/ VOID 
+AddPs2Keyboard (
+  VOID
+  )
+{
+  SIO_PCI_ISA_BRIDGE_DEVICE_INFO *SioIsaInfo;
+
+  DEBUG ((DEBUG_INFO, "[AddPs2Keyboard]\n"));
+
+  SioIsaInfo = (SIO_PCI_ISA_BRIDGE_DEVICE_INFO*) FixedPcdGetPtr 
+ (PcdSuperIoPciIsaBridgeDevice);
+
+  //
+  // patch IsaBridge device and and function  //  
+ gKeyboardDevicePath.IsaBridge.Device = SioIsaInfo->Device;  
+ gKeyboardDevicePath.IsaBridge.Function = SioIsaInfo->Funtion;
+
+  //
+  // Append Ps2 Keyboard into "ConIn"
+  //
+  EfiBootManagerUpdateConsoleVariable (ConIn, (EFI_DEVICE_PATH_PROTOCOL 
+ *) &gKeyboardDevicePath, NULL);
+
+  //
+  // Append Ps2 Keyboard into "ConInDev"
+  //
+  EfiBootManagerUpdateConsoleVariable (ConInDev, 
+(EFI_DEVICE_PATH_PROTOCOL *) &gKeyboardDevicePath, NULL); }
+
+
+/**
+  Constructor for the Ps2 keyboard controller library.
+
+  @param ImageHandle    the image handle of the process
+  @param SystemTable    the EFI System Table pointer
+
+  @retval EFI_SUCCESS        the shell command handlers were installed sucessfully
+  @retval EFI_UNSUPPORTED    the shell level required was not found.
+**/
+EFI_STATUS
+EFIAPI
+Ps2KbcLibConstructor (
+  IN EFI_HANDLE        ImageHandle,
+  IN EFI_SYSTEM_TABLE  *SystemTable
+  )
+{
+  UINT8                               Ps2KbMsEnable;
+
+  Ps2KbMsEnable = PcdGet8 (PcdPs2KbMsEnable);
+
+  if (Ps2KbMsEnable == 0x1
+    && IsPs2KeyboardConnected())
+  {
+      // add ps2 device path to ConIn and ConInDev
+      AddPs2Keyboard ();
+  }
+
+  return EFI_SUCCESS;
+}
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/Ps2KbcLib.h b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/Ps2KbcLib.h
new file mode 100644
index 0000000000..60bba122d6
--- /dev/null
+++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/P
+++ s2KbcLib.h
@@ -0,0 +1,65 @@
+/** @file
+  Header file for NULL named library for Ps2 keyboard controller library.
+
+  Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _PS2_KBC_LIB_H
+#define _PS2_KBC_LIB_H
+
+#include <Uefi.h>
+#include <Library/UefiLib.h>
+#include <Library/DevicePathLib.h>
+#include <Library/DebugLib.h>
+#include <Library/IoLib.h>
+#include <Library/TimerLib.h>
+#include <Library/UefiBootManagerLib.h>
+
+//
+// Below is the platform console device path // typedef struct {
+  ACPI_HID_DEVICE_PATH      PciRootBridge;
+  PCI_DEVICE_PATH           IsaBridge;
+  ACPI_HID_DEVICE_PATH      Keyboard;
+  EFI_DEVICE_PATH_PROTOCOL  End;
+} PLATFORM_KEYBOARD_DEVICE_PATH;
+
+typedef struct {
+  UINT8 Segment;
+  UINT8 Bus;
+  UINT8 Device;
+  UINT8 Funtion;
+} SIO_PCI_ISA_BRIDGE_DEVICE_INFO;
+
+#define gPciRootBridge \
+  { \
+    { \
+      ACPI_DEVICE_PATH, \
+      ACPI_DP, \
+      { \
+        (UINT8) (sizeof (ACPI_HID_DEVICE_PATH)), \
+        (UINT8) ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) \
+      }, \
+    }, \
+    EISA_PNP_ID (0x0A03), \
+    0 \
+  }
+
+#define gEndEntire \
+  { \
+    END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, { 
+END_DEVICE_PATH_LENGTH, 0 } \
+  }
+
+#define KBC_INPBUF_VIA60_KBECHO             0xEE
+#define KEYBOARD_8042_DATA_REGISTER         0x60
+#define KEYBOARD_8042_STATUS_REGISTER       0x64
+
+#define PS2_KEYBOARD_TIMEOUT                65536   // 0.07s
+#define PS2_KEYBOARD_WAITFORVALUE_TIMEOUT   1000000 // 1s
+#define PS2_KEYBOARD_KBEN                   0xF4
+#define PS2_KEYBOARD_CMDECHO_ACK            0xFA
+
+#endif
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/Ps2KbcLib.inf b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/Ps2KbcLib.inf
new file mode 100644
index 0000000000..7ab1b628e3
--- /dev/null
+++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/P
+++ s2KbcLib.inf
@@ -0,0 +1,39 @@
+## @file
+# Component information file for PEI GalagoPro3 Board Init Pre-Mem 
+Library # # Copyright (c) 2019, Intel Corporation. All rights 
+reserved.<BR> # # SPDX-License-Identifier: BSD-2-Clause-Patent # ## 
+[Defines]
+  INF_VERSION                    = 0x00010006
+  BASE_NAME                      = Ps2KbcLib
+  FILE_GUID                      = E94EA52E-E84C-42E7-B863-EA1327EFA265
+  MODULE_TYPE                    = UEFI_DRIVER
+  VERSION_STRING                 = 1.2
+  LIBRARY_CLASS                  = NULL|UEFI_DRIVER
+  CONSTRUCTOR                    = Ps2KbcLibConstructor
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  KabylakeOpenBoardPkg/OpenBoardPkg.dec
+  BoardModulePkg/BoardModulePkg.dec
+
+[Sources]
+  Ps2KbcLib.c
+  Ps2KbcLib.h
+
+[LibraryClasses]
+  DevicePathLib
+  DebugLib
+  IoLib
+  UefiDriverEntryPoint
+  UefiBootManagerLib
+  UefiLib
+  TimerLib
+
+[Pcd]
+  gBoardModulePkgTokenSpaceGuid.PcdPs2KbMsEnable
+  gBoardModulePkgTokenSpaceGuid.PcdSuperIoPciIsaBridgeDevice
--
2.19.1.windows.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [edk2-platforms] [PATCH 1/5] Platform/Intel: Add gBoardModulePkgTokenSpaceGuid
  2019-11-01 19:51 ` [edk2-platforms] [PATCH 1/5] Platform/Intel: Add gBoardModulePkgTokenSpaceGuid Agyeman, Prince
@ 2019-11-01 21:55   ` Nate DeSimone
  0 siblings, 0 replies; 16+ messages in thread
From: Nate DeSimone @ 2019-11-01 21:55 UTC (permalink / raw)
  To: Agyeman, Prince, devel@edk2.groups.io; +Cc: Kubacki, Michael A, Chiu, Chasel

Reviewed-by: Nate DeSimone <nathaniel.l.desimone@intel.com>

-----Original Message-----
From: Agyeman, Prince <prince.agyeman@intel.com> 
Sent: Friday, November 1, 2019 12:51 PM
To: devel@edk2.groups.io
Cc: Kubacki, Michael A <michael.a.kubacki@intel.com>; Chiu, Chasel <chasel.chiu@intel.com>; Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>
Subject: [edk2-platforms] [PATCH 1/5] Platform/Intel: Add gBoardModulePkgTokenSpaceGuid

Added gBoardModulePkgTokenSpaceGuid to BoardModulePkg

Added ps2 keyboard and Uart enable PCDs.

Added PCDs to define IO ports for Uart1 and Uart2

Enabled KabylakeOpenBoardPkg and WhiskeylakeOpenBoardPkg boards to use the ps2 keyboard enable PCD.

Cc: Michael Kubacki <michael.a.kubacki@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>

Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
---
 .../Intel/BoardModulePkg/BoardModulePkg.dec   | 25 +++++++++++++++++++
 .../BoardAcpiLib/DxeBoardAcpiTableLib.inf     |  3 ++-
 .../DxeMultiBoardAcpiSupportLib.inf           |  3 ++-
 .../GalagoPro3/OpenBoardPkgPcd.dsc            |  5 ++++
 .../BoardAcpiLib/DxeBoardAcpiTableLib.inf     |  3 ++-
 .../DxeMultiBoardAcpiSupportLib.inf           |  3 ++-
 .../KabylakeRvp3/OpenBoardPkgPcd.dsc          |  5 ++++
 .../KabylakeOpenBoardPkg/OpenBoardPkg.dec     |  2 --
 .../WhiskeylakeOpenBoardPkg/OpenBoardPkg.dec  |  1 -
 .../WhiskeylakeURvp/OpenBoardPkgPcd.dsc       |  5 ++++
 10 files changed, 48 insertions(+), 7 deletions(-)

diff --git a/Platform/Intel/BoardModulePkg/BoardModulePkg.dec b/Platform/Intel/BoardModulePkg/BoardModulePkg.dec
index f461cc7cab..26e662f711 100644
--- a/Platform/Intel/BoardModulePkg/BoardModulePkg.dec
+++ b/Platform/Intel/BoardModulePkg/BoardModulePkg.dec
@@ -42,3 +42,28 @@
 
   ## GUID to publish BIOS information HOB
   gBiosInfoGuid = { 0x09d0d15c, 0xe9f0, 0x4dfc, {0x9e, 0x0b, 0x39, 0x33, 0x1f, 0xca, 0x66, 0x85} }
+
+  ## {7F4EE1A3-C1F3-43E4-BA1A-39DCDE46C343}
+  gBoardModulePkgTokenSpaceGuid = { 0x7f4ee1a3, 0xc1f3, 0x43e4, { 0xba, 
+ 0x1a, 0x39, 0xdc, 0xde, 0x46, 0xc3, 0x43 } }
+
+[PcdsFixedAtBuild]
+  ## PcdPs2KbMsEnable 0x0:Disable, 0x1:Enable
+  gBoardModulePkgTokenSpaceGuid.PcdPs2KbMsEnable|0x00|UINT8|0x00000001
+
+  ## SuperIo Pci ISA Bridge info. It is an array that contains the 
+ Segment, Bus, Device and Function  #  information describing the PCI 
+ Device Info. The first byte is the segment number,  #  the second is 
+ the bus number, third byte is the device number, the fourth byte  #  is the Function.
+  gBoardModulePkgTokenSpaceGuid.PcdSuperIoPciIsaBridgeDevice|{0xFF, 
+ 0xFF, 0xFF, 0xFF}|VOID*|0x00000002
+
+  ## PcdUart1Enable 0x0:Disable, 0x1:Enable
+  gBoardModulePkgTokenSpaceGuid.PcdUart1Enable|0x00|UINT8|0x00000003
+  
+ gBoardModulePkgTokenSpaceGuid.PcdUart1IrqMask|0x0010|UINT16|0x00000004
+  gBoardModulePkgTokenSpaceGuid.PcdUart1IoPort|0x03F8|UINT16|0x00000005
+  gBoardModulePkgTokenSpaceGuid.PcdUart1Length|0x08|UINT8|0x00000006
+
+  ## PcdUart2Enable 0x0:Disable, 0x1:Enable
+  gBoardModulePkgTokenSpaceGuid.PcdUart2Enable|0x00|UINT8|0x00000007
+  
+ gBoardModulePkgTokenSpaceGuid.PcdUart2IrqMask|0x0008|UINT16|0x00000008
+  gBoardModulePkgTokenSpaceGuid.PcdUart2IoPort|0x02F8|UINT16|0x00000009
+  gBoardModulePkgTokenSpaceGuid.PcdUart2Length|0x08|UINT8|0x0000000A
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/BoardAcpiLib/DxeBoardAcpiTableLib.inf b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/BoardAcpiLib/DxeBoardAcpiTableLib.inf
index a79bdcdbc6..35cd5c8fdb 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/BoardAcpiLib/DxeBoardAcpiTableLib.inf
+++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/BoardAcpiLi
+++ b/DxeBoardAcpiTableLib.inf
@@ -33,9 +33,10 @@
   MinPlatformPkg/MinPlatformPkg.dec
   KabylakeOpenBoardPkg/OpenBoardPkg.dec
   KabylakeSiliconPkg/SiPkg.dec
+  BoardModulePkg/BoardModulePkg.dec
 
 [Pcd]
-  gKabylakeOpenBoardPkgTokenSpaceGuid.PcdPs2KbMsEnable
+  gBoardModulePkgTokenSpaceGuid.PcdPs2KbMsEnable
   gMinPlatformPkgTokenSpaceGuid.PcdPciExpNative
   gMinPlatformPkgTokenSpaceGuid.PcdNativeAspmEnable
   gMinPlatformPkgTokenSpaceGuid.PcdLowPowerS0Idle
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/BoardAcpiLib/DxeMultiBoardAcpiSupportLib.inf b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/BoardAcpiLib/DxeMultiBoardAcpiSupportLib.inf
index db8ba7a822..9fe27f9fda 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/BoardAcpiLib/DxeMultiBoardAcpiSupportLib.inf
+++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/BoardAcpiLi
+++ b/DxeMultiBoardAcpiSupportLib.inf
@@ -34,9 +34,10 @@
   MinPlatformPkg/MinPlatformPkg.dec
   KabylakeOpenBoardPkg/OpenBoardPkg.dec
   KabylakeSiliconPkg/SiPkg.dec
+  BoardModulePkg/BoardModulePkg.dec
 
 [Pcd]
-  gKabylakeOpenBoardPkgTokenSpaceGuid.PcdPs2KbMsEnable
+  gBoardModulePkgTokenSpaceGuid.PcdPs2KbMsEnable
   gKabylakeOpenBoardPkgTokenSpaceGuid.PcdPciExpNative
   gKabylakeOpenBoardPkgTokenSpaceGuid.PcdNativeAspmEnable
   gKabylakeOpenBoardPkgTokenSpaceGuid.PcdLowPowerS0Idle
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd.dsc b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd.dsc
index c68b8a49cf..4550a4e0b5 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd.dsc
+++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd.dsc
@@ -308,6 +308,11 @@
   gMinPlatformPkgTokenSpaceGuid.PcdTestPointIbvPlatformFeature|{0x03, 0x0F, 0x07, 0x1F, 0x1F, 0x0F, 0x0F, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}  !endif
 
+  ######################################
+  # Board Configuration
+  ######################################
+  gBoardModulePkgTokenSpaceGuid.PcdPs2KbMsEnable|1
+
 [PcdsFixedAtBuild.IA32]
   ######################################
   # Edk2 Configuration
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Library/BoardAcpiLib/DxeBoardAcpiTableLib.inf b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Library/BoardAcpiLib/DxeBoardAcpiTableLib.inf
index bfb58e868f..e0bf5823d8 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Library/BoardAcpiLib/DxeBoardAcpiTableLib.inf
+++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Library/BoardAcpi
+++ Lib/DxeBoardAcpiTableLib.inf
@@ -33,9 +33,10 @@
   MinPlatformPkg/MinPlatformPkg.dec
   KabylakeOpenBoardPkg/OpenBoardPkg.dec
   KabylakeSiliconPkg/SiPkg.dec
+  BoardModulePkg/BoardModulePkg.dec
 
 [Pcd]
-  gKabylakeOpenBoardPkgTokenSpaceGuid.PcdPs2KbMsEnable
+  gBoardModulePkgTokenSpaceGuid.PcdPs2KbMsEnable
   gKabylakeOpenBoardPkgTokenSpaceGuid.PcdPciExpNative
   gKabylakeOpenBoardPkgTokenSpaceGuid.PcdNativeAspmEnable
   gKabylakeOpenBoardPkgTokenSpaceGuid.PcdLowPowerS0Idle
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Library/BoardAcpiLib/DxeMultiBoardAcpiSupportLib.inf b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Library/BoardAcpiLib/DxeMultiBoardAcpiSupportLib.inf
index 00cdbe80ce..e5de9268e7 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Library/BoardAcpiLib/DxeMultiBoardAcpiSupportLib.inf
+++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Library/BoardAcpi
+++ Lib/DxeMultiBoardAcpiSupportLib.inf
@@ -34,9 +34,10 @@
   MinPlatformPkg/MinPlatformPkg.dec
   KabylakeOpenBoardPkg/OpenBoardPkg.dec
   KabylakeSiliconPkg/SiPkg.dec
+  BoardModulePkg/BoardModulePkg.dec
 
 [Pcd]
-  gKabylakeOpenBoardPkgTokenSpaceGuid.PcdPs2KbMsEnable
+  gBoardModulePkgTokenSpaceGuid.PcdPs2KbMsEnable
   gKabylakeOpenBoardPkgTokenSpaceGuid.PcdPciExpNative
   gKabylakeOpenBoardPkgTokenSpaceGuid.PcdNativeAspmEnable
   gKabylakeOpenBoardPkgTokenSpaceGuid.PcdLowPowerS0Idle
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkgPcd.dsc b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkgPcd.dsc
index 34cc731313..8728586bfd 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkgPcd.dsc
+++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkgPcd.d
+++ sc
@@ -324,6 +324,11 @@
   gMinPlatformPkgTokenSpaceGuid.PcdTestPointIbvPlatformFeature|{0x03, 0x0F, 0x07, 0x1F, 0x1F, 0x0F, 0x0F, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}  !endif
 
+  ######################################
+  # Board Configuration
+  ######################################
+  gBoardModulePkgTokenSpaceGuid.PcdPs2KbMsEnable|0
+
 [PcdsFixedAtBuild.IA32]
   ######################################
   # Edk2 Configuration
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/OpenBoardPkg.dec b/Platform/Intel/KabylakeOpenBoardPkg/OpenBoardPkg.dec
index 9680e63bad..01d6116616 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/OpenBoardPkg.dec
+++ b/Platform/Intel/KabylakeOpenBoardPkg/OpenBoardPkg.dec
@@ -288,8 +288,6 @@ gKabylakeOpenBoardPkgTokenSpaceGuid.PcdBoardUcmcGpioTableSize|0|UINT16|0x0000001
 # Misc
 gKabylakeOpenBoardPkgTokenSpaceGuid.PcdIoExpanderPresent|FALSE|BOOLEAN|0x000000EC
 
-  gKabylakeOpenBoardPkgTokenSpaceGuid.PcdPs2KbMsEnable|1|UINT8|0x40000009
-
   gKabylakeOpenBoardPkgTokenSpaceGuid.PcdAcpiSleepState|1|UINT8|0x40000002
   gKabylakeOpenBoardPkgTokenSpaceGuid.PcdAcpiHibernate|1|UINT8|0x40000003
   gKabylakeOpenBoardPkgTokenSpaceGuid.PcdLowPowerS0Idle|0|UINT8|0x40000004
diff --git a/Platform/Intel/WhiskeylakeOpenBoardPkg/OpenBoardPkg.dec b/Platform/Intel/WhiskeylakeOpenBoardPkg/OpenBoardPkg.dec
index 34494d0168..fbb9549e44 100644
--- a/Platform/Intel/WhiskeylakeOpenBoardPkg/OpenBoardPkg.dec
+++ b/Platform/Intel/WhiskeylakeOpenBoardPkg/OpenBoardPkg.dec
@@ -271,7 +271,6 @@ gWhiskeylakeOpenBoardPkgTokenSpaceGuid.PcdAcpiHibernate|1|UINT8|0x40000003
 gWhiskeylakeOpenBoardPkgTokenSpaceGuid.PcdLowPowerS0Idle|0|UINT8|0x40000004
 gWhiskeylakeOpenBoardPkgTokenSpaceGuid.PcdPciExpNative|0|UINT8|0x40000005
 gWhiskeylakeOpenBoardPkgTokenSpaceGuid.PcdNativeAspmEnable|1|UINT8|0x40000006
-gWhiskeylakeOpenBoardPkgTokenSpaceGuid.PcdPs2KbMsEnable|0|UINT8|0x40000009
 gWhiskeylakeOpenBoardPkgTokenSpaceGuid.PcdDisableActiveTripPoints|1|UINT8|0x4000000A
 gWhiskeylakeOpenBoardPkgTokenSpaceGuid.PcdDisablePassiveTripPoints|0|UINT8|0x4000000B
 gWhiskeylakeOpenBoardPkgTokenSpaceGuid.PcdDisableCriticalTripPoints|1|UINT8|0x4000000C
diff --git a/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPkgPcd.dsc b/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPkgPcd.dsc
index adbd48f6d7..805013429e 100644
--- a/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPkgPcd.dsc
+++ b/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPk
+++ gPcd.dsc
@@ -296,6 +296,11 @@
   gMinPlatformPkgTokenSpaceGuid.PcdTestPointIbvPlatformFeature|{0x03, 0x0F, 0x07, 0x1F, 0x1F, 0x0F, 0x0F, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}  !endif
 
+  ######################################
+  # Board Configuration
+  ######################################
+  gBoardModulePkgTokenSpaceGuid.PcdPs2KbMsEnable|0
+
 [PcdsFixedAtBuild.IA32]
   ######################################
   # Edk2 Configuration
--
2.19.1.windows.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [edk2-platforms] [PATCH 2/5] Platform/Intel: Move Sio Dxe Driver
  2019-11-01 19:51 ` [edk2-platforms] [PATCH 2/5] Platform/Intel: Move Sio Dxe Driver Agyeman, Prince
@ 2019-11-01 21:55   ` Nate DeSimone
  2019-11-04  9:15   ` Chiu, Chasel
  1 sibling, 0 replies; 16+ messages in thread
From: Nate DeSimone @ 2019-11-01 21:55 UTC (permalink / raw)
  To: Agyeman, Prince, devel@edk2.groups.io; +Cc: Kubacki, Michael A, Chiu, Chasel

Reviewed-by: Nate DeSimone <nathaniel.l.desimone@intel.com>

-----Original Message-----
From: Agyeman, Prince <prince.agyeman@intel.com> 
Sent: Friday, November 1, 2019 12:51 PM
To: devel@edk2.groups.io
Cc: Kubacki, Michael A <michael.a.kubacki@intel.com>; Chiu, Chasel <chasel.chiu@intel.com>; Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>
Subject: [edk2-platforms] [PATCH 2/5] Platform/Intel: Move Sio Dxe Driver

Moved LegacySioDxe from SimicsOpenBoardPkg to BoardModulePkg as LegacySioDxe is generic and can be shared between open board packages

Removed unused libraries and functions in LegacySioDxe

Pointed BoardX58Ich10 to the current LegacySioDxe location

Cc: Michael Kubacki <michael.a.kubacki@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>

Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
---
 Platform/Intel/BoardModulePkg/BoardModulePkg.dsc       |  1 +
 .../LegacySioDxe/ComponentName.c                       |  0
 .../LegacySioDxe/ComponentName.h                       |  0
 .../LegacySioDxe/LegacySioDxe.inf                      |  3 ---
 .../LegacySioDxe/Register.h                            |  0
 .../LegacySioDxe/SioChip.c                             |  2 --
 .../LegacySioDxe/SioChip.h                             | 10 ----------
 .../LegacySioDxe/SioDriver.c                           |  0
 .../LegacySioDxe/SioDriver.h                           |  1 -
 .../LegacySioDxe/SioService.c                          |  0
 .../LegacySioDxe/SioService.h                          |  0
 .../SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc  |  2 +-  .../SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf  |  2 +-
 13 files changed, 3 insertions(+), 18 deletions(-)  rename Platform/Intel/{SimicsOpenBoardPkg => BoardModulePkg}/LegacySioDxe/ComponentName.c (100%)  rename Platform/Intel/{SimicsOpenBoardPkg => BoardModulePkg}/LegacySioDxe/ComponentName.h (100%)  rename Platform/Intel/{SimicsOpenBoardPkg => BoardModulePkg}/LegacySioDxe/LegacySioDxe.inf (92%)  rename Platform/Intel/{SimicsOpenBoardPkg => BoardModulePkg}/LegacySioDxe/Register.h (100%)  rename Platform/Intel/{SimicsOpenBoardPkg => BoardModulePkg}/LegacySioDxe/SioChip.c (94%)  rename Platform/Intel/{SimicsOpenBoardPkg => BoardModulePkg}/LegacySioDxe/SioChip.h (93%)  rename Platform/Intel/{SimicsOpenBoardPkg => BoardModulePkg}/LegacySioDxe/SioDriver.c (100%)  rename Platform/Intel/{SimicsOpenBoardPkg => BoardModulePkg}/LegacySioDxe/SioDriver.h (95%)  rename Platform/Intel/{SimicsOpenBoardPkg => BoardModulePkg}/LegacySioDxe/SioService.c (100%)  rename Platform/Intel/{SimicsOpenBoardPkg => BoardModulePkg}/LegacySioDxe/SioService.h (100%)

diff --git a/Platform/Intel/BoardModulePkg/BoardModulePkg.dsc b/Platform/Intel/BoardModulePkg/BoardModulePkg.dsc
index 5ec68ceebf..fffc135d75 100644
--- a/Platform/Intel/BoardModulePkg/BoardModulePkg.dsc
+++ b/Platform/Intel/BoardModulePkg/BoardModulePkg.dsc
@@ -76,6 +76,7 @@
 
 [Components]
   BoardModulePkg/FirmwareBootMediaInfo/FirmwareBootMediaInfoPei.inf
+  BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
   BoardModulePkg/Library/CmosAccessLib/CmosAccessLib.inf
   BoardModulePkg/Library/PlatformCmosAccessLibNull/PlatformCmosAccessLibNull.inf
 
diff --git a/Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/ComponentName.c b/Platform/Intel/BoardModulePkg/LegacySioDxe/ComponentName.c
similarity index 100%
rename from Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/ComponentName.c
rename to Platform/Intel/BoardModulePkg/LegacySioDxe/ComponentName.c
diff --git a/Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/ComponentName.h b/Platform/Intel/BoardModulePkg/LegacySioDxe/ComponentName.h
similarity index 100%
rename from Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/ComponentName.h
rename to Platform/Intel/BoardModulePkg/LegacySioDxe/ComponentName.h
diff --git a/Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/LegacySioDxe.inf b/Platform/Intel/BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
similarity index 92%
rename from Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/LegacySioDxe.inf
rename to Platform/Intel/BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
index 275f36ca47..d606ba43dc 100644
--- a/Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/LegacySioDxe.inf
+++ b/Platform/Intel/BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
@@ -28,11 +28,8 @@
   MemoryAllocationLib
   PcdLib
   DevicePathLib
-  IoLib
   UefiDriverEntryPoint
   UefiBootServicesTableLib
-  S3BootScriptLib
-  S3IoLib
 
 [Packages]
   MdePkg/MdePkg.dec
diff --git a/Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/Register.h b/Platform/Intel/BoardModulePkg/LegacySioDxe/Register.h
similarity index 100%
rename from Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/Register.h
rename to Platform/Intel/BoardModulePkg/LegacySioDxe/Register.h
diff --git a/Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/SioChip.c b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.c
similarity index 94%
rename from Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/SioChip.c
rename to Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.c
index b9a7b9cd24..81efe3c38b 100644
--- a/Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/SioChip.c
+++ b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.c
@@ -7,9 +7,7 @@
 **/
 
 #include "SioDriver.h"
-#include <Library/S3IoLib.h>
 
-LOCAL_IO_WRITE8    mIoWrite8         = IoWrite8;
 //
 // System configuration (setup) information  // diff --git a/Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/SioChip.h b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.h
similarity index 93%
rename from Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/SioChip.h
rename to Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.h
index 48e28c44b0..9322365923 100644
--- a/Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/SioChip.h
+++ b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.h
@@ -46,16 +46,6 @@ typedef struct {
   ACPI_RESOURCE_HEADER_PTR    PossibleResources;
 } DEVICE_INFO;
 
-
-/**
-  Initialize the SIO chip for S3.
-**/
-VOID
-SioInitForS3 (
-  VOID
-  );
-
-
 /**
   Return the supported devices.
 
diff --git a/Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/SioDriver.c b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioDriver.c
similarity index 100%
rename from Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/SioDriver.c
rename to Platform/Intel/BoardModulePkg/LegacySioDxe/SioDriver.c
diff --git a/Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/SioDriver.h b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioDriver.h
similarity index 95%
rename from Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/SioDriver.h
rename to Platform/Intel/BoardModulePkg/LegacySioDxe/SioDriver.h
index 2e75871f7f..8817019fbf 100644
--- a/Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/SioDriver.h
+++ b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioDriver.h
@@ -16,7 +16,6 @@
 #include <Library/BaseMemoryLib.h>
 #include <Library/DebugLib.h>
 #include <Library/IoLib.h>
-#include <Library/S3BootScriptLib.h>
 #include <Library/PciLib.h>
 #include <Library/UefiBootServicesTableLib.h>
 #include <Library/DevicePathLib.h>
diff --git a/Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/SioService.c b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioService.c
similarity index 100%
rename from Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/SioService.c
rename to Platform/Intel/BoardModulePkg/LegacySioDxe/SioService.c
diff --git a/Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/SioService.h b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioService.h
similarity index 100%
rename from Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/SioService.h
rename to Platform/Intel/BoardModulePkg/LegacySioDxe/SioService.h
diff --git a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc
index 78f1e80990..f91f71e246 100644
--- a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc
+++ b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc
@@ -280,7 +280,7 @@
   #######################################
   $(BOARD_PKG)/AcpiTables/AcpiTables.inf
   $(BOARD_PKG)/AcpiTables/MinPlatformAcpiTables/AcpiPlatform.inf
-  $(BOARD_PKG)/LegacySioDxe/LegacySioDxe.inf
+  BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
   $(BOARD_PKG)/SimicsDxe/SimicsDxe.inf
   $(BOARD_PKG)/SimicsVideoDxe/SimicsVideoDxe.inf
   $(BOARD_PKG)/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
diff --git a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf
index 39226251a7..590e01a14e 100644
--- a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf
+++ b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf
@@ -213,7 +213,7 @@ INF  MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
 INF  MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceSmm.inf
 INF  MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf
 
-INF  $(BOARD_PKG)/LegacySioDxe/LegacySioDxe.inf
+INF  BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
 INF  MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KeyboardDxe.inf
 
 INF  $(BOARD_PKG)/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
--
2.19.1.windows.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [edk2-devel] [edk2-platforms] [PATCH 3/5] BoardModulePkg: Added Pcds Sio Driver
  2019-11-01 19:51 ` [edk2-platforms] [PATCH 3/5] BoardModulePkg: Added Pcds Sio Driver Agyeman, Prince
@ 2019-11-01 21:55   ` Nate DeSimone
  2019-11-04 18:19   ` Kubacki, Michael A
  1 sibling, 0 replies; 16+ messages in thread
From: Nate DeSimone @ 2019-11-01 21:55 UTC (permalink / raw)
  To: devel@edk2.groups.io, Agyeman, Prince; +Cc: Kubacki, Michael A, Chiu, Chasel

Reviewed-by: Nate DeSimone <nathaniel.l.desimone@intel.com>

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Agyeman, Prince
Sent: Friday, November 1, 2019 12:51 PM
To: devel@edk2.groups.io
Cc: Kubacki, Michael A <michael.a.kubacki@intel.com>; Chiu, Chasel <chasel.chiu@intel.com>; Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>
Subject: [edk2-devel] [edk2-platforms] [PATCH 3/5] BoardModulePkg: Added Pcds Sio Driver

Included PCDs to the Sio dxe driver,
to allow the enable/disable of Ps2 keyboard/mouse,
UART1 and UART2 com ports.

Renamed the Sio driver's base name

Cc: Michael Kubacki <michael.a.kubacki@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>

Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
---
 .../LegacySioDxe/LegacySioDxe.inf             | 15 +++-
 .../BoardModulePkg/LegacySioDxe/SioChip.c     | 69 +++++++++++++++++--
 .../BoardModulePkg/LegacySioDxe/SioChip.h     | 10 +++
 .../BoardModulePkg/LegacySioDxe/SioDriver.c   | 42 ++++++++++-
 .../BoardX58Ich10/OpenBoardPkgPcd.dsc         |  6 ++
 5 files changed, 133 insertions(+), 9 deletions(-)

diff --git a/Platform/Intel/BoardModulePkg/LegacySioDxe/LegacySioDxe.inf b/Platform/Intel/BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
index d606ba43dc..4ab01a6098 100644
--- a/Platform/Intel/BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
+++ b/Platform/Intel/BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
@@ -10,7 +10,7 @@
 
 [Defines]
   INF_VERSION                    = 0x00010017
-  BASE_NAME                      = HitachiH8s2113Dxe
+  BASE_NAME                      = LegacySioDxe
   FILE_GUID                      = 7807E404-8281-4FF1-8457-0B54BABE263F
   VERSION_STRING                 = 1.0
   MODULE_TYPE                    = UEFI_DRIVER
@@ -34,6 +34,7 @@
 [Packages]
   MdePkg/MdePkg.dec
   MdeModulePkg/MdeModulePkg.dec
+  BoardModulePkg/BoardModulePkg.dec
 
 [Sources]
   SioChip.c
@@ -44,6 +45,18 @@
   SioDriver.h
   ComponentName.c
 
+[Pcd]
+  gBoardModulePkgTokenSpaceGuid.PcdPs2KbMsEnable
+  gBoardModulePkgTokenSpaceGuid.PcdUart1Enable
+  gBoardModulePkgTokenSpaceGuid.PcdUart1IrqMask
+  gBoardModulePkgTokenSpaceGuid.PcdUart1IoPort
+  gBoardModulePkgTokenSpaceGuid.PcdUart1Length
+  gBoardModulePkgTokenSpaceGuid.PcdUart2Enable
+  gBoardModulePkgTokenSpaceGuid.PcdUart2IrqMask
+  gBoardModulePkgTokenSpaceGuid.PcdUart2IoPort
+  gBoardModulePkgTokenSpaceGuid.PcdUart2Length
+  gBoardModulePkgTokenSpaceGuid.PcdSuperIoPciIsaBridgeDevice
+
 [Protocols]
   gEfiPciIoProtocolGuid                         ## CONSUMES
   gEfiDevicePathProtocolGuid                    ## PRODUCES
diff --git a/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.c b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.c
index 81efe3c38b..09403a7354 100644
--- a/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.c
+++ b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.c
@@ -19,12 +19,31 @@
 ACPI_SIO_RESOURCES_IO_IRQ      mCom1Resources = {
   {
     { ACPI_FIXED_LOCATION_IO_PORT_DESCRIPTOR },
-    0x3f8,
-    8
+      FixedPcdGet16 (PcdUart1IoPort),
+      FixedPcdGet8 (PcdUart1Length)
+    },
+    {
+      { ACPI_IRQ_NOFLAG_DESCRIPTOR },
+      FixedPcdGet16 (PcdUart1IrqMask)
+    },
+    {
+      ACPI_END_TAG_DESCRIPTOR,
+      0
+    }
+};
+
+//
+// COM 2 UART Controller
+//
+ACPI_SIO_RESOURCES_IO_IRQ      mCom2Resources = {
+  {
+    { ACPI_FIXED_LOCATION_IO_PORT_DESCRIPTOR },
+    FixedPcdGet16 (PcdUart2IoPort),
+    FixedPcdGet8 (PcdUart2Length)
   },
   {
     { ACPI_IRQ_NOFLAG_DESCRIPTOR },
-    BIT4    // IRQ4
+    FixedPcdGet16 (PcdUart2IrqMask),
   },
   {
     ACPI_END_TAG_DESCRIPTOR,
@@ -70,10 +89,12 @@ ACPI_SIO_RESOURCES_IO_IRQ      mMouseResources = {
   }
 };
 
+
 //
 // Table of SIO Controllers
 //
 DEVICE_INFO    mDeviceInfo[] = {
+#if FixedPcdGet8 (PcdUart1Enable) == DEVICE_ENABLED
   {
     {
       EISA_PNP_ID(0x501),
@@ -84,6 +105,20 @@ DEVICE_INFO    mDeviceInfo[] = {
     { (ACPI_SMALL_RESOURCE_HEADER *) &mCom1Resources },
     { (ACPI_SMALL_RESOURCE_HEADER *) &mCom1Resources }
   },  // COM 1 UART Controller
+#endif
+#if FixedPcdGet8 (PcdUart2Enable) == DEVICE_ENABLED
+  {
+    {
+      EISA_PNP_ID(0x501),
+      0
+    },
+    0,
+    RESOURCE_IO | RESOURCE_IRQ,
+    { (ACPI_SMALL_RESOURCE_HEADER *) &mCom2Resources },
+    { (ACPI_SMALL_RESOURCE_HEADER *) &mCom2Resources }
+  },  // COM 2 UART Controller
+#endif
+#if FixedPcdGet8 (PcdPs2KbMsEnable) == DEVICE_ENABLED
   {
     {
       EISA_PNP_ID(0x303),
@@ -103,10 +138,28 @@ DEVICE_INFO    mDeviceInfo[] = {
     0,  // Cannot change resource
     { (ACPI_SMALL_RESOURCE_HEADER *) &mMouseResources },
     { (ACPI_SMALL_RESOURCE_HEADER *) &mMouseResources }
-  }  // PS/2 Mouse Controller
+  },  // PS/2 Mouse Controller
+#endif
+  DEVICE_INFO_END
 };
 
 
+
+/**
+  Gets the number of devices in Table of SIO Controllers mDeviceInfo
+
+  @retval     Number of enabled devices in Table of SIO Controllers.
+**/
+UINTN
+EFIAPI
+GetDeviceCount(
+  VOID
+){
+   UINTN        Count;
+   Count = ARRAY_SIZE(mDeviceInfo) - 1; // -1 to account for for the end device info
+   return Count;
+}
+
 /**
   Return the supported devices.
 
@@ -128,7 +181,7 @@ DeviceGetList (
   //
   // Allocate enough memory for simplicity
   //
-  DeviceCount =  sizeof (mDeviceInfo) / sizeof (mDeviceInfo[0]);
+  DeviceCount = GetDeviceCount();
   LocalDevices = AllocatePool (sizeof (EFI_SIO_ACPI_DEVICE_ID) * DeviceCount);
   ASSERT (LocalDevices != NULL);
   if (LocalDevices == NULL) {
@@ -157,7 +210,6 @@ SioInit (
   VOID
   )
 {
-
   return EFI_SUCCESS;
 }
 
@@ -175,8 +227,11 @@ DeviceSearch (
   )
 {
   UINTN       Index;
+  UINTN       DeviceCount;
+
+  DeviceCount = GetDeviceCount();
 
-  for (Index = 0; Index < sizeof (mDeviceInfo) / sizeof (mDeviceInfo[0]); Index++) {
+  for (Index = 0; Index < DeviceCount; Index++) {
     if (CompareMem (Device, &mDeviceInfo[Index].Device, sizeof (*Device)) == 0) {
       return &mDeviceInfo[Index];
     }
diff --git a/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.h b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.h
index 9322365923..8bd53ccdd6 100644
--- a/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.h
+++ b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.h
@@ -24,6 +24,9 @@ UINT8
 #define RESOURCE_DMA   BIT2
 #define RESOURCE_MEM   BIT3
 
+#define DEVICE_ENABLED  0x01
+#define DEVICE_INFO_END { { 0xFFFFFFFF, 0xFFFFFFFF } }
+
 #pragma pack(1)
 
 typedef struct {
@@ -46,6 +49,13 @@ typedef struct {
   ACPI_RESOURCE_HEADER_PTR    PossibleResources;
 } DEVICE_INFO;
 
+typedef struct {
+  UINT8 Segment;
+  UINT8 Bus;
+  UINT8 Device;
+  UINT8 Funtion;
+} SIO_PCI_ISA_BRIDGE_DEVICE_INFO;
+
 /**
   Return the supported devices.
 
diff --git a/Platform/Intel/BoardModulePkg/LegacySioDxe/SioDriver.c b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioDriver.c
index 408c6ff301..5ab9109ad9 100644
--- a/Platform/Intel/BoardModulePkg/LegacySioDxe/SioDriver.c
+++ b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioDriver.c
@@ -8,7 +8,6 @@
 
 #include "SioDriver.h"
 
-
 //
 // This driver is for ACPI(PNP0A03,0)/PCI(0x1f,0)  // @@ -106,6 +105,27 @@ SioDriverEntryPoint (  }
 
 
+/**
+  Compares a PCI to ISA bridge device segment, bus, device and function 
+to the
+  PcdSuperIoPciIsaBridgeDevice values.
+
+  @param[in]  CurrentDevice       The device to be compared with the PcdSuperIoPciIsaBridgeDevice information
+  @retval     TRUE                This device matches PcdSuperIoPciIsaBridgeDevice values
+  @retval     FALSE               This device does not match the PcdSuperIoPciIsaBridgeDevice values
+**/
+BOOLEAN
+EFIAPI
+SioDeviceEnabled (
+  IN SIO_PCI_ISA_BRIDGE_DEVICE_INFO *CurrentDevice ){
+    SIO_PCI_ISA_BRIDGE_DEVICE_INFO *Device = \
+      (SIO_PCI_ISA_BRIDGE_DEVICE_INFO *) FixedPcdGetPtr (PcdSuperIoPciIsaBridgeDevice);
+    if(CompareMem (Device, CurrentDevice, sizeof (SIO_PCI_ISA_BRIDGE_DEVICE_INFO)) == 0) {
+      return TRUE;
+    }
+    return FALSE;
+}
+
 /**
   Test to see if this driver supports Controller Handle.
 
@@ -138,6 +158,7 @@ SioDriverSupported (
   UINTN                     BusNumber;
   UINTN                     DeviceNumber;
   UINTN                     FunctionNumber;
+  SIO_PCI_ISA_BRIDGE_DEVICE_INFO  SioDevice;
 
   //
   // If RemainingDevicePath is not NULL, it should verify that the first device @@ -250,6 +271,25 @@ SioDriverSupported (
             Status = EFI_UNSUPPORTED;
           }
         }
+
+        if(!EFI_ERROR (Status)) {
+          Status = PciIo->GetLocation (
+                            PciIo,
+                            &SegmentNumber,
+                            &BusNumber,
+                            &DeviceNumber,
+                            &FunctionNumber
+                            );
+          if(!EFI_ERROR (Status)) {
+            SioDevice.Segment = (UINT8) SegmentNumber;
+            SioDevice.Bus = (UINT8) BusNumber;
+            SioDevice.Device = (UINT8) DeviceNumber;
+            SioDevice.Funtion = (UINT8) FunctionNumber;
+            if(!SioDeviceEnabled (&SioDevice)) {
+              Status = EFI_UNSUPPORTED;
+            }
+          }
+        }
       }
     }
 
diff --git a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.dsc b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.dsc
index 0298e4b12d..b85991b772 100644
--- a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.dsc
+++ b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.ds
+++ c
@@ -196,6 +196,12 @@
   gMinPlatformPkgTokenSpaceGuid.PcdMaxCpuThreadCount|4
   gMinPlatformPkgTokenSpaceGuid.PcdPcIoApicAddressBase|0xFEC01000
 
+  ######################################
+  # Board Configuration
+  ######################################
+  gBoardModulePkgTokenSpaceGuid.PcdPs2KbMsEnable|1
+
+ gBoardModulePkgTokenSpaceGuid.PcdSuperIoPciIsaBridgeDevice|{0x00,0x00,
+ 0x1F,0x00}
+
 [PcdsFixedAtBuild.X64]
   ######################################
   # Edk2 Configuration
--
2.19.1.windows.1





^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [edk2-platforms] [PATCH 4/5] KabylakeOpenBoardPkg: Add Ps2 keyboard Null Library
  2019-11-01 19:51 ` [edk2-platforms] [PATCH 4/5] KabylakeOpenBoardPkg: Add Ps2 keyboard Null Library Agyeman, Prince
  2019-11-01 21:55   ` Nate DeSimone
@ 2019-11-04  9:03   ` Chiu, Chasel
  2019-11-04 17:17     ` Agyeman, Prince
  1 sibling, 1 reply; 16+ messages in thread
From: Chiu, Chasel @ 2019-11-04  9:03 UTC (permalink / raw)
  To: Agyeman, Prince, devel@edk2.groups.io
  Cc: Kubacki, Michael A, Desimone, Nathaniel L


Hi Prince,

I added 3 questions below inline, please help to check them. Thanks!


> -----Original Message-----
> From: Agyeman, Prince <prince.agyeman@intel.com>
> Sent: Saturday, November 2, 2019 3:51 AM
> To: devel@edk2.groups.io
> Cc: Kubacki, Michael A <michael.a.kubacki@intel.com>; Chiu, Chasel
> <chasel.chiu@intel.com>; Desimone, Nathaniel L
> <nathaniel.l.desimone@intel.com>
> Subject: [edk2-platforms] [PATCH 4/5] KabylakeOpenBoardPkg: Add Ps2
> keyboard Null Library
> 
> Added GalagoPro3 board ps2 keyboard library that adds ps2 device path to
> ConIn and ConInDev Uefi variables
> 
> Cc: Michael Kubacki <michael.a.kubacki@intel.com>
> Cc: Chasel Chiu <chasel.chiu@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
> 
> Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
> ---
>  .../GalagoPro3/Library/Ps2KbcLib/Ps2KbcLib.c  | 202
> ++++++++++++++++++  .../GalagoPro3/Library/Ps2KbcLib/Ps2KbcLib.h  |
> 65 ++++++
>  .../Library/Ps2KbcLib/Ps2KbcLib.inf           |  39 ++++
>  3 files changed, 306 insertions(+)
>  create mode 100644
> Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/Ps2Kb
> cLib.c
>  create mode 100644
> Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/Ps2Kb
> cLib.h
>  create mode 100644
> Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/Ps2Kb
> cLib.inf
> 
> diff --git
> a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/Ps2K
> bcLib.c
> b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/Ps2
> KbcLib.c
> new file mode 100644
> index 0000000000..ac1563d3cd
> --- /dev/null
> +++
> b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/P
> +++ s2KbcLib.c
> @@ -0,0 +1,202 @@
> +/** @file
> +  Main file for NULL named library for Ps2 keyboard controller librarr.

I think this is not really a NULL library right? It actually does a lot real functionality.
Also the typo "librarr"


> +
> +  Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include "Ps2KbcLib.h"
> +
> +GLOBAL_REMOVE_IF_UNREFERENCED PLATFORM_KEYBOARD_DEVICE_PATH
> +gKeyboardDevicePath = {
> +  gPciRootBridge,
> +  {
> +    {
> +      HARDWARE_DEVICE_PATH,
> +      HW_PCI_DP,
> +      {
> +        (UINT8) (sizeof (PCI_DEVICE_PATH)),
> +        (UINT8) ((sizeof (PCI_DEVICE_PATH)) >> 8)
> +      }
> +    },
> +    0, // Function, patched in EnumPs2Keyboard
> +    0  // Device, patched in EnumPs2Keyboard
> +  },
> +  {
> +    {
> +      ACPI_DEVICE_PATH,
> +      ACPI_DP,
> +      {
> +        (UINT8) (sizeof (ACPI_HID_DEVICE_PATH)),
> +        (UINT8) ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8)
> +      }
> +    },
> +    EISA_PNP_ID(0x0303),
> +    0
> +  },
> +  gEndEntire
> +};
> +
> +/**
> +  Check if PS2 keyboard is conntected, by sending ECHO command.
> +  @retval                       TRUE if connected FALSE otherwise
> +**/
> +BOOLEAN
> +DetectPs2Keyboard (
> +  VOID
> +  )
> +{
> +  UINT32                TimeOut;
> +  UINT32                RegEmptied;
> +  UINT8                 Data;
> +  UINT32                SumTimeOut;
> +  BOOLEAN               FoundPs2Kbc;
> +
> +  TimeOut     = 0;
> +  RegEmptied  = 0;
> +  FoundPs2Kbc       = FALSE;
> +
> +  //
> +  // Wait for input buffer empty
> +  //
> +  for (TimeOut = 0; TimeOut < PS2_KEYBOARD_TIMEOUT; TimeOut += 30) {
> +    if ((IoRead8 (KEYBOARD_8042_STATUS_REGISTER) & 0x02) == 0) {
> +      FoundPs2Kbc = TRUE;
> +      break;
> +    }
> +    MicroSecondDelay (30);
> +  }
> +
> +  if (FoundPs2Kbc == FALSE) {
> +    return FALSE;
> +  }
> +
> +  //
> +  // Send echo command
> +  //
> +  IoWrite8 (KEYBOARD_8042_DATA_REGISTER,
> KBC_INPBUF_VIA60_KBECHO);
> +
> +  //
> +  // Init variables
> +  //
> +  FoundPs2Kbc       = FALSE;
> +  TimeOut     = 0;
> +  SumTimeOut  = 0;
> +  Data = 0;
> +
> +  //
> +  // Read from 8042 (multiple times if needed)  // until the expected
> + value appears  // use SumTimeOut to control the iteration  //  while
> + (1) {
> +    //
> +    // Perform a read
> +    //
> +    for (TimeOut = 0; TimeOut < PS2_KEYBOARD_TIMEOUT; TimeOut += 30)
> {
> +      if (IoRead8 (KEYBOARD_8042_STATUS_REGISTER) & 0x01) {
> +        Data = IoRead8 (KEYBOARD_8042_DATA_REGISTER);
> +        break;
> +      }
> +      MicroSecondDelay (30);
> +    }
> +
> +    SumTimeOut += TimeOut;
> +
> +    if (Data == KBC_INPBUF_VIA60_KBECHO) {
> +      FoundPs2Kbc = TRUE;
> +      break;
> +    }
> +
> +    if (SumTimeOut >= PS2_KEYBOARD_WAITFORVALUE_TIMEOUT) {
> +      break;
> +    }
> +  }
> +  return FoundPs2Kbc;
> +}
> +
> +/**
> +  Check if PS2 keyboard is conntected. If the result of first time is
> +  error, it will retry again.
> +  @retval                       TRUE if connected FALSE otherwise
> +**/
> +BOOLEAN
> +IsPs2KeyboardConnected (
> +  VOID
> +  )
> +{
> +  BOOLEAN Result;
> +  Result = DetectPs2Keyboard ();
> +
> +  if (Result == FALSE) {
> +    //
> +    // If there is no ps2 keyboard detected for the 1st time, retry again.
> +    //
> +    Result = DetectPs2Keyboard ();
> +  }
> +  return Result;
> +}
> +
> +
> +/**
> +  Updates the ConIn variable with Ps2 Keyboard device path,
> +  if it doesn't already exists in ConIn and ConInDev **/ VOID
> +AddPs2Keyboard (
> +  VOID
> +  )
> +{
> +  SIO_PCI_ISA_BRIDGE_DEVICE_INFO *SioIsaInfo;
> +
> +  DEBUG ((DEBUG_INFO, "[AddPs2Keyboard]\n"));
> +
> +  SioIsaInfo = (SIO_PCI_ISA_BRIDGE_DEVICE_INFO*) FixedPcdGetPtr
> + (PcdSuperIoPciIsaBridgeDevice);
> +
> +  //
> +  // patch IsaBridge device and and function  //
> + gKeyboardDevicePath.IsaBridge.Device = SioIsaInfo->Device;
> + gKeyboardDevicePath.IsaBridge.Function = SioIsaInfo->Funtion;
> +
> +  //
> +  // Append Ps2 Keyboard into "ConIn"
> +  //
> +  EfiBootManagerUpdateConsoleVariable (ConIn,
> (EFI_DEVICE_PATH_PROTOCOL
> + *) &gKeyboardDevicePath, NULL);
> +
> +  //
> +  // Append Ps2 Keyboard into "ConInDev"
> +  //
> +  EfiBootManagerUpdateConsoleVariable (ConInDev,
> +(EFI_DEVICE_PATH_PROTOCOL *) &gKeyboardDevicePath, NULL); }
> +
> +
> +/**
> +  Constructor for the Ps2 keyboard controller library.
> +
> +  @param ImageHandle    the image handle of the process
> +  @param SystemTable    the EFI System Table pointer
> +
> +  @retval EFI_SUCCESS        the shell command handlers were
> installed sucessfully
> +  @retval EFI_UNSUPPORTED    the shell level required was not found.
> +**/
> +EFI_STATUS
> +EFIAPI
> +Ps2KbcLibConstructor (
> +  IN EFI_HANDLE        ImageHandle,
> +  IN EFI_SYSTEM_TABLE  *SystemTable
> +  )
> +{
> +  UINT8                               Ps2KbMsEnable;
> +
> +  Ps2KbMsEnable = PcdGet8 (PcdPs2KbMsEnable);
> +
> +  if (Ps2KbMsEnable == 0x1
> +    && IsPs2KeyboardConnected())
> +  {
> +      // add ps2 device path to ConIn and ConInDev
> +      AddPs2Keyboard ();
> +  }
> +
> +  return EFI_SUCCESS;
> +}
> diff --git
> a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/Ps2K
> bcLib.h
> b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/Ps2
> KbcLib.h
> new file mode 100644
> index 0000000000..60bba122d6
> --- /dev/null
> +++
> b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/P
> +++ s2KbcLib.h
> @@ -0,0 +1,65 @@
> +/** @file
> +  Header file for NULL named library for Ps2 keyboard controller library.

Same question here, is this really NULL library instance?



> +
> +  Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef _PS2_KBC_LIB_H
> +#define _PS2_KBC_LIB_H
> +
> +#include <Uefi.h>
> +#include <Library/UefiLib.h>
> +#include <Library/DevicePathLib.h>
> +#include <Library/DebugLib.h>
> +#include <Library/IoLib.h>
> +#include <Library/TimerLib.h>
> +#include <Library/UefiBootManagerLib.h>
> +
> +//
> +// Below is the platform console device path // typedef struct {
> +  ACPI_HID_DEVICE_PATH      PciRootBridge;
> +  PCI_DEVICE_PATH           IsaBridge;
> +  ACPI_HID_DEVICE_PATH      Keyboard;
> +  EFI_DEVICE_PATH_PROTOCOL  End;
> +} PLATFORM_KEYBOARD_DEVICE_PATH;
> +
> +typedef struct {
> +  UINT8 Segment;
> +  UINT8 Bus;
> +  UINT8 Device;
> +  UINT8 Funtion;
> +} SIO_PCI_ISA_BRIDGE_DEVICE_INFO;
> +
> +#define gPciRootBridge \
> +  { \
> +    { \
> +      ACPI_DEVICE_PATH, \
> +      ACPI_DP, \
> +      { \
> +        (UINT8) (sizeof (ACPI_HID_DEVICE_PATH)), \
> +        (UINT8) ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) \
> +      }, \
> +    }, \
> +    EISA_PNP_ID (0x0A03), \
> +    0 \
> +  }
> +
> +#define gEndEntire \
> +  { \
> +    END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, {
> +END_DEVICE_PATH_LENGTH, 0 } \
> +  }
> +
> +#define KBC_INPBUF_VIA60_KBECHO             0xEE
> +#define KEYBOARD_8042_DATA_REGISTER         0x60
> +#define KEYBOARD_8042_STATUS_REGISTER       0x64
> +
> +#define PS2_KEYBOARD_TIMEOUT                65536   // 0.07s
> +#define PS2_KEYBOARD_WAITFORVALUE_TIMEOUT   1000000 // 1s
> +#define PS2_KEYBOARD_KBEN                   0xF4
> +#define PS2_KEYBOARD_CMDECHO_ACK            0xFA
> +
> +#endif
> diff --git
> a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/Ps2K
> bcLib.inf
> b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/Ps2
> KbcLib.inf
> new file mode 100644
> index 0000000000..7ab1b628e3
> --- /dev/null
> +++
> b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/P
> +++ s2KbcLib.inf
> @@ -0,0 +1,39 @@
> +## @file
> +# Component information file for PEI GalagoPro3 Board Init Pre-Mem
> +Library # # Copyright (c) 2019, Intel Corporation. All rights

This library is for PS2 initialization, not "Board Init Pre-Mem".


> +reserved.<BR> # # SPDX-License-Identifier: BSD-2-Clause-Patent # ##
> +[Defines]
> +  INF_VERSION                    = 0x00010006
> +  BASE_NAME                      = Ps2KbcLib
> +  FILE_GUID                      =
> E94EA52E-E84C-42E7-B863-EA1327EFA265
> +  MODULE_TYPE                    = UEFI_DRIVER
> +  VERSION_STRING                 = 1.2
> +  LIBRARY_CLASS                  = NULL|UEFI_DRIVER
> +  CONSTRUCTOR                    = Ps2KbcLibConstructor
> +
> +[Packages]
> +  MdePkg/MdePkg.dec
> +  MdeModulePkg/MdeModulePkg.dec
> +  KabylakeOpenBoardPkg/OpenBoardPkg.dec
> +  BoardModulePkg/BoardModulePkg.dec
> +
> +[Sources]
> +  Ps2KbcLib.c
> +  Ps2KbcLib.h
> +
> +[LibraryClasses]
> +  DevicePathLib
> +  DebugLib
> +  IoLib
> +  UefiDriverEntryPoint
> +  UefiBootManagerLib
> +  UefiLib
> +  TimerLib
> +
> +[Pcd]
> +  gBoardModulePkgTokenSpaceGuid.PcdPs2KbMsEnable
> +  gBoardModulePkgTokenSpaceGuid.PcdSuperIoPciIsaBridgeDevice
> --
> 2.19.1.windows.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [edk2-platforms] [PATCH 2/5] Platform/Intel: Move Sio Dxe Driver
  2019-11-01 19:51 ` [edk2-platforms] [PATCH 2/5] Platform/Intel: Move Sio Dxe Driver Agyeman, Prince
  2019-11-01 21:55   ` Nate DeSimone
@ 2019-11-04  9:15   ` Chiu, Chasel
  1 sibling, 0 replies; 16+ messages in thread
From: Chiu, Chasel @ 2019-11-04  9:15 UTC (permalink / raw)
  To: Agyeman, Prince, devel@edk2.groups.io
  Cc: Kubacki, Michael A, Desimone, Nathaniel L


Hi Prince,

Below 2 files description does not match the driver purpose, please help to correct them. Thanks!
edk2-platforms\Platform\Intel\BoardModulePkg\LegacySioDxe\ComponentName.c ("Install Base and Size Info Ppi for Firmware Volume Recovery.")
edk2-platforms\Platform\Intel\BoardModulePkg\LegacySioDxe\ComponentName.h ("Install Base and Size Info Ppi for Firmware Volume Recovery.")

> -----Original Message-----
> From: Agyeman, Prince <prince.agyeman@intel.com>
> Sent: Saturday, November 2, 2019 3:51 AM
> To: devel@edk2.groups.io
> Cc: Kubacki, Michael A <michael.a.kubacki@intel.com>; Chiu, Chasel
> <chasel.chiu@intel.com>; Desimone, Nathaniel L
> <nathaniel.l.desimone@intel.com>
> Subject: [edk2-platforms] [PATCH 2/5] Platform/Intel: Move Sio Dxe Driver
> 
> Moved LegacySioDxe from SimicsOpenBoardPkg to BoardModulePkg as
> LegacySioDxe is generic and can be shared between open board packages
> 
> Removed unused libraries and functions in LegacySioDxe
> 
> Pointed BoardX58Ich10 to the current LegacySioDxe location
> 
> Cc: Michael Kubacki <michael.a.kubacki@intel.com>
> Cc: Chasel Chiu <chasel.chiu@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
> 
> Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
> ---
>  Platform/Intel/BoardModulePkg/BoardModulePkg.dsc       |  1 +
>  .../LegacySioDxe/ComponentName.c                       |  0
>  .../LegacySioDxe/ComponentName.h                       |  0
>  .../LegacySioDxe/LegacySioDxe.inf                      |  3 ---
>  .../LegacySioDxe/Register.h                            |  0
>  .../LegacySioDxe/SioChip.c                             |  2 --
>  .../LegacySioDxe/SioChip.h                             | 10 ----------
>  .../LegacySioDxe/SioDriver.c                           |  0
>  .../LegacySioDxe/SioDriver.h                           |  1 -
>  .../LegacySioDxe/SioService.c                          |  0
>  .../LegacySioDxe/SioService.h                          |  0
>  .../SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc  |  2
> +-  .../SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf  |  2 +-
>  13 files changed, 3 insertions(+), 18 deletions(-)  rename
> Platform/Intel/{SimicsOpenBoardPkg =>
> BoardModulePkg}/LegacySioDxe/ComponentName.c (100%)  rename
> Platform/Intel/{SimicsOpenBoardPkg =>
> BoardModulePkg}/LegacySioDxe/ComponentName.h (100%)  rename
> Platform/Intel/{SimicsOpenBoardPkg =>
> BoardModulePkg}/LegacySioDxe/LegacySioDxe.inf (92%)  rename
> Platform/Intel/{SimicsOpenBoardPkg =>
> BoardModulePkg}/LegacySioDxe/Register.h (100%)  rename
> Platform/Intel/{SimicsOpenBoardPkg =>
> BoardModulePkg}/LegacySioDxe/SioChip.c (94%)  rename
> Platform/Intel/{SimicsOpenBoardPkg =>
> BoardModulePkg}/LegacySioDxe/SioChip.h (93%)  rename
> Platform/Intel/{SimicsOpenBoardPkg =>
> BoardModulePkg}/LegacySioDxe/SioDriver.c (100%)  rename
> Platform/Intel/{SimicsOpenBoardPkg =>
> BoardModulePkg}/LegacySioDxe/SioDriver.h (95%)  rename
> Platform/Intel/{SimicsOpenBoardPkg =>
> BoardModulePkg}/LegacySioDxe/SioService.c (100%)  rename
> Platform/Intel/{SimicsOpenBoardPkg =>
> BoardModulePkg}/LegacySioDxe/SioService.h (100%)
> 
> diff --git a/Platform/Intel/BoardModulePkg/BoardModulePkg.dsc
> b/Platform/Intel/BoardModulePkg/BoardModulePkg.dsc
> index 5ec68ceebf..fffc135d75 100644
> --- a/Platform/Intel/BoardModulePkg/BoardModulePkg.dsc
> +++ b/Platform/Intel/BoardModulePkg/BoardModulePkg.dsc
> @@ -76,6 +76,7 @@
> 
>  [Components]
> 
> BoardModulePkg/FirmwareBootMediaInfo/FirmwareBootMediaInfoPei.inf
> +  BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
>    BoardModulePkg/Library/CmosAccessLib/CmosAccessLib.inf
> 
> BoardModulePkg/Library/PlatformCmosAccessLibNull/PlatformCmosAccessLi
> bNull.inf
> 
> diff --git
> a/Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/ComponentName.c
> b/Platform/Intel/BoardModulePkg/LegacySioDxe/ComponentName.c
> similarity index 100%
> rename from
> Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/ComponentName.c
> rename to
> Platform/Intel/BoardModulePkg/LegacySioDxe/ComponentName.c
> diff --git
> a/Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/ComponentName.h
> b/Platform/Intel/BoardModulePkg/LegacySioDxe/ComponentName.h
> similarity index 100%
> rename from
> Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/ComponentName.h
> rename to
> Platform/Intel/BoardModulePkg/LegacySioDxe/ComponentName.h
> diff --git
> a/Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/LegacySioDxe.inf
> b/Platform/Intel/BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
> similarity index 92%
> rename from
> Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/LegacySioDxe.inf
> rename to Platform/Intel/BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
> index 275f36ca47..d606ba43dc 100644
> --- a/Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/LegacySioDxe.inf
> +++ b/Platform/Intel/BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
> @@ -28,11 +28,8 @@
>    MemoryAllocationLib
>    PcdLib
>    DevicePathLib
> -  IoLib
>    UefiDriverEntryPoint
>    UefiBootServicesTableLib
> -  S3BootScriptLib
> -  S3IoLib
> 
>  [Packages]
>    MdePkg/MdePkg.dec
> diff --git a/Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/Register.h
> b/Platform/Intel/BoardModulePkg/LegacySioDxe/Register.h
> similarity index 100%
> rename from Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/Register.h
> rename to Platform/Intel/BoardModulePkg/LegacySioDxe/Register.h
> diff --git a/Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/SioChip.c
> b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.c
> similarity index 94%
> rename from Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/SioChip.c
> rename to Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.c
> index b9a7b9cd24..81efe3c38b 100644
> --- a/Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/SioChip.c
> +++ b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.c
> @@ -7,9 +7,7 @@
>  **/
> 
>  #include "SioDriver.h"
> -#include <Library/S3IoLib.h>
> 
> -LOCAL_IO_WRITE8    mIoWrite8         = IoWrite8;
>  //
>  // System configuration (setup) information  // diff --git
> a/Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/SioChip.h
> b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.h
> similarity index 93%
> rename from Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/SioChip.h
> rename to Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.h
> index 48e28c44b0..9322365923 100644
> --- a/Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/SioChip.h
> +++ b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.h
> @@ -46,16 +46,6 @@ typedef struct {
>    ACPI_RESOURCE_HEADER_PTR    PossibleResources;
>  } DEVICE_INFO;
> 
> -
> -/**
> -  Initialize the SIO chip for S3.
> -**/
> -VOID
> -SioInitForS3 (
> -  VOID
> -  );
> -
> -
>  /**
>    Return the supported devices.
> 
> diff --git a/Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/SioDriver.c
> b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioDriver.c
> similarity index 100%
> rename from Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/SioDriver.c
> rename to Platform/Intel/BoardModulePkg/LegacySioDxe/SioDriver.c
> diff --git a/Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/SioDriver.h
> b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioDriver.h
> similarity index 95%
> rename from Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/SioDriver.h
> rename to Platform/Intel/BoardModulePkg/LegacySioDxe/SioDriver.h
> index 2e75871f7f..8817019fbf 100644
> --- a/Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/SioDriver.h
> +++ b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioDriver.h
> @@ -16,7 +16,6 @@
>  #include <Library/BaseMemoryLib.h>
>  #include <Library/DebugLib.h>
>  #include <Library/IoLib.h>
> -#include <Library/S3BootScriptLib.h>
>  #include <Library/PciLib.h>
>  #include <Library/UefiBootServicesTableLib.h>
>  #include <Library/DevicePathLib.h>
> diff --git a/Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/SioService.c
> b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioService.c
> similarity index 100%
> rename from Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/SioService.c
> rename to Platform/Intel/BoardModulePkg/LegacySioDxe/SioService.c
> diff --git a/Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/SioService.h
> b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioService.h
> similarity index 100%
> rename from Platform/Intel/SimicsOpenBoardPkg/LegacySioDxe/SioService.h
> rename to Platform/Intel/BoardModulePkg/LegacySioDxe/SioService.h
> diff --git
> a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc
> b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc
> index 78f1e80990..f91f71e246 100644
> --- a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc
> +++
> b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc
> @@ -280,7 +280,7 @@
>    #######################################
>    $(BOARD_PKG)/AcpiTables/AcpiTables.inf
>    $(BOARD_PKG)/AcpiTables/MinPlatformAcpiTables/AcpiPlatform.inf
> -  $(BOARD_PKG)/LegacySioDxe/LegacySioDxe.inf
> +  BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
>    $(BOARD_PKG)/SimicsDxe/SimicsDxe.inf
>    $(BOARD_PKG)/SimicsVideoDxe/SimicsVideoDxe.inf
>    $(BOARD_PKG)/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
> diff --git
> a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf
> b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf
> index 39226251a7..590e01a14e 100644
> --- a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf
> +++
> b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf
> @@ -213,7 +213,7 @@ INF
> MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
>  INF  MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceSmm.inf
>  INF  MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf
> 
> -INF  $(BOARD_PKG)/LegacySioDxe/LegacySioDxe.inf
> +INF  BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
>  INF  MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KeyboardDxe.inf
> 
>  INF  $(BOARD_PKG)/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
> --
> 2.19.1.windows.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [edk2-platforms] [PATCH 4/5] KabylakeOpenBoardPkg: Add Ps2 keyboard Null Library
  2019-11-04  9:03   ` Chiu, Chasel
@ 2019-11-04 17:17     ` Agyeman, Prince
  0 siblings, 0 replies; 16+ messages in thread
From: Agyeman, Prince @ 2019-11-04 17:17 UTC (permalink / raw)
  To: Chiu, Chasel, devel@edk2.groups.io
  Cc: Kubacki, Michael A, Desimone, Nathaniel L

Hi Chasel, 

I will fix the descriptions and typos as suggested in my v2 patch series.

Thanks for the feedback!

Prince 

-----Original Message-----
From: Chiu, Chasel <chasel.chiu@intel.com> 
Sent: Monday, November 4, 2019 1:04 AM
To: Agyeman, Prince <prince.agyeman@intel.com>; devel@edk2.groups.io
Cc: Kubacki, Michael A <michael.a.kubacki@intel.com>; Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>
Subject: RE: [edk2-platforms] [PATCH 4/5] KabylakeOpenBoardPkg: Add Ps2 keyboard Null Library


Hi Prince,

I added 3 questions below inline, please help to check them. Thanks!


> -----Original Message-----
> From: Agyeman, Prince <prince.agyeman@intel.com>
> Sent: Saturday, November 2, 2019 3:51 AM
> To: devel@edk2.groups.io
> Cc: Kubacki, Michael A <michael.a.kubacki@intel.com>; Chiu, Chasel 
> <chasel.chiu@intel.com>; Desimone, Nathaniel L 
> <nathaniel.l.desimone@intel.com>
> Subject: [edk2-platforms] [PATCH 4/5] KabylakeOpenBoardPkg: Add Ps2 
> keyboard Null Library
> 
> Added GalagoPro3 board ps2 keyboard library that adds ps2 device path 
> to ConIn and ConInDev Uefi variables
> 
> Cc: Michael Kubacki <michael.a.kubacki@intel.com>
> Cc: Chasel Chiu <chasel.chiu@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
> 
> Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
> ---
>  .../GalagoPro3/Library/Ps2KbcLib/Ps2KbcLib.c  | 202
> ++++++++++++++++++  .../GalagoPro3/Library/Ps2KbcLib/Ps2KbcLib.h  |
> 65 ++++++
>  .../Library/Ps2KbcLib/Ps2KbcLib.inf           |  39 ++++
>  3 files changed, 306 insertions(+)
>  create mode 100644
> Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/Ps2Kb
> cLib.c
>  create mode 100644
> Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/Ps2Kb
> cLib.h
>  create mode 100644
> Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/Ps2Kb
> cLib.inf
> 
> diff --git
> a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/Ps2
> K
> bcLib.c
> b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/Ps2
> KbcLib.c
> new file mode 100644
> index 0000000000..ac1563d3cd
> --- /dev/null
> +++
> b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/P
> +++ s2KbcLib.c
> @@ -0,0 +1,202 @@
> +/** @file
> +  Main file for NULL named library for Ps2 keyboard controller librarr.

I think this is not really a NULL library right? It actually does a lot real functionality.
Also the typo "librarr"


> +
> +  Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include "Ps2KbcLib.h"
> +
> +GLOBAL_REMOVE_IF_UNREFERENCED PLATFORM_KEYBOARD_DEVICE_PATH 
> +gKeyboardDevicePath = {
> +  gPciRootBridge,
> +  {
> +    {
> +      HARDWARE_DEVICE_PATH,
> +      HW_PCI_DP,
> +      {
> +        (UINT8) (sizeof (PCI_DEVICE_PATH)),
> +        (UINT8) ((sizeof (PCI_DEVICE_PATH)) >> 8)
> +      }
> +    },
> +    0, // Function, patched in EnumPs2Keyboard
> +    0  // Device, patched in EnumPs2Keyboard
> +  },
> +  {
> +    {
> +      ACPI_DEVICE_PATH,
> +      ACPI_DP,
> +      {
> +        (UINT8) (sizeof (ACPI_HID_DEVICE_PATH)),
> +        (UINT8) ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8)
> +      }
> +    },
> +    EISA_PNP_ID(0x0303),
> +    0
> +  },
> +  gEndEntire
> +};
> +
> +/**
> +  Check if PS2 keyboard is conntected, by sending ECHO command.
> +  @retval                       TRUE if connected FALSE otherwise
> +**/
> +BOOLEAN
> +DetectPs2Keyboard (
> +  VOID
> +  )
> +{
> +  UINT32                TimeOut;
> +  UINT32                RegEmptied;
> +  UINT8                 Data;
> +  UINT32                SumTimeOut;
> +  BOOLEAN               FoundPs2Kbc;
> +
> +  TimeOut     = 0;
> +  RegEmptied  = 0;
> +  FoundPs2Kbc       = FALSE;
> +
> +  //
> +  // Wait for input buffer empty
> +  //
> +  for (TimeOut = 0; TimeOut < PS2_KEYBOARD_TIMEOUT; TimeOut += 30) {
> +    if ((IoRead8 (KEYBOARD_8042_STATUS_REGISTER) & 0x02) == 0) {
> +      FoundPs2Kbc = TRUE;
> +      break;
> +    }
> +    MicroSecondDelay (30);
> +  }
> +
> +  if (FoundPs2Kbc == FALSE) {
> +    return FALSE;
> +  }
> +
> +  //
> +  // Send echo command
> +  //
> +  IoWrite8 (KEYBOARD_8042_DATA_REGISTER,
> KBC_INPBUF_VIA60_KBECHO);
> +
> +  //
> +  // Init variables
> +  //
> +  FoundPs2Kbc       = FALSE;
> +  TimeOut     = 0;
> +  SumTimeOut  = 0;
> +  Data = 0;
> +
> +  //
> +  // Read from 8042 (multiple times if needed)  // until the expected 
> + value appears  // use SumTimeOut to control the iteration  //  while
> + (1) {
> +    //
> +    // Perform a read
> +    //
> +    for (TimeOut = 0; TimeOut < PS2_KEYBOARD_TIMEOUT; TimeOut += 30)
> {
> +      if (IoRead8 (KEYBOARD_8042_STATUS_REGISTER) & 0x01) {
> +        Data = IoRead8 (KEYBOARD_8042_DATA_REGISTER);
> +        break;
> +      }
> +      MicroSecondDelay (30);
> +    }
> +
> +    SumTimeOut += TimeOut;
> +
> +    if (Data == KBC_INPBUF_VIA60_KBECHO) {
> +      FoundPs2Kbc = TRUE;
> +      break;
> +    }
> +
> +    if (SumTimeOut >= PS2_KEYBOARD_WAITFORVALUE_TIMEOUT) {
> +      break;
> +    }
> +  }
> +  return FoundPs2Kbc;
> +}
> +
> +/**
> +  Check if PS2 keyboard is conntected. If the result of first time is
> +  error, it will retry again.
> +  @retval                       TRUE if connected FALSE otherwise
> +**/
> +BOOLEAN
> +IsPs2KeyboardConnected (
> +  VOID
> +  )
> +{
> +  BOOLEAN Result;
> +  Result = DetectPs2Keyboard ();
> +
> +  if (Result == FALSE) {
> +    //
> +    // If there is no ps2 keyboard detected for the 1st time, retry again.
> +    //
> +    Result = DetectPs2Keyboard ();
> +  }
> +  return Result;
> +}
> +
> +
> +/**
> +  Updates the ConIn variable with Ps2 Keyboard device path,
> +  if it doesn't already exists in ConIn and ConInDev **/ VOID 
> +AddPs2Keyboard (
> +  VOID
> +  )
> +{
> +  SIO_PCI_ISA_BRIDGE_DEVICE_INFO *SioIsaInfo;
> +
> +  DEBUG ((DEBUG_INFO, "[AddPs2Keyboard]\n"));
> +
> +  SioIsaInfo = (SIO_PCI_ISA_BRIDGE_DEVICE_INFO*) FixedPcdGetPtr 
> + (PcdSuperIoPciIsaBridgeDevice);
> +
> +  //
> +  // patch IsaBridge device and and function  // 
> + gKeyboardDevicePath.IsaBridge.Device = SioIsaInfo->Device; 
> + gKeyboardDevicePath.IsaBridge.Function = SioIsaInfo->Funtion;
> +
> +  //
> +  // Append Ps2 Keyboard into "ConIn"
> +  //
> +  EfiBootManagerUpdateConsoleVariable (ConIn,
> (EFI_DEVICE_PATH_PROTOCOL
> + *) &gKeyboardDevicePath, NULL);
> +
> +  //
> +  // Append Ps2 Keyboard into "ConInDev"
> +  //
> +  EfiBootManagerUpdateConsoleVariable (ConInDev, 
> +(EFI_DEVICE_PATH_PROTOCOL *) &gKeyboardDevicePath, NULL); }
> +
> +
> +/**
> +  Constructor for the Ps2 keyboard controller library.
> +
> +  @param ImageHandle    the image handle of the process
> +  @param SystemTable    the EFI System Table pointer
> +
> +  @retval EFI_SUCCESS        the shell command handlers were
> installed sucessfully
> +  @retval EFI_UNSUPPORTED    the shell level required was not found.
> +**/
> +EFI_STATUS
> +EFIAPI
> +Ps2KbcLibConstructor (
> +  IN EFI_HANDLE        ImageHandle,
> +  IN EFI_SYSTEM_TABLE  *SystemTable
> +  )
> +{
> +  UINT8                               Ps2KbMsEnable;
> +
> +  Ps2KbMsEnable = PcdGet8 (PcdPs2KbMsEnable);
> +
> +  if (Ps2KbMsEnable == 0x1
> +    && IsPs2KeyboardConnected())
> +  {
> +      // add ps2 device path to ConIn and ConInDev
> +      AddPs2Keyboard ();
> +  }
> +
> +  return EFI_SUCCESS;
> +}
> diff --git
> a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/Ps2
> K
> bcLib.h
> b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/Ps2
> KbcLib.h
> new file mode 100644
> index 0000000000..60bba122d6
> --- /dev/null
> +++
> b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/P
> +++ s2KbcLib.h
> @@ -0,0 +1,65 @@
> +/** @file
> +  Header file for NULL named library for Ps2 keyboard controller library.

Same question here, is this really NULL library instance?



> +
> +  Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef _PS2_KBC_LIB_H
> +#define _PS2_KBC_LIB_H
> +
> +#include <Uefi.h>
> +#include <Library/UefiLib.h>
> +#include <Library/DevicePathLib.h>
> +#include <Library/DebugLib.h>
> +#include <Library/IoLib.h>
> +#include <Library/TimerLib.h>
> +#include <Library/UefiBootManagerLib.h>
> +
> +//
> +// Below is the platform console device path // typedef struct {
> +  ACPI_HID_DEVICE_PATH      PciRootBridge;
> +  PCI_DEVICE_PATH           IsaBridge;
> +  ACPI_HID_DEVICE_PATH      Keyboard;
> +  EFI_DEVICE_PATH_PROTOCOL  End;
> +} PLATFORM_KEYBOARD_DEVICE_PATH;
> +
> +typedef struct {
> +  UINT8 Segment;
> +  UINT8 Bus;
> +  UINT8 Device;
> +  UINT8 Funtion;
> +} SIO_PCI_ISA_BRIDGE_DEVICE_INFO;
> +
> +#define gPciRootBridge \
> +  { \
> +    { \
> +      ACPI_DEVICE_PATH, \
> +      ACPI_DP, \
> +      { \
> +        (UINT8) (sizeof (ACPI_HID_DEVICE_PATH)), \
> +        (UINT8) ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) \
> +      }, \
> +    }, \
> +    EISA_PNP_ID (0x0A03), \
> +    0 \
> +  }
> +
> +#define gEndEntire \
> +  { \
> +    END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, { 
> +END_DEVICE_PATH_LENGTH, 0 } \
> +  }
> +
> +#define KBC_INPBUF_VIA60_KBECHO             0xEE
> +#define KEYBOARD_8042_DATA_REGISTER         0x60
> +#define KEYBOARD_8042_STATUS_REGISTER       0x64
> +
> +#define PS2_KEYBOARD_TIMEOUT                65536   // 0.07s
> +#define PS2_KEYBOARD_WAITFORVALUE_TIMEOUT   1000000 // 1s
> +#define PS2_KEYBOARD_KBEN                   0xF4
> +#define PS2_KEYBOARD_CMDECHO_ACK            0xFA
> +
> +#endif
> diff --git
> a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/Ps2
> K
> bcLib.inf
> b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/Ps2
> KbcLib.inf
> new file mode 100644
> index 0000000000..7ab1b628e3
> --- /dev/null
> +++
> b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/P
> +++ s2KbcLib.inf
> @@ -0,0 +1,39 @@
> +## @file
> +# Component information file for PEI GalagoPro3 Board Init Pre-Mem 
> +Library # # Copyright (c) 2019, Intel Corporation. All rights

This library is for PS2 initialization, not "Board Init Pre-Mem".


> +reserved.<BR> # # SPDX-License-Identifier: BSD-2-Clause-Patent # ## 
> +[Defines]
> +  INF_VERSION                    = 0x00010006
> +  BASE_NAME                      = Ps2KbcLib
> +  FILE_GUID                      =
> E94EA52E-E84C-42E7-B863-EA1327EFA265
> +  MODULE_TYPE                    = UEFI_DRIVER
> +  VERSION_STRING                 = 1.2
> +  LIBRARY_CLASS                  = NULL|UEFI_DRIVER
> +  CONSTRUCTOR                    = Ps2KbcLibConstructor
> +
> +[Packages]
> +  MdePkg/MdePkg.dec
> +  MdeModulePkg/MdeModulePkg.dec
> +  KabylakeOpenBoardPkg/OpenBoardPkg.dec
> +  BoardModulePkg/BoardModulePkg.dec
> +
> +[Sources]
> +  Ps2KbcLib.c
> +  Ps2KbcLib.h
> +
> +[LibraryClasses]
> +  DevicePathLib
> +  DebugLib
> +  IoLib
> +  UefiDriverEntryPoint
> +  UefiBootManagerLib
> +  UefiLib
> +  TimerLib
> +
> +[Pcd]
> +  gBoardModulePkgTokenSpaceGuid.PcdPs2KbMsEnable
> +  gBoardModulePkgTokenSpaceGuid.PcdSuperIoPciIsaBridgeDevice
> --
> 2.19.1.windows.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [edk2-devel] [edk2-platforms] [PATCH 0/5] Enable Ps2 keyboard
  2019-11-01 19:51 [edk2-platforms] [PATCH 0/5] Enable Ps2 keyboard Agyeman, Prince
                   ` (4 preceding siblings ...)
  2019-11-01 19:51 ` [edk2-platforms] [PATCH 5/5] KabylakeOpenBoardPkg: Add Ps2 Keyboard Support Agyeman, Prince
@ 2019-11-04 18:18 ` Kubacki, Michael A
  5 siblings, 0 replies; 16+ messages in thread
From: Kubacki, Michael A @ 2019-11-04 18:18 UTC (permalink / raw)
  To: devel@edk2.groups.io, Agyeman, Prince

Hi Prince,

There's some high-level changes I suggest to the patch series:
1. This patch series mixes changes across packages in single patches
   which should be avoided.

2. Some of the patches include unrelated changes that would make git
   revert difficult.
   2.a. Example: In patch #1, one change is to add
        gBoardModulePkgTokenSpaceGuid. This is a pre-requisite for
        adding the PCDs to BoardModulePkg.dec but still an isolated
        change. If someone were to add more commits in the future
        that rely upon gBoardModulePkgTokenSpaceGuid and then wanted
        to revert the PS/2 keyboard change it would be difficult due to
        the coupling.
   2.b. Example: In patch #3, a change is made that affects all
        driver consumers in BoardModulePkg/LegacySioDxe but the commit
        includes changes for enabling the driver in SimicsOpenBoardPkg.
        The change to enable PS/2 keyboard/mouse in SimicsOpenBoardPkg
        could not easily be reverted without affecting the overall driver.

3. The order of changes leaves some earlier commits incomplete.
   3.a. For example, patch #1 exposes a PCD interface in BoardModulePkg
        that is effectively not used until later patches so using the
        PCDs at that point in the commit log would be misleading.

As far as I can tell, there's a high-level order to do the following:
1. Define gBoardModulePkgTokenSpaceGuid in BoardModulePkg.dec
2. Remove the LegacySioDxe driver from SimicsOpenBoardPkg
3. Add the LegacySioDxe driver to BoardModulePkg
4. Add new PCDs to BoardModulePkg for usage with LegacySioDxe
5. Update relevant boards in KabylakeOpenBoardPkg to use the LegacySioDxe
   driver and PCDs from BoardModulePkg, remove the now redundant PCD
   gKabylakeOpenBoardPkgTokenSpaceGuid.PcdPs2KbMsEnable in
   KabylakeOpenBoardPkg/OpenBoardPkg.dec, configure the relevant PCDs
   in BoardModulePkg in the board DSC files to properly use the
   LegacySioDxe driver.
6. Add the Ps2KbcLib changes in KabylakeOpenBoardPkg as currently done
   in V1 patches #4 and #5.
7. Do the same as #5 for SimicsOpenBoardPkg.
8. Explicitly set gBoardModulePkgTokenSpaceGuid.PcdPs2KbMsEnable
   in WhiskeylakeOpenBoardPkg/WhiskeylakeURvp.

Thanks,
Michael
> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of
> Agyeman, Prince
> Sent: Friday, November 1, 2019 12:51 PM
> To: devel@edk2.groups.io
> Subject: [edk2-devel] [edk2-platforms] [PATCH 0/5] Enable Ps2 keyboard
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2228
> 
> This patch series enables BIOS Ps2 keyboard in GalagoPro3
> 
> 
> What was done:
> Patch 0001 adds PCDs to BoardModulePkg that will enable/disable, describe
> Super I/O , Ps2 keyboard/mouse, uart1 and uart2 com ports
> 
> Patch 0002 moves the generic Super I/O driver from SimicsOpenBoardPkg to
> BoardModulePkg in order for it to be shared. This driver publishes the
> gEfiSioProtocolGuid consumed by edk2's
> MdeModulePkg/Bus/Isa/Ps2KeyboardDxe
> driver to enable Ps2 keyboard functions in BIOS
> 
> Patch 0003 adds PCDs defined in patch 0001 to enable/disable devices in the
> Super I/O driver added in patch 0002
> 
> Patch 0004 adds a Null Ps2 Library that adds Ps2 keyboard device path to
> ConIn and ConInDev
> 
> Patch 0005 enables Ps2 keyboard in BIOS by setting Ps2 keyboard related
> PCDs Prince Agyeman (5):
>   Platform/Intel: Add gBoardModulePkgTokenSpaceGuid
>   Platform/Intel: Move Sio Dxe Driver
>   BoardModulePkg: Added Pcds Sio Driver
>   KabylakeOpenBoardPkg: Add Ps2 keyboard Null Library
>   KabylakeOpenBoardPkg: Add Ps2 Keyboard Support
> 
>  .../Intel/BoardModulePkg/BoardModulePkg.dec   |  25 +++
>  .../Intel/BoardModulePkg/BoardModulePkg.dsc   |   1 +
>  .../LegacySioDxe/ComponentName.c              |   0
>  .../LegacySioDxe/ComponentName.h              |   0
>  .../LegacySioDxe/LegacySioDxe.inf             |  18 +-
>  .../LegacySioDxe/Register.h                   |   0
>  .../LegacySioDxe/SioChip.c                    |  71 +++++-
>  .../LegacySioDxe/SioChip.h                    |  18 +-
>  .../LegacySioDxe/SioDriver.c                  |  42 +++-
>  .../LegacySioDxe/SioDriver.h                  |   1 -
>  .../LegacySioDxe/SioService.c                 |   0
>  .../LegacySioDxe/SioService.h                 |   0
>  .../BoardAcpiLib/DxeBoardAcpiTableLib.inf     |   3 +-
>  .../DxeMultiBoardAcpiSupportLib.inf           |   3 +-
>  .../GalagoPro3/Library/Ps2KbcLib/Ps2KbcLib.c  | 202 ++++++++++++++++++
> .../GalagoPro3/Library/Ps2KbcLib/Ps2KbcLib.h  |  65 ++++++
>  .../Library/Ps2KbcLib/Ps2KbcLib.inf           |  39 ++++
>  .../GalagoPro3/OpenBoardPkg.dsc               |   7 +
>  .../GalagoPro3/OpenBoardPkg.fdf               |   2 +
>  .../GalagoPro3/OpenBoardPkgPcd.dsc            |   6 +
>  .../BoardAcpiLib/DxeBoardAcpiTableLib.inf     |   3 +-
>  .../DxeMultiBoardAcpiSupportLib.inf           |   3 +-
>  .../KabylakeRvp3/OpenBoardPkgPcd.dsc          |   5 +
>  .../KabylakeOpenBoardPkg/OpenBoardPkg.dec     |   2 -
>  .../BoardX58Ich10/OpenBoardPkg.dsc            |   2 +-
>  .../BoardX58Ich10/OpenBoardPkg.fdf            |   2 +-
>  .../BoardX58Ich10/OpenBoardPkgPcd.dsc         |   6 +
>  .../WhiskeylakeOpenBoardPkg/OpenBoardPkg.dec  |   1 -
>  .../WhiskeylakeURvp/OpenBoardPkgPcd.dsc       |   5 +
>  29 files changed, 499 insertions(+), 33 deletions(-)  rename
> Platform/Intel/{SimicsOpenBoardPkg =>
> BoardModulePkg}/LegacySioDxe/ComponentName.c (100%)  rename
> Platform/Intel/{SimicsOpenBoardPkg =>
> BoardModulePkg}/LegacySioDxe/ComponentName.h (100%)  rename
> Platform/Intel/{SimicsOpenBoardPkg =>
> BoardModulePkg}/LegacySioDxe/LegacySioDxe.inf (63%)  rename
> Platform/Intel/{SimicsOpenBoardPkg =>
> BoardModulePkg}/LegacySioDxe/Register.h (100%)  rename
> Platform/Intel/{SimicsOpenBoardPkg =>
> BoardModulePkg}/LegacySioDxe/SioChip.c (75%)  rename
> Platform/Intel/{SimicsOpenBoardPkg =>
> BoardModulePkg}/LegacySioDxe/SioChip.h (90%)  rename
> Platform/Intel/{SimicsOpenBoardPkg =>
> BoardModulePkg}/LegacySioDxe/SioDriver.c (88%)  rename
> Platform/Intel/{SimicsOpenBoardPkg =>
> BoardModulePkg}/LegacySioDxe/SioDriver.h (95%)  rename
> Platform/Intel/{SimicsOpenBoardPkg =>
> BoardModulePkg}/LegacySioDxe/SioService.c (100%)  rename
> Platform/Intel/{SimicsOpenBoardPkg =>
> BoardModulePkg}/LegacySioDxe/SioService.h (100%)  create mode 100644
> Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/Ps2K
> bcLib.c
>  create mode 100644
> Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/Ps2K
> bcLib.h
>  create mode 100644
> Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/Ps2KbcLib/Ps2K
> bcLib.inf
> 
> --
> 2.19.1.windows.1
> 
> 
> 


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [edk2-platforms] [PATCH 3/5] BoardModulePkg: Added Pcds Sio Driver
  2019-11-01 19:51 ` [edk2-platforms] [PATCH 3/5] BoardModulePkg: Added Pcds Sio Driver Agyeman, Prince
  2019-11-01 21:55   ` [edk2-devel] " Nate DeSimone
@ 2019-11-04 18:19   ` Kubacki, Michael A
  1 sibling, 0 replies; 16+ messages in thread
From: Kubacki, Michael A @ 2019-11-04 18:19 UTC (permalink / raw)
  To: devel@edk2.groups.io, Agyeman, Prince; +Cc: Chiu, Chasel, Desimone, Nathaniel L

Please fix style formatting, especially in this function:

/**
  Gets the number of devices in Table of SIO Controllers mDeviceInfo

  @retval     Number of enabled devices in Table of SIO Controllers.
**/
UINTN
EFIAPI
GetDeviceCount(
  VOID
){
   UINTN        Count;
   Count = ARRAY_SIZE(mDeviceInfo) - 1; // -1 to account for for the end device info
   return Count;
}

This patch contains a change in SimicsOpenBoardPkg, as I suggested in the reply to the cover
letter, I believe that is better in a separate patch.

Thanks,
Michael

> -----Original Message-----
> From: Agyeman, Prince <prince.agyeman@intel.com>
> Sent: Friday, November 1, 2019 12:51 PM
> To: devel@edk2.groups.io
> Cc: Kubacki, Michael A <michael.a.kubacki@intel.com>; Chiu, Chasel
> <chasel.chiu@intel.com>; Desimone, Nathaniel L
> <nathaniel.l.desimone@intel.com>
> Subject: [edk2-platforms] [PATCH 3/5] BoardModulePkg: Added Pcds Sio
> Driver
> 
> Included PCDs to the Sio dxe driver,
> to allow the enable/disable of Ps2 keyboard/mouse,
> UART1 and UART2 com ports.
> 
> Renamed the Sio driver's base name
> 
> Cc: Michael Kubacki <michael.a.kubacki@intel.com>
> Cc: Chasel Chiu <chasel.chiu@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
> 
> Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
> ---
>  .../LegacySioDxe/LegacySioDxe.inf             | 15 +++-
>  .../BoardModulePkg/LegacySioDxe/SioChip.c     | 69 +++++++++++++++++--
>  .../BoardModulePkg/LegacySioDxe/SioChip.h     | 10 +++
>  .../BoardModulePkg/LegacySioDxe/SioDriver.c   | 42 ++++++++++-
>  .../BoardX58Ich10/OpenBoardPkgPcd.dsc         |  6 ++
>  5 files changed, 133 insertions(+), 9 deletions(-)
> 
> diff --git a/Platform/Intel/BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
> b/Platform/Intel/BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
> index d606ba43dc..4ab01a6098 100644
> --- a/Platform/Intel/BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
> +++ b/Platform/Intel/BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
> @@ -10,7 +10,7 @@
> 
>  [Defines]
>    INF_VERSION                    = 0x00010017
> -  BASE_NAME                      = HitachiH8s2113Dxe
> +  BASE_NAME                      = LegacySioDxe
>    FILE_GUID                      = 7807E404-8281-4FF1-8457-0B54BABE263F
>    VERSION_STRING                 = 1.0
>    MODULE_TYPE                    = UEFI_DRIVER
> @@ -34,6 +34,7 @@
>  [Packages]
>    MdePkg/MdePkg.dec
>    MdeModulePkg/MdeModulePkg.dec
> +  BoardModulePkg/BoardModulePkg.dec
> 
>  [Sources]
>    SioChip.c
> @@ -44,6 +45,18 @@
>    SioDriver.h
>    ComponentName.c
> 
> +[Pcd]
> +  gBoardModulePkgTokenSpaceGuid.PcdPs2KbMsEnable
> +  gBoardModulePkgTokenSpaceGuid.PcdUart1Enable
> +  gBoardModulePkgTokenSpaceGuid.PcdUart1IrqMask
> +  gBoardModulePkgTokenSpaceGuid.PcdUart1IoPort
> +  gBoardModulePkgTokenSpaceGuid.PcdUart1Length
> +  gBoardModulePkgTokenSpaceGuid.PcdUart2Enable
> +  gBoardModulePkgTokenSpaceGuid.PcdUart2IrqMask
> +  gBoardModulePkgTokenSpaceGuid.PcdUart2IoPort
> +  gBoardModulePkgTokenSpaceGuid.PcdUart2Length
> +  gBoardModulePkgTokenSpaceGuid.PcdSuperIoPciIsaBridgeDevice
> +
>  [Protocols]
>    gEfiPciIoProtocolGuid                         ## CONSUMES
>    gEfiDevicePathProtocolGuid                    ## PRODUCES
> diff --git a/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.c
> b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.c
> index 81efe3c38b..09403a7354 100644
> --- a/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.c
> +++ b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.c
> @@ -19,12 +19,31 @@
>  ACPI_SIO_RESOURCES_IO_IRQ      mCom1Resources = {
>    {
>      { ACPI_FIXED_LOCATION_IO_PORT_DESCRIPTOR },
> -    0x3f8,
> -    8
> +      FixedPcdGet16 (PcdUart1IoPort),
> +      FixedPcdGet8 (PcdUart1Length)
> +    },
> +    {
> +      { ACPI_IRQ_NOFLAG_DESCRIPTOR },
> +      FixedPcdGet16 (PcdUart1IrqMask)
> +    },
> +    {
> +      ACPI_END_TAG_DESCRIPTOR,
> +      0
> +    }
> +};
> +
> +//
> +// COM 2 UART Controller
> +//
> +ACPI_SIO_RESOURCES_IO_IRQ      mCom2Resources = {
> +  {
> +    { ACPI_FIXED_LOCATION_IO_PORT_DESCRIPTOR },
> +    FixedPcdGet16 (PcdUart2IoPort),
> +    FixedPcdGet8 (PcdUart2Length)
>    },
>    {
>      { ACPI_IRQ_NOFLAG_DESCRIPTOR },
> -    BIT4    // IRQ4
> +    FixedPcdGet16 (PcdUart2IrqMask),
>    },
>    {
>      ACPI_END_TAG_DESCRIPTOR,
> @@ -70,10 +89,12 @@ ACPI_SIO_RESOURCES_IO_IRQ      mMouseResources
> = {
>    }
>  };
> 
> +
>  //
>  // Table of SIO Controllers
>  //
>  DEVICE_INFO    mDeviceInfo[] = {
> +#if FixedPcdGet8 (PcdUart1Enable) == DEVICE_ENABLED
>    {
>      {
>        EISA_PNP_ID(0x501),
> @@ -84,6 +105,20 @@ DEVICE_INFO    mDeviceInfo[] = {
>      { (ACPI_SMALL_RESOURCE_HEADER *) &mCom1Resources },
>      { (ACPI_SMALL_RESOURCE_HEADER *) &mCom1Resources }
>    },  // COM 1 UART Controller
> +#endif
> +#if FixedPcdGet8 (PcdUart2Enable) == DEVICE_ENABLED
> +  {
> +    {
> +      EISA_PNP_ID(0x501),
> +      0
> +    },
> +    0,
> +    RESOURCE_IO | RESOURCE_IRQ,
> +    { (ACPI_SMALL_RESOURCE_HEADER *) &mCom2Resources },
> +    { (ACPI_SMALL_RESOURCE_HEADER *) &mCom2Resources }
> +  },  // COM 2 UART Controller
> +#endif
> +#if FixedPcdGet8 (PcdPs2KbMsEnable) == DEVICE_ENABLED
>    {
>      {
>        EISA_PNP_ID(0x303),
> @@ -103,10 +138,28 @@ DEVICE_INFO    mDeviceInfo[] = {
>      0,  // Cannot change resource
>      { (ACPI_SMALL_RESOURCE_HEADER *) &mMouseResources },
>      { (ACPI_SMALL_RESOURCE_HEADER *) &mMouseResources }
> -  }  // PS/2 Mouse Controller
> +  },  // PS/2 Mouse Controller
> +#endif
> +  DEVICE_INFO_END
>  };
> 
> 
> +
> +/**
> +  Gets the number of devices in Table of SIO Controllers mDeviceInfo
> +
> +  @retval     Number of enabled devices in Table of SIO Controllers.
> +**/
> +UINTN
> +EFIAPI
> +GetDeviceCount(
> +  VOID
> +){
> +   UINTN        Count;
> +   Count = ARRAY_SIZE(mDeviceInfo) - 1; // -1 to account for for the end
> device info
> +   return Count;
> +}
> +
>  /**
>    Return the supported devices.
> 
> @@ -128,7 +181,7 @@ DeviceGetList (
>    //
>    // Allocate enough memory for simplicity
>    //
> -  DeviceCount =  sizeof (mDeviceInfo) / sizeof (mDeviceInfo[0]);
> +  DeviceCount = GetDeviceCount();
>    LocalDevices = AllocatePool (sizeof (EFI_SIO_ACPI_DEVICE_ID) *
> DeviceCount);
>    ASSERT (LocalDevices != NULL);
>    if (LocalDevices == NULL) {
> @@ -157,7 +210,6 @@ SioInit (
>    VOID
>    )
>  {
> -
>    return EFI_SUCCESS;
>  }
> 
> @@ -175,8 +227,11 @@ DeviceSearch (
>    )
>  {
>    UINTN       Index;
> +  UINTN       DeviceCount;
> +
> +  DeviceCount = GetDeviceCount();
> 
> -  for (Index = 0; Index < sizeof (mDeviceInfo) / sizeof (mDeviceInfo[0]);
> Index++) {
> +  for (Index = 0; Index < DeviceCount; Index++) {
>      if (CompareMem (Device, &mDeviceInfo[Index].Device, sizeof (*Device))
> == 0) {
>        return &mDeviceInfo[Index];
>      }
> diff --git a/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.h
> b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.h
> index 9322365923..8bd53ccdd6 100644
> --- a/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.h
> +++ b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioChip.h
> @@ -24,6 +24,9 @@ UINT8
>  #define RESOURCE_DMA   BIT2
>  #define RESOURCE_MEM   BIT3
> 
> +#define DEVICE_ENABLED  0x01
> +#define DEVICE_INFO_END { { 0xFFFFFFFF, 0xFFFFFFFF } }
> +
>  #pragma pack(1)
> 
>  typedef struct {
> @@ -46,6 +49,13 @@ typedef struct {
>    ACPI_RESOURCE_HEADER_PTR    PossibleResources;
>  } DEVICE_INFO;
> 
> +typedef struct {
> +  UINT8 Segment;
> +  UINT8 Bus;
> +  UINT8 Device;
> +  UINT8 Funtion;
> +} SIO_PCI_ISA_BRIDGE_DEVICE_INFO;
> +
>  /**
>    Return the supported devices.
> 
> diff --git a/Platform/Intel/BoardModulePkg/LegacySioDxe/SioDriver.c
> b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioDriver.c
> index 408c6ff301..5ab9109ad9 100644
> --- a/Platform/Intel/BoardModulePkg/LegacySioDxe/SioDriver.c
> +++ b/Platform/Intel/BoardModulePkg/LegacySioDxe/SioDriver.c
> @@ -8,7 +8,6 @@
> 
>  #include "SioDriver.h"
> 
> -
>  //
>  // This driver is for ACPI(PNP0A03,0)/PCI(0x1f,0)  // @@ -106,6 +105,27 @@
> SioDriverEntryPoint (  }
> 
> 
> +/**
> +  Compares a PCI to ISA bridge device segment, bus, device and function
> +to the
> +  PcdSuperIoPciIsaBridgeDevice values.
> +
> +  @param[in]  CurrentDevice       The device to be compared with the
> PcdSuperIoPciIsaBridgeDevice information
> +  @retval     TRUE                This device matches PcdSuperIoPciIsaBridgeDevice
> values
> +  @retval     FALSE               This device does not match the
> PcdSuperIoPciIsaBridgeDevice values
> +**/
> +BOOLEAN
> +EFIAPI
> +SioDeviceEnabled (
> +  IN SIO_PCI_ISA_BRIDGE_DEVICE_INFO *CurrentDevice ){
> +    SIO_PCI_ISA_BRIDGE_DEVICE_INFO *Device = \
> +      (SIO_PCI_ISA_BRIDGE_DEVICE_INFO *) FixedPcdGetPtr
> (PcdSuperIoPciIsaBridgeDevice);
> +    if(CompareMem (Device, CurrentDevice, sizeof
> (SIO_PCI_ISA_BRIDGE_DEVICE_INFO)) == 0) {
> +      return TRUE;
> +    }
> +    return FALSE;
> +}
> +
>  /**
>    Test to see if this driver supports Controller Handle.
> 
> @@ -138,6 +158,7 @@ SioDriverSupported (
>    UINTN                     BusNumber;
>    UINTN                     DeviceNumber;
>    UINTN                     FunctionNumber;
> +  SIO_PCI_ISA_BRIDGE_DEVICE_INFO  SioDevice;
> 
>    //
>    // If RemainingDevicePath is not NULL, it should verify that the first device
> @@ -250,6 +271,25 @@ SioDriverSupported (
>              Status = EFI_UNSUPPORTED;
>            }
>          }
> +
> +        if(!EFI_ERROR (Status)) {
> +          Status = PciIo->GetLocation (
> +                            PciIo,
> +                            &SegmentNumber,
> +                            &BusNumber,
> +                            &DeviceNumber,
> +                            &FunctionNumber
> +                            );
> +          if(!EFI_ERROR (Status)) {
> +            SioDevice.Segment = (UINT8) SegmentNumber;
> +            SioDevice.Bus = (UINT8) BusNumber;
> +            SioDevice.Device = (UINT8) DeviceNumber;
> +            SioDevice.Funtion = (UINT8) FunctionNumber;
> +            if(!SioDeviceEnabled (&SioDevice)) {
> +              Status = EFI_UNSUPPORTED;
> +            }
> +          }
> +        }
>        }
>      }
> 
> diff --git
> a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.ds
> c
> b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.ds
> c
> index 0298e4b12d..b85991b772 100644
> ---
> a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.ds
> c
> +++
> b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.ds
> +++ c
> @@ -196,6 +196,12 @@
>    gMinPlatformPkgTokenSpaceGuid.PcdMaxCpuThreadCount|4
>    gMinPlatformPkgTokenSpaceGuid.PcdPcIoApicAddressBase|0xFEC01000
> 
> +  ######################################
> +  # Board Configuration
> +  ######################################
> +  gBoardModulePkgTokenSpaceGuid.PcdPs2KbMsEnable|1
> +
> +
> gBoardModulePkgTokenSpaceGuid.PcdSuperIoPciIsaBridgeDevice|{0x00,0x0
> 0,
> + 0x1F,0x00}
> +
>  [PcdsFixedAtBuild.X64]
>    ######################################
>    # Edk2 Configuration
> --
> 2.19.1.windows.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2019-11-04 18:19 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-11-01 19:51 [edk2-platforms] [PATCH 0/5] Enable Ps2 keyboard Agyeman, Prince
2019-11-01 19:51 ` [edk2-platforms] [PATCH 1/5] Platform/Intel: Add gBoardModulePkgTokenSpaceGuid Agyeman, Prince
2019-11-01 21:55   ` Nate DeSimone
2019-11-01 19:51 ` [edk2-platforms] [PATCH 2/5] Platform/Intel: Move Sio Dxe Driver Agyeman, Prince
2019-11-01 21:55   ` Nate DeSimone
2019-11-04  9:15   ` Chiu, Chasel
2019-11-01 19:51 ` [edk2-platforms] [PATCH 3/5] BoardModulePkg: Added Pcds Sio Driver Agyeman, Prince
2019-11-01 21:55   ` [edk2-devel] " Nate DeSimone
2019-11-04 18:19   ` Kubacki, Michael A
2019-11-01 19:51 ` [edk2-platforms] [PATCH 4/5] KabylakeOpenBoardPkg: Add Ps2 keyboard Null Library Agyeman, Prince
2019-11-01 21:55   ` Nate DeSimone
2019-11-04  9:03   ` Chiu, Chasel
2019-11-04 17:17     ` Agyeman, Prince
2019-11-01 19:51 ` [edk2-platforms] [PATCH 5/5] KabylakeOpenBoardPkg: Add Ps2 Keyboard Support Agyeman, Prince
2019-11-01 21:54   ` [edk2-devel] " Nate DeSimone
2019-11-04 18:18 ` [edk2-devel] [edk2-platforms] [PATCH 0/5] Enable Ps2 keyboard Kubacki, Michael A

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox