Commit f6e20fc6 authored by wdenk's avatar wdenk
Browse files

Patch by Anders Larsen, 09 Jan 2004:

ARM memory layout fixes: the abort-stack is now set up in the
correct RAM area, and the BSS is zeroed out as it should be.

Furthermore, the magic variables 'armboot_end' and 'armboot_end_data'
of the linker scripts are replaced by '__bss_start' and '_end',
resp., which is a further step to eliminate unnecessary differences
between the implementation of the CPU architectures.
parent f4863a7a
......@@ -2,6 +2,16 @@
Changes since U-Boot 1.0.1:
======================================================================
* Patch by Anders Larsen, 09 Jan 2004:
ARM memory layout fixes: the abort-stack is now set up in the
correct RAM area, and the BSS is zeroed out as it should be.
Furthermore, the magic variables 'armboot_end' and 'armboot_end_data'
of the linker scripts are replaced by '__bss_start' and '_end',
resp., which is a further step to eliminate unnecessary differences
between the implementation of the CPU architectures.
* Patch by liang a lei, 9 Jan 2004:
Fix Intel 28F128J3 ID in include/flash.h
......
......@@ -45,14 +45,12 @@ SECTIONS
. = ALIGN(4);
.got : { *(.got) }
__u_boot_cmd_start = .;
.u_boot_cmd : { *(.u_boot_cmd) }
__u_boot_cmd_end = .;
armboot_end_data = .;
__u_boot_cmd_start = .;
.u_boot_cmd : { *(.u_boot_cmd) }
__u_boot_cmd_end = .;
. = ALIGN(4);
__bss_start = .;
.bss : { *(.bss) }
armboot_end = .;
_end = .;
}
......@@ -44,17 +44,12 @@ SECTIONS
. = ALIGN(4);
.got : { *(.got) }
__u_boot_cmd_start = .;
.u_boot_cmd : { *(.u_boot_cmd) }
__u_boot_cmd_end = .;
armboot_end_data = .;
__u_boot_cmd_start = .;
.u_boot_cmd : { *(.u_boot_cmd) }
__u_boot_cmd_end = .;
. = ALIGN(4);
bss_start = .;
__bss_start = .;
.bss : { *(.bss) }
bss_end = .;
armboot_end = .;
_end = .;
}
......@@ -44,16 +44,12 @@ SECTIONS
. = ALIGN(4);
.got : { *(.got) }
__u_boot_cmd_start = .;
.u_boot_cmd : { *(.u_boot_cmd) }
__u_boot_cmd_end = .;
armboot_end_data = .;
__u_boot_cmd_start = .;
.u_boot_cmd : { *(.u_boot_cmd) }
__u_boot_cmd_end = .;
. = ALIGN(4);
bss_start = .;
__bss_start = .;
.bss : { *(.bss) }
bss_end = .;
armboot_end = .;
_end = .;
}
......@@ -44,16 +44,12 @@ SECTIONS
. = ALIGN(4);
.got : { *(.got) }
__u_boot_cmd_start = .;
.u_boot_cmd : { *(.u_boot_cmd) }
__u_boot_cmd_end = .;
armboot_end_data = .;
__u_boot_cmd_start = .;
.u_boot_cmd : { *(.u_boot_cmd) }
__u_boot_cmd_end = .;
. = ALIGN(4);
__bss_start = .;
.bss : { *(.bss) }
armboot_end = .;
_end = .;
}
......@@ -44,14 +44,12 @@ SECTIONS
. = ALIGN(4);
.got : { *(.got) }
__u_boot_cmd_start = .;
.u_boot_cmd : { *(.u_boot_cmd) }
__u_boot_cmd_end = .;
armboot_end_data = .;
__u_boot_cmd_start = .;
.u_boot_cmd : { *(.u_boot_cmd) }
__u_boot_cmd_end = .;
. = ALIGN(4);
__bss_start = .;
.bss : { *(.bss) }
armboot_end = .;
_end = .;
}
......@@ -44,15 +44,12 @@ SECTIONS
. = ALIGN(4);
.got : { *(.got) }
__u_boot_cmd_start = .;
.u_boot_cmd : { *(.u_boot_cmd) }
__u_boot_cmd_end = .;
armboot_end_data = .;
__u_boot_cmd_start = .;
.u_boot_cmd : { *(.u_boot_cmd) }
__u_boot_cmd_end = .;
. = ALIGN(4);
__bss_start = .;
.bss : { *(.bss) }
armboot_end = .;
_end = .;
}
......@@ -44,16 +44,12 @@ SECTIONS
. = ALIGN(4);
.got : { *(.got) }
__u_boot_cmd_start = .;
.u_boot_cmd : { *(.u_boot_cmd) }
__u_boot_cmd_end = .;
armboot_end_data = .;
__u_boot_cmd_start = .;
.u_boot_cmd : { *(.u_boot_cmd) }
__u_boot_cmd_end = .;
. = ALIGN(4);
bss_start = .;
__bss_start = .;
.bss : { *(.bss) }
bss_end = .;
armboot_end = .;
_end = .;
}
#TEXT_BASE = 0x00100000
TEXT_BASE = 0x00f00000
TEXT_BASE = 0x00f80000
......@@ -72,7 +72,7 @@ unsigned long flash_init (void)
flash_get_offsets (PHYS_FLASH_1, &flash_info[i]);
break;
default:
panic ("configured to many flash banks!\n");
panic ("configured too many flash banks!\n");
break;
}
size += flash_info[i].size;
......@@ -82,7 +82,7 @@ unsigned long flash_init (void)
*/
flash_protect (FLAG_PROTECT_SET,
CFG_FLASH_BASE,
CFG_FLASH_BASE + _armboot_end_data - _armboot_start,
CFG_FLASH_BASE + _bss_start - _armboot_start,
&flash_info[0]);
flash_protect (FLAG_PROTECT_SET,
......
......@@ -48,12 +48,8 @@ SECTIONS
.u_boot_cmd : { *(.u_boot_cmd) }
__u_boot_cmd_end = .;
armboot_end_data = .;
. = ALIGN(4);
bss_start = .;
__bss_start = .;
.bss : { *(.bss) }
bss_end = .;
armboot_end = .;
_end = .;
}
......@@ -44,14 +44,12 @@ SECTIONS
. = ALIGN(4);
.got : { *(.got) }
__u_boot_cmd_start = .;
.u_boot_cmd : { *(.u_boot_cmd) }
__u_boot_cmd_end = .;
armboot_end_data = .;
__u_boot_cmd_start = .;
.u_boot_cmd : { *(.u_boot_cmd) }
__u_boot_cmd_end = .;
. = ALIGN(4);
__bss_start = .;
.bss : { *(.bss) }
armboot_end = .;
_end = .;
}
......@@ -105,7 +105,7 @@ ulong flash_init(void)
*/
flash_protect(FLAG_PROTECT_SET,
CFG_FLASH_BASE,
CFG_FLASH_BASE + _armboot_end_data - _armboot_start,
CFG_FLASH_BASE + _bss_start - _armboot_start,
&flash_info[0]);
flash_protect(FLAG_PROTECT_SET,
......
......@@ -44,12 +44,12 @@ SECTIONS
. = ALIGN(4);
.got : { *(.got) }
armboot_end_data = .;
__u_boot_cmd_start = .;
.u_boot_cmd : { *(.u_boot_cmd) }
__u_boot_cmd_end = .;
. = ALIGN(4);
bss_start = .;
__bss_start = .;
.bss : { *(.bss) }
bss_end = .;
armboot_end = .;
_end = .;
}
#TEXT_BASE = 0xa1700000
TEXT_BASE = 0xa3000000
TEXT_BASE = 0xa3080000
#TEXT_BASE = 0
......@@ -44,16 +44,12 @@ SECTIONS
. = ALIGN(4);
.got : { *(.got) }
__u_boot_cmd_start = .;
.u_boot_cmd : { *(.u_boot_cmd) }
__u_boot_cmd_end = .;
armboot_end_data = .;
__u_boot_cmd_start = .;
.u_boot_cmd : { *(.u_boot_cmd) }
__u_boot_cmd_end = .;
. = ALIGN(4);
bss_start = .;
__bss_start = .;
.bss : { *(.bss) }
bss_end = .;
armboot_end = .;
_end = .;
}
......@@ -14,11 +14,11 @@
# Linux-Kernel is expected to be at 3000'8000, entry 3000'8000
# optionally with a ramdisk at 3040'0000
#
# we load ourself to 30F8'0000
# we load ourself to 33F8'0000
#
# download area is 3080'0000
#
#TEXT_BASE = 0x30F80000
TEXT_BASE = 0x33F00000
TEXT_BASE = 0x33F80000
......@@ -45,14 +45,12 @@ SECTIONS
. = ALIGN(4);
.got : { *(.got) }
__u_boot_cmd_start = .;
.u_boot_cmd : { *(.u_boot_cmd) }
__u_boot_cmd_end = .;
armboot_end_data = .;
__u_boot_cmd_start = .;
.u_boot_cmd : { *(.u_boot_cmd) }
__u_boot_cmd_end = .;
. = ALIGN(4);
__bss_start = .;
.bss : { *(.bss) }
armboot_end = .;
_end = .;
}
......@@ -17,9 +17,9 @@
#
# Linux-Kernel is expected to be at 1000'8000, entry 1000'8000 (mem base + reserved)
#
# we load ourself to 1100'0000
# we load ourself to 1108'0000
#
#
TEXT_BASE = 0x11000000
TEXT_BASE = 0x11080000
......@@ -45,14 +45,12 @@ SECTIONS
. = ALIGN(4);
.got : { *(.got) }
__u_boot_cmd_start = .;
.u_boot_cmd : { *(.u_boot_cmd) }
__u_boot_cmd_end = .;
armboot_end_data = .;
__u_boot_cmd_start = .;
.u_boot_cmd : { *(.u_boot_cmd) }
__u_boot_cmd_end = .;
. = ALIGN(4);
__bss_start = .;
.bss : { *(.bss) }
armboot_end = .;
_end = .;
}
......@@ -18,9 +18,9 @@
# Linux-Kernel is expected to be at 1000'8000, entry 1000'8000
# (mem base + reserved)
#
# we load ourself to 1100'0000
# we load ourself to 1108'0000
#
#
TEXT_BASE = 0x11000000
TEXT_BASE = 0x11080000
......@@ -44,8 +44,8 @@ SECTIONS
.u_boot_cmd : { *(.u_boot_cmd) }
__u_boot_cmd_end = .;
armboot_end_data = .;
. = ALIGN(4);
__bss_start = .;
.bss : { *(.bss) }
armboot_end = .;
_end = .;
}
......@@ -44,15 +44,12 @@ SECTIONS
. = ALIGN(4);
.got : { *(.got) }
__u_boot_cmd_start = .;
.u_boot_cmd : { *(.u_boot_cmd) }
__u_boot_cmd_end = .;
armboot_end_data = .;
__u_boot_cmd_start = .;
.u_boot_cmd : { *(.u_boot_cmd) }
__u_boot_cmd_end = .;
. = ALIGN(4);
__bss_start = .;
.bss : { *(.bss) }
armboot_end = .;
_end = .;
}
......@@ -15,11 +15,11 @@
# Linux-Kernel is expected to be at 0cf0'0000, entry 0cf0'0000
# optionally with a ramdisk at 0c80'0000
#
# we load ourself to 0CF00000 (must be high enough not to be
# we load ourself to 0CF80000 (must be high enough not to be
# overwritten by the uncompessing Linux kernel)
#
# download area is 0C80'0000
#
TEXT_BASE = 0x0CF00000
TEXT_BASE = 0x0CF80000
......@@ -45,15 +45,12 @@ SECTIONS
. = ALIGN(4);
.got : { *(.got) }
__u_boot_cmd_start = .;
.u_boot_cmd : { *(.u_boot_cmd) }
__u_boot_cmd_end = .;
armboot_end_data = .;
__u_boot_cmd_start = .;
.u_boot_cmd : { *(.u_boot_cmd) }
__u_boot_cmd_end = .;
. = ALIGN(4);
__bss_start = .;
.bss : { *(.bss) }
armboot_end = .;
_end = .;
}
......@@ -45,16 +45,12 @@ SECTIONS
. = ALIGN(4);
.got : { *(.got) }
__u_boot_cmd_start = .;
.u_boot_cmd : { *(.u_boot_cmd) }
__u_boot_cmd_end = .;
armboot_end_data = .;
__u_boot_cmd_start = .;
.u_boot_cmd : { *(.u_boot_cmd) }
__u_boot_cmd_end = .;
. = ALIGN(4);
__bss_start = .;
.bss : { *(.bss) }
armboot_end = .;
_end = .;
}
......@@ -39,7 +39,7 @@ SECTIONS
lib_generic/string.o (.text)
. = DEFINED(env_offset) ? env_offset : .;
common/environment.o (.ppcenv)
common/environment.o (.ppcenv)
*(.text)
}
......@@ -53,15 +53,12 @@ SECTIONS
. = ALIGN(4);
.got : { *(.got) }
__u_boot_cmd_start = .;
.u_boot_cmd : { *(.u_boot_cmd) }
__u_boot_cmd_end = .;
armboot_end_data = .;
__u_boot_cmd_start = .;
.u_boot_cmd : { *(.u_boot_cmd) }
__u_boot_cmd_end = .;
. = ALIGN(4);
__bss_start = .;
.bss : { *(.bss) }
armboot_end = .;
_end = .;
}
......@@ -48,12 +48,8 @@ SECTIONS
.u_boot_cmd : { *(.u_boot_cmd) }
__u_boot_cmd_end = .;
armboot_end_data = .;
. = ALIGN(4);
bss_start = .;
__bss_start = .;
.bss : { *(.bss) }
bss_end = .;
armboot_end = .;
_end = .;
}
......@@ -193,7 +193,7 @@ void putc (const char c)
#ifdef CONFIG_SILENT_CONSOLE
if (gd->flags & GD_FLG_SILENT)
return(0);
return;
#endif
if (gd->flags & GD_FLG_DEVINIT) {
......
......@@ -87,7 +87,7 @@ int cpu_init (void)
#ifdef CONFIG_USE_IRQ
DECLARE_GLOBAL_DATA_PTR;
IRQ_STACK_START = _armboot_start - CFG_MALLOC_LEN - CFG_GBL_DATA_LEN - 4;
IRQ_STACK_START = _armboot_start - CFG_MALLOC_LEN - CFG_GBL_DATA_SIZE - 4;
FIQ_STACK_START = IRQ_STACK_START - CONFIG_STACKSIZE_IRQ;
#endif
return 0;
......
......@@ -63,7 +63,7 @@ _fiq: .word fiq
*
* Startup Code (reset vector)
*
* do important init only if we don't start from memory!
* do important init only if we don't start from RAM!
* relocate armboot to ram
* setup stack
* jump to second stage
......@@ -79,16 +79,15 @@ _armboot_start:
.word _start
/*
* Note: _armboot_end_data and _armboot_end are defined
* by the (board-dependent) linker script.
* _armboot_end_data is the first usable FLASH address after armboot
* These are defined in the board-specific linker script.
*/
.globl _armboot_end_data
_armboot_end_data:
.word armboot_end_data
.globl _armboot_end
_armboot_end:
.word armboot_end
.globl _bss_start
_bss_start:
.word __bss_start
.globl _bss_end
_bss_end:
.word _end
#ifdef CONFIG_USE_IRQ
/* IRQ stack memory (calculated at run-time) */
......@@ -131,7 +130,7 @@ relocate: /* relocate U-Boot to RAM */
beq stack_setup
ldr r2, _armboot_start
ldr r3, _armboot_end
ldr r3, _bss_start
sub r2, r3, r2 /* r2 <- size of armboot */
add r2, r0, r2 /* r2 <- source end address */
......@@ -151,6 +150,17 @@ stack_setup:
#endif
sub sp, r0, #12 /* leave 3 words for abort-stack */
clear_bss:
ldr r0, _bss_start /* find start of bss segment */
add r0, r0, #4 /* start at first byte of bss */
ldr r1, _bss_end /* stop here */
mov r2, #0x00000000 /* clear */
clbss_l:str r2, [r0] /* clear loop... */
add r0, r0, #4
cmp r0, r1
bne clbss_l
ldr pc, _start_armboot
_start_armboot: .word start_armboot
......@@ -225,7 +235,7 @@ cpu_init_crit:
/*
* before relocating, we have to setup RAM timing
* because memory timing is board-dependend, you will
* because memory timing is board-dependent, you will
* find a memsetup.S in your board directory.
*/
mov ip, lr
......@@ -281,9 +291,9 @@ cpu_init_crit:
stmia sp, {r0 - r12} @ Calling r0-r12
add r8, sp, #S_PC
ldr r2, _armboot_end
add r2, r2, #CONFIG_STACKSIZE
sub r2, r2, #8
ldr r2, _armboot_start
sub r2, r2, #(CONFIG_STACKSIZE+CFG_MALLOC_LEN)
sub r2, r2, #(CFG_GBL_DATA_SIZE+8) @ set base 2 words into abort stack
ldmia r2, {r2 - r4} @ get pc, cpsr, old_r0
add r0, sp, #S_FRAME_SIZE @ restore sp_SVC
......@@ -314,9 +324,9 @@ cpu_init_crit:
.endm
.macro get_bad_stack
ldr r13, _armboot_end @ setup our mode stack
add r13, r13, #CONFIG_STACKSIZE @ resides at top of normal stack
sub r13, r13, #8
ldr r13, _armboot_start @ setup our mode stack
sub r13, r13, #(CONFIG_STACKSIZE+CFG_MALLOC_LEN)
sub r13, r13, #(CFG_GBL_DATA_SIZE+8) @ reserved a couple spots in abort stack
str lr, [r13] @ save caller lr / spsr
mrs lr, spsr
......
......@@ -92,7 +92,7 @@ int cpu_init (void)
#ifdef CONFIG_USE_IRQ
DECLARE_GLOBAL_DATA_PTR;
IRQ_STACK_START = _armboot_start - CFG_MALLOC_LEN - CFG_GBL_DATA_LEN - 4;
IRQ_STACK_START = _armboot_start - CFG_MALLOC_LEN - CFG_GBL_DATA_SIZE - 4;
FIQ_STACK_START = IRQ_STACK_START - CONFIG_STACKSIZE_IRQ;