]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
remoteproc: add find_loaded_rsc_table firmware ops
authorSjur Brændeland <sjur.brandeland@stericsson.com>
Thu, 21 Feb 2013 17:15:34 +0000 (18:15 +0100)
committerOhad Ben-Cohen <ohad@wizery.com>
Fri, 5 Apr 2013 05:49:52 +0000 (08:49 +0300)
Add function find_loaded_rsc_table 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@stericsson.com>
Acked-by: Ido Yariv <ido@wizery.com>
[align function name with existing terminology, update commit log]
[document new function, rebase patch, small cleanups]
Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
drivers/remoteproc/remoteproc_elf_loader.c
drivers/remoteproc/remoteproc_internal.h

index 774e5f768bf37aedf67f23849becaf0eae6f81b7..ce283a5b42a1e2b677133b9ee2d6284fb80625a7 100644 (file)
@@ -304,9 +304,34 @@ rproc_elf_find_rsc_table(struct rproc *rproc, const struct firmware *fw,
        return table;
 }
 
+/**
+ * rproc_elf_find_loaded_rsc_table() - find the loaded resource table
+ * @rproc: the rproc handle
+ * @fw: the ELF firmware image
+ *
+ * This function finds the location of the loaded resource table. Don't
+ * call this function if the table wasn't loaded yet - it's a bug if you do.
+ *
+ * Returns the pointer to the resource table if it is found or NULL otherwise.
+ * If the table wasn't loaded yet the result is unspecified.
+ */
+static struct resource_table *
+rproc_elf_find_loaded_rsc_table(struct rproc *rproc, const struct firmware *fw)
+{
+       struct elf32_hdr *ehdr = (struct elf32_hdr *)fw->data;
+       struct elf32_shdr *shdr;
+
+       shdr = find_table(&rproc->dev, ehdr, fw->size);
+       if (!shdr)
+               return NULL;
+
+       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,
+       .find_loaded_rsc_table = rproc_elf_find_loaded_rsc_table,
        .sanity_check = rproc_elf_sanity_check,
        .get_boot_addr = rproc_elf_get_boot_addr
 };
index 7bb66482d061d33e41cd9f4e69fb97fe0fa91655..157e762c15714d3c03778edd6ae3df8f68a31bab 100644 (file)
@@ -27,7 +27,8 @@ struct rproc;
 
 /**
  * struct rproc_fw_ops - firmware format specific operations.
- * @find_rsc_table:    finds the resource table inside the firmware image
+ * @find_rsc_table:    find the resource table inside the firmware image
+ * @find_loaded_rsc_table: find the loaded resouce table
  * @load:              load firmeware to memory, where the remote processor
  *                     expects to find it
  * @sanity_check:      sanity check the fw image
@@ -37,6 +38,8 @@ struct rproc_fw_ops {
        struct resource_table *(*find_rsc_table) (struct rproc *rproc,
                                                const struct firmware *fw,
                                                int *tablesz);
+       struct resource_table *(*find_loaded_rsc_table)(struct rproc *rproc,
+                                               const struct firmware *fw);
        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);
@@ -102,6 +105,16 @@ struct resource_table *rproc_find_rsc_table(struct rproc *rproc,
        return NULL;
 }
 
+static inline
+struct resource_table *rproc_find_loaded_rsc_table(struct rproc *rproc,
+                                const struct firmware *fw)
+{
+       if (rproc->fw_ops->find_loaded_rsc_table)
+               return rproc->fw_ops->find_loaded_rsc_table(rproc, fw);
+
+        return NULL;
+}
+
 extern const struct rproc_fw_ops rproc_elf_fw_ops;
 
 #endif /* REMOTEPROC_INTERNAL_H */