Merge branch 'main' of git.chauvet.pro:starnakin/42_KFS

This commit is contained in:
2024-10-17 16:11:40 +02:00
10 changed files with 95 additions and 16 deletions

View File

@ -91,7 +91,7 @@ _start:
# Enable paging and the write-protect bit.
movl %cr0, %ecx
orl $0x80010000, %ecx
orl $0x80000000, %ecx
movl %ecx, %cr0
# Jump to higher half with an absolute jump.
@ -119,4 +119,4 @@ _start:
# Infinite loop if the system has nothing more to do.
cli
1: hlt
jmp 1b
jmp 1b

View File

@ -1,5 +1,6 @@
#include "debug.h"
#include "kprintf.h"
#include <stddef.h>
void print_stack(void)
{

View File

@ -0,0 +1,10 @@
#include "signal.h"
#include <stddef.h>
void (*signal(int sig, void (*func)(int)))(int)
{
// TODO after multi tasking and processes
(void)sig;
(void)func;
return NULL;
}

View File

@ -6,6 +6,7 @@
#include "memory.h"
#include "power.h"
#include "shell.h"
#include "string.h"
#include "terminal.h"
#include <stdbool.h>
@ -28,13 +29,15 @@ void kernel_main(void)
terminal_initialize();
init_gdt();
init_idt();
/* init_memory(); */
init_memory();
load_drivers();
memset((void *)0x10001, 'a', 10);
kprintf(KERN_ALERT
"I see no way to confuse an array of 256 seg:off pairs with a "
"complex 8*unknown quantity -byte descriptor table. -- Troy "
"Martin 03:50, 22 March 2009 (UTC)\n");
while (!kmalloc(10))
;
/* vmalloc(10); */
/* while (!vmalloc(10)) */
/* ; */
shell_init();
}

View File

@ -8,15 +8,18 @@ void kpanic(const char *format, ...)
{
va_list va;
terminal_set_bg_color(VGA_COLOR_BLUE);
terminal_clear();
/* terminal_set_bg_color(VGA_COLOR_BLUE); */
/* terminal_clear(); */
va_start(va, format);
kvprintf(format, va);
va_end(va);
kprintf("\n\n");
print_stack();
kprintf("\n\n");
kprintf("PRESS SPACE TO REBOOT");
uint32_t faulting_address;
__asm__ __volatile__("mov %%cr2, %0" : "=r"(faulting_address));
kprintf("fault at address: %p\n", faulting_address);
/* kprintf("\n\n"); */
/* print_stack(); */
/* kprintf("\n\n"); */
/* kprintf("PRESS SPACE TO REBOOT"); */
while (terminal_getkey().scan_code != KEY_SPACE)
;
reboot();

View File

@ -6,10 +6,10 @@
#include "memory.h"
#include "utils.h"
#define PT_SIZE 0x300
#define PT_SIZE 1024
#define MAX_TLB_ENTRIES 32
extern uint32_t page_table_entries[PT_SIZE] __attribute__((aligned(4096)));
extern uint32_t page_table_entries[PT_SIZE];
static int16_t find_next_block(size_t nb_pages)
{