Re: [PATCH 3/9] remoteproc: Parse ELF file to find resource tableaddress

From: Ido Yariv
Date: Wed Feb 20 2013 - 05:44:57 EST


Hi Sjur,

On Sun, Feb 10, 2013 at 12:39:06PM +0100, sjur.brandeland@xxxxxxxxxxxxxx wrote:
> From: Sjur Brændeland <sjur.brandeland@xxxxxxxxxxxxxx>
>
> 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 <sjur.brandeland@xxxxxxxxxxxxxx>
> ---
> drivers/remoteproc/remoteproc_elf_loader.c | 17 ++++++++++++++++-
> drivers/remoteproc/remoteproc_internal.h | 13 +++++++++++++
> 2 files changed, 29 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/remoteproc/remoteproc_elf_loader.c b/drivers/remoteproc/remoteproc_elf_loader.c
> index a958950..3137fba 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

Since this new op returns a VA (unlike get_boot_addr), it would probably be
better to use an indicative name like get_rsctab_va.

> };
> diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h
> index 7bb6648..3a5cb7d 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 */
> --
> 1.7.5.4
>

Thanks,
Ido.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/