diff options
author | Lokesh Vutla <lokeshvutla@ti.com> | 2019-09-04 16:01:30 +0530 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2019-10-11 10:07:34 -0400 |
commit | 856c0ad413f52d20963ef6b0fe982a0ca91086f2 (patch) | |
tree | e9c1c8729acb11ab54a367e2fcae8e8c3ec1450e /drivers | |
parent | e3c4d6f01fb5c86ee8a67d28cc3a0eb708954e40 (diff) | |
download | u-boot-856c0ad413f52d20963ef6b0fe982a0ca91086f2.tar.gz u-boot-856c0ad413f52d20963ef6b0fe982a0ca91086f2.tar.xz u-boot-856c0ad413f52d20963ef6b0fe982a0ca91086f2.zip |
remoteproc: elf_loader: Introduce a common elf loader and checker functions
Introduce a common remoteproc elf loader and checker functions that
automatically detects the 64 bit elf file or 32 bit elf file and
loads/checks the sections accordingly.
Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
Reviewed-by: Fabien Dessenne <fabien.dessenne@st.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/remoteproc/rproc-elf-loader.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/drivers/remoteproc/rproc-elf-loader.c b/drivers/remoteproc/rproc-elf-loader.c index 1aece2fc31..42a78f4207 100644 --- a/drivers/remoteproc/rproc-elf-loader.c +++ b/drivers/remoteproc/rproc-elf-loader.c @@ -120,6 +120,22 @@ int rproc_elf64_sanity_check(ulong addr, ulong size) return 0; } +/* Basic function to verify ELF image format */ +int rproc_elf_sanity_check(ulong addr, ulong size) +{ + Elf32_Ehdr *ehdr = (Elf32_Ehdr *)addr; + + if (!addr) { + dev_err(dev, "Invalid firmware address\n"); + return -EFAULT; + } + + if (ehdr->e_ident[EI_CLASS] == ELFCLASS64) + return rproc_elf64_sanity_check(addr, size); + else + return rproc_elf32_sanity_check(addr, size); +} + int rproc_elf32_load_image(struct udevice *dev, unsigned long addr, ulong size) { Elf32_Ehdr *ehdr; /* Elf header structure pointer */ @@ -220,3 +236,18 @@ int rproc_elf64_load_image(struct udevice *dev, ulong addr, ulong size) return ret; } + +int rproc_elf_load_image(struct udevice *dev, ulong addr, ulong size) +{ + Elf32_Ehdr *ehdr = (Elf32_Ehdr *)addr; + + if (!addr) { + dev_err(dev, "Invalid firmware address\n"); + return -EFAULT; + } + + if (ehdr->e_ident[EI_CLASS] == ELFCLASS64) + return rproc_elf64_load_image(dev, addr, size); + else + return rproc_elf32_load_image(dev, addr, size); +} |