mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-05-28 15:34:33 +00:00
Create a new stack for kernel and update BootInfo structure before anything else
This commit is contained in:
parent
c9e2d99570
commit
1efc8f9537
21
Kernel.cpp
21
Kernel.cpp
@ -255,11 +255,8 @@ EXTERNC void KPrint(const char *Format, ...)
|
|||||||
Display->SetBuffer(0);
|
Display->SetBuffer(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
EXTERNC NIF void Main(BootInfo *Info)
|
EXTERNC NIF void Main()
|
||||||
{
|
{
|
||||||
memcpy(&bInfo, Info, sizeof(BootInfo));
|
|
||||||
debug("BootInfo structure is at %p", bInfo);
|
|
||||||
|
|
||||||
Display = new Video::Display(bInfo.Framebuffer[0]);
|
Display = new Video::Display(bInfo.Framebuffer[0]);
|
||||||
KPrint("%s - %s [\e058C19%s\eFFFFFF]", KERNEL_NAME, KERNEL_VERSION, GIT_COMMIT_SHORT);
|
KPrint("%s - %s [\e058C19%s\eFFFFFF]", KERNEL_NAME, KERNEL_VERSION, GIT_COMMIT_SHORT);
|
||||||
KPrint("CPU: \e058C19%s \e8822AA%s \e8888FF%s", CPU::Hypervisor(), CPU::Vendor(), CPU::Name());
|
KPrint("CPU: \e058C19%s \e8822AA%s \e8888FF%s", CPU::Hypervisor(), CPU::Vendor(), CPU::Name());
|
||||||
@ -272,7 +269,7 @@ EXTERNC NIF void Main(BootInfo *Info)
|
|||||||
Interrupts::Initialize(0);
|
Interrupts::Initialize(0);
|
||||||
|
|
||||||
KPrint("Loading Kernel Symbols");
|
KPrint("Loading Kernel Symbols");
|
||||||
KernelSymbolTable = new SymbolResolver::Symbols((uintptr_t)Info->Kernel.FileBase);
|
KernelSymbolTable = new SymbolResolver::Symbols((uintptr_t)bInfo.Kernel.FileBase);
|
||||||
|
|
||||||
KPrint("Reading Kernel Parameters");
|
KPrint("Reading Kernel Parameters");
|
||||||
ParseConfig((char *)bInfo.Kernel.CommandLine, &Config);
|
ParseConfig((char *)bInfo.Kernel.CommandLine, &Config);
|
||||||
@ -483,6 +480,9 @@ EXTERNC __no_stack_protector NIF void Entry(BootInfo *Info)
|
|||||||
DebuggerIsAttached = true;
|
DebuggerIsAttached = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
memcpy(&bInfo, Info, sizeof(BootInfo));
|
||||||
|
debug("BootInfo structure is at %p", &bInfo);
|
||||||
|
|
||||||
// https://wiki.osdev.org/Calling_Global_Constructors
|
// https://wiki.osdev.org/Calling_Global_Constructors
|
||||||
trace("There are %d constructors to call", __init_array_end - __init_array_start);
|
trace("There are %d constructors to call", __init_array_end - __init_array_start);
|
||||||
for (CallPtr *func = __init_array_start; func != __init_array_end; func++)
|
for (CallPtr *func = __init_array_start; func != __init_array_end; func++)
|
||||||
@ -499,8 +499,17 @@ EXTERNC __no_stack_protector NIF void Entry(BootInfo *Info)
|
|||||||
TestMemoryAllocation();
|
TestMemoryAllocation();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void *KernelStackAddress = KernelAllocator.RequestPages(TO_PAGES(STACK_SIZE));
|
||||||
|
uintptr_t KernelStack = (uintptr_t)KernelStackAddress + STACK_SIZE - 0x10;
|
||||||
|
debug("Kernel stack: %#lx-%#lx", KernelStackAddress, KernelStack);
|
||||||
|
asmv("mov %0, %%rsp"
|
||||||
|
:
|
||||||
|
: "r"(KernelStack)
|
||||||
|
: "memory");
|
||||||
|
asmv("mov $0, %rbp");
|
||||||
|
|
||||||
EnableProfiler = true;
|
EnableProfiler = true;
|
||||||
Main(Info);
|
Main();
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma GCC diagnostic ignored "-Wdelete-non-virtual-dtor"
|
#pragma GCC diagnostic ignored "-Wdelete-non-virtual-dtor"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user