diff --git a/kernel/inc/boot/boot_info.h b/kernel/inc/boot/boot_info.h new file mode 100644 index 0000000..d6632e3 --- /dev/null +++ b/kernel/inc/boot/boot_info.h @@ -0,0 +1,30 @@ +/* Copyright (C) Antifallobst + * + * NoxOS is free software: + * you can redistribute it and/or modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 of the License, + * or (at your option) any later version. + * + * NoxOS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. + * If not, see . + */ + +#ifndef NOX_BOOT_INFO_H +#define NOX_BOOT_INFO_H + +#include "utils/stdtypes.h" +#include "limine.h" + +typedef struct { + struct limine_framebuffer* framebuffer; + struct limine_terminal* terminal; + struct limine_memmap_entry** memory_map; + uint64_t memory_map_size; + void* rsdp; +} boot_info_T; + +#endif //NOX_BOOT_INFO_H diff --git a/kernel/src/boot/limine.c b/kernel/src/boot/limine.c new file mode 100644 index 0000000..6882bd3 --- /dev/null +++ b/kernel/src/boot/limine.c @@ -0,0 +1,63 @@ +/* Copyright (C) Antifallobst + * + * NoxOS is free software: + * you can redistribute it and/or modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 of the License, + * or (at your option) any later version. + * + * NoxOS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. + * If not, see . + */ + +#include "boot/boot_info.h" +#include "utils/logger.h" + +extern void kmain(boot_info_T boot_info); + +static volatile struct limine_terminal_request terminal_request = { + .id = LIMINE_TERMINAL_REQUEST, + .revision = 0 +}; + +static volatile struct limine_framebuffer_request framebuffer_request = { + .id = LIMINE_FRAMEBUFFER_REQUEST, + .revision = 1 +}; + +static volatile struct limine_memmap_request memmap_request = { + .id = LIMINE_MEMMAP_REQUEST, + .revision = 2 +}; + +void halt() { + while(true) { asm("hlt"); } +} + +void _start() { + boot_info_T boot_info; + + if (terminal_request.response == NULL || terminal_request.response->terminal_count < 0) { + halt(); + } + log(LOG_INFO, "( LimineEntry ) Found Terminal"); + boot_info.terminal = terminal_request.response->terminals[0]; + + if (framebuffer_request.response == NULL || framebuffer_request.response->framebuffer_count < 0) { + halt(); + } + log(LOG_INFO, "( LimineEntry ) Found Framebuffer"); + boot_info.framebuffer = framebuffer_request.response->framebuffers[0]; + + if (memmap_request.response == NULL || memmap_request.response->entry_count < 0) { + halt(); + } + log(LOG_INFO, "( LimineEntry ) Found Memory Map"); + boot_info.memory_map_size = memmap_request.response->entry_count; + boot_info.memory_map = memmap_request.response->entries; + + kmain(boot_info); +} \ No newline at end of file diff --git a/kernel/src/kmain.c b/kernel/src/kmain.c index f21c933..7f9f44d 100644 --- a/kernel/src/kmain.c +++ b/kernel/src/kmain.c @@ -15,22 +15,11 @@ #include "utils/stdtypes.h" #include "utils/logger.h" -#include "boot/limine.h" +#include "boot/boot_info.h" -static volatile struct limine_terminal_request terminal_request = { - .id = LIMINE_TERMINAL_REQUEST, - .revision = 0, - .response = NULL -}; +void kmain(boot_info_T boot_info) { -void _start() { - if (terminal_request.response == NULL || terminal_request.response->terminal_count < 0) { - while(true) asm("hlt"); - } - - struct limine_terminal* terminal = terminal_request.response->terminals[0]; - - terminal_request.response->write(terminal, "Booting NoxOS...", 16); +// terminal_request.response->write(terminal, "Booting NoxOS...", 16); log(LOG_DEBUG, "Booting NoxOS"); while(true) asm("hlt");