[Concept,09/13] x86: binman: Extract common ROM entries into a template

Message ID 20260214021317.816170-10-sjg@u-boot.org
State New
Headers
Series ulib: Support building examples for x86 |

Commit Message

Simon Glass Feb. 14, 2026, 2:13 a.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

The x86 ROM image (u-boot.rom) contains a set of entries that are common
to all x86 boards: the start16/reset16 vectors and image-header. These
are currently inlined in the &rom node, making them hard to reuse.

Add a 'binman' label to the binman node and use it to add a
rom_common template containing these shared entries. The &rom node
then pulls them in with insert-template, so board-specific dtsi files
can also reference the template.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---

 arch/x86/dts/u-boot.dtsi | 66 ++++++++++++++++++++++------------------
 1 file changed, 36 insertions(+), 30 deletions(-)
  

Patch

diff --git a/arch/x86/dts/u-boot.dtsi b/arch/x86/dts/u-boot.dtsi
index c26b855edc9..630f85db31a 100644
--- a/arch/x86/dts/u-boot.dtsi
+++ b/arch/x86/dts/u-boot.dtsi
@@ -7,7 +7,7 @@ 
 #include <config.h>
 
 / {
-	binman {
+	binman: binman {
 		multiple-images;
 		rom: rom {
 		};
@@ -15,12 +15,43 @@ 
 };
 
 #ifdef CONFIG_ROM_SIZE
+&binman {
+	rom_common: template {
+		end-at-4gb;
+		sort-by-offset;
+		pad-byte = <0xff>;
+		size = <CONFIG_ROM_SIZE>;
+#ifdef CONFIG_TPL
+		x86-start16-tpl {
+			offset = <CONFIG_SYS_X86_START16>;
+		};
+		x86-reset16-tpl {
+			offset = <CONFIG_RESET_VEC_LOC>;
+		};
+#elif defined(CONFIG_SPL)
+		x86-start16-spl {
+			offset = <CONFIG_SYS_X86_START16>;
+		};
+		x86-reset16-spl {
+			offset = <CONFIG_RESET_VEC_LOC>;
+		};
+#else
+		x86-start16 {
+			offset = <CONFIG_SYS_X86_START16>;
+		};
+		x86-reset16 {
+			offset = <CONFIG_RESET_VEC_LOC>;
+		};
+#endif
+		image-header {
+			location = "end";
+		};
+	};
+};
+
 &rom {
 	filename = "u-boot.rom";
-	end-at-4gb;
-	sort-by-offset;
-	pad-byte = <0xff>;
-	size = <CONFIG_ROM_SIZE>;
+	insert-template = <&rom_common>;
 #ifdef CONFIG_HAVE_INTEL_ME
 	intel-descriptor {
 		filename = CONFIG_FLASH_DESCRIPTOR_FILE;
@@ -163,30 +194,5 @@ 
 		offset = <CFG_X86_REFCODE_ADDR>;
 	};
 #endif
-#ifdef CONFIG_TPL
-	x86-start16-tpl {
-		offset = <CONFIG_SYS_X86_START16>;
-	};
-	x86-reset16-tpl {
-		offset = <CONFIG_RESET_VEC_LOC>;
-	};
-#elif defined(CONFIG_SPL)
-	x86-start16-spl {
-		offset = <CONFIG_SYS_X86_START16>;
-	};
-	x86-reset16-spl {
-		offset = <CONFIG_RESET_VEC_LOC>;
-	};
-#else
-	x86-start16 {
-		offset = <CONFIG_SYS_X86_START16>;
-	};
-	x86-reset16 {
-		offset = <CONFIG_RESET_VEC_LOC>;
-	};
-#endif
-	image-header {
-		location = "end";
-	};
 };
 #endif