diff options
Diffstat (limited to 'src/kernel')
-rw-r--r-- | src/kernel/elf.c | 1 | ||||
-rw-r--r-- | src/kernel/isrs.asm | 2 | ||||
-rw-r--r-- | src/kernel/log.c | 20 | ||||
-rw-r--r-- | src/kernel/log.h | 7 | ||||
-rw-r--r-- | src/kernel/main.c | 8 | ||||
-rw-r--r-- | src/kernel/panic.c | 2 | ||||
-rw-r--r-- | src/kernel/task.c | 4 |
7 files changed, 31 insertions, 13 deletions
diff --git a/src/kernel/elf.c b/src/kernel/elf.c index 8cd659c..bd2f12d 100644 --- a/src/kernel/elf.c +++ b/src/kernel/elf.c @@ -107,6 +107,7 @@ bool try_elf_run(const struct drive *d, const char *path) { } free_pages(phtable, phtable_pages); + d->free_file(d, h); struct task_state tstate; tstate.page_directory = pd; diff --git a/src/kernel/isrs.asm b/src/kernel/isrs.asm index 56f3c12..1fd6fcb 100644 --- a/src/kernel/isrs.asm +++ b/src/kernel/isrs.asm @@ -39,7 +39,7 @@ syscall_isr: quit_isr: push dword [active_task] call delete_task - push yield_isr.return_to_task + mov dword [esp], yield_isr.return_to_task jmp advance_active_task yield_isr: diff --git a/src/kernel/log.c b/src/kernel/log.c index bc8ff84..39fc1ba 100644 --- a/src/kernel/log.c +++ b/src/kernel/log.c @@ -1,20 +1,26 @@ #include "vga.h" #include "serial.h" +#include "log.h" -#define INFO_COM COM1 +#define LOG_COM COM1 -void init_log() { - vga_set_color(0x30); - vga_blank(); +static const uint8_t log_mode_colors[] = { + 0x30, + 0x07, + 0x4f +}; + +void set_log_mode(enum log_mode mode) { + vga_set_color(log_mode_colors[mode]); } void logch(char ch) { if (ch == '\n') { - sout(INFO_COM, (uint8_t)'\r'); - sout(INFO_COM, (uint8_t)'\n'); + sout(LOG_COM, (uint8_t)'\r'); + sout(LOG_COM, (uint8_t)'\n'); } else - sout(INFO_COM, (uint8_t)ch); + sout(LOG_COM, (uint8_t)ch); vga_printch(ch); } diff --git a/src/kernel/log.h b/src/kernel/log.h index ff2a7a2..90a94f4 100644 --- a/src/kernel/log.h +++ b/src/kernel/log.h @@ -1,7 +1,14 @@ #ifndef LOG_H #define LOG_H +enum log_mode { + LOG_SYSTEM, + LOG_USER, + LOG_PANIC +}; + void init_log(); +void set_log_mode(enum log_mode mode); void logch(char ch); void logsz(const char *sz); diff --git a/src/kernel/main.c b/src/kernel/main.c index 1fe8e7b..2f63d71 100644 --- a/src/kernel/main.c +++ b/src/kernel/main.c @@ -10,8 +10,8 @@ #include "pmap.h" #include "task.h" #include "pci.h" -#include "log.h" #include "elf.h" +#include "log.h" #include "vga.h" void reset_tree(); @@ -27,7 +27,8 @@ void main() { init_paging(); init_tasks(); init_serial(); - init_log(); + set_log_mode(LOG_SYSTEM); + vga_blank(); logsz("Portland v0.0.11\n\n"); @@ -146,6 +147,7 @@ void main() { init_idt(); - vga_set_color(0x07); + set_log_mode(LOG_USER); + logch('\n'); _start_user_mode(); }
\ No newline at end of file diff --git a/src/kernel/panic.c b/src/kernel/panic.c index 7793065..a2e68e3 100644 --- a/src/kernel/panic.c +++ b/src/kernel/panic.c @@ -3,7 +3,7 @@ #include "vga.h" void panic(const char *message) { - vga_set_color(0x4f); + set_log_mode(LOG_PANIC); vga_blank(); logsz("Kernel panic: "); logsz(message); diff --git a/src/kernel/task.c b/src/kernel/task.c index c8a8ac8..80818a7 100644 --- a/src/kernel/task.c +++ b/src/kernel/task.c @@ -79,7 +79,9 @@ void advance_active_task() { if (++active_task == tasks + MAX_TASKS) active_task = tasks; if (active_task == prev_task) { - logsz("No active tasks.\nHalting."); + logch('\n'); + set_log_mode(LOG_SYSTEM); + logsz("\nNo active tasks, halting."); while (1) asm ("hlt"); } |