Refactor gsTCB struct for debugging and update usage in related files

This commit is contained in:
EnderIce2 2024-03-13 03:41:12 +02:00
parent e021c1d9eb
commit 2ffd8e3c34
Signed by untrusted user who does not match committer: enderice2
GPG Key ID: EACC3AD603BAB4DD
3 changed files with 27 additions and 20 deletions

View File

@ -239,38 +239,42 @@ namespace Tasking
*/
struct gsTCB
{
/**
* Used by syscall handler
*
/** Used by syscall handler
* gs+0x0
*/
uintptr_t SyscallStack;
void *SyscallStack;
/**
* Used by syscall handler
*
/** Used by syscall handler
* gs+0x8
*/
uintptr_t TempStack;
/**
* Used by syscall handler
*
* gs+0x10
*/
uint8_t Flags;
void *TempStack;
/* For future use */
/* gs+0x11 */
uintptr_t Padding : 7;
/** Used by syscall handler
* gs+0x10
*/
uintptr_t Flags;
/* gs+0x18 */
uintptr_t Padding;
/* gs+0x20 */
void *SyscallStackBase;
int ScPages;
/* gs+0x28 */
intptr_t ScPages;
/**
* The current thread class
* gs+0x30
*/
class TCB *t;
#ifdef DEBUG
/* gs+0x38 */
uintptr_t __stub;
#endif
};
class TCB

View File

@ -452,7 +452,7 @@ namespace Tasking
sf->rax = si->tf.rax;
sf->Flags = si->tf.rflags.raw;
sf->ReturnAddress = si->tf.rip;
gs->TempStack = si->tf.rsp;
gs->TempStack = (void *)si->tf.rsp;
SignalMask.store(si->SignalMask);

View File

@ -508,10 +508,13 @@ namespace Tasking
this->Stack = new Memory::StackGuard(true, this->vma);
gsTCB *gsT = (gsTCB *)this->vma->RequestPages(TO_PAGES(sizeof(gsTCB)));
#ifdef DEBUG
gsT->__stub = 0xFFFFFFFFFFFFFFFF;
#endif
gsT->ScPages = TO_PAGES(STACK_SIZE);
gsT->SyscallStackBase = this->vma->RequestPages(gsT->ScPages);
gsT->SyscallStack = (uintptr_t)gsT->SyscallStackBase + STACK_SIZE - 0x10;
gsT->SyscallStack = (void *)((uintptr_t)gsT->SyscallStackBase + STACK_SIZE - 0x10);
debug("New syscall stack created: %#lx (base: %#lx) with gs base at %#lx",
gsT->SyscallStack, gsT->SyscallStackBase, gsT);