feat(sptool): invoke the HOB list creation code
Add an SP setup function that invokes the HOB creation
utilities.
It introduces an argument "hob_path" to the shared dictionary of args
with the location of the generated binary containing the HOB list.
Signed-off-by: Kathleen Capella <kathleen.capella@arm.com>
Signed-off-by: J-Alves <joao.alves@arm.com>
Change-Id: I26a07027b6344c9d7ba732d022932736a62e2505
diff --git a/tools/sptool/sp_mk_generator.py b/tools/sptool/sp_mk_generator.py
index f80050e..e15b11b 100644
--- a/tools/sptool/sp_mk_generator.py
+++ b/tools/sptool/sp_mk_generator.py
@@ -55,10 +55,15 @@
import re
import sys
import uuid
+import fdt
from spactions import SpSetupActions
+import hob
+import struct
+from hob import HobList
MAX_SP = 8
UUID_LEN = 4
+HOB_OFFSET_DEFAULT=0x2000
# Some helper functions to access args propagated to the action functions in
# SpSetupActions framework.
@@ -179,6 +184,28 @@
write_to_sp_mk_gen(f"FDT_SOURCES += {manifest_path}", args)
return args
+@SpSetupActions.sp_action(exec_order=1)
+def generate_hob_list(sp_layout, sp, args: dict):
+ '''
+ Generates a HOB file for the partition, if it requested it in its FF-A
+ manifest.
+ '''
+ with open(get_sp_manifest_full_path(sp_layout[sp], args), "r") as f:
+ sp_fdt = fdt.parse_dts(f.read())
+
+ if sp_fdt.exist_property('hob_list', '/boot-info'):
+ sp_hob_name = os.path.basename(sp + ".hob.bin")
+ sp_hob_name = os.path.join(args["out_dir"], f"{sp_hob_name}")
+
+ # Add to the args so it can be consumed by the TL pkg function.
+ sp_layout[sp]["hob_path"] = sp_hob_name
+ hob_list = hob.generate_hob_from_fdt_node(sp_fdt, HOB_OFFSET_DEFAULT)
+ with open(sp_hob_name, "wb") as h:
+ for block in hob_list.get_list():
+ h.write(block.pack())
+
+ return args
+
def generate_sp_pkg(sp_node, pkg, sp_img, sp_dtb):
''' Generates the rule in case SP is to be generated in an SP Pkg. '''
pm_offset = get_pm_offset(sp_node)