Skip to content

Commit 4cb876b

Browse files
ArcaneNibbledlech
authored andcommitted
pbio/platform/ev3: Use linker script and ELF loader to copy vector table
U-boot will automatically copy the table to the ARM local RAM, so we no longer need to manually perform the copy in SystemInit.
1 parent cd8f693 commit 4cb876b

File tree

3 files changed

+16
-28
lines changed

3 files changed

+16
-28
lines changed

lib/pbio/platform/ev3/exceptionhandler.S

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
@ SPDX-License-Identifier: MPL-1.0
22
@ Copyright (c) 2016 Tobias Schießl
3-
.global ExceptionHandler
4-
.global IRQHandler
5-
.global SWIHandler
6-
73
.set MODE_USR, 0x10
84
.set MODE_FIQ, 0x11
95
.set MODE_IRQ, 0x12
@@ -16,22 +12,21 @@
1612
.equ I_F_BIT, 0xC0
1713
.equ MASK_SWI_NUM, 0xFF000000
1814

19-
.text
15+
@ This will be placed at 0xffff0000 by the linker script
16+
.section .vector,"ax",%progbits
2017

2118
.code 32
2219

23-
@ Default entry for all vectors except Reset is "B ExceptionHandler" so each interrupt would cause a reset
24-
@ Since I can only say that the IRQ Handler works, we leave the remaining ones as they are
25-
ExceptionHandler:
20+
ResetToEntry:
2621
B Entry
27-
B ExceptionHandler
22+
B ResetToEntry
2823
B SWIHandler
29-
B ExceptionHandler
30-
B ExceptionHandler
31-
B ExceptionHandler
24+
B ResetToEntry
25+
B ResetToEntry
26+
B ResetToEntry
3227
B IRQHandler
3328
NOP @ Fall to FIQHandler
34-
29+
3530
FIQHandler:
3631
STMFD r13!, {r0-r7, lr}
3732
LDR r0, =0xFFFEF600

lib/pbio/platform/ev3/platform.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -393,19 +393,6 @@ const pbdrv_ioport_platform_data_t pbdrv_ioport_platform_data[PBDRV_CONFIG_IOPOR
393393
},
394394
};
395395

396-
// See exceptionhandler.S
397-
extern void ExceptionHandler(void);
398-
399-
void copy_vector_table(void) {
400-
unsigned int *dest = (unsigned int *)0xFFFF0000;
401-
unsigned int *addrExceptionHandler = (unsigned int *)ExceptionHandler;
402-
int i = 1;
403-
404-
for (; i < 8 + 2048; ++i) {
405-
dest[i] = addrExceptionHandler[i];
406-
}
407-
}
408-
409396
unsigned int EDMAVersionGet(void) {
410397
return 1;
411398
}
@@ -558,8 +545,6 @@ void SystemInit(void) {
558545

559546
SysCfgRegistersUnlock();
560547

561-
copy_vector_table();
562-
563548
// Initialize advanced interrupt controller (AINTC)
564549
IntAINTCInit();
565550
IntMasterIRQEnable();

lib/pbio/platform/ev3/platform.ld

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ MEMORY
88
SRAM (rwx) : ORIGIN = 0x80000000, LENGTH = 128K
99
DDR_unused (rwx) : ORIGIN = 0xC0000000, LENGTH = 0x8000
1010
DDR (rwx) : ORIGIN = 0xC0008000, LENGTH = (64M - 0x8000)
11+
ARM_LRAM (rwx) : ORIGIN = 0xFFFF0000, LENGTH = 8K
1112
}
1213

1314
_minimal_stack_size = 4M;
@@ -53,6 +54,13 @@ SECTIONS
5354
*(.noinit)
5455
} > DDR
5556

57+
/* Exception vector table */
58+
.vector :
59+
{
60+
. = ALIGN(4);
61+
KEEP(*(.vector));
62+
} > ARM_LRAM
63+
5664
.stack :
5765
{
5866
. = ALIGN(4);

0 commit comments

Comments
 (0)