pci direct: Allow a preset MMConf address per `Dev` instance
In virtualized environments (e.g. PCI pass-through), it's possible
that the MMConf/ECAM space might not be fully mapped into the guest,
so allow to override it per device.
Change-Id: I2447cec8e413e746f492c0e32126b34a7bfb2195
Signed-off-by: Nico Huber <nico.huber@secunet.com>
Reviewed-on: https://review.sourcearcade.org/c/libhwbase/+/550
Tested-by: Ada SPARK <gnatbot@sourcearcade.org>
Reviewed-by: Thomas Heijligen <src@posteo.de>
diff --git a/common/direct/hw-pci-dev.adb b/common/direct/hw-pci-dev.adb
index 8a1a56b..903dde1 100644
--- a/common/direct/hw-pci-dev.adb
+++ b/common/direct/hw-pci-dev.adb
@@ -25,7 +25,7 @@
PCI_State => MM.PCI_State)
is
- package MM is new HW.PCI.MMConf (Dev);
+ package MM is new HW.PCI.MMConf (Dev, MMConf_Base);
procedure Read8 (Value : out Word8; Offset : Index) renames MM.Read8;
procedure Read16 (Value : out Word16; Offset : Index) renames MM.Read16;
@@ -103,7 +103,9 @@
Write16 (PCI.Command, Cmd);
end Resource_Size;
- procedure Initialize (Success : out Boolean; MMConf_Base : Word64 := 0)
+ procedure Initialize
+ (Success : out Boolean;
+ MMConf_Base : in Word64 := PCI.Dev.MMConf_Base)
is
begin
if MMConf_Base /= 0 then