[PATCH] bsps/sparc: Fix BSS initialization
Daniel Hellstrom
daniel at gaisler.com
Wed May 14 07:37:30 UTC 2014
Hello Sebastian,
I think the patch is correct, however I would rather see that you use g4 instead of g2 to increment, that way you don't need the move either.
Looking in the area of the code that you patch, it seems as if this code hasn't been run. I have a TODO since long to go over this code, however the main usage of the RTEMS is to run it from RAM. As I
understand RTEMS on LEON is never run from ROM, which I would like to fix some day.
Looking at the code above:
copy_data:
ldd [ %g2 ], %g5
std %g5 , [ %g3 ] ! copy this double word
add %g3, 8, %g3 ! bump the destination pointer
add %g2, 8, %g2 ! bump the source pointer
cmp %g3, %g4 ! Is the pointer past the end of dest?
bl copy_data
nop
It does a LDD and STD to/from non-double registers, which should cause illegal-instruction trap to happen. %g5 can not be used together with LDD or STD.
Thanks,
Daniel Hellstrom
On 05/13/2014 02:34 PM, Sebastian Huber wrote:
> Use __bss_start available via %g4 to clear the BSS section. The usage
> of _edata resulted in a copy of [_edata, __bss_start) from ROM to RAM
> and then a clear to zero of this area.
>
> Clear now only [__bss_start, _end).
> ---
> c/src/lib/libbsp/sparc/shared/start/start.S | 3 +--
> 1 files changed, 1 insertions(+), 2 deletions(-)
>
> diff --git a/c/src/lib/libbsp/sparc/shared/start/start.S b/c/src/lib/libbsp/sparc/shared/start/start.S
> index 26da7b4..b191c7e 100644
> --- a/c/src/lib/libbsp/sparc/shared/start/start.S
> +++ b/c/src/lib/libbsp/sparc/shared/start/start.S
> @@ -344,8 +344,7 @@ copy_data:
> /* clear the bss */
> 1:
>
> - sethi %hi(_edata),%g2
> - or %g2,%lo(_edata),%g2 ! g2 = start of bss
> + mov %g4, %g2 ! g2 = start of bss
> sethi %hi(_end),%g3
> or %g3,%lo(_end),%g3 ! g3 = end of bss
> mov %g0,%g1 ! so std has two zeros
More information about the devel
mailing list