simplified and corrected BaS copy

This commit is contained in:
Markus Fröschle
2012-10-19 08:42:35 +00:00
parent f13e2c9a5a
commit ee65c96f7c
2 changed files with 13 additions and 14 deletions

View File

@@ -1,5 +1,5 @@
MEMORY { MEMORY {
flash (RX) : ORIGIN = 0xE0000000, LENGTH = 0xFFFFFFFF flash (RX) : ORIGIN = 0xE0000000, LENGTH = 0x00200000
ram (WX) : ORIGIN = 0x1FE00000, LENGTH = 0x00100000 /* target to copy BaS to */ ram (WX) : ORIGIN = 0x1FE00000, LENGTH = 0x00100000 /* target to copy BaS to */
} }
@@ -80,6 +80,7 @@ SECTIONS {
.bas _Bas_base : AT (ADDR(.text) + SIZEOF(.text)) .bas _Bas_base : AT (ADDR(.text) + SIZEOF(.text))
{ {
objs/BaS.o(.text) objs/BaS.o(.text)
_bas_length = . - _BaS; _bas_end = ABSOLUTE(.);
} > ram } > ram
} }

View File

@@ -668,15 +668,13 @@ livo:
} }
void initialize_hardware(void) { void initialize_hardware(void) {
extern uint8_t *Bas_base; /* target address to copy bas to (from linker script) */ extern uint32_t bas; /* source address to copy bas from (from linker script) FIXME: beware of possible alignment */
extern uint8_t *bas; /* source address to copy bas from (from linker script) FIXME: beware of possible alignment */ extern uint32_t bas_end; /* end of BaS code to copy (from linker script) */
extern uint32_t bas_length;/* length of BaS code to copy (from linker script) */ extern uint32_t BaS; /* BaS routine to jump to after copy */
extern void *BaS; /* BaS routine to jump to after copy */
int i;
uint32_t *src; uint32_t *src;
uint32_t *dst; uint32_t *dst;
uint8_t *jmp; uint32_t *jmp;
__asm__ __volatile__( __asm__ __volatile__(
"move.l #0x000C8120,D0\n\t" "move.l #0x000C8120,D0\n\t"
@@ -710,18 +708,18 @@ void initialize_hardware(void) {
/* copy the BaS code contained in flash to its final location */ /* copy the BaS code contained in flash to its final location */
src = (uint32_t *)&bas; src = (uint32_t *)&bas;
dst = (uint32_t *)&Bas_base; dst = jmp = (uint32_t *)&BaS;
jmp = (uint8_t *)&BaS;
for (i = 0; i < (int) &bas_length / 16; i+= 4) do
{ {
*src++ = *dst++; *src++ = *dst++;
*src++ = *dst++; *src++ = *dst++;
*src++ = *dst++; *src++ = *dst++;
*src++ = *dst++; *src++ = *dst++;
} } while (dst < &bas_end);
flushDataCacheRegion(&Bas_base, (int) &bas_length); flushDataCacheRegion(&BaS, (uint32_t) (&bas_end - &BaS));
flushInstructionCacheRegion(&Bas_base, (int) &bas_length); flushInstructionCacheRegion(&BaS, (uint32_t) (&bas_end - &BaS));
__asm__ __volatile__( __asm__ __volatile__(
" move.l %0,a3 | calculated start address\n\t" " move.l %0,a3 | calculated start address\n\t"