improved startup architecture

This commit is contained in:
antifallobst 2023-01-26 15:15:10 +01:00
parent 44f5ceaeaa
commit 972174054b
3 changed files with 96 additions and 14 deletions

View File

@ -0,0 +1,30 @@
/* Copyright (C) Antifallobst <antifallobst@systemausfall.org>
*
* 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 <https://www.gnu.org/licenses/>.
*/
#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

63
kernel/src/boot/limine.c Normal file
View File

@ -0,0 +1,63 @@
/* Copyright (C) Antifallobst <antifallobst@systemausfall.org>
*
* 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 <https://www.gnu.org/licenses/>.
*/
#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);
}

View File

@ -15,22 +15,11 @@
#include "utils/stdtypes.h" #include "utils/stdtypes.h"
#include "utils/logger.h" #include "utils/logger.h"
#include "boot/limine.h" #include "boot/boot_info.h"
static volatile struct limine_terminal_request terminal_request = { void kmain(boot_info_T boot_info) {
.id = LIMINE_TERMINAL_REQUEST,
.revision = 0,
.response = NULL
};
void _start() { // terminal_request.response->write(terminal, "Booting NoxOS...", 16);
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);
log(LOG_DEBUG, "Booting NoxOS"); log(LOG_DEBUG, "Booting NoxOS");
while(true) asm("hlt"); while(true) asm("hlt");