[Skiboot] [PATCH v2] astbmc: Allow loading of separate payload from flash
Joel Stanley
joel at jms.id.au
Mon Feb 2 13:44:10 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 KERNEL 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 KERNEL 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>
---
v2:
Review from jk:
- use KERNEL instead of SKIROOT for partition name
- s/astbmc_load_resource/pnor_load_resource/
platforms/astbmc/astbmc.h | 2 ++
platforms/astbmc/habanero.c | 1 +
platforms/astbmc/palmetto.c | 1 +
platforms/astbmc/pnor.c | 46 +++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 50 insertions(+)
diff --git a/platforms/astbmc/astbmc.h b/platforms/astbmc/astbmc.h
index cee475a..22d404d 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 pnor_load_resource(enum resource_id id, void *buf, size_t *len);
#endif /* __ASTBMC_H */
diff --git a/platforms/astbmc/habanero.c b/platforms/astbmc/habanero.c
index d442d1f..a19aafd 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 = pnor_load_resource,
};
diff --git a/platforms/astbmc/palmetto.c b/platforms/astbmc/palmetto.c
index a0030e8..cfa7236 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 = pnor_load_resource,
};
diff --git a/platforms/astbmc/pnor.c b/platforms/astbmc/pnor.c
index f6e7a5d..90ec3b1 100644
--- a/platforms/astbmc/pnor.c
+++ b/platforms/astbmc/pnor.c
@@ -85,3 +85,49 @@ 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;
+}
+
+bool pnor_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("KERNEL", buf, len) == OPAL_SUCCESS;
+}
--
2.1.4
More information about the Skiboot
mailing list