diff --git a/src/interrupt/handler.c b/src/interrupt/handler.c index 7b8b9ac..1ab1436 100644 --- a/src/interrupt/handler.c +++ b/src/interrupt/handler.c @@ -1,6 +1,7 @@ #include "interrupts.h" #include "kpanic.h" #include "kprintf.h" +#include "power.h" #include "utils.h" #include @@ -35,6 +36,8 @@ void isr_handler(struct registers *regs) { uint8_t i = 0; while (i < ARRAY_SIZE(faults)) { + if (i == 6) + reboot(); if (i == regs->int_no) kpanic("interrupt: %s\n", faults[i]); i++; diff --git a/src/kernel.c b/src/kernel.c index d638609..7cd597b 100644 --- a/src/kernel.c +++ b/src/kernel.c @@ -59,16 +59,21 @@ 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"); */ + // 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(); - exec_fn(owo); - /* exec_fn(owo); */ - /* exec_fn(owo); */ - /* exec_fn(owo); */ + vmalloc(1231231); + // uint32_t nb_alloc = 0; + // while (vmalloc(10)) + // nb_alloc++; + // kprintf("%d\n", nb_alloc); + for (uint8_t i = 0; i < 10; i++) + vmalloc(32); + // exec_fn(owo); + // exec_fn(owo); + // exec_fn(owo); + // exec_fn(owo); shell_init(); } diff --git a/src/kpanic.c b/src/kpanic.c index bbe5516..930d6a7 100644 --- a/src/kpanic.c +++ b/src/kpanic.c @@ -21,11 +21,11 @@ __attribute__((noreturn)) void kpanic(const char *format, ...) va_end(va); uint32_t faulting_address; - __asm__ __volatile__("mov %%cr2, %0" : "=r"(faulting_address)); - kprintf("fault at address: %p\n", faulting_address); + // __asm__ __volatile__("mov %%cr2, %0" : "=r"(faulting_address)); + // kprintf("fault at address: %p\n", faulting_address); /* for (int i = 16; i < 32; i++) */ /* kprintf("%p\n", page_table1[i]); */ - /* show_valloc_mem(); */ + // show_valloc_mem(); /* kprintf("\n\n"); */ /* print_stack(); */ /* kprintf("\n\n"); */ diff --git a/src/memory/virt/allocator.c b/src/memory/virt/allocator.c index ef2fd13..3285498 100644 --- a/src/memory/virt/allocator.c +++ b/src/memory/virt/allocator.c @@ -49,7 +49,7 @@ static void new_block(Zone *zone, uint32_t zone_size) int new_vzone(block_type_t type, uint32_t size) { - assert(current_task->pid); + // assert(current_task->pid); void *heap = alloc_pages(size, NULL); if (heap == NULL) { kprintf(KERN_ERR "error: alloc_pages failed\n"); diff --git a/src/memory/virt/vmalloc.c b/src/memory/virt/vmalloc.c index 8dc3c72..ade2cf2 100644 --- a/src/memory/virt/vmalloc.c +++ b/src/memory/virt/vmalloc.c @@ -52,6 +52,11 @@ static void frag_block(Zone *zone, Block *old_block, uint32_t size) assert(new_block < (Block *)((uint32_t)zone + get_zone_size(zone->type))); + if (old_block->size - align_mem(size) < sizeof(Block)) { + zone->free = NULL; + goto last_block; + } + // Newly created block metadata new_block->size = old_block->size - align_mem(size); new_block->sub_size = new_block->size; @@ -74,6 +79,7 @@ static void frag_block(Zone *zone, Block *old_block, uint32_t size) if (zone->free == old_block) zone->free = new_block; +last_block: old_block->next_free = NULL; old_block->prev_free = NULL; diff --git a/src/terminal/put.c b/src/terminal/put.c index 18a175d..a7c47d8 100644 --- a/src/terminal/put.c +++ b/src/terminal/put.c @@ -2,7 +2,7 @@ #include "debug.h" #include "font.h" #include "fonts/consolas_regular_13.h" -/* #include "icons/image.h" */ +// #include "icons/image.h" #include "kprintf.h" #include "shell.h" #include "string.h" @@ -28,7 +28,7 @@ void terminal_initialize(void) screens[i].column = 0; screens[i].default_color = 0xffffff; screens[i].fg_color = screens[i].default_color; - /* screens[i].background = &image_icon; */ + // screens[i].background = &image_icon; screens[i].font = consolas_regular_13_font; memset(screens[i].line, 0, sizeof(screen->line)); } @@ -52,13 +52,12 @@ void terminal_remove_last_char(void) for (uint32_t x = 0; x < node.width; x++) { // Current bg is taking too much memory // so we do a black bg for now - /* struct icon *bg = screen->background; */ - /* uint32_t pixel = 0; */ - /* if (bg->width > pos_x + x && bg->height > pos_y + y) - */ - /* pixel = bg->pixels[(pos_y + y) * bg->width + */ - /* (pos_x + x)]; */ - put_pixel(0, pos_x + x, pos_y + y); + // struct icon *bg = screen->background; + // uint32_t pixel = 0; + // if (bg->width > pos_x + x && bg->height > pos_y + y) + // pixel = bg->pixels[(pos_y + y) * bg->width + + // (pos_x + x)]; + put_pixel(0, pos_x + x, pos_y + y + node.yoffset); } } }