commit b7dd79006d5729904c2967fffc23143850508683
parent 8daf3f3bbd5f2f0949eb308fbaf9f4b01b98d4b9
Author: Roberto Vargas <roberto.vargas@arm.com>
Date: Sun, 14 Oct 2018 15:20:25 +0100
[arch/arm64] Add a context stack
This patc only allocates space for the context stack at the
botton of the sram, over the bss.
Change-Id: I943da955c89bbc90c31bb2c318c46ee29c5a8ae8
Diffstat:
2 files changed, 30 insertions(+), 14 deletions(-)
diff --git a/arch/arm64/crt-none.s b/arch/arm64/crt-none.s
@@ -1,14 +1,13 @@
/* TODO: extract data section address from RSCB */
-BSS = 0x2E00F000
-BSSSIZ = 1024
-PAGESIZ = 4096
+SRAMADDR = 0x2E00F000
+SRAMSIZE = 4096
.text
.globl _start
_start:
msr spsel,#1
- ldr x0,=BSS
- mov x1,#(PAGESIZ-16) /* Stack grows down towards BSS */
+ ldr x0,=SRAMADDR
+ mov x1,#(SRAMSIZE-16) /* Stack grows down towards BSS */
add x0,x0,x1
mov sp,x0
mov x29,sp
@@ -21,11 +20,8 @@ _start:
bl _uart_init
stp xzr,xzr,[x29] /* zero FP/LR to terminate backtrace */
- ldr x0,=BSS
- mov x1,#0
- mov x2,BSSSIZ
- bl memset
+ ldr x0,=SRAMADDR
bl main
adr x0,outsync
b panic
diff --git a/arch/arm64/rom.c b/arch/arm64/rom.c
@@ -1,5 +1,15 @@
+#include <string.h>
+
#include <rcode.h>
+/*
+ * We allocate space for 3 nested exceptions, covering
+ * the case of having an abort while dealing a panic
+ * from an abort generated by the rmc. You are not
+ * expected to understand this.
+ */
+#define NR_NESTED 3
+
void
synchdl(struct trapframe *fp)
{
@@ -30,14 +40,24 @@ badrmc(Rmucmd *cmd, int error)
}
void
-main(void)
+main(void *sram)
{
- struct trapframe frame = { 0 }; /* don't leak info to EL3h */
+ struct trapframe *fp;
+ char *bp;
+ size_t bsssiz;
+
+ bsssiz = (sizeof(struct bssmap)+15) & ~15;
+ memset(sram, 0, bsssiz);
- frame.elr = read_rvbar_el3();
- frame.spsr = 0xf << 6 | 0xd;
+ bp = (char *) sram + bsssiz;
+ fp = (struct trapframe *) bp;
+ fp += NR_NESTED - 1;
+ memset(fp, 0, sizeof(*fp));
- swtch(&frame);
+ fp->elr = read_rvbar_el3();
+ fp->spsr = 0xf << 6 | 0xd;
+
+ swtch(fp);
/*
* main is not expected to return. If it happens we will
* be out of sync and we will panic