Nico Huber has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/38923 )
Change subject: drivers/pc80/rtc: Expose get_option() in Ada ......................................................................
drivers/pc80/rtc: Expose get_option() in Ada
Change-Id: I723b4a2d5ef61c738146f86547d0da1d70840ccb Signed-off-by: Nico Huber nico.huber@secunet.com --- M src/drivers/pc80/rtc/Makefile.inc A src/drivers/pc80/rtc/cb-nvram.adb A src/drivers/pc80/rtc/cb-nvram.ads 3 files changed, 56 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/23/38923/1
diff --git a/src/drivers/pc80/rtc/Makefile.inc b/src/drivers/pc80/rtc/Makefile.inc index 4938d78..bb33ccd 100644 --- a/src/drivers/pc80/rtc/Makefile.inc +++ b/src/drivers/pc80/rtc/Makefile.inc @@ -8,6 +8,9 @@ ramstage-$(CONFIG_DRIVERS_MC146818) += mc146818rtc.c smm-$(CONFIG_DRIVERS_MC146818) += mc146818rtc.c
+ramstage-$(CONFIG_DRIVERS_MC146818) += cb-nvram.ads +ramstage-$(CONFIG_DRIVERS_MC146818) += cb-nvram.adb + all-$(CONFIG_USE_OPTION_TABLE) += option.c smm-$(CONFIG_USE_OPTION_TABLE) += option.c
diff --git a/src/drivers/pc80/rtc/cb-nvram.adb b/src/drivers/pc80/rtc/cb-nvram.adb new file mode 100644 index 0000000..8549458 --- /dev/null +++ b/src/drivers/pc80/rtc/cb-nvram.adb @@ -0,0 +1,42 @@ +with System; +with Interfaces.C; + +package body CB.NVRAM is + + function c_get_option (dst: System.Address; name: System.Address) return Interfaces.C.int; + pragma import (C, c_get_option, "get_option"); + + procedure get_option (dst: System.Address; name: String) + is + use type Interfaces.C.size_t; + + c_name : Interfaces.C.char_array (0 .. 255); + ignored : Interfaces.C.int; + begin + if Interfaces.C.size_t (name'length) > c_name'last then + return; + end if; + for i in name'range loop + c_name (Interfaces.C.size_t (i - name'first)) := Interfaces.C.To_C (name (i)); + end loop; + c_name (Interfaces.C.size_t (name'length)) := Interfaces.C.nul; + + ignored := c_get_option (dst, c_name (0)'address); + end get_option; + + procedure get_option (val: in out Word8; name: String) is + begin + get_option (val'address, name); + end get_option; + + procedure get_option (val: in out Word16; name: String) is + begin + get_option (val'address, name); + end get_option; + + procedure get_option (val: in out Word32; name: String) is + begin + get_option (val'address, name); + end get_option; + +end CB.NVRAM; diff --git a/src/drivers/pc80/rtc/cb-nvram.ads b/src/drivers/pc80/rtc/cb-nvram.ads new file mode 100644 index 0000000..8d564f3 --- /dev/null +++ b/src/drivers/pc80/rtc/cb-nvram.ads @@ -0,0 +1,11 @@ +with HW; + +use HW; + +package CB.NVRAM is + + procedure get_option (val: in out Word8; name: String); + procedure get_option (val: in out Word16; name: String); + procedure get_option (val: in out Word32; name: String); + +end CB.NVRAM;