From 4a969e2452cc48b5a9fb466dc3e4e66e3f61c820 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vincent=20Rivi=C3=A8re?= Date: Wed, 7 Nov 2012 20:24:42 +0000 Subject: [PATCH] Fixed potential BaS size alignment issue. --- bas.lk.in | 6 +++++- sources/sysinit.c | 8 +++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/bas.lk.in b/bas.lk.in index 7205203..de853e9 100644 --- a/bas.lk.in +++ b/bas.lk.in @@ -91,7 +91,11 @@ SECTIONS { objs/illegal_instruction.o(.text) *(.data) *(.bss) - . = ALIGN(4); + + /* The BaS copy routine assumes that tha BaS size + * is a multiple of the following value. + */ + . = ALIGN(16); } > ram __BAS_LMA = LOADADDR(.bas); diff --git a/sources/sysinit.c b/sources/sysinit.c index 673360a..ef6c2a0 100644 --- a/sources/sysinit.c +++ b/sources/sysinit.c @@ -807,14 +807,16 @@ void initialize_hardware(void) { end = (uint32_t *)(BAS_LMA + BAS_SIZE); dst = jmp = (uint32_t *)BAS_VMA; - /* FIXME: beware of possible alignment */ - do + /* The linker script will ensure that the Bas size + * is a multiple of the following. + */ + while (src < end) { *dst++ = *src++; *dst++ = *src++; *dst++ = *src++; *dst++ = *src++; - } while (src < end); + } /* we have copied a code area, so flush the caches */ flush_and_invalidate_caches();