mirror of
https://git.openwrt.org/openwrt/openwrt.git
synced 2026-05-05 01:46:11 +02:00
realtek: rt-loader: make search_image() generic
Until now search_image() is used for searching a uImage on flash (or the memory mapped equivalent). In a future commit this will be reused to search for a piggy-backed uimage. Make this function generic by - replacing "flash" with "image" in variables - Search bytewise and do not rely on 4 byte alignment - remove 2 obsolete variables - move console output to caller Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de> Link: https://github.com/openwrt/openwrt/pull/21332 Signed-off-by: Robert Marko <robimarko@gmail.com>
This commit is contained in:
parent
8f66b33503
commit
2e74ef5be1
@ -128,19 +128,15 @@ void *decompress(void *out, void *in, int len)
|
||||
return out;
|
||||
}
|
||||
|
||||
void search_image(void **flash_addr, int *flash_size, void **load_addr)
|
||||
void search_image(void **image_addr, int *image_size, void **load_addr)
|
||||
{
|
||||
unsigned char *addr = *flash_addr;
|
||||
unsigned int image_size = 0;
|
||||
unsigned int *maxaddr;
|
||||
unsigned char *addr = *image_addr;
|
||||
|
||||
printf("Searching for uImage starting at 0x%08x ...\n", addr);
|
||||
|
||||
*flash_addr = NULL;
|
||||
for (int i = 0; i < 256 * 1024; i += 4, addr += 4) {
|
||||
*image_addr = NULL;
|
||||
for (int i = 0; i < 256 * 1024; i += 1, addr += 1) {
|
||||
if (is_uimage(addr)) {
|
||||
*flash_addr = addr;
|
||||
*flash_size = *(int *)(addr + 12);
|
||||
*image_addr = addr;
|
||||
*image_size = *(int *)(addr + 12);
|
||||
*load_addr = *(void **)(addr + 16);
|
||||
_kernel_comp_type = addr[31];
|
||||
break;
|
||||
@ -152,6 +148,8 @@ void load_kernel(void *flash_start)
|
||||
{
|
||||
void *flash_addr = flash_start;
|
||||
|
||||
printf("Searching for uImage starting at 0x%08x ...\n", flash_addr);
|
||||
|
||||
search_image(&flash_addr, &_kernel_data_size, &_kernel_load_addr);
|
||||
_kernel_data_addr = _my_load_addr - _kernel_data_size - 1024;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user