1
0
Fork 0
mirror of https://gitlab.com/sortix/sortix.git synced 2023-02-13 20:55:38 -05:00

Better abstraction of setting kernel stack.

This commit is contained in:
Jonas 'Sortie' Termansen 2012-08-02 15:24:00 +02:00
parent 950610e1eb
commit 61dbb4a2ec
3 changed files with 11 additions and 11 deletions

View file

@ -80,17 +80,17 @@ namespace Sortix
Syscall::Register(SYSCALL_SLEEP, (void*) SysSleep);
Syscall::Register(SYSCALL_USLEEP, (void*) SysUSleep);
addr_t stackstart = Memory::GetKernelStack();
addr_t stackhigher = Memory::GetKernelStack();
size_t stacksize = Memory::GetKernelStackSize();
addr_t stackend = stackstart - stacksize;
addr_t stacklower = stackhigher - stacksize;
int prot = PROT_KREAD | PROT_KWRITE;
if ( !Memory::MapRange(stackend, stacksize, prot) )
if ( !Memory::MapRange(stacklower, stacksize, prot) )
{
PanicF("could not create kernel stack (%zx to %zx)",
stackend, stackstart);
stacklower, stackhigher);
}
GDT::SetKernelStack((size_t*) stackstart);
GDT::SetKernelStack(stacklower, stacksize, stackhigher);
}
// The no operating thread is a thread stuck in an infinite loop that

View file

@ -1,6 +1,6 @@
/*******************************************************************************
COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2011, 2012.
Copyright(C) Jonas 'Sortie' Termansen 2011, 2012.
This file is part of Sortix.
@ -142,12 +142,12 @@ namespace Sortix
#endif
}
void SetKernelStack(size_t* stack)
void SetKernelStack(addr_t stacklower, size_t stacksize, addr_t stackhigher)
{
#ifdef PLATFORM_X86
tss_entry.esp0 = (uint32_t) stack;
tss_entry.esp0 = (uint32_t) stackhigher;
#elif defined(PLATFORM_X64)
tss_entry.stack0 = (uint64_t) stack;
tss_entry.stack0 = (uint64_t) stackhigher;
#else
#warning "TSS is not yet supported on this arch!"
while(true);

View file

@ -1,6 +1,6 @@
/*******************************************************************************
COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2011, 2012.
Copyright(C) Jonas 'Sortie' Termansen 2011, 2012.
This file is part of Sortix.
@ -120,7 +120,7 @@ namespace Sortix
void Init();
void SetGate(int32_t num, uint32_t base, uint32_t limit, uint8_t access, uint8_t gran);
void WriteTSS(int32_t num, uint16_t ss0, addr_t stack0);
void SetKernelStack(size_t* stack);
void SetKernelStack(addr_t stacklower, size_t stacksize, addr_t stackhigher);
}
}