Standardize mem_malloc_init() implementation
This lays the groundwork to allow architectures to share a common mem_malloc_init(). Note that the x86 implementation was not modified as it did not fit the mold of all other architectures. Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
This commit is contained in:
		
							parent
							
								
									5e93bd1c9a
								
							
						
					
					
						commit
						a483a167bc
					
				|  | @ -83,14 +83,13 @@ extern void rtl8019_get_enetaddr (uchar * addr); | |||
| #endif | ||||
| 
 | ||||
| static | ||||
| void mem_malloc_init (ulong dest_addr) | ||||
| void mem_malloc_init (ulong start, ulong size) | ||||
| { | ||||
| 	mem_malloc_start = dest_addr; | ||||
| 	mem_malloc_end = dest_addr + CONFIG_SYS_MALLOC_LEN; | ||||
| 	mem_malloc_brk = mem_malloc_start; | ||||
| 	mem_malloc_start = start; | ||||
| 	mem_malloc_end = start + size; | ||||
| 	mem_malloc_brk = start; | ||||
| 
 | ||||
| 	memset ((void *) mem_malloc_start, 0, | ||||
| 			mem_malloc_end - mem_malloc_start); | ||||
| 	memset ((void *)mem_malloc_start, 0, size); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
|  | @ -300,7 +299,8 @@ void start_armboot (void) | |||
| 	} | ||||
| 
 | ||||
| 	/* armboot_start is defined in the board-specific linker script */ | ||||
| 	mem_malloc_init (_armboot_start - CONFIG_SYS_MALLOC_LEN); | ||||
| 	mem_malloc_init (_armboot_start - CONFIG_SYS_MALLOC_LEN, | ||||
| 			CONFIG_SYS_MALLOC_LEN); | ||||
| 
 | ||||
| #ifndef CONFIG_SYS_NO_FLASH | ||||
| 	/* configure available FLASH banks */ | ||||
|  |  | |||
|  | @ -50,20 +50,16 @@ int board_postclk_init(void) __attribute__((weak, alias("__do_nothing"))); | |||
| int board_early_init_r(void) __attribute__((weak, alias("__do_nothing"))); | ||||
| 
 | ||||
| /* The malloc area is right below the monitor image in RAM */ | ||||
| static void mem_malloc_init(void) | ||||
| static void mem_malloc_init(ulong start, ulong size) | ||||
| { | ||||
| 	unsigned long monitor_addr; | ||||
| 
 | ||||
| 	monitor_addr = CONFIG_SYS_MONITOR_BASE + gd->reloc_off; | ||||
| 	mem_malloc_end = monitor_addr; | ||||
| 	mem_malloc_start = mem_malloc_end - CONFIG_SYS_MALLOC_LEN; | ||||
| 	mem_malloc_brk = mem_malloc_start; | ||||
| 	mem_malloc_start = start; | ||||
| 	mem_malloc_end = start + size; | ||||
| 	mem_malloc_brk = start; | ||||
| 
 | ||||
| 	printf("malloc: Using memory from 0x%08lx to 0x%08lx\n", | ||||
| 	       mem_malloc_start, mem_malloc_end); | ||||
| 
 | ||||
| 	memset ((void *)mem_malloc_start, 0, | ||||
| 		mem_malloc_end - mem_malloc_start); | ||||
| 	memset((void *)mem_malloc_start, 0, size); | ||||
| } | ||||
| 
 | ||||
| #ifdef CONFIG_SYS_DMA_ALLOC_LEN | ||||
|  | @ -312,7 +308,8 @@ void board_init_r(gd_t *new_gd, ulong dest_addr) | |||
| #endif | ||||
| 
 | ||||
| 	timer_init(); | ||||
| 	mem_malloc_init(); | ||||
| 	mem_malloc_init(CONFIG_SYS_MONITOR_BASE + gd->reloc_off - | ||||
| 			CONFIG_SYS_MALLOC_LEN, CONFIG_SYS_MALLOC_LEN); | ||||
| 	malloc_bin_reloc(); | ||||
| 	dma_alloc_init(); | ||||
| 
 | ||||
|  |  | |||
|  | @ -44,13 +44,13 @@ static inline void serial_early_puts(const char *s) | |||
| #endif | ||||
| } | ||||
| 
 | ||||
| static void mem_malloc_init(void) | ||||
| static void mem_malloc_init(ulong start, ulong size) | ||||
| { | ||||
| 	mem_malloc_start = (ulong)CONFIG_SYS_MALLOC_BASE; | ||||
| 	mem_malloc_end = (ulong)(CONFIG_SYS_MALLOC_BASE + CONFIG_SYS_MALLOC_LEN); | ||||
| 	mem_malloc_brk = mem_malloc_start; | ||||
| 	mem_malloc_start = start; | ||||
| 	mem_malloc_end = start + size; | ||||
| 	mem_malloc_brk = start; | ||||
| 
 | ||||
| 	memset((void*)mem_malloc_start, 0, mem_malloc_end - mem_malloc_start); | ||||
| 	memset((void*)mem_malloc_start, 0, size); | ||||
| } | ||||
| 
 | ||||
| static int display_banner(void) | ||||
|  | @ -311,7 +311,7 @@ void board_init_r(gd_t * id, ulong dest_addr) | |||
| #endif | ||||
| 
 | ||||
| 	/* initialize malloc() area */ | ||||
| 	mem_malloc_init(); | ||||
| 	mem_malloc_init(CONFIG_SYS_MALLOC_BASE, CONFIG_SYS_MALLOC_LEN); | ||||
| 	malloc_bin_reloc(); | ||||
| 
 | ||||
| #if	!defined(CONFIG_SYS_NO_FLASH) | ||||
|  |  | |||
|  | @ -109,17 +109,13 @@ ulong monitor_flash_len; | |||
| /*
 | ||||
|  * The Malloc area is immediately below the monitor copy in DRAM | ||||
|  */ | ||||
| static void mem_malloc_init (void) | ||||
| static void mem_malloc_init(ulong start, ulong size) | ||||
| { | ||||
| 	ulong dest_addr = CONFIG_SYS_MONITOR_BASE + gd->reloc_off; | ||||
| 	mem_malloc_start = start; | ||||
| 	mem_malloc_end = start + size; | ||||
| 	mem_malloc_brk = start; | ||||
| 
 | ||||
| 	mem_malloc_end = dest_addr; | ||||
| 	mem_malloc_start = dest_addr - TOTAL_MALLOC_LEN; | ||||
| 	mem_malloc_brk = mem_malloc_start; | ||||
| 
 | ||||
| 	memset ((void *) mem_malloc_start, | ||||
| 		0, | ||||
| 		mem_malloc_end - mem_malloc_start); | ||||
| 	memset ((void *)mem_malloc_start, 0, size); | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|  | @ -499,7 +495,8 @@ void board_init_r (gd_t *id, ulong dest_addr) | |||
| 	trap_init (CONFIG_SYS_SDRAM_BASE); | ||||
| 
 | ||||
| 	/* initialize malloc() area */ | ||||
| 	mem_malloc_init (); | ||||
| 	mem_malloc_init (CONFIG_SYS_MONITOR_BASE + gd->reloc_off - | ||||
| 			TOTAL_MALLOC_LEN, TOTAL_MALLOC_LEN); | ||||
| 	malloc_bin_reloc (); | ||||
| 
 | ||||
| #if !defined(CONFIG_SYS_NO_FLASH) | ||||
|  |  | |||
|  | @ -51,12 +51,13 @@ extern int getenv_IPaddr (char *); | |||
|  * aka CONFIG_SYS_MONITOR_BASE - Note there is no need for reloc_off | ||||
|  * as our monitory code is run from SDRAM | ||||
|  */ | ||||
| static void mem_malloc_init (void) | ||||
| static void mem_malloc_init(ulong start, ulong size) | ||||
| { | ||||
| 	mem_malloc_end = (CONFIG_SYS_MALLOC_BASE + CONFIG_SYS_MALLOC_LEN); | ||||
| 	mem_malloc_start = CONFIG_SYS_MALLOC_BASE; | ||||
| 	mem_malloc_brk = mem_malloc_start; | ||||
| 	memset ((void *)mem_malloc_start, 0, mem_malloc_end - mem_malloc_start); | ||||
| 	mem_malloc_start = start; | ||||
| 	mem_malloc_end = start + size; | ||||
| 	mem_malloc_brk = start; | ||||
| 
 | ||||
| 	memset ((void *)mem_malloc_start, 0, size); | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|  | @ -104,7 +105,7 @@ void board_init (void) | |||
| 	gd->flags |= GD_FLG_RELOC;      /* tell others: relocation done */ | ||||
| 
 | ||||
| 	/* Initialise malloc() area */ | ||||
| 	mem_malloc_init (); | ||||
| 	mem_malloc_init (CONFIG_SYS_MALLOC_BASE, CONFIG_SYS_MALLOC_LEN); | ||||
| 
 | ||||
| 	for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) { | ||||
| 		WATCHDOG_RESET (); | ||||
|  |  | |||
|  | @ -77,17 +77,13 @@ int board_early_init_f(void) __attribute__((weak, alias("__board_early_init_f")) | |||
| /*
 | ||||
|  * The Malloc area is immediately below the monitor copy in DRAM | ||||
|  */ | ||||
| static void mem_malloc_init (void) | ||||
| static void mem_malloc_init(ulong start, ulong size) | ||||
| { | ||||
| 	ulong dest_addr = CONFIG_SYS_MONITOR_BASE + gd->reloc_off; | ||||
| 	mem_malloc_start = start; | ||||
| 	mem_malloc_end = start + size; | ||||
| 	mem_malloc_brk = start; | ||||
| 
 | ||||
| 	mem_malloc_end = dest_addr; | ||||
| 	mem_malloc_start = dest_addr - TOTAL_MALLOC_LEN; | ||||
| 	mem_malloc_brk = mem_malloc_start; | ||||
| 
 | ||||
| 	memset ((void *) mem_malloc_start, | ||||
| 		0, | ||||
| 		mem_malloc_end - mem_malloc_start); | ||||
| 	memset ((void *)mem_malloc_start, 0, size); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
|  | @ -352,7 +348,8 @@ void board_init_r (gd_t *id, ulong dest_addr) | |||
| 	bd = gd->bd; | ||||
| 
 | ||||
| 	/* initialize malloc() area */ | ||||
| 	mem_malloc_init(); | ||||
| 	mem_malloc_init(CONFIG_SYS_MONITOR_BASE + gd->reloc_off - | ||||
| 			TOTAL_MALLOC_LEN, TOTAL_MALLOC_LEN); | ||||
| 	malloc_bin_reloc(); | ||||
| 
 | ||||
| #ifndef CONFIG_SYS_NO_FLASH | ||||
|  |  | |||
|  | @ -55,14 +55,13 @@ typedef int (init_fnc_t) (void); | |||
| /*
 | ||||
|  * The Malloc area is immediately below the monitor copy in RAM | ||||
|  */ | ||||
| static void mem_malloc_init (void) | ||||
| static void mem_malloc_init(ulong start, ulong size) | ||||
| { | ||||
| 	mem_malloc_start = CONFIG_SYS_MALLOC_BASE; | ||||
| 	mem_malloc_end = mem_malloc_start + CONFIG_SYS_MALLOC_LEN; | ||||
| 	mem_malloc_brk = mem_malloc_start; | ||||
| 	memset ((void *) mem_malloc_start, | ||||
| 		0, | ||||
| 		mem_malloc_end - mem_malloc_start); | ||||
| 	mem_malloc_start = start; | ||||
| 	mem_malloc_end = start + size; | ||||
| 	mem_malloc_brk = start; | ||||
| 
 | ||||
| 	memset ((void *)mem_malloc_start, 0, size); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
|  | @ -125,7 +124,7 @@ void board_init (void) | |||
| 	} | ||||
| 
 | ||||
| 	WATCHDOG_RESET (); | ||||
| 	mem_malloc_init(); | ||||
| 	mem_malloc_init(CONFIG_SYS_MALLOC_BASE, CONFIG_SYS_MALLOC_LEN); | ||||
| 	malloc_bin_reloc(); | ||||
| 
 | ||||
| 	WATCHDOG_RESET (); | ||||
|  |  | |||
|  | @ -60,12 +60,11 @@ typedef int (init_fnc_t) (void); | |||
|  */ | ||||
| static void mem_malloc_init (void) | ||||
| { | ||||
| 	mem_malloc_start = CONFIG_SYS_MALLOC_BASE; | ||||
| 	mem_malloc_end = mem_malloc_start + CONFIG_SYS_MALLOC_LEN; | ||||
| 	mem_malloc_brk = mem_malloc_start; | ||||
| 	memset ((void *) mem_malloc_start, | ||||
| 		0, | ||||
| 		mem_malloc_end - mem_malloc_start); | ||||
| 	mem_malloc_start = start; | ||||
| 	mem_malloc_end = start + size; | ||||
| 	mem_malloc_brk = start | ||||
| 
 | ||||
| 	memset((void *)mem_malloc_start, 0, size); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
|  | @ -131,7 +130,7 @@ void board_init (void) | |||
| 	} | ||||
| 
 | ||||
| 	WATCHDOG_RESET (); | ||||
| 	mem_malloc_init(); | ||||
| 	mem_malloc_init(CONFIG_SYS_MALLOC_BASE, CONFIG_SYS_MALLOC_LEN); | ||||
| 	malloc_bin_reloc(); | ||||
| 
 | ||||
| 	WATCHDOG_RESET (); | ||||
|  |  | |||
|  | @ -144,17 +144,13 @@ ulong monitor_flash_len; | |||
| /*
 | ||||
|  * The Malloc area is immediately below the monitor copy in DRAM | ||||
|  */ | ||||
| static void mem_malloc_init (void) | ||||
| static void mem_malloc_init(ulong start, ulong size) | ||||
| { | ||||
| #if !defined(CONFIG_RELOC_FIXUP_WORKS) | ||||
| 	mem_malloc_end = CONFIG_SYS_MONITOR_BASE + gd->reloc_off; | ||||
| #endif | ||||
| 	mem_malloc_start = mem_malloc_end - TOTAL_MALLOC_LEN; | ||||
| 	mem_malloc_brk = mem_malloc_start; | ||||
| 	mem_malloc_start = start; | ||||
| 	mem_malloc_end = start + size; | ||||
| 	mem_malloc_brk = start; | ||||
| 
 | ||||
| 	memset ((void *) mem_malloc_start, | ||||
| 		0, | ||||
| 		mem_malloc_end - mem_malloc_start); | ||||
| 	memset ((void *)mem_malloc_start, 0, size); | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|  | @ -650,6 +646,7 @@ void board_init_r (gd_t *id, ulong dest_addr) | |||
| #ifndef CONFIG_ENV_IS_NOWHERE | ||||
| 	extern char * env_name_spec; | ||||
| #endif | ||||
| 	ulong malloc_start; | ||||
| 
 | ||||
| #ifndef CONFIG_SYS_NO_FLASH | ||||
| 	ulong flash_size; | ||||
|  | @ -662,9 +659,11 @@ void board_init_r (gd_t *id, ulong dest_addr) | |||
| 
 | ||||
| #if defined(CONFIG_RELOC_FIXUP_WORKS) | ||||
| 	gd->reloc_off = 0; | ||||
| 	mem_malloc_end = dest_addr; | ||||
| 	malloc_start = dest_addr - TOTAL_MALLOC_LEN; | ||||
| #else | ||||
| 	gd->reloc_off = dest_addr - CONFIG_SYS_MONITOR_BASE; | ||||
| 	malloc_start = CONFIG_SYS_MONITOR_BASE + gd->reloc_off - | ||||
| 			TOTAL_MALLOC_LEN; | ||||
| #endif | ||||
| 
 | ||||
| #ifdef CONFIG_SERIAL_MULTI | ||||
|  | @ -760,7 +759,7 @@ void board_init_r (gd_t *id, ulong dest_addr) | |||
| 	asm ("sync ; isync"); | ||||
| 
 | ||||
| 	/* initialize malloc() area */ | ||||
| 	mem_malloc_init (); | ||||
| 	mem_malloc_init (malloc_start, TOTAL_MALLOC_LEN); | ||||
| 	malloc_bin_reloc (); | ||||
| 
 | ||||
| #if !defined(CONFIG_SYS_NO_FLASH) | ||||
|  |  | |||
|  | @ -38,14 +38,13 @@ const char version_string[] = U_BOOT_VERSION" ("U_BOOT_DATE" - "U_BOOT_TIME")"; | |||
| 
 | ||||
| unsigned long monitor_flash_len = CONFIG_SYS_MONITOR_LEN; | ||||
| 
 | ||||
| static void mem_malloc_init(void) | ||||
| static void mem_malloc_init(ulong start, ulong size) | ||||
| { | ||||
| 	mem_malloc_start = start; | ||||
| 	mem_malloc_end = start + size; | ||||
| 	mem_malloc_brk = start; | ||||
| 
 | ||||
| 	mem_malloc_start = (TEXT_BASE - CONFIG_SYS_GBL_DATA_SIZE - CONFIG_SYS_MALLOC_LEN); | ||||
| 	mem_malloc_end = (mem_malloc_start + CONFIG_SYS_MALLOC_LEN - 16); | ||||
| 	mem_malloc_brk = mem_malloc_start; | ||||
| 	memset((void *) mem_malloc_start, 0, | ||||
| 		(mem_malloc_end - mem_malloc_start)); | ||||
| 	memset((void *)mem_malloc_start, 0, size); | ||||
| } | ||||
| 
 | ||||
| static int sh_flash_init(void) | ||||
|  | @ -96,7 +95,8 @@ static int sh_pci_init(void) | |||
| 
 | ||||
| static int sh_mem_env_init(void) | ||||
| { | ||||
| 	mem_malloc_init(); | ||||
| 	mem_malloc_init(TEXT_BASE - CONFIG_SYS_GBL_DATA_SIZE - | ||||
| 			CONFIG_SYS_MALLOC_LEN, CONFIG_SYS_MALLOC_LEN - 16); | ||||
| 	malloc_bin_reloc(); | ||||
| 	env_relocate(); | ||||
| 	jumptable_init(); | ||||
|  |  | |||
|  | @ -82,12 +82,13 @@ ulong monitor_flash_len; | |||
| /*
 | ||||
|  * The Malloc area is immediately below the monitor copy in RAM | ||||
|  */ | ||||
| static void mem_malloc_init(void) | ||||
| static void mem_malloc_init(ulong start, ulong size) | ||||
| { | ||||
| 	mem_malloc_start = CONFIG_SYS_MALLOC_BASE; | ||||
| 	mem_malloc_end = CONFIG_SYS_MALLOC_END; | ||||
| 	mem_malloc_brk = mem_malloc_start; | ||||
| 	memset((void *)mem_malloc_start, 0, mem_malloc_end - mem_malloc_start); | ||||
| 	mem_malloc_start = start; | ||||
| 	mem_malloc_end = start + size; | ||||
| 	mem_malloc_brk = start | ||||
| 
 | ||||
| 	memset((void *)mem_malloc_start, 0, size); | ||||
| } | ||||
| 
 | ||||
| /***********************************************************************/ | ||||
|  | @ -313,7 +314,8 @@ void board_init_f(ulong bootflag) | |||
| 	interrupt_init(); | ||||
| 
 | ||||
| 	/* initialize malloc() area */ | ||||
| 	mem_malloc_init(); | ||||
| 	mem_malloc_init(CONFIG_SYS_MALLOC_BASE, | ||||
| 			CONFIG_SYS_MALLOC_END - CONFIG_SYS_MALLOC_BASE); | ||||
| 	malloc_bin_reloc(); | ||||
| 
 | ||||
| #if !defined(CONFIG_SYS_NO_FLASH) | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue