From: Laszlo Ersek <lersek@redhat.com>
To: edk2-devel-01 <edk2-devel@ml01.01.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Subject: [PATCH] OvmfPkg/SmmControl2Dxe: correct PCI_CONFIG_READ_WRITE in S3 boot script
Date: Fri, 2 Dec 2016 11:48:44 +0100 [thread overview]
Message-ID: <20161202104844.6093-1-lersek@redhat.com> (raw)
EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE expects the PCI address to
access in UEFI encoding, not in edk2/PciLib encoding. Convert the
ICH9_GEN_PMCON_1 register's address to UEFI representation before storing
it in the boot script.
Cc: Jordan Justen <jordan.l.justen@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.c | 32 +++++++++++++++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)
diff --git a/OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.c b/OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.c
index c5e5ed02f5ad..3694282c82ad 100644
--- a/OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.c
+++ b/OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.c
@@ -33,6 +33,7 @@
#include <Library/PciLib.h>
#include <Library/QemuFwCfgLib.h>
#include <Library/UefiBootServicesTableLib.h>
+#include <Protocol/PciRootBridgeIo.h>
#include <Protocol/S3SaveState.h>
#include <Protocol/SmmControl2.h>
@@ -307,6 +308,33 @@ FatalError:
}
/**
+ Convert a PCI address originally composed with PCI_LIB_ADDRESS() to
+ EFI_PCI_ADDRESS() representation (see Table 111. "PCI Configuration Address"
+ in UEFI-2.6).
+
+ @param[in] PciLibAddress A PCI address originally composed with
+ PCI_LIB_ADDRESS().
+
+ @return The converted address suitable for consumers that expect
+ EFI_PCI_ADDRESS() representation.
+**/
+STATIC
+UINT64
+ConvertPciLibToEfiPciAddress (
+ IN UINT32 PciLibAddress
+ )
+{
+ UINT32 Bus, Device, Function, Register;
+
+ Register = BitFieldRead32 (PciLibAddress, 0, 11);
+ Function = BitFieldRead32 (PciLibAddress, 12, 14);
+ Device = BitFieldRead32 (PciLibAddress, 15, 19);
+ Bus = BitFieldRead32 (PciLibAddress, 20, 27);
+
+ return EFI_PCI_ADDRESS (Bus, Device, Function, Register);
+}
+
+/**
Notification callback for S3SaveState installation.
@param[in] Event Event whose notification function is being invoked.
@@ -362,7 +390,9 @@ OnS3SaveStateInstalled (
S3SaveState,
EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE,
EfiBootScriptWidthUint16,
- (UINT64)POWER_MGMT_REGISTER_Q35 (ICH9_GEN_PMCON_1),
+ ConvertPciLibToEfiPciAddress (
+ POWER_MGMT_REGISTER_Q35 (ICH9_GEN_PMCON_1)
+ ),
&GenPmCon1OrMask,
&GenPmCon1AndMask
);
--
2.9.2
next reply other threads:[~2016-12-02 10:48 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-02 10:48 Laszlo Ersek [this message]
2017-01-03 11:41 ` [PATCH] OvmfPkg/SmmControl2Dxe: correct PCI_CONFIG_READ_WRITE in S3 boot script Laszlo Ersek
2017-01-04 1:30 ` Jordan Justen
2017-01-04 11:19 ` Laszlo Ersek
2017-01-04 22:01 ` Jordan Justen
2017-01-05 1:03 ` Yao, Jiewen
2017-01-05 1:45 ` Yao, Jiewen
2017-01-05 11:47 ` Laszlo Ersek
2017-01-05 13:09 ` Yao, Jiewen
2017-01-05 13:15 ` Laszlo Ersek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161202104844.6093-1-lersek@redhat.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox