layout: Introduce get_default_layout()

Containing an included, full-flash-chip sized default region.
This allows us to query the default layout specifically, also
if an additional layout is attached to the flash context.

Change-Id: Ia343e9775ec5bdc3fea5cdb6b347298515996e34
Signed-off-by: Nico Huber <nico.h@gmx.de>
Original-Reviewed-on: https://review.coreboot.org/c/flashrom/+/33519
Original-Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Original-Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Original-Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Original-Reviewed-by: Peter Marheine <pmarheine@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom-stable/+/72215
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/layout.c b/layout.c
index f7f68b3..36fa0b6 100644
--- a/layout.c
+++ b/layout.c
@@ -32,12 +32,17 @@
 	return &global_layout;
 }
 
+const struct flashrom_layout *get_default_layout(const struct flashrom_flashctx *const flashctx)
+{
+	return flashctx->default_layout;
+}
+
 const struct flashrom_layout *get_layout(const struct flashrom_flashctx *const flashctx)
 {
 	if (flashctx->layout && flashctx->layout->num_entries)
 		return flashctx->layout;
 	else
-		return flashctx->default_layout;
+		return get_default_layout(flashctx);
 }
 
 static struct romentry *mutable_layout_next(
diff --git a/layout.h b/layout.h
index 9df1beb..6bd3732 100644
--- a/layout.h
+++ b/layout.h
@@ -56,8 +56,9 @@
 	struct layout_include_args *next;
 };
 
-struct flashrom_layout *get_global_layout(void);
 struct flashrom_flashctx;
+struct flashrom_layout *get_global_layout(void);
+const struct flashrom_layout *get_default_layout(const struct flashrom_flashctx *);
 const struct flashrom_layout *get_layout(const struct flashrom_flashctx *const flashctx);
 
 int process_include_args(struct flashrom_layout *l, const struct layout_include_args *const args);