mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-05-28 15:34:33 +00:00
Runtime stuff
This commit is contained in:
parent
77b24c45ec
commit
08ab104eb1
17
Architecture/aarch64/runtime/crt0.S
Normal file
17
Architecture/aarch64/runtime/crt0.S
Normal 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
|
1
Architecture/aarch64/runtime/crtbegin.c
Normal file
1
Architecture/aarch64/runtime/crtbegin.c
Normal file
@ -0,0 +1 @@
|
|||||||
|
// C++ constructor/destructor stuff
|
1
Architecture/aarch64/runtime/crtend.c
Normal file
1
Architecture/aarch64/runtime/crtend.c
Normal file
@ -0,0 +1 @@
|
|||||||
|
// C++ constructor/destructor stuff
|
13
Architecture/aarch64/runtime/crti.S
Normal file
13
Architecture/aarch64/runtime/crti.S
Normal 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
|
7
Architecture/aarch64/runtime/crtn.S
Normal file
7
Architecture/aarch64/runtime/crtn.S
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
.section .init
|
||||||
|
// popq %rbp
|
||||||
|
ret
|
||||||
|
|
||||||
|
.section .fini
|
||||||
|
// popq %rbp
|
||||||
|
ret
|
@ -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;
|
||||||
|
@ -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
|
||||||
{
|
{
|
||||||
|
15
Architecture/amd64/runtime/crt0.c
Normal file
15
Architecture/amd64/runtime/crt0.c
Normal 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
|
15
Architecture/amd64/runtime/crt1.c
Normal file
15
Architecture/amd64/runtime/crt1.c
Normal 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
|
1
Architecture/amd64/runtime/crtbegin.c
Normal file
1
Architecture/amd64/runtime/crtbegin.c
Normal file
@ -0,0 +1 @@
|
|||||||
|
// C++ constructor/destructor stuff
|
1
Architecture/amd64/runtime/crtend.c
Normal file
1
Architecture/amd64/runtime/crtend.c
Normal file
@ -0,0 +1 @@
|
|||||||
|
// C++ constructor/destructor stuff
|
13
Architecture/amd64/runtime/crti.S
Normal file
13
Architecture/amd64/runtime/crti.S
Normal 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
|
7
Architecture/amd64/runtime/crtn.S
Normal file
7
Architecture/amd64/runtime/crtn.S
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
.section .init
|
||||||
|
popq %rbp
|
||||||
|
ret
|
||||||
|
|
||||||
|
.section .fini
|
||||||
|
popq %rbp
|
||||||
|
ret
|
15
Architecture/i686/runtime/crt0.c
Normal file
15
Architecture/i686/runtime/crt0.c
Normal 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
|
@ -63,7 +63,6 @@ Loop:
|
|||||||
hlt
|
hlt
|
||||||
jmp Loop
|
jmp Loop
|
||||||
|
|
||||||
|
|
||||||
section .bss
|
section .bss
|
||||||
align 16
|
align 16
|
||||||
KernelStack :
|
KernelStack :
|
1
Architecture/i686/runtime/crtbegin.c
Normal file
1
Architecture/i686/runtime/crtbegin.c
Normal file
@ -0,0 +1 @@
|
|||||||
|
// C++ constructor/destructor stuff
|
1
Architecture/i686/runtime/crtend.c
Normal file
1
Architecture/i686/runtime/crtend.c
Normal file
@ -0,0 +1 @@
|
|||||||
|
// C++ constructor/destructor stuff
|
13
Architecture/i686/runtime/crti.S
Normal file
13
Architecture/i686/runtime/crti.S
Normal 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
|
7
Architecture/i686/runtime/crtn.S
Normal file
7
Architecture/i686/runtime/crtn.S
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
.section .init
|
||||||
|
popq %ebp
|
||||||
|
ret
|
||||||
|
|
||||||
|
.section .fini
|
||||||
|
popq %ebp
|
||||||
|
ret
|
Loading…
x
Reference in New Issue
Block a user