mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-11-15 09:36:35 +00:00
thermosphere: add cctx->userFrame
This commit is contained in:
parent
dd96c8b32b
commit
a7741c8576
2 changed files with 27 additions and 22 deletions
|
@ -20,29 +20,32 @@
|
|||
#include "barrier.h"
|
||||
#include "execute_function.h"
|
||||
|
||||
struct ExceptionStackFrame;
|
||||
typedef struct CoreCtx {
|
||||
u64 kernelArgument; // @0x00
|
||||
uintptr_t kernelEntrypoint; // @0x08
|
||||
u8 *crashStack; // @0x10
|
||||
u64 scratch; // @0x18
|
||||
u32 coreId; // @0x20
|
||||
u8 gicInterfaceMask; // @0x24. Equal to BIT(coreId) anyway
|
||||
bool isBootCore; // @0x25
|
||||
bool warmboot; // @0x26
|
||||
|
||||
// "Execute function"
|
||||
ExecutedFunction executedFunction; // @0x28
|
||||
void *executedFunctionArgs; // @0x30
|
||||
Barrier executedFunctionBarrier; // @0x38
|
||||
bool executedFunctionSync; // @0x3C
|
||||
struct ExceptionStackFrame *userFrame; // @0x00
|
||||
u64 scratch; // @0x08
|
||||
u8 *crashStack; // @0x10
|
||||
u64 kernelArgument; // @0x18
|
||||
uintptr_t kernelEntrypoint; // @0x20
|
||||
u32 coreId; // @0x28
|
||||
u8 gicInterfaceMask; // @0x2C. Equal to BIT(coreId) anyway
|
||||
bool isBootCore; // @0x2D
|
||||
bool warmboot; // @0x2E
|
||||
|
||||
// Timer stuff
|
||||
u64 totalTimeInHypervisor; // @0x40. cntvoff_el2 is updated to that value.
|
||||
u64 emulPtimerCval; // @0x48. When setting cntp_cval_el0 and on interrupt
|
||||
u64 totalTimeInHypervisor; // @0x30. cntvoff_el2 is updated to that value.
|
||||
u64 emulPtimerCval; // @0x38. When setting cntp_cval_el0 and on interrupt
|
||||
|
||||
// "Execute function"
|
||||
ExecutedFunction executedFunction; // @0x40
|
||||
void *executedFunctionArgs; // @0x48
|
||||
Barrier executedFunctionBarrier; // @0x50
|
||||
bool executedFunctionSync; // @0x54
|
||||
} CoreCtx;
|
||||
|
||||
static_assert(offsetof(CoreCtx, executedFunctionSync) == 0x3C, "Wrong definition for CoreCtx");
|
||||
static_assert(offsetof(CoreCtx, emulPtimerCval) == 0x48, "Wrong definition for CoreCtx");
|
||||
static_assert(offsetof(CoreCtx, warmboot) == 0x2E, "Wrong definition for CoreCtx");
|
||||
static_assert(offsetof(CoreCtx, emulPtimerCval) == 0x38, "Wrong definition for CoreCtx");
|
||||
static_assert(offsetof(CoreCtx, executedFunctionSync) == 0x54, "Wrong definition for CoreCtx");
|
||||
|
||||
extern CoreCtx g_coreCtxs[4];
|
||||
register CoreCtx *currentCoreCtx asm("x18");
|
||||
|
|
|
@ -65,12 +65,12 @@
|
|||
.macro PIVOT_STACK_FOR_CRASH
|
||||
// Note: x18 assumed uncorrupted
|
||||
// Note: replace sp_el0 with crashing sp
|
||||
str x16, [x18, #0x18] // currentCoreCtx->scratch = x16
|
||||
str x16, [x18, #8] // currentCoreCtx->scratch = x16
|
||||
mov x16, sp
|
||||
msr sp_el0, x16
|
||||
ldr x16, [x18, #0x10] // currentCoreCtx->crashStack
|
||||
ldr x16, [x18, #0x10] // currentCoreCtx->crashStack
|
||||
mov sp, x16
|
||||
ldr x16, [x18, #0x18]
|
||||
ldr x16, [x18, #8]
|
||||
.endm
|
||||
|
||||
.equ EXCEPTION_TYPE_HOST, 0
|
||||
|
@ -85,14 +85,16 @@ vector_entry \name
|
|||
|
||||
SAVE_MOST_REGISTERS
|
||||
|
||||
mov x0, sp
|
||||
|
||||
.if \type == EXCEPTION_TYPE_GUEST
|
||||
ldp x18, xzr, [sp, #STACK_FRAME_SIZE]
|
||||
str x0, [x18] // currentCoreCtx->userFrame
|
||||
mov w1, #1
|
||||
.else
|
||||
mov w1, #0
|
||||
.endif
|
||||
|
||||
mov x0, sp
|
||||
bl exceptionEntryPostprocess
|
||||
.endm
|
||||
|
||||
|
|
Loading…
Reference in a new issue