gxf: Per-CPU gxf stack

Signed-off-by: Hector Martin <marcan@marcan.st>
This commit is contained in:
Hector Martin 2021-09-15 22:09:07 +09:00
parent 368b48a365
commit 8752d5fbba
3 changed files with 33 additions and 12 deletions

View file

@ -4,18 +4,14 @@
#include "exception.h"
#include "gxf.h"
#include "memory.h"
#include "smp.h"
#include "uart.h"
#include "utils.h"
#define GL_STACK_SIZE 0x4000
uint64_t gxf_enter(void *func, uint64_t a, uint64_t b, uint64_t c, uint64_t d);
u8 gl1_stack[GL_STACK_SIZE] ALIGNED(64);
void *gl1_stack_base = &gl1_stack[GL_STACK_SIZE];
u8 gl2_stack[GL_STACK_SIZE] ALIGNED(64);
void *gl2_stack_base = &gl2_stack[GL_STACK_SIZE];
u8 gl1_stack[MAX_CPUS][GL_STACK_SIZE] ALIGNED(0x4000);
u8 gl2_stack[MAX_CPUS][GL_STACK_SIZE] ALIGNED(0x4000);
bool gxf_enabled(void)
{

View file

@ -5,6 +5,10 @@
#include "types.h"
#define GL_STACK_SIZE 0x10000
#ifndef __ASSEMBLER__
bool gxf_enabled(void);
bool in_gl12(void);
@ -14,3 +18,5 @@ uint64_t gl1_call(void *func, uint64_t a, uint64_t b, uint64_t c, uint64_t d);
uint64_t gl2_call(void *func, uint64_t a, uint64_t b, uint64_t c, uint64_t d);
#endif
#endif

View file

@ -1,10 +1,14 @@
/* SPDX-License-Identifier: MIT */
#include "cpu_regs.h"
#include "gxf.h"
#define genter .long 0x00201420
#define gexit .long 0x00201400
.extern gl1_stack
.extern gl2_stack
.global gxf_init
.type gxf_init, @function
gxf_init:
@ -32,8 +36,19 @@ gxf_enter:
ret
_gxf_setup:
ldr x0, =gl2_stack_base
ldr x0, [x0]
mrs x2, TPIDR_EL1
mrs x4, CurrentEL
cmp x4, #8
bne 1f
mrs x2, TPIDR_EL2
1:
add x2, x2, 1
ldr x0, =gl2_stack
ldr x1, =GL_STACK_SIZE
mul x1, x1, x2
add x0, x0, x1
mov sp, x0
ldr x1, =_gxf_vectors
ldr x2, =_gxf_exc_sync
@ -46,14 +61,18 @@ _gxf_setup:
cmp x4, #8
bne 1f
ldr x0, =gl1_stack_base
ldr x0, [x0]
mrs x2, TPIDR_EL2
ldr x0, =gl1_stack
ldr x1, =GL_STACK_SIZE
mul x1, x1, x2
add x0, x0, x1
msr SYS_IMP_APL_SP_GL12, x0
msr SYS_IMP_APL_VBAR_GL12, x1
msr SYS_IMP_APL_GXF_ABORT_EL12, x2
msr SYS_IMP_APL_GXF_ENTER_EL12, x3
1:
1:
isb
gexit