]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg: enable PIIX4 IO space in the PEI phase
authorjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 12 Sep 2012 07:19:16 +0000 (07:19 +0000)
committerjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 12 Sep 2012 07:19:16 +0000 (07:19 +0000)
I. There are at least three locations in OvmfPkg that manipulate the PMBA
and related PIIX4 registers.

1. MiscInitialization() [OvmfPkg/PlatformPei/Platform.c]
   module type: PEIM -- Pre-EFI Initialization Module
   (a) currently sets the PMBA only: 00.01.3 / 0x40 bits [15:6]

2. AcpiTimerLibConstructor() [OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.c]
   module type: BASE -- probably callable anywhere after PEI
   (a) sets the PMBA if needed:      00.01.3 / 0x40 bits [15:6]
   (b) sets PCICMD/IOSE if needed:   00.01.3 / 0x04 bit  0
   (c) sets PMREGMISC/PMIOSE:        00.01.3 / 0x80 bit  0

3. AcpiInitialization() [OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c]
   module type: DXE_DRIVER -- Driver eXecution Environment
   (a) sets SCI_EN, which depends on correct PMBA setting from earlier

(
  The relative order of #1 and #3 is dictated minimally by their module
  types. Said relative order can be verified with the boot log:

       27 Loading PEIM at 0x00000822320 EntryPoint=0x00000822580
          PlatformPei.efi
       28 Platform PEIM Loaded
     1259 PlatformBdsInit
     1270 PlatformBdsPolicyBehavior

  Line 28 is printed by InitializePlatform()
  [OvmfPkg/PlatformPei/Platform.c] which is the entry point of that
  module. The other two lines are printed by the corresponding functions
  in "OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c".
)

Currently #2 (AcpiTimerLibConstructor()) is called in a random spot
(whenever it gets loaded from the firmware image) and masks the
insufficient setup in #1. We shouldn't depend on that, PEI should finish
with IO space being fully accessibe. In addition, PEI should program the
same PMBA value as AcpiTimerLib.

II. The PEI change notwithstanding, AcpiTimerLib should stay defensive and
ensure proper PM configuration for itself (either by confirming or by
doing).

III. Considering a possible cleanup/unification of #2 and #3: timer
functions relying on AcpiTimerLibConstructor(),

- MicroSecondDelay()
- NanoSecondDelay()
- GetPerformanceCounter()
- GetPerformanceCounterProperties()
- GetTimeInNanoSecond()

may be called before #3 is reached (in Boot Device Selection phase), so we
should not move the initialization from #2 to #3. (Again, AcpiTimerLib
should contain its own setup.)

We should also not move #3 to an earlier phase -- SCI_EN is premature
unless we're about to boot real soon ("enable generation of SCI upon
assertion of PWRBTN_STS, LID_STS, THRM_STS, or GPI_STS bits").

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13722 6f19259b-4bc3-4df7-8a09-765794883524

OvmfPkg/PlatformPei/Platform.c
OvmfPkg/PlatformPei/PlatformPei.inf

index 589c5c3804f27d61a8e1842d7bb71f257b5465fd..ce149e4f979e2c6589fa383ebc2b4232e9df99dc 100644 (file)
@@ -33,6 +33,7 @@
 #include <Library/ResourcePublicationLib.h>\r
 #include <Guid/MemoryTypeInformation.h>\r
 #include <Ppi/MasterBootMode.h>\r
+#include <IndustryStandard/Pci22.h>\r
 \r
 #include "Platform.h"\r
 #include "Cmos.h"\r
@@ -228,9 +229,27 @@ MiscInitialization (
 \r
   if (!Xen) {\r
     //\r
-    // Set the PM I/O base address to 0x400\r
+    // The PEI phase should be exited with fully accessibe PIIX4 IO space:\r
+    // 1. set PMBA\r
     //\r
-    PciAndThenOr32 (PCI_LIB_ADDRESS (0, 1, 3, 0x40), (UINT32) ~0xFFC0, 0x400);\r
+    PciAndThenOr32 (\r
+      PCI_LIB_ADDRESS (0, 1, 3, 0x40),\r
+      (UINT32) ~0xFFC0,\r
+      PcdGet16 (PcdAcpiPmBaseAddress)\r
+      );\r
+\r
+    //\r
+    // 2. set PCICMD/IOSE\r
+    //\r
+    PciOr8 (\r
+      PCI_LIB_ADDRESS (0, 1, 3, PCI_COMMAND_OFFSET),\r
+      EFI_PCI_COMMAND_IO_SPACE\r
+      );\r
+\r
+    //\r
+    // 3. set PMREGMISC/PMIOSE\r
+    //\r
+    PciOr8 (PCI_LIB_ADDRESS (0, 1, 3, 0x80), 0x01);\r
   }\r
 }\r
 \r
index 8742008c0d409c1f9b7b84920a8b43f936bd1159..3d5cbbbc2b59dd1bcd3629ff89e5378d3cb61156 100644 (file)
@@ -60,6 +60,7 @@
 [Pcd]\r
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfMemFvBase\r
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfMemFvSize\r
+  gUefiOvmfPkgTokenSpaceGuid.PcdAcpiPmBaseAddress\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize\r