From bcd10078fe4266cadbc437b130832dd90c00df33 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Fri, 15 Nov 2019 19:01:49 +0800 Subject: [PATCH 8/9] remoteproc: make all elf_* functions static except elf_identify it's the best practice to reduce the name scope as small as possible Signed-off-by: Xiang Xiao --- lib/include/openamp/elf_loader.h | 93 -------------------------------- lib/remoteproc/elf_loader.c | 28 +++++----- 2 files changed, 14 insertions(+), 107 deletions(-) diff --git a/lib/include/openamp/elf_loader.h open-amp/lib/include/openamp/elf_loader.h index e7dda748..916a23f9 100644 --- a/lib/include/openamp/elf_loader.h +++ open-amp/lib/include/openamp/elf_loader.h @@ -323,99 +323,6 @@ extern const struct loader_ops elf_ops; */ int elf_identify(const void *img_data, size_t len); -/** - * elf_load_header - Load ELF headers - * - * It will get the ELF header, the program header, and the section header. - * - * @img_data: image data - * @offset: input image data offset to the start of image file - * @len: input image data length - * @img_info: pointer to store image information data - * @last_load_state: last state return by this function - * @noffset: pointer to next offset required by loading ELF header - * @nlen: pointer to next data length required by loading ELF header - * - * return ELF loading header state, or negative value for failure - */ -int elf_load_header(const void *img_data, size_t offset, size_t len, - void **img_info, int last_load_state, - size_t *noffset, size_t *nlen); - -/** - * elf_load - load ELF data - * - * It will parse the ELF image and return the target device address, - * offset to the start of the ELF image of the data to load and the - * length of the data to load. - * - * @rproc: pointer to remoteproc instance - * @img_data: image data which will passed to the function. - * it can be NULL, if image data doesn't need to be handled - * by the load function. E.g. binary data which was - * loaded to the target memory. - * @offset: last loaded image data offset to the start of image file - * @len: last loaded image data length - * @img_info: pointer to store image information data - * @last_load_state: the returned state of the last function call. - * @da: target device address, if the data to load is not for target memory - * the da will be set to ANY. - * @noffset: pointer to next offset required by loading ELF header - * @nlen: pointer to next data length required by loading ELF header - * @padding: value to pad it is possible that a size of a segment in memory - * is larger than what it is in the ELF image. e.g. a segment - * can have stack section .bss. It doesn't need to copy image file - * space, in this case, it will be packed with 0. - * @nmemsize: pointer to next data target memory size. The size of a segment - * in the target memory can be larger than the its size in the - * image file. - * - * return 0 for success, otherwise negative value for failure - */ -int elf_load(struct remoteproc *rproc, const void *img_data, - size_t offset, size_t len, - void **img_info, int last_load_state, - metal_phys_addr_t *da, - size_t *noffset, size_t *nlen, - unsigned char *padding, size_t *nmemsize); - -/** - * elf_release - Release ELF image information - * - * It will release ELF image information data. - * - * @img_info: pointer to ELF image information - */ -void elf_release(void *img_info); - -/** - * elf_get_entry - Get entry point - * - * It will return entry point specified in the ELF file. - * - * @img_info: pointer to ELF image information - * - * return entry address - */ -metal_phys_addr_t elf_get_entry(void *img_info); - -/** - * elf_locate_rsc_table - locate the resource table information - * - * It will return the length of the resource table, and the device address of - * the resource table. - * - * @img_info: pointer to ELF image information - * @da: pointer to the device address - * @offset: pointer to the offset to in the ELF image of the resource - * table section. - * @size: pointer to the size of the resource table section. - * - * return 0 if successfully locate the resource table, negative value for - * failure. - */ -int elf_locate_rsc_table(void *img_info, metal_phys_addr_t *da, - size_t *offset, size_t *size); #if defined __cplusplus } diff --git a/lib/remoteproc/elf_loader.c open-amp/lib/remoteproc/elf_loader.c index c90b8d46..ffb253fb 100644 --- a/lib/remoteproc/elf_loader.c +++ open-amp/lib/remoteproc/elf_loader.c @@ -392,9 +392,9 @@ int elf_identify(const void *img_data, size_t len) return 0; } -int elf_load_header(const void *img_data, size_t offset, size_t len, - void **img_info, int last_load_state, - size_t *noffset, size_t *nlen) +static int elf_load_header(const void *img_data, size_t offset, size_t len, + void **img_info, int last_load_state, + size_t *noffset, size_t *nlen) { int *load_state; @@ -531,12 +531,12 @@ int elf_load_header(const void *img_data, size_t offset, size_t len, return last_load_state; } -int elf_load(struct remoteproc *rproc, - const void *img_data, size_t offset, size_t len, - void **img_info, int last_load_state, - metal_phys_addr_t *da, - size_t *noffset, size_t *nlen, - unsigned char *padding, size_t *nmemsize) +static int elf_load(struct remoteproc *rproc, + const void *img_data, size_t offset, size_t len, + void **img_info, int last_load_state, + metal_phys_addr_t *da, + size_t *noffset, size_t *nlen, + unsigned char *padding, size_t *nmemsize) { int *load_state; const void *phdr; @@ -614,7 +614,7 @@ int elf_load(struct remoteproc *rproc, return *load_state; } -void elf_release(void *img_info) +static void elf_release(void *img_info) { if (!img_info) return; @@ -642,7 +642,7 @@ void elf_release(void *img_info) } } -metal_phys_addr_t elf_get_entry(void *elf_info) +static metal_phys_addr_t elf_get_entry(void *elf_info) { if (!elf_info) return METAL_BAD_PHYS; @@ -662,8 +662,8 @@ metal_phys_addr_t elf_get_entry(void *elf_info) } } -int elf_locate_rsc_table(void *elf_info, metal_phys_addr_t *da, - size_t *offset, size_t *size) +static int elf_locate_rsc_table(void *elf_info, metal_phys_addr_t *da, + size_t *offset, size_t *size) { char *sect_name = ".resource_table"; void *shdr; @@ -687,7 +687,7 @@ int elf_locate_rsc_table(void *elf_info, metal_phys_addr_t *da, return 0; } -int elf_get_load_state(void *img_info) +static int elf_get_load_state(void *img_info) { int *load_state; -- 2.25.1