Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/evbarm/stand/gzboot Add support for running directl...



details:   https://anonhg.NetBSD.org/src/rev/e87c46260277
branches:  trunk
changeset: 522645:e87c46260277
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sat Feb 23 18:19:09 2002 +0000

description:
Add support for running directly out of flash:
* Require that the builder Makefile provide a linker script.
* After making sure the MMU is disabled, check to see if
  _etext == __data_start.  If not, then copy the .data contents
  into RAM.
* Put the stack in .bss.

diffstat:

 sys/arch/evbarm/stand/gzboot/Makefile.gzboot |   6 ++--
 sys/arch/evbarm/stand/gzboot/srtbegin.S      |  33 +++++++++++++++++++++++++--
 2 files changed, 33 insertions(+), 6 deletions(-)

diffs (93 lines):

diff -r d0d2f84949bf -r e87c46260277 sys/arch/evbarm/stand/gzboot/Makefile.gzboot
--- a/sys/arch/evbarm/stand/gzboot/Makefile.gzboot      Sat Feb 23 17:27:42 2002 +0000
+++ b/sys/arch/evbarm/stand/gzboot/Makefile.gzboot      Sat Feb 23 18:19:09 2002 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.gzboot,v 1.1 2002/02/23 05:41:14 thorpej Exp $
+#      $NetBSD: Makefile.gzboot,v 1.2 2002/02/23 18:19:09 thorpej Exp $
 
 NOMAN=  # defined
 
@@ -77,7 +77,7 @@
 cleanlibdir:
        rm -rf lib
 
-LDFLAGS= -M -N -e start
+LDFLAGS= -M -e start -T ${LDSCRIPT}
 
 LIBLIST=${LIBSA} ${LIBZ} ${LIBSA} ${LIBKERN} ${LIBSA}
 
@@ -87,7 +87,7 @@
            ${NEWVERSWHAT}
 
 ${PROG}: ${STARTFILE} ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN}
-       ${LD} -o ${BASE}.sym ${LDFLAGS} -Ttext 0x${RELOC} ${STARTFILE} \
+       ${LD} -o ${BASE}.sym ${LDFLAGS} ${STARTFILE} \
            ${OBJS} ${LIBLIST} > ${BASE}.list
 
 .include <bsd.prog.mk>
diff -r d0d2f84949bf -r e87c46260277 sys/arch/evbarm/stand/gzboot/srtbegin.S
--- a/sys/arch/evbarm/stand/gzboot/srtbegin.S   Sat Feb 23 17:27:42 2002 +0000
+++ b/sys/arch/evbarm/stand/gzboot/srtbegin.S   Sat Feb 23 18:19:09 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: srtbegin.S,v 1.1 2002/02/23 05:41:14 thorpej Exp $     */
+/*     $NetBSD: srtbegin.S,v 1.2 2002/02/23 18:19:09 thorpej Exp $     */
 
 /*
  * Copyright (c) 2002 Wasabi Systems, Inc.
@@ -38,6 +38,8 @@
 #include <machine/asm.h>
 #include <arm/armreg.h>
 
+#define        STACKSIZE       1024
+
 ENTRY(start)
        /*
         * We assume we've been loaded VA==PA, or that the MMU
@@ -52,6 +54,23 @@
        nop
        nop
 
+       /*
+        * Check to see if &_etext == &__data_start.  If not,
+        * we're most likely built for running from flash,
+        * and must copy the data segment out to RAM.
+        */
+       add     r1, pc, #(Ldata - . - 8)
+       ldmia   r1, {r1-r3}
+       cmp     r1, r2                  /* &_etext == &__data_start? */
+       beq     2f                      /* yes, in RAM */
+
+       /* Copy data segment from ROM to RAM */
+1:     ldrb    r0, [r1], #0x01
+       strb    r0, [r2], #0x01
+       cmp     r2, r3                  /* copy done? */
+       bne     1b
+
+2:
        /* Clear the BSS. */
        add     r1, pc, #(Lbss - . - 8)
        ldmia   r1, {r1, r2}
@@ -63,13 +82,21 @@
        bgt     1b
 
        /* Set the stack pointer */
-       add     sp, pc, #(Lstack - . - 8)       /* XXX for now */
+       add     r1, pc, #(Lstack - . - 8)
+       ldr     r1, [r1]
+       add     sp, r1, #STACKSIZE
 
        b       _C_LABEL(main)
 
+Ldata:
+       .word   _C_LABEL(_etext)
+       .word   _C_LABEL(__data_start)
+
 Lbss:
        .word   _C_LABEL(_edata)
        .word   _C_LABEL(_end)
 
 Lstack:
-       .space  1024                            /* XXX for now */
+       .word   Lstackspace
+
+       .comm   Lstackspace, STACKSIZE



Home | Main Index | Thread Index | Old Index