Compare commits

...

6 Commits

Author SHA1 Message Date
44f5d687b0 changed main to a signal demo 2025-04-21 20:50:39 +02:00
1f5a358b19 fix: make iso 2025-04-21 13:29:56 +02:00
e15f0af292 fix: kpanic clearing registers and hlt correctly 2025-04-21 13:23:56 +02:00
8e2017bd29 clean 2025-04-18 17:31:08 +02:00
11125325ca Merge branch 'main' of git.chauvet.pro:starnakin/42_KFS 2025-04-18 17:20:43 +02:00
81c54647d2 feature: clear registers when kpanic is called 2025-04-18 17:19:56 +02:00
4 changed files with 25 additions and 45 deletions

View File

@ -33,7 +33,9 @@ $(NAME): $(OBJ)
run: $(NAME)
qemu-system-i386 -kernel build/$(NAME).bin -vga std
iso: $(NAME) mkdir -p isodir/boot/grub cp build/$(NAME).bin isodir/boot/$(NAME).bin
iso: $(NAME)
mkdir -p isodir/boot/grub
cp build/$(NAME).bin isodir/boot/$(NAME).bin
cp config/grub.cfg isodir/boot/grub/grub.cfg
grub-mkrescue -o build/$(NAME).iso --compress=xz --locales=en@quot --themes= isodir
rm -rf isodir

View File

@ -30,28 +30,6 @@
#error "This tutorial needs to be compiled with a ix86-elf compiler"
#endif
static void uwu(void)
{
kprintf("uwu\n");
}
static void owo(void)
{
while (true)
kprintf("owoooooooooooooooooooooooooooooooooooo\n");
}
static void awa(void)
{
uint32_t pid = fork();
PRINT_INT(pid);
if (pid < 0)
kprintf("awais");
kprintf("awaille\n");
if (pid)
wait();
}
static void bozo(int int_code)
{
kprintf("apagnan code\n");
@ -64,26 +42,7 @@ void kernel_main(multiboot_info_t *mbd, uint32_t magic)
init_idt();
init_memory(mbd, magic);
load_drivers();
// 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");
create_kernel_task();
vmalloc(1231231);
// uint32_t nb_alloc = 0;
// while (kmalloc(10))
// nb_alloc++;
// kprintf("%d\n", nb_alloc);
for (uint8_t i = 0; i < 10; i++)
vmalloc(32);
char *str = kmalloc(20);
show_kalloc_mem();
strcpy(str, "test\n");
kprintf("%s", str);
// exec_fn(owo);
// exec_fn(owo);
// exec_fn(owo);
// exec_fn(owo);
kill(0, 4);
for (size_t i = 0; i < 10000; i++)
free_pages(alloc_pages(1, NULL), 1);

View File

@ -9,6 +9,7 @@
extern uint32_t page_table1[1024];
extern const char *faults[];
void clear_registers(void);
__attribute__((noreturn)) void kpanic(const char *format, ...)
{
@ -16,6 +17,7 @@ __attribute__((noreturn)) void kpanic(const char *format, ...)
/* terminal_set_bg_color(VGA_COLOR_BLUE); */
/* terminal_clear(); */
kprintf("kpanic: ");
va_start(va, format);
kvprintf(format, &va);
va_end(va);
@ -30,7 +32,5 @@ __attribute__((noreturn)) void kpanic(const char *format, ...)
/* print_stack(); */
/* kprintf("\n\n"); */
/* kprintf("PRESS SPACE TO REBOOT"); */
while (terminal_getkey().scan_code != KEY_SPACE)
;
reboot();
__asm__ __volatile__("jmp panic");
}

19
src/panic.s Normal file
View File

@ -0,0 +1,19 @@
.intel_syntax noprefix
.section .text
.global panic
panic:
xor eax, eax
xor ebx, ebx
xor ecx, ecx
xor edx, edx
xor esp, esp
xor ebp, ebp
xor esi, esi
xor edi, edi
cli
loop:
hlt
jmp loop