Angel Pons has uploaded this change for review. ( https://review.coreboot.org/c/libgfxinit/+/44792 )
Change subject: gma registers: Allow writing and waiting quietly ......................................................................
gma registers: Allow writing and waiting quietly
When accessing registers behind a mailbox interface, printing the "raw" register accesses only results in noise. To allow mailbox accessors to print more useful high-level operations, raw register accessors should be able to operate "quietly", without printing any debug messages. Add and adapt the necessary parameters and/or procedures to that end.
Change-Id: I56f0ee588ac779bd246b46af645402d7b21824f8 Signed-off-by: Angel Pons th3fanbus@gmail.com --- M common/hw-gfx-gma-registers.adb M common/hw-gfx-gma-registers.ads 2 files changed, 47 insertions(+), 21 deletions(-)
git pull ssh://review.coreboot.org:29418/libgfxinit refs/changes/92/44792/1
diff --git a/common/hw-gfx-gma-registers.adb b/common/hw-gfx-gma-registers.adb index 641f192..66d16e8 100644 --- a/common/hw-gfx-gma-registers.adb +++ b/common/hw-gfx-gma-registers.adb @@ -252,15 +252,18 @@ ----------------------------------------------------------------------------
-- Write a specific register - procedure Write (Register : Registers_Index; Value : Word32) + procedure Write + (Register : Registers_Index; + Value : Word32; + Verbose : Boolean := True) is begin - pragma Debug (Debug.Put (GNAT.Source_Info.Enclosing_Entity & ": ")); - pragma Debug (Debug.Put_Word32 (Value)); - pragma Debug (Debug.Put (" -> ")); - pragma Debug (Debug.Put_Word32 (Register'Enum_Rep * Register_Width)); - pragma Debug (Debug.Put (":")); - pragma Debug (Debug.Put_Line (Registers_Index'Image (Register))); + pragma Debug (Verbose, Debug.Put (GNAT.Source_Info.Enclosing_Entity & ": ")); + pragma Debug (Verbose, Debug.Put_Word32 (Value)); + pragma Debug (Verbose, Debug.Put (" -> ")); + pragma Debug (Verbose, Debug.Put_Word32 (Register'Enum_Rep * Register_Width)); + pragma Debug (Verbose, Debug.Put (":")); + pragma Debug (Verbose, Debug.Put_Line (Registers_Index'Image (Register)));
Regs.Write (Rep.Index (Register), Value); pragma Debug (Debug.Register_Write_Wait); @@ -289,7 +292,7 @@ pragma Warnings (GNATprove, Off, "unused assignment to ""Ignored_Success""");
-- Wait for the bits in @Register@ indicated by @Mask@ to be of @Value@ - procedure Wait + procedure Wait_Quietly (Register : in Registers_Index; Mask : in Word32; Value : in Word32; @@ -301,14 +304,6 @@ Timeout : Time.T; Timed_Out : Boolean := False; begin - pragma Debug (Debug.Put (GNAT.Source_Info.Enclosing_Entity & ": ")); - pragma Debug (Debug.Put_Word32 (Value)); - pragma Debug (Debug.Put (" <- ")); - pragma Debug (Debug.Put_Word32 (Mask)); - pragma Debug (Debug.Put (" & ")); - pragma Debug (Debug.Put_Word32 (Register'Enum_Rep * Register_Width)); - pragma Debug (Debug.Put (":")); - pragma Debug (Debug.Put_Line (Registers_Index'Image (Register)));
Timeout := Time.MS_From_Now (TOut_MS); loop @@ -318,14 +313,36 @@ Timed_Out := False; exit; end if; - pragma Debug (Timed_Out, Debug.Put (GNAT.Source_Info.Enclosing_Entity)); - pragma Debug (Timed_Out, Debug.Put_Line (": Timed Out!")); exit when Timed_Out;
Timed_Out := Time.Timed_Out (Timeout); end loop;
Success := not Timed_Out; + end Wait_Quietly; + + procedure Wait + (Register : in Registers_Index; + Mask : in Word32; + Value : in Word32; + TOut_MS : in Natural := Default_Timeout_MS; + Verbose : in Boolean := False; + Success : out Boolean) + is + begin + pragma Debug (Debug.Put (GNAT.Source_Info.Enclosing_Entity & ": ")); + pragma Debug (Debug.Put_Word32 (Value)); + pragma Debug (Debug.Put (" <- ")); + pragma Debug (Debug.Put_Word32 (Mask)); + pragma Debug (Debug.Put (" & ")); + pragma Debug (Debug.Put_Word32 (Register'Enum_Rep * Register_Width)); + pragma Debug (Debug.Put (":")); + pragma Debug (Debug.Put_Line (Registers_Index'Image (Register))); + + Wait_Quietly (Register, Mask, Value, TOut_MS, Verbose, Success); + + pragma Debug (not Success, Debug.Put (GNAT.Source_Info.Enclosing_Entity)); + pragma Debug (not Success, Debug.Put_Line (": Timed Out!")); end Wait;
procedure Wait diff --git a/common/hw-gfx-gma-registers.ads b/common/hw-gfx-gma-registers.ads index 68e5664..f4f427f 100644 --- a/common/hw-gfx-gma-registers.ads +++ b/common/hw-gfx-gma-registers.ads @@ -1700,16 +1700,17 @@ null => Verbose), Pre => True, Post => True; - pragma Warnings (GNATprove, On, "unused variable ""Verbose""");
procedure Write (Register : Registers_Index; - Value : Word32) + Value : Word32; + Verbose : Boolean := True) with Global => (In_Out => Register_State), - Depends => (Register_State => (Register, Register_State, Value)), + Depends => (Register_State => (Register, Register_State, Value), null => Verbose), Pre => True, Post => True; + pragma Warnings (GNATprove, On, "unused variable ""Verbose""");
procedure Is_Set_Mask (Register : in Registers_Index; @@ -1718,6 +1719,14 @@
pragma Warnings (GNATprove, Off, "unused initial value of ""Verbose""", Reason => "Only used on debugging path"); + + procedure Wait_Quietly + (Register : in Registers_Index; + Mask : in Word32; + Value : in Word32; + TOut_MS : in Natural := Default_Timeout_MS; + Verbose : in Boolean := False; + Success : out Boolean); procedure Wait (Register : in Registers_Index; Mask : in Word32;