thermosphere: rework linkscrips, use discardable sections, better sp pivot on crash

This commit is contained in:
TuxSH
2019-08-02 00:47:48 +02:00
parent e6c5eb3928
commit e0339049b3
9 changed files with 92 additions and 56 deletions

View File

@@ -19,6 +19,8 @@
// start.s
extern uintptr_t g_initialKernelEntrypoint;
extern u8 __stacks_top__[], __crash_stacks_top__[];
// Prevents it from being put in BSS
CoreCtx g_coreCtxs[4] = {
{ .coreId = 0 },
@@ -29,10 +31,12 @@ CoreCtx g_coreCtxs[4] = {
void coreCtxInit(u32 coreId, bool isColdbootCore, u64 argument)
{
size_t crashStackSize = (__crash_stacks_top__ - __stacks_top__) / 4;
currentCoreCtx = &g_coreCtxs[coreId];
currentCoreCtx->isColdbootCore = isColdbootCore;
currentCoreCtx->kernelArgument = argument;
if (isColdbootCore) {
currentCoreCtx->crashStack = __crash_stacks_top__ - crashStackSize * coreId;
if (isColdbootCore && currentCoreCtx->kernelEntrypoint == 0) {
currentCoreCtx->kernelEntrypoint = g_initialKernelEntrypoint;
}
}