From 4797b3eee3a0fc41ff5d68408dc73ac5e6fd248e Mon Sep 17 00:00:00 2001 From: Jeremy Kerr Date: Fri, 12 Sep 2014 14:26:06 +0800 Subject: platform: add a platform hook for loading external resources Currently, in core/init.c we do a fsp-specific load procedure to grab the kernel image. We'd like to do two things: allow other types of resources, and have paths for non-FSP platforms to perform loads. This change adds a platform-specific load_resource hook, and moves the currently loading code to fsp_load_resource. To allow other resource types, we add an identifier to indicate the type of resouce to load. Signed-off-by: Jeremy Kerr Acked-by: Stewart Smith Acked-by: Stewart Smith --- hw/fsp/fsp.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'hw/fsp/fsp.c') diff --git a/hw/fsp/fsp.c b/hw/fsp/fsp.c index 51d06b00..7a07835f 100644 --- a/hw/fsp/fsp.c +++ b/hw/fsp/fsp.c @@ -98,6 +98,12 @@ static u64 fsp_hir_timeout; #define FSP_CRITICAL_OP_TIMEOUT 128 #define FSP_DRCR_CLEAR_TIMEOUT 128 +/* LID numbers. For now we hijack some of pHyp's own until i figure + * out the whole business with the MasterLID + */ +#define KERNEL_LID_PHYP 0x80a00701 +#define KERNEL_LID_OPAL 0x80f00101 + /* * We keep track on last logged values for some things to print only on * value changes, but also to releive pressure on the tracer which @@ -2171,6 +2177,48 @@ int fsp_fetch_data_queue(uint8_t flags, uint16_t id, uint32_t sub_id, return OPAL_SUCCESS; } +bool fsp_load_resource(enum resource_id id, void *buf, size_t *size) +{ + uint32_t lid_no, lid; + size_t tmp_size; + int rc; + + switch (id) { + case RESOURCE_ID_KERNEL: + lid_no = KERNEL_LID_OPAL; + break; + default: + return false; + } + +retry: + tmp_size = *size; + + printf("Trying to load OPAL LID %08x...\n", lid_no); + lid = fsp_adjust_lid_side(lid_no); + rc = fsp_fetch_data(0, FSP_DATASET_NONSP_LID, lid, 0, buf, &tmp_size); + + /* Fall back to a PHYP LID for kernel loads */ + if (rc && lid_no == KERNEL_LID_OPAL) { + const char *ltype = dt_prop_get_def(dt_root, "lid-type", NULL); + if (!ltype || strcmp(ltype, "opal")) { + prerror("Failed to load in OPAL mode...\n"); + return false; + } + printf("Trying to load as PHYP LID...\n"); + lid_no = KERNEL_LID_PHYP; + goto retry; + } + + if (rc) { + prerror("Failed to load LID\n"); + return false; + } + + *size = tmp_size; + return true; +} + void fsp_used_by_console(void) { fsp_lock.in_con_path = true; -- cgit v1.2.1