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