aboutsummaryrefslogtreecommitdiff
path: root/lib/lpc43xx/vector.c
diff options
context:
space:
mode:
authorTitanMKD2012-06-10 11:44:36 +0200
committerTitanMKD2012-06-10 11:44:36 +0200
commit3c8e76f679158d2a5cb1a16a7da1c4f48066ddfc (patch)
tree0f8f4b8e95125113f8c37a81230159d7571c4a1d /lib/lpc43xx/vector.c
parentd2b15c72be1d3d3a85598cffce237bbae8401f9d (diff)
Added ROM to RAM code copy & exec with example of how to use it (miniblink_rom_to_ram).
Diffstat (limited to 'lib/lpc43xx/vector.c')
-rw-r--r--lib/lpc43xx/vector.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/lpc43xx/vector.c b/lib/lpc43xx/vector.c
index 33eee4a..631e54e 100644
--- a/lib/lpc43xx/vector.c
+++ b/lib/lpc43xx/vector.c
@@ -22,6 +22,7 @@
/* Symbols exported by the linker script(s). */
extern unsigned _etext, _data, _edata, _ebss, _stack;
+extern unsigned _etext_ram, _text_ram, _etext_rom;
void main(void);
void reset_handler(void);
@@ -158,11 +159,29 @@ void (*const vector_table[]) (void) = {
qei_irqhandler,
};
+#define MMIO32(addr) (*(volatile unsigned long*)(addr))
+#define CREG_M4MEMMAP MMIO32( (0x40043000 + 0x100) )
+
void reset_handler(void)
{
volatile unsigned *src, *dest;
__asm__("MSR msp, %0" : : "r"(&_stack));
+ /* Copy the code from ROM to Real RAM (if enabled) */
+ if( (&_etext_ram-&_text_ram) > 0 )
+ {
+ src = &_etext_rom-(&_etext_ram-&_text_ram);
+ for(dest = &_text_ram; dest < &_etext_ram; )
+ {
+ *dest++ = *src++;
+ }
+
+ /* Change Shadow memory to Real RAM */
+ CREG_M4MEMMAP = (unsigned long)&_text_ram;
+
+ /* Continue Execution in RAM */
+ }
+
for (src = &_etext, dest = &_data; dest < &_edata; src++, dest++)
*dest = *src;