From: Sjur Brændeland Date: Mon, 26 Nov 2012 11:41:00 +0000 (+0100) Subject: remoteproc: Parse ELF file to find resource table address X-Git-Tag: next-20130218~3^2~6 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=7d7b590e6309549217d76524f0c855729a38eac1;p=karo-tx-linux.git remoteproc: Parse ELF file to find resource table address Add function find_rsc_table_va to firmware ops. This function returns the location of the resource table in shared memory after loading. Signed-off-by: Sjur Brændeland --- diff --git a/drivers/remoteproc/remoteproc_elf_loader.c b/drivers/remoteproc/remoteproc_elf_loader.c index a958950e388d..3137fba3dc99 100644 --- a/drivers/remoteproc/remoteproc_elf_loader.c +++ b/drivers/remoteproc/remoteproc_elf_loader.c @@ -312,9 +312,24 @@ rproc_elf_find_rsc_table(struct rproc *rproc, const struct firmware *fw, return table; } +struct resource_table *rproc_elf_get_rsctab_addr(struct rproc *rproc, + const struct firmware *fw) +{ + struct elf32_shdr *shdr; + + shdr = find_rsc_shdr(&rproc->dev, (struct elf32_hdr *)fw->data, + fw->size); + if (!shdr) + return NULL; + + /* Find resource table in loaded segments */ + return rproc_da_to_va(rproc, shdr->sh_addr, shdr->sh_size); +} + const struct rproc_fw_ops rproc_elf_fw_ops = { .load = rproc_elf_load_segments, .find_rsc_table = rproc_elf_find_rsc_table, .sanity_check = rproc_elf_sanity_check, - .get_boot_addr = rproc_elf_get_boot_addr + .get_boot_addr = rproc_elf_get_boot_addr, + .get_rsctab_addr = rproc_elf_get_rsctab_addr }; diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h index 7bb66482d061..3a5cb7d64a0f 100644 --- a/drivers/remoteproc/remoteproc_internal.h +++ b/drivers/remoteproc/remoteproc_internal.h @@ -32,6 +32,7 @@ struct rproc; * expects to find it * @sanity_check: sanity check the fw image * @get_boot_addr: get boot address to entry point specified in firmware + * @get_rsctab_addr: get resouce table address as specified in firmware */ struct rproc_fw_ops { struct resource_table *(*find_rsc_table) (struct rproc *rproc, @@ -40,6 +41,8 @@ struct rproc_fw_ops { int (*load)(struct rproc *rproc, const struct firmware *fw); int (*sanity_check)(struct rproc *rproc, const struct firmware *fw); u32 (*get_boot_addr)(struct rproc *rproc, const struct firmware *fw); + struct resource_table *(*get_rsctab_addr)(struct rproc *rproc, + const struct firmware *fw); }; /* from remoteproc_core.c */ @@ -102,6 +105,16 @@ struct resource_table *rproc_find_rsc_table(struct rproc *rproc, return NULL; } +static inline +struct resource_table *rproc_get_rsctab_addr(struct rproc *rproc, + const struct firmware *fw) +{ + if (rproc->fw_ops->get_rsctab_addr) + return rproc->fw_ops->get_rsctab_addr(rproc, fw); + + return NULL; +} + extern const struct rproc_fw_ops rproc_elf_fw_ops; #endif /* REMOTEPROC_INTERNAL_H */