hw-debug: Place global variables in the .bss section

It places the Middle_Of_Line and Register_Write_Delay_Nanoseconds
variables in the .bss section. As a result they are set at runtime to
their desired default value which is respectively False and 0.

It helps to integrate the libhwbase library debug package in
environments where global initialized variables are not
supported such as coreboot romstage.

This change does not impact GNATprove as this package has SPARK_Mode
disabled.

BUG=b:252792591
BRANCH=firmware-brya-14505.B
TEST=Working as expected on skolas

Signed-off-by: Jeremy Compostella <jeremy.compostella@intel.com>
Change-Id: Ib23699f3f3446219c34c60ccd9987346e17769f2
Reviewed-on: https://review.coreboot.org/c/libhwbase/+/69854
Tested-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
This commit is contained in:
Jeremy Compostella 2022-11-21 18:07:06 -07:00 committed by Subrata Banik
parent 8be5a82b85
commit 95ad8c53c6
1 changed files with 12 additions and 6 deletions

View File

@ -22,9 +22,15 @@ package body HW.Debug
with
SPARK_Mode => Off
is
Start_Of_Line : Boolean := True;
Register_Write_Delay_Nanoseconds : Word64 := 0;
-- Placing the two variables below in the .bss section set them to
-- their desired default value which is respectively False and
-- 0. It helps to integrate the libhwbase library debug package in
-- environments where global initialized variables are not
-- supported such as coreboot romstage.
Middle_Of_Line : Boolean;
pragma Linker_Section (Middle_Of_Line, ".bss");
Register_Write_Delay_Nanoseconds : Word64;
pragma Linker_Section (Register_Write_Delay_Nanoseconds, ".bss");
type Base_Range is new Positive range 2 .. 16;
type Width_Range is new Natural range 0 .. 64;
@ -43,8 +49,8 @@ is
is
Now_US : Int64;
begin
if Start_Of_Line then
Start_Of_Line := False;
if not Middle_Of_Line then
Middle_Of_Line := True;
Now_US := Time.Now_US;
Debug_Sink.Put_Char ('[');
Do_Put_Int64 ((Now_US / 1_000_000) mod 1_000_000);
@ -71,7 +77,7 @@ is
procedure New_Line is
begin
HW.Debug_Sink.New_Line;
Start_Of_Line := True;
Middle_Of_Line := False;
end New_Line;
----------------------------------------------------------------------------