Runtime stuff

This commit is contained in:
Alex 2022-11-11 04:41:12 +02:00
parent 77b24c45ec
commit 08ab104eb1
Signed by untrusted user who does not match committer: enderice2
GPG Key ID: EACC3AD603BAB4DD
20 changed files with 131 additions and 4 deletions

View File

@ -0,0 +1,17 @@
// .section ".text.boot"
//
// .global _start
// .org 0x80000
// _start:
// ldr x5, =_start
// mov sp, x5
// ldr x5, =_kernel_rodata_end
// ldr w6, =_bss_size
// 1: cbz w6, 2f
// str xzr, [x5], #8
// sub w6, w6, #1
// cbnz w6, 1b
// 2: bl arm64Entry
// Halt:
// wfe
// b Halt

View File

@ -0,0 +1 @@
// C++ constructor/destructor stuff

View File

@ -0,0 +1 @@
// C++ constructor/destructor stuff

View File

@ -0,0 +1,13 @@
.section .init
.global _init
.type _init, @function
_init:
// push %rbp
// movq %rsp, %rbp
.section .fini
.global _fini
.type _fini, @function
_fini:
// push %rbp
// movq %rsp, %rbp

View File

@ -0,0 +1,7 @@
.section .init
// popq %rbp
ret
.section .fini
// popq %rbp
ret

View File

@ -89,7 +89,7 @@ namespace GlobalDescriptorTable
void *CPUStackPointer[MAX_CPU]; void *CPUStackPointer[MAX_CPU];
__attribute__((no_stack_protector)) void Init(int Core) __no_stack_protector void Init(int Core)
{ {
memcpy(&GDTEntries[Core], &GDTEntriesTemplate, sizeof(GlobalDescriptorTableEntries)); memcpy(&GDTEntries[Core], &GDTEntriesTemplate, sizeof(GlobalDescriptorTableEntries));
gdt[Core] = {.Length = sizeof(GlobalDescriptorTableEntries) - 1, .Entries = &GDTEntries[Core]}; gdt[Core] = {.Length = sizeof(GlobalDescriptorTableEntries) - 1, .Entries = &GDTEntries[Core]};
@ -143,7 +143,7 @@ namespace GlobalDescriptorTable
trace("Global Descriptor Table initialized"); trace("Global Descriptor Table initialized");
} }
__attribute__((no_stack_protector)) void SetKernelStack(void *Stack) __no_stack_protector void SetKernelStack(void *Stack)
{ {
if (Stack) if (Stack)
tss[GetCurrentCPU()->ID].StackPointer[0] = (uint64_t)Stack; tss[GetCurrentCPU()->ID].StackPointer[0] = (uint64_t)Stack;

View File

@ -1,7 +1,7 @@
OUTPUT_FORMAT(elf64-x86-64) OUTPUT_FORMAT(elf64-x86-64)
OUTPUT_ARCH(i386:x86-64) OUTPUT_ARCH(i386:x86-64)
ENTRY(Entry) ENTRY(_start)
SECTIONS SECTIONS
{ {

View File

@ -0,0 +1,15 @@
// #include <types.h>
// #include <debug.h>
// int Entry(void *Info);
// void _start(void *Raw)
// {
// error("Todo");
// while (1)
// asmv("hlt");
// Entry(NULL);
// return;
// }
// C stuff

View File

@ -0,0 +1,15 @@
#include <types.h>
#include <debug.h>
int Entry(void *Info);
void _start(void *Raw)
{
error("ERROR! INVALID BOOT PROTOCOL!");
while (1)
asmv("hlt");
Entry(NULL);
return;
}
// C stuff

View File

@ -0,0 +1 @@
// C++ constructor/destructor stuff

View File

@ -0,0 +1 @@
// C++ constructor/destructor stuff

View File

@ -0,0 +1,13 @@
.section .init
.global _init
.type _init, @function
_init:
push %rbp
movq %rsp, %rbp
.section .fini
.global _fini
.type _fini, @function
_fini:
push %rbp
movq %rsp, %rbp

View File

@ -0,0 +1,7 @@
.section .init
popq %rbp
ret
.section .fini
popq %rbp
ret

View File

@ -0,0 +1,15 @@
// #include <types.h>
// #include <debug.h>
// int Entry(void *Info);
// void _start(void *Raw)
// {
// error("Todo");
// while (1)
// asmv("hlt");
// Entry(NULL);
// return;
// }
// C stuff

View File

@ -63,7 +63,6 @@ Loop:
hlt hlt
jmp Loop jmp Loop
section .bss section .bss
align 16 align 16
KernelStack : KernelStack :

View File

@ -0,0 +1 @@
// C++ constructor/destructor stuff

View File

@ -0,0 +1 @@
// C++ constructor/destructor stuff

View File

@ -0,0 +1,13 @@
.section .init
.global _init
.type _init, @function
_init:
push %ebp
movq %esp, %ebp
.section .fini
.global _fini
.type _fini, @function
_fini:
push %ebp
movq %esp, %ebp

View File

@ -0,0 +1,7 @@
.section .init
popq %ebp
ret
.section .fini
popq %ebp
ret