[Skiboot] [PATCH 03/10] core: Add load_resource()
Michael Neuling
mikey at neuling.org
Thu Feb 12 12:57:52 AEDT 2015
Add new function call load_resource(). This helps cleanup the callers of
platform.load_resource().
Signed-off-by: Michael Neuling <mikey at neuling.org>
---
core/init.c | 21 ++++++++-------------
core/platform.c | 10 ++++++++++
include/platform.h | 3 +++
3 files changed, 21 insertions(+), 13 deletions(-)
diff --git a/core/init.c b/core/init.c
index 0b29e2b..c18b71c 100644
--- a/core/init.c
+++ b/core/init.c
@@ -289,16 +289,14 @@ extern uint64_t boot_offset;
static bool load_kernel(void)
{
struct elf_hdr *kh;
- size_t ksize = 0;
+ size_t ksize;
/* Try to load an external kernel payload through the platform hooks */
- if (platform.load_resource) {
- ksize = KERNEL_LOAD_SIZE;
- if (!platform.load_resource(RESOURCE_ID_KERNEL,
- KERNEL_LOAD_BASE, &ksize)) {
- printf("INIT: platform kernel load failed\n");
- ksize = 0;
- }
+ ksize = KERNEL_LOAD_SIZE;
+ if (!load_resource(RESOURCE_ID_KERNEL, KERNEL_LOAD_BASE,
+ &ksize)) {
+ printf("INIT: platform kernel load failed\n");
+ ksize = 0;
}
/* Try embedded kernel payload */
@@ -335,12 +333,9 @@ static void load_initramfs(void)
size_t size;
bool loaded;
- if (!platform.load_resource)
- return;
-
size = INITRAMFS_LOAD_SIZE;
- loaded = platform.load_resource(RESOURCE_ID_INITRAMFS,
- INITRAMFS_LOAD_BASE, &size);
+ loaded = load_resource(RESOURCE_ID_INITRAMFS,
+ INITRAMFS_LOAD_BASE, &size);
if (!loaded || !size)
return;
diff --git a/core/platform.c b/core/platform.c
index 69d8e91..4232294 100644
--- a/core/platform.c
+++ b/core/platform.c
@@ -76,3 +76,13 @@ void probe_platform(void)
printf("PLAT: Detected %s platform\n", platform.name);
}
+
+bool load_resource(enum resource_id id,
+ void *buf, size_t *len)
+{
+ if (!platform.load_resource)
+ return false;
+
+ return platform.load_resource(id, buf, len);
+
+}
diff --git a/include/platform.h b/include/platform.h
index 44e67ef..ec5cbc6 100644
--- a/include/platform.h
+++ b/include/platform.h
@@ -148,4 +148,7 @@ static const struct platform __used __section(".platforms") name ##_platform
extern void probe_platform(void);
+extern bool load_resource(enum resource_id id,
+ void *buf, size_t *len);
+
#endif /* __PLATFORM_H */
--
2.1.0
More information about the Skiboot
mailing list