1
0
Fork 0
mirror of https://github.com/tailix/kernel.git synced 2025-02-17 15:45:37 -05:00

Add module "panic"

This commit is contained in:
Braiden Vasco 2017-11-08 04:49:30 +00:00
parent 9d2f0e80aa
commit e6afb473b0
6 changed files with 30 additions and 10 deletions

View file

@ -7,6 +7,7 @@ OBJS += init.c.o
OBJS += multiboot.c.o
OBJS += memory.c.o
OBJS += paging.c.o paging.asm.cpp.o
OBJS += panic.c.o panic.asm.cpp.o
# Architecture-independent
OBJS += info.c.o

View file

@ -32,7 +32,4 @@ void main(const struct KernelMQ_Info *const kinfo_ptr)
paging_identity(); // Still need 1:1 for lapic and video mem and such.
paging_mapkernel(&kinfo);
paging_load();
logger_warn_from("main", "Nothing to do.");
logger_fail_from("main", "Halt.");
}

6
arch/panic.asm Normal file
View file

@ -0,0 +1,6 @@
[GLOBAL hang]
hang:
cli
hlt
jmp hang

16
arch/panic.c Normal file
View file

@ -0,0 +1,16 @@
#include "panic.h"
#include "logger.h"
void hang();
void panic(const char *const s)
{
logger_fail_from("panic", s);
hang();
}
void halt()
{
panic("Kernel main function returned.");
}

6
arch/panic.h Normal file
View file

@ -0,0 +1,6 @@
#ifndef KERNELMQ_INCLUDED_PANIC
#define KERNELMQ_INCLUDED_PANIC 1
void panic(const char *s);
#endif

View file

@ -22,7 +22,6 @@ _kernel_stack_top:
.section .text
.global _start
.global halt
.type _start, @function
.type halt, @function
@ -39,11 +38,6 @@ _start:
push %eax // Kernel information pointer
call main
halt:
cli
1:
hlt
jmp 1b
call halt
.size _start, . - _start
.size _halt, . - halt