From 81e39fbd9251bfbef3bc156735e95b67cd7a828f Mon Sep 17 00:00:00 2001 From: Lokesh Vutla Date: Wed, 4 Sep 2019 16:01:31 +0530 Subject: remoteproc: elf_loader: Introduce rproc_elf_get_boot_addr() api Introduce rproc_elf_get_boot_addr() that returns the entry point of the elf file. This api auto detects the 64/32 bit elf file and returns the boot addr accordingly. Signed-off-by: Lokesh Vutla --- drivers/remoteproc/rproc-elf-loader.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'drivers') diff --git a/drivers/remoteproc/rproc-elf-loader.c b/drivers/remoteproc/rproc-elf-loader.c index 42a78f4207e..b38a226065d 100644 --- a/drivers/remoteproc/rproc-elf-loader.c +++ b/drivers/remoteproc/rproc-elf-loader.c @@ -251,3 +251,27 @@ int rproc_elf_load_image(struct udevice *dev, ulong addr, ulong size) else return rproc_elf32_load_image(dev, addr, size); } + +static ulong rproc_elf32_get_boot_addr(ulong addr) +{ + Elf32_Ehdr *ehdr = (Elf32_Ehdr *)addr; + + return ehdr->e_entry; +} + +static ulong rproc_elf64_get_boot_addr(ulong addr) +{ + Elf64_Ehdr *ehdr = (Elf64_Ehdr *)addr; + + return ehdr->e_entry; +} + +ulong rproc_elf_get_boot_addr(struct udevice *dev, ulong addr) +{ + Elf32_Ehdr *ehdr = (Elf32_Ehdr *)addr; + + if (ehdr->e_ident[EI_CLASS] == ELFCLASS64) + return rproc_elf64_get_boot_addr(addr); + else + return rproc_elf32_get_boot_addr(addr); +} -- cgit v1.3.1