aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorMichael Neuling <mikey@neuling.org>2015-02-12 12:57:52 +1100
committerStewart Smith <stewart@linux.vnet.ibm.com>2015-02-17 09:20:37 +1100
commit4a4efc42a87da445333da85ce7f13db2f6095d03 (patch)
tree95170ebe18179e758ee9916bc4ff86a219b9a7f5 /core
parentea7d806ab0ba7acbc4143261c2648864d3def1f1 (diff)
downloadskiboot-4a4efc42a87da445333da85ce7f13db2f6095d03.zip
skiboot-4a4efc42a87da445333da85ce7f13db2f6095d03.tar.gz
skiboot-4a4efc42a87da445333da85ce7f13db2f6095d03.tar.bz2
core: Add load_resource()
Add new function call load_resource(). This helps cleanup the callers of platform.load_resource(). Signed-off-by: Michael Neuling <mikey@neuling.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'core')
-rw-r--r--core/init.c21
-rw-r--r--core/platform.c10
2 files changed, 18 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);
+
+}