fix: memory is now working completely (size issue)
fix: reboot with invalid opcode
This commit is contained in:
parent
5e561bfa15
commit
2e09db2dd1
@ -1,6 +1,7 @@
|
|||||||
#include "interrupts.h"
|
#include "interrupts.h"
|
||||||
#include "kpanic.h"
|
#include "kpanic.h"
|
||||||
#include "kprintf.h"
|
#include "kprintf.h"
|
||||||
|
#include "power.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
@ -35,6 +36,8 @@ void isr_handler(struct registers *regs)
|
|||||||
{
|
{
|
||||||
uint8_t i = 0;
|
uint8_t i = 0;
|
||||||
while (i < ARRAY_SIZE(faults)) {
|
while (i < ARRAY_SIZE(faults)) {
|
||||||
|
if (i == 6)
|
||||||
|
reboot();
|
||||||
if (i == regs->int_no)
|
if (i == regs->int_no)
|
||||||
kpanic("interrupt: %s\n", faults[i]);
|
kpanic("interrupt: %s\n", faults[i]);
|
||||||
i++;
|
i++;
|
||||||
|
25
src/kernel.c
25
src/kernel.c
@ -59,16 +59,21 @@ void kernel_main(multiboot_info_t *mbd, uint32_t magic)
|
|||||||
init_idt();
|
init_idt();
|
||||||
init_memory(mbd, magic);
|
init_memory(mbd, magic);
|
||||||
load_drivers();
|
load_drivers();
|
||||||
/* kprintf(KERN_ALERT */
|
// kprintf(KERN_ALERT
|
||||||
/* "I see no way to confuse an array of 256 seg:off pairs with a
|
// "I see no way to confuse an array of 256 seg:off pairs with a
|
||||||
* " */
|
// " "complex 8*unknown quantity -byte descriptor table. -- Troy
|
||||||
/* "complex 8*unknown quantity -byte descriptor table. -- Troy "
|
// " "Martin 03:50, 22 March 2009 (UTC)\n");
|
||||||
*/
|
|
||||||
/* "Martin 03:50, 22 March 2009 (UTC)\n"); */
|
|
||||||
create_kernel_task();
|
create_kernel_task();
|
||||||
exec_fn(owo);
|
vmalloc(1231231);
|
||||||
/* exec_fn(owo); */
|
// uint32_t nb_alloc = 0;
|
||||||
/* exec_fn(owo); */
|
// while (vmalloc(10))
|
||||||
/* exec_fn(owo); */
|
// 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();
|
shell_init();
|
||||||
}
|
}
|
||||||
|
@ -21,11 +21,11 @@ __attribute__((noreturn)) void kpanic(const char *format, ...)
|
|||||||
va_end(va);
|
va_end(va);
|
||||||
|
|
||||||
uint32_t faulting_address;
|
uint32_t faulting_address;
|
||||||
__asm__ __volatile__("mov %%cr2, %0" : "=r"(faulting_address));
|
// __asm__ __volatile__("mov %%cr2, %0" : "=r"(faulting_address));
|
||||||
kprintf("fault at address: %p\n", faulting_address);
|
// kprintf("fault at address: %p\n", faulting_address);
|
||||||
/* for (int i = 16; i < 32; i++) */
|
/* for (int i = 16; i < 32; i++) */
|
||||||
/* kprintf("%p\n", page_table1[i]); */
|
/* kprintf("%p\n", page_table1[i]); */
|
||||||
/* show_valloc_mem(); */
|
// show_valloc_mem();
|
||||||
/* kprintf("\n\n"); */
|
/* kprintf("\n\n"); */
|
||||||
/* print_stack(); */
|
/* print_stack(); */
|
||||||
/* kprintf("\n\n"); */
|
/* kprintf("\n\n"); */
|
||||||
|
@ -49,7 +49,7 @@ static void new_block(Zone *zone, uint32_t zone_size)
|
|||||||
|
|
||||||
int new_vzone(block_type_t type, uint32_t 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);
|
void *heap = alloc_pages(size, NULL);
|
||||||
if (heap == NULL) {
|
if (heap == NULL) {
|
||||||
kprintf(KERN_ERR "error: alloc_pages failed\n");
|
kprintf(KERN_ERR "error: alloc_pages failed\n");
|
||||||
|
@ -52,6 +52,11 @@ static void frag_block(Zone *zone, Block *old_block, uint32_t size)
|
|||||||
assert(new_block <
|
assert(new_block <
|
||||||
(Block *)((uint32_t)zone + get_zone_size(zone->type)));
|
(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
|
// Newly created block metadata
|
||||||
new_block->size = old_block->size - align_mem(size);
|
new_block->size = old_block->size - align_mem(size);
|
||||||
new_block->sub_size = new_block->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)
|
if (zone->free == old_block)
|
||||||
zone->free = new_block;
|
zone->free = new_block;
|
||||||
|
|
||||||
|
last_block:
|
||||||
old_block->next_free = NULL;
|
old_block->next_free = NULL;
|
||||||
old_block->prev_free = NULL;
|
old_block->prev_free = NULL;
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "font.h"
|
#include "font.h"
|
||||||
#include "fonts/consolas_regular_13.h"
|
#include "fonts/consolas_regular_13.h"
|
||||||
/* #include "icons/image.h" */
|
// #include "icons/image.h"
|
||||||
#include "kprintf.h"
|
#include "kprintf.h"
|
||||||
#include "shell.h"
|
#include "shell.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
@ -28,7 +28,7 @@ void terminal_initialize(void)
|
|||||||
screens[i].column = 0;
|
screens[i].column = 0;
|
||||||
screens[i].default_color = 0xffffff;
|
screens[i].default_color = 0xffffff;
|
||||||
screens[i].fg_color = screens[i].default_color;
|
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;
|
screens[i].font = consolas_regular_13_font;
|
||||||
memset(screens[i].line, 0, sizeof(screen->line));
|
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++) {
|
for (uint32_t x = 0; x < node.width; x++) {
|
||||||
// Current bg is taking too much memory
|
// Current bg is taking too much memory
|
||||||
// so we do a black bg for now
|
// so we do a black bg for now
|
||||||
/* struct icon *bg = screen->background; */
|
// struct icon *bg = screen->background;
|
||||||
/* uint32_t pixel = 0; */
|
// uint32_t pixel = 0;
|
||||||
/* if (bg->width > pos_x + x && bg->height > pos_y + y)
|
// if (bg->width > pos_x + x && bg->height > pos_y + y)
|
||||||
*/
|
// pixel = bg->pixels[(pos_y + y) * bg->width +
|
||||||
/* pixel = bg->pixels[(pos_y + y) * bg->width + */
|
// (pos_x + x)];
|
||||||
/* (pos_x + x)]; */
|
put_pixel(0, pos_x + x, pos_y + y + node.yoffset);
|
||||||
put_pixel(0, pos_x + x, pos_y + y);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user