From 32ecc0ef781d44f462aaeb441458d72b7dd5023d Mon Sep 17 00:00:00 2001
From: J-Alves <joao.alves@arm.com>
Date: Mon, 16 Dec 2024 17:49:47 +0000
Subject: [PATCH] feat(sptool): include HOB file in the TL pkg

If the "hob_path" has been introduced in the `args`
dictionary, use it when creating a Transfer List
type of package.

Create a HOB entry in the transfer list with the
respective transfer entry type.

Signed-off-by: Kathleen Capella <kathleen.capella@arm.com>
Signed-off-by: J-Alves <joao.alves@arm.com>
Change-Id: Ie5fefe90205cf89ee26c3683048bf42229cb4bee
---
 tools/sptool/sp_mk_generator.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/sptool/sp_mk_generator.py b/tools/sptool/sp_mk_generator.py
index e15b11b3f..9a00c745a 100644
--- a/tools/sptool/sp_mk_generator.py
+++ b/tools/sptool/sp_mk_generator.py
@@ -227,11 +227,12 @@ def generate_tl_pkg(sp_node, pkg, sp_img, sp_dtb, hob_path = None):
     TE_SP_BINARY = 0x103
     # TE Type for the HOB List.
     TE_HOB_LIST = 0x3
-    tlc_add_hob = f"\t$(Q)poetry run tlc add --entry {TE_HOB_LIST} {hob_path} {pkg}" if hob_path is not None else ""
+    tlc_add_hob = f"\t$(Q)$(TLCTOOL) add --entry {TE_HOB_LIST} {hob_path} {pkg}" if hob_path is not None else ""
     return f'''
 {pkg}: {sp_dtb} {sp_img}
 \t$(Q)echo Generating {pkg}
 \t$(Q)$(TLCTOOL) create --size {get_size(sp_node)} --entry {TE_FFA_MANIFEST} {sp_dtb} {pkg} --align 12
+{tlc_add_hob}
 \t$(Q)$(TLCTOOL) add --entry {TE_SP_BINARY} {sp_img} {pkg}
 '''
 
@@ -255,7 +256,10 @@ def gen_partition_pkg(sp_layout, sp, args :dict):
     if package_type == "sp_pkg":
         partition_pkg_rule = generate_sp_pkg(sp_layout[sp], pkg, sp_img, sp_dtb)
     elif package_type == "tl_pkg":
-        partition_pkg_rule = generate_tl_pkg(sp_layout[sp], pkg, sp_img, sp_dtb)
+        # Conditionally provide the Hob.
+        hob_path = sp_layout[sp]["hob_path"] if "hob_path" in sp_layout[sp] else None
+        partition_pkg_rule = generate_tl_pkg(
+                sp_layout[sp], pkg, sp_img, sp_dtb, hob_path)
     else:
         raise ValueError(f"Specified invalid pkg type {package_type}")