[Skiboot] [PATCH] astbmc: Allow loading of separate payload from flash

Joel Stanley joel at jms.id.au
Mon Feb 2 09:18:26 AEDT 2015


To date BMC platforms have had their payload built in to the skiboot
binary. This patch adds the option of loading from a flash partition
instead.

If the partition named SKIROOT cannot be found, the core loading logic
will fall back to using the built-in payload. In this case, the user
gets the following messages:

  [2214557191,3] PLAT: No SKIROOT partition in PNOR.
  [2220486159,5] INIT: platform kernel load failed.
  [2221293286,5] Using built-in kernel.
  [2265861935,5] INIT: Kernel loaded, size: 14706638 bytes (0 = unknown
  preload).

Signed-off-by: Joel Stanley <joel at jms.id.au>
---
 platforms/astbmc/astbmc.h   |  2 ++
 platforms/astbmc/common.c   |  9 +++++++++
 platforms/astbmc/habanero.c |  1 +
 platforms/astbmc/palmetto.c |  1 +
 platforms/astbmc/pnor.c     | 37 +++++++++++++++++++++++++++++++++++++
 5 files changed, 50 insertions(+)

diff --git a/platforms/astbmc/astbmc.h b/platforms/astbmc/astbmc.h
index cee475a..5a8248d 100644
--- a/platforms/astbmc/astbmc.h
+++ b/platforms/astbmc/astbmc.h
@@ -24,5 +24,7 @@ extern int64_t astbmc_ipmi_power_down(uint64_t request);
 extern void astbmc_init(void);
 extern void astbmc_ext_irq(unsigned int chip_id);
 extern int pnor_init(void);
+extern int pnor_load_part(const char *name, void *addr, size_t *len);
+extern bool astbmc_load_resource(enum resource_id id, void *buf, size_t *len);
 
 #endif /* __ASTBMC_H */
diff --git a/platforms/astbmc/common.c b/platforms/astbmc/common.c
index f9c988d..3145b9f 100644
--- a/platforms/astbmc/common.c
+++ b/platforms/astbmc/common.c
@@ -337,3 +337,12 @@ void astbmc_early_init(void)
 	/* Setup UART and use it as console with interrupts */
 	uart_init(true);
 }
+
+bool astbmc_load_resource(enum resource_id id, void *buf, size_t *len)
+{
+	if (id != RESOURCE_ID_KERNEL)
+		/* Initramfs provided with the kernel image */
+		return false;
+
+	return pnor_load_part("SKIROOT", buf, len) == OPAL_SUCCESS;
+}
diff --git a/platforms/astbmc/habanero.c b/platforms/astbmc/habanero.c
index d442d1f..66681e6 100644
--- a/platforms/astbmc/habanero.c
+++ b/platforms/astbmc/habanero.c
@@ -49,4 +49,5 @@ DECLARE_PLATFORM(habanero) = {
 	.external_irq		= astbmc_ext_irq,
 	.cec_power_down         = astbmc_ipmi_power_down,
 	.cec_reboot             = astbmc_ipmi_reboot,
+	.load_resource		= astbmc_load_resource,
 };
diff --git a/platforms/astbmc/palmetto.c b/platforms/astbmc/palmetto.c
index a0030e8..402c714 100644
--- a/platforms/astbmc/palmetto.c
+++ b/platforms/astbmc/palmetto.c
@@ -51,4 +51,5 @@ DECLARE_PLATFORM(palmetto) = {
 	.cec_power_down         = astbmc_ipmi_power_down,
 	.cec_reboot             = astbmc_ipmi_reboot,
 	.elog_commit		= ipmi_elog_commit,
+	.load_resource		= astbmc_load_resource,
 };
diff --git a/platforms/astbmc/pnor.c b/platforms/astbmc/pnor.c
index f6e7a5d..87dd4f3 100644
--- a/platforms/astbmc/pnor.c
+++ b/platforms/astbmc/pnor.c
@@ -85,3 +85,40 @@ int pnor_init(void)
 	return rc;
 }
 
+int pnor_load_part(const char *name, void *dst, size_t *len)
+{
+	int rc, part_num, part_size, part_start;
+
+	if (!pnor_ffs || !pnor_chip) {
+		prerror("PLAT: PNOR not initialized\n");
+		return OPAL_HARDWARE;
+	}
+
+	rc = ffs_lookup_part(pnor_ffs, name, &part_num);
+	if (rc) {
+		prerror("PLAT: No %s partition in PNOR\n", name);
+		return OPAL_HARDWARE;
+	}
+	rc = ffs_part_info(pnor_ffs, part_num, NULL,
+			   &part_start, &part_size, NULL);
+	if (rc) {
+		prerror("PLAT: Failed to get %s partition info\n", name);
+		return OPAL_HARDWARE;
+	}
+
+	if (part_size > *len) {
+		prerror("PLAT: %s image too large (%d > %zd)\n", name,
+			part_size, *len);
+		return OPAL_HARDWARE;
+	}
+
+	rc = flash_read(pnor_chip, part_start, dst, part_size);
+	if (rc) {
+		prerror("PLAT: failed to read %s partition\n", name);
+		return OPAL_HARDWARE;
+	}
+
+	*len = part_size;
+
+	return OPAL_SUCCESS;
+}
-- 
2.1.4



More information about the Skiboot mailing list