Patrick Georgi has uploaded this change for review. ( https://review.coreboot.org/c/libhwbase/+/55167 )
Change subject: Make gcc11 compatible ......................................................................
Make gcc11 compatible
It's much more picky when dealing with arrays containing volatile or atomic members.
Meanwhile System.Address_To_Access_Conversions doesn't seem to be able to return an element with atomic/volatile aspect, so everything fell apart.
Entire untested except that it builds (for me)
Change-Id: Ieb50c4dd8ba96248c3051a7282f9e5cdbb270344 Signed-off-by: Patrick Georgi pgeorgi@google.com --- M ada/dynamic_mmio/hw-mmio_range.adb M common/hw-mmio_range.ads M common/hw-pci-dev.ads M common/hw-pci-mmconf.adb M common/hw-pci-mmconf.ads 5 files changed, 30 insertions(+), 31 deletions(-)
git pull ssh://review.coreboot.org:29418/libhwbase refs/changes/67/55167/1
diff --git a/ada/dynamic_mmio/hw-mmio_range.adb b/ada/dynamic_mmio/hw-mmio_range.adb index 86c8d1b..60cbbd5 100644 --- a/ada/dynamic_mmio/hw-mmio_range.adb +++ b/ada/dynamic_mmio/hw-mmio_range.adb @@ -14,14 +14,12 @@
with HW.Debug; with GNAT.Source_Info; -with System.Storage_Elements; -with System.Address_To_Access_Conversions;
package body HW.MMIO_Range with Refined_State => - (State => null, -- the contents accessed, Range_A points to it - Base_Address => Range_A) -- the address, stored in Range_A + (State => null, -- the contents accessed, Base points to it + Base_Address => (Base, Range_A)) -- the address, stored in Base is pragma Warnings (Off, "implicit dereference", Reason => "This is what this package is about."); @@ -29,12 +27,6 @@ Debug_Reads : constant Boolean := False; Debug_Writes : constant Boolean := False;
- type Range_Access is access all Array_T; - package Conv_Range is new System.Address_To_Access_Conversions (Array_T); - - Range_A : Range_Access := - Range_Access (Conv_Range.To_Pointer (System'To_Address (Base_Addr))); - procedure Read (Value : out Element_T; Index : in Index_T) is use type Word32; @@ -45,9 +37,8 @@ pragma Debug (Debug_Reads, Debug.Put_Word32 (Word32 (Value))); pragma Debug (Debug_Reads, Debug.Put (" <- ")); pragma Debug (Debug_Reads, Debug.Put_Word32 - (Word32 (System.Storage_Elements.To_Integer - (Conv_Range.To_Address (Conv_Range.Object_Pointer (Range_A)))) + - Word32 (Index) * (Element_T'Size / 8))); + (Word32 (System.Storage_Elements.To_Integer (Base)) + + Word32 (Index) * (Element_T'Size / 8))); pragma Debug (Debug_Reads, Debug.New_Line); end Read;
@@ -60,17 +51,17 @@ pragma Debug (Debug_Writes, Debug.Put_Word32 (Word32 (Value))); pragma Debug (Debug_Writes, Debug.Put (" -> ")); pragma Debug (Debug_Writes, Debug.Put_Word32 - (Word32 (System.Storage_Elements.To_Integer - (Conv_Range.To_Address (Conv_Range.Object_Pointer (Range_A)))) + - Word32 (Index) * (Element_T'Size / 8))); + (Word32 (System.Storage_Elements.To_Integer (Base)) + + Word32 (Index) * (Element_T'Size / 8))); pragma Debug (Debug_Writes, Debug.New_Line); Range_A (Index) := Value; end Write;
- procedure Set_Base_Address (Base : Word64) is + procedure Set_Base_Address (New_Base : Word64) is + Address : System.Storage_Elements.Integer_Address; begin - Range_A := Range_Access - (Conv_Range.To_Pointer (System'To_Address (Base))); + Address := System.Storage_Elements.Integer_Address (New_Base); + Base := System.Storage_Elements.To_Address(Address); end Set_Base_Address;
end HW.MMIO_Range; diff --git a/common/hw-mmio_range.ads b/common/hw-mmio_range.ads index 8495f73..86ddcd6 100644 --- a/common/hw-mmio_range.ads +++ b/common/hw-mmio_range.ads @@ -13,17 +13,17 @@ --
with System; +with System.Storage_Elements;
generic Base_Addr : Word64; type Element_T is mod <>; type Index_T is range <>; - type Array_T is array (Index_T) of Element_T; package HW.MMIO_Range with Abstract_State => ((State with External), - Base_Address), + (Base_Address with External)), Initializes => Base_Address is
@@ -31,6 +31,18 @@
procedure Write (Index : in Index_T; Value : in Element_T);
- procedure Set_Base_Address (Base : Word64); + procedure Set_Base_Address (New_Base : Word64); + +private + + Base : System.Address := System.Storage_Elements.To_Address + (System.Storage_Elements.Integer_Address (Base_Addr)) + with Part_Of => Base_Address; + + type Volatile_Element_T is new Element_T with Volatile; + type Array_T is array (Index_T) of Element_T with Volatile_Components; + + Range_A : Array_T with Part_Of => Base_Address; + for Range_A'Address use Base;
end HW.MMIO_Range; diff --git a/common/hw-pci-dev.ads b/common/hw-pci-dev.ads index 5b20aa1..6bfef74 100644 --- a/common/hw-pci-dev.ads +++ b/common/hw-pci-dev.ads @@ -16,7 +16,7 @@ Dev : PCI.Address := (0, 0, 0); package HW.PCI.Dev with - Abstract_State => (Address_State, (PCI_State with External)), + Abstract_State => ((Address_State with External), (PCI_State with External)), Initializes => Address_State is
diff --git a/common/hw-pci-mmconf.adb b/common/hw-pci-mmconf.adb index 180f2d7..493780d 100644 --- a/common/hw-pci-mmconf.adb +++ b/common/hw-pci-mmconf.adb @@ -29,16 +29,12 @@ type Index16 is new Index range 0 .. Index'Last / 2; type Index32 is new Index range 0 .. Index'Last / 4;
- type Array8 is array (Index) of Byte with Atomic_Components; - type Array16 is array (Index16) of Word16 with Atomic_Components; - type Array32 is array (Index32) of Word32 with Atomic_Components; - package MM8 is new HW.MMIO_Range - (Default_Base_Address, Word8, Index, Array8); + (Default_Base_Address, Word8, Index); package MM16 is new HW.MMIO_Range - (Default_Base_Address, Word16, Index16, Array16); + (Default_Base_Address, Word16, Index16); package MM32 is new HW.MMIO_Range - (Default_Base_Address, Word32, Index32, Array32); + (Default_Base_Address, Word32, Index32);
procedure Read8 (Value : out Word8; Offset : Index) renames MM8.Read;
diff --git a/common/hw-pci-mmconf.ads b/common/hw-pci-mmconf.ads index 597ebfa..22e2e2e 100644 --- a/common/hw-pci-mmconf.ads +++ b/common/hw-pci-mmconf.ads @@ -21,7 +21,7 @@ Dev : Address := (0, 0, 0); package HW.PCI.MMConf with - Abstract_State => (Address_State, (PCI_State with External)), + Abstract_State => ((Address_State with External), (PCI_State with External)), Initializes => Address_State is