From: Erik M. <er...@us...> - 2001-10-28 20:39:41
|
Update of /cvsroot/blob/blob/src/blob In directory usw-pr-cvs1:/tmp/cvs-serv31022 Modified Files: Makefile.am start.S Added Files: chain.S Log Message: This is quite a large cleanup: - Add a chain loader (chain.S) so blob can be called from other bootloaders - Add an extra target to the Makefile.am: blob-chain - Remove the chain loading capabilities from start.S - Remove memory cleaning and stack setup from start.S --- NEW FILE: chain.S --- /* * chain.S: blob chain loader * * Copyright (C) 2001 Erik Mouw (J.A...@it...) * * $Id: chain.S,v 1.1 2001/10/28 20:39:37 erikm Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ /* * This is a blob first stage loader that can be called with a * hostile non-linux compatible bootloader, so you'll get a linux * compatible chain loader. It's also nice for debugging blob. * * This loader is position independent. */ .ident "$Id: chain.S,v 1.1 2001/10/28 20:39:37 erikm Exp $" #ifdef HAVE_CONFIG_H # include <blob/config.h> #endif #include <blob/arch.h> .text .globl _start _start: /* store our start location */ sub r0, pc, #8 str r0, START /* init LED */ bl ledinit /* assume that the CPU and the memory are already set up at * this point. also assume that interrupts are disabled, and if * not, there is a valid reason for it. */ /* since we're probably running from RAM, we assume that the * RAM is not broken, so we don't want to run a memory tester at * the part of memory where we are loaded. */ relocate: /* get a clue where we are running so we know what to copy */ ldr r0, START /* relocate the second stage loader */ add r2, r0, #(128 * 1024) /* blob is 128kB */ add r0, r0, #0x400 /* skip first 1024 bytes */ ldr r1, MEM_START add r1, r1, #0x400 /* skip over here as well */ /* r0 = source address * r1 = target address * r2 = source end address */ copy_loop: ldmia r0!, {r3-r10} stmia r1!, {r3-r10} cmp r0, r2 ble copy_loop /* turn off the LED. if it stays off it is an indication that * we didn't make it into the C code */ bl led_off /* blob is copied to ram, so jump to it */ ldr r0, MEM_START add r0, r0, #0x400 mov pc, r0 START: .word 0x00000000 MEM_START: .word MEMORY_START Index: Makefile.am =================================================================== RCS file: /cvsroot/blob/blob/src/blob/Makefile.am,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- Makefile.am 2001/10/27 21:04:20 1.8 +++ Makefile.am 2001/10/28 20:39:37 1.9 @@ -25,9 +25,12 @@ bin_PROGRAMS = \ blob-start-elf32 \ blob-start \ + blob-start-chain-elf32 \ + blob-start-chain \ blob-rest-elf32 \ blob-rest \ - blob + blob \ + blob-chain INCLUDES += \ @@ -49,7 +52,8 @@ memsetup-sa1110.S blob_start_elf32_DEPENDENCIES = \ - @MEMSETUP@ + @MEMSETUP@ \ + start-ld-script blob_start_elf32_LDFLAGS += \ -Wl,-T,${srcdir}/start-ld-script @@ -68,7 +72,33 @@ +# ---- Blob first stage chain loader -------------------------------- + +# WARNING: chain.S *must* be the first file, otherwise the target will +# be linked in the wrong order! +blob_start_chain_elf32_SOURCES = \ + chain.S \ + ledasm.S + +blob_start_chain_elf32_DEPENDENCIES =\ + start-ld-script + +blob_start_chain_elf32_LDFLAGS += \ + -Wl,-T,${srcdir}/start-ld-script + +blob_start_chain_elf32_LDADD += \ + -lgcc + + +blob_start_chain_SOURCES = + +blob-start-chain: blob-start-chain-elf32 + $(OBJCOPY) $(OCFLAGS) $< $@ + + + + # ---- Blob second stage --------------------------------------------- # WARNING: trampoline.S *must* be the first file, otherwise the target @@ -76,6 +106,7 @@ blob_rest_elf32_SOURCES = \ trampoline.S \ flashasm.S \ + stack.S \ testmem2.S \ commands.c \ flash.c \ @@ -113,7 +144,8 @@ @BLOB_FLASH_OBJS@ \ @CHKMEM@ \ @DEBUG@ \ - @CLOCK@ + @CLOCK@ \ + rest-ld-script blob_rest_elf32_LDFLAGS += \ @@ -148,7 +180,20 @@ rm -f $@ dd if=blob-start of=$@ bs=1k conv=sync dd if=blob-rest of=$@ bs=1k seek=1 - chmod +x blob + chmod +x $@ + + + + +# ---- Final blob chain loader binary -------------------------------- + +blob_chain_SOURCES = + +blob-chain: blob-start-chain blob-rest + rm -f $@ + dd if=blob-start-chain of=$@ bs=1k conv=sync + dd if=blob-rest of=$@ bs=1k seek=1 + chmod +x $@ Index: start.S =================================================================== RCS file: /cvsroot/blob/blob/src/blob/start.S,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- start.S 2001/10/14 22:37:43 1.3 +++ start.S 2001/10/28 20:39:37 1.4 @@ -71,13 +71,13 @@ #define RCSR 0x04 /* main memory starts at 0xc0000000 */ -MEM_START: .long MEMORY_START +MEM_START: .word MEMORY_START /* The initial CPU speed. Note that the SA11x0 CPUs can be safely overclocked: * 190 MHz CPUs are able to run at 221 MHz, 133 MHz CPUs can do 190 Mhz. */ -cpuspeed: .long CPU_SPEED +cpuspeed: .word CPU_SPEED @@ -88,14 +88,9 @@ mov r1, #0x00 str r1, [r0, #ICMR] - /* if we're running from RAM, we don't want to setup and clear again */ - and r0, pc, #0xff000000 - teq r0, #0 - bne relocate - /* switch CPU to correct speed */ ldr r0, PWR_BASE - LDR r1, cpuspeed + ldr r1, cpuspeed str r1, [r0, #PPCR] @@ -139,27 +134,8 @@ bne mem_test_loop - /* the first megabyte is OK, so let's clear it */ - mov r0, #((1024 * 1024) / (8 * 4)) /* 1MB in steps of 32 bytes */ - ldr r1, MEM_START - mov r2, #0 - mov r3, #0 - mov r4, #0 - mov r5, #0 - mov r6, #0 - mov r7, #0 - mov r8, #0 - mov r9, #0 - -clear_loop: - stmia r1!, {r2-r9} - subs r0, r0, #(8 * 4) - bne clear_loop - - -relocate: - /* get a clue where we are running, so we know what to copy */ - and r0, pc, #0xff000000 /* we don't care about the low bits */ +relocate: + adr r0, _start /* relocate the second stage loader */ add r2, r0, #(128 * 1024) /* blob is 128kB */ @@ -184,13 +160,8 @@ bl led_off - /* set up the stack pointer */ - ldr r0, MEM_START - add r1, r0, #(1024 * 1024) - sub sp, r1, #0x04 - - /* blob is copied to ram, so jump to it */ + ldr r0, MEM_START add r0, r0, #0x400 mov pc, r0 |