Finished Aurix Protocol, AxBoot logs to file now
This commit is contained in:
parent
b1d59e02eb
commit
d1a5d7d43d
37 changed files with 744 additions and 221 deletions
|
@ -18,10 +18,10 @@
|
|||
/*********************************************************************************/
|
||||
|
||||
#include <config/config.h>
|
||||
#include <config/ini.h>
|
||||
#include <lib/string.h>
|
||||
#include <loader/loader.h>
|
||||
#include <mm/mman.h>
|
||||
#include <time/dt.h>
|
||||
#include <vfs/vfs.h>
|
||||
#include <print.h>
|
||||
#include <axboot.h>
|
||||
|
@ -47,8 +47,9 @@ struct axboot_cfg cfg = {
|
|||
.timeout = DEFAULT_TIMEOUT,
|
||||
.ui_mode = UI_TEXT,
|
||||
|
||||
//.entry_count = 0
|
||||
.entry_count = 2
|
||||
//.entry_count = 0,
|
||||
.entry_count = 2,
|
||||
.bootlog_filename = NULL
|
||||
};
|
||||
|
||||
struct axboot_entry entries[2] = {
|
||||
|
@ -69,6 +70,20 @@ struct axboot_entry entries[2] = {
|
|||
|
||||
void config_init(void)
|
||||
{
|
||||
// create a filename for boot log
|
||||
// format: \AXBOOT_LOG-YY-MM-DD_HHMMSS.txt
|
||||
char bootlog_fn[33];
|
||||
struct datetime dt;
|
||||
get_datetime(&dt);
|
||||
|
||||
snprintf(bootlog_fn, 33, "\\AXBOOT_LOG-%u-%u-%u_%u%u%u.txt", dt.year, dt.month, dt.day, dt.h, dt.m, dt.s);
|
||||
cfg.bootlog_filename = (char *)mem_alloc(ARRAY_LENGTH(bootlog_fn));
|
||||
if (!cfg.bootlog_filename) {
|
||||
debug("Error!\n");
|
||||
} else {
|
||||
strncpy(cfg.bootlog_filename, (char *)&bootlog_fn, 33);
|
||||
}
|
||||
|
||||
char *config_buf = NULL;
|
||||
uint8_t open = 0;
|
||||
|
||||
|
@ -81,7 +96,7 @@ void config_init(void)
|
|||
}
|
||||
|
||||
if (open == 0) {
|
||||
debug("Couldn't open a configuration file! Entering console...\n");
|
||||
debug("config_init(): Couldn't open a configuration file! Entering console...\n");
|
||||
//console();
|
||||
while (1);
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ struct vfs_drive *sfs_init(char *mountpoint)
|
|||
|
||||
fs->fsdata = fsdata;
|
||||
fs->read = sfs_read;
|
||||
fs->write = NULL; // sfs_write()
|
||||
fs->write = sfs_write;
|
||||
|
||||
struct vfs_drive *drive = (struct vfs_drive *)mem_alloc(sizeof(struct vfs_drive));
|
||||
if (drive == NULL) {
|
||||
|
@ -121,7 +121,7 @@ size_t sfs_read(char *filename, char **buffer, struct vfs_drive *dev, void *fsda
|
|||
wfilename[n] = L'\0';
|
||||
|
||||
/* open the file */
|
||||
status = volume->Open(volume, &file, wfilename, EFI_FILE_MODE_READ, EFI_FILE_READ_ONLY | EFI_FILE_HIDDEN | EFI_FILE_SYSTEM);
|
||||
status = volume->Open(volume, &file, wfilename, EFI_FILE_MODE_READ, 0);
|
||||
if (EFI_ERROR(status)) {
|
||||
debug("sfs_read(): Failed to open file '%s': %s (%lx)\n", filename, efi_status_to_str(status), status);
|
||||
mem_free(wfilename);
|
||||
|
@ -159,4 +159,49 @@ size_t sfs_read(char *filename, char **buffer, struct vfs_drive *dev, void *fsda
|
|||
return len;
|
||||
}
|
||||
|
||||
uint8_t sfs_write(char *filename, char *buffer, size_t size, struct vfs_drive *dev, void *fsdata)
|
||||
{
|
||||
(void)dev;
|
||||
|
||||
struct sfs_fsdata *data = (struct sfs_fsdata *)fsdata;
|
||||
EFI_FILE_PROTOCOL *volume = data->volume;
|
||||
EFI_FILE_PROTOCOL *file;
|
||||
CHAR16 *wfilename;
|
||||
EFI_STATUS status = EFI_SUCCESS;
|
||||
size_t len = 0;
|
||||
|
||||
wfilename = (CHAR16 *)mem_alloc(strlen(filename) * sizeof(CHAR16));
|
||||
if (!wfilename) {
|
||||
debug("sfs_write(): Failed to allocate memory for wide strings!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t n = mbstowcs(wfilename, (const char **)&filename, strlen(filename));
|
||||
wfilename[n] = L'\0';
|
||||
|
||||
/* open the file */
|
||||
status = volume->Open(volume, &file, wfilename, EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE, EFI_FILE_SYSTEM);
|
||||
if (EFI_ERROR(status)) {
|
||||
debug("sfs_write(): Failed to open file '%s': %s (%lx)\n", filename, efi_status_to_str(status), status);
|
||||
mem_free(wfilename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
mem_free(wfilename);
|
||||
|
||||
// set position to the end of the file
|
||||
file->SetPosition(file, 0xffffffffffffffff);
|
||||
|
||||
status = file->Write(file, &size, buffer);
|
||||
if (EFI_ERROR(status)) {
|
||||
debug("sfs_write(): Failed to read file '%s': %s (%lx)\n", filename, efi_status_to_str(status), status);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* close the file */
|
||||
file->Close(file);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
#endif
|
|
@ -31,18 +31,18 @@ void axboot_init()
|
|||
uart_init(115200);
|
||||
|
||||
if (!vfs_init("\\")) {
|
||||
debug("axboot_init(): Failed to mount boot drive! Halting...\n");
|
||||
log("axboot_init(): Failed to mount boot drive! Halting...\n");
|
||||
// TODO: Halt
|
||||
while (1);
|
||||
}
|
||||
|
||||
config_init();
|
||||
|
||||
#ifdef AXBOOT_UEFI
|
||||
#include <driver.h>
|
||||
load_drivers();
|
||||
#endif
|
||||
|
||||
//config_init();
|
||||
|
||||
// boot straight away
|
||||
if (config_get_timeout() < 1) {
|
||||
struct axboot_entry *entries = config_get_entries();
|
||||
|
@ -51,16 +51,6 @@ void axboot_init()
|
|||
|
||||
ui_init();
|
||||
|
||||
debug("axboot_init(): Returned from main menu, something went wrong. Halting!");
|
||||
//UNREACHABLE();
|
||||
|
||||
// just boot aurixos for now
|
||||
struct axboot_entry axos = {
|
||||
.name = "AurixOS",
|
||||
.description = "",
|
||||
.image_path = "\\System\\axkrnl",
|
||||
.protocol = PROTO_AURIX
|
||||
};
|
||||
loader_load(&axos);
|
||||
log("axboot_init(): Returned from main menu, something went wrong. Halting!");
|
||||
UNREACHABLE();
|
||||
}
|
|
@ -28,14 +28,15 @@
|
|||
/* https://github.com/KevinAlavik/nekonix/blob/main/kernel/src/proc/elf.c */
|
||||
/* Thanks, Kevin <3 */
|
||||
|
||||
uintptr_t elf32_load(char *data, pagetable *pagemap)
|
||||
uintptr_t elf32_load(char *data, uintptr_t *addr, pagetable *pagemap)
|
||||
{
|
||||
(void)data;
|
||||
(void)addr;
|
||||
(void)pagemap;
|
||||
return 0;
|
||||
}
|
||||
|
||||
uintptr_t elf64_load(char *data, pagetable *pagemap)
|
||||
uintptr_t elf64_load(char *data, uintptr_t *addr, pagetable *pagemap)
|
||||
{
|
||||
struct elf_header *header = (struct elf_header *)data;
|
||||
struct elf_program_header *ph = (struct elf_program_header *)((uint8_t *)data + header->e_phoff);
|
||||
|
@ -65,42 +66,46 @@ uintptr_t elf64_load(char *data, pagetable *pagemap)
|
|||
|
||||
uint64_t phys = ((uint64_t)mem_alloc(ph[i].p_memsz + ph[i].p_vaddr - aligned_vaddr + 4096) + 4096) & ~0xFFF;
|
||||
if (!phys) {
|
||||
debug("elf64_load(): Out of memory\n");
|
||||
log("elf64_load(): Out of memory\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (addr != NULL && *addr == 0) {
|
||||
*addr = phys;
|
||||
}
|
||||
|
||||
debug("elf64_load(): phys=0x%llx, virt=0x%llx, size=%lu\n", phys, ph[i].p_vaddr, ph[i].p_filesz);
|
||||
log("elf64_load(): phys=0x%llx, virt=0x%llx, size=%lu\n", phys, ph[i].p_vaddr, ph[i].p_filesz);
|
||||
|
||||
map_page(pagemap, aligned_vaddr, phys, flags);
|
||||
memcpy((void*)(phys + ph[i].p_vaddr - aligned_vaddr), data + ph[i].p_offset, ph[i].p_filesz);
|
||||
}
|
||||
|
||||
debug("elf64_load(): ELF loaded successfully, entry: 0x%llx\n", header->e_entry);
|
||||
log("elf64_load(): ELF loaded successfully, entry: 0x%llx\n", header->e_entry);
|
||||
return (uintptr_t)header->e_entry;
|
||||
}
|
||||
|
||||
uintptr_t elf_load(char *data, pagetable *pagemap)
|
||||
uintptr_t elf_load(char *data, uintptr_t *addr, pagetable *pagemap)
|
||||
{
|
||||
struct elf_header *header = (struct elf_header *)data;
|
||||
|
||||
if (header->e_magic != ELF_MAGIC) {
|
||||
debug("Invalid ELF magic: 0x%x", header->e_magic);
|
||||
log("Invalid ELF magic: 0x%x", header->e_magic);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (header->e_class != 2) {
|
||||
debug("Unsupported ELF class: %u", header->e_class);
|
||||
log("Unsupported ELF class: %u", header->e_class);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (header->e_machine == 20 ||
|
||||
header->e_machine == 3 ||
|
||||
header->e_machine == 40) {
|
||||
return elf32_load(data, pagemap);
|
||||
return elf32_load(data, addr, pagemap);
|
||||
} else if (header->e_machine == 62) {
|
||||
return elf64_load(data, pagemap);
|
||||
return elf64_load(data, addr, pagemap);
|
||||
}
|
||||
|
||||
debug("Unsupported ELF machine: %u", header->e_machine);
|
||||
log("Unsupported ELF machine: %u", header->e_machine);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ int proto_str_to_int(char *proto)
|
|||
|
||||
void loader_load(struct axboot_entry *entry)
|
||||
{
|
||||
debug("loader_load(): Booting \"%s\"...\n", entry->name);
|
||||
log("loader_load(): Booting \"%s\"...\n", entry->name);
|
||||
|
||||
switch (entry->protocol) {
|
||||
case PROTO_AURIX: {
|
||||
|
@ -49,7 +49,7 @@ void loader_load(struct axboot_entry *entry)
|
|||
break;
|
||||
}
|
||||
default: {
|
||||
debug("Entry doesn't have a supported protocol!\n");
|
||||
log("Entry doesn't have a supported protocol!\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ int find_alloc(void *addr)
|
|||
int add_alloc(void *addr, size_t size)
|
||||
{
|
||||
for (int i = 0; i < MAX_ALLOCATIONS; i++) {
|
||||
if (allocation_list[i].addr == 0) {
|
||||
if (allocation_list[i].addr == NULL) {
|
||||
allocation_list[i].addr = addr;
|
||||
allocation_list[i].size = size;
|
||||
return 1;
|
||||
|
@ -112,8 +112,6 @@ void *mem_alloc(size_t n)
|
|||
}
|
||||
|
||||
add_alloc(alloc, n);
|
||||
|
||||
debug("mem_alloc(): Allocated %u bytes\n", n);
|
||||
return alloc;
|
||||
}
|
||||
|
||||
|
@ -128,7 +126,6 @@ int mem_allocat(void *addr, size_t npages)
|
|||
}
|
||||
|
||||
add_alloc(addr, npages * PAGE_SIZE);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -152,7 +149,6 @@ void *mem_realloc(void *addr, size_t n)
|
|||
|
||||
memcpy(new, addr, old_size);
|
||||
mem_free(addr);
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
|
@ -170,9 +166,8 @@ void mem_free(void *addr)
|
|||
return;
|
||||
}
|
||||
|
||||
debug("mem_free(): Freed 0x%llx\n", addr);
|
||||
|
||||
remove_alloc(addr);
|
||||
debug("mem_free(): Freed 0x%llx\n", addr);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -26,7 +26,9 @@
|
|||
#define NANOPRINTF_USE_WRITEBACK_FORMAT_SPECIFIERS 0
|
||||
#include <nanoprintf.h>
|
||||
|
||||
#include <config/config.h>
|
||||
#include <uart/uart.h>
|
||||
#include <vfs/vfs.h>
|
||||
#include <print.h>
|
||||
|
||||
#include <stddef.h>
|
||||
|
@ -38,22 +40,29 @@ int32_t _fltused = 0;
|
|||
int32_t __eqdf2 = 0;
|
||||
int32_t __ltdf2 = 0;
|
||||
|
||||
extern struct axboot_cfg cfg;
|
||||
|
||||
void log(const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
char buf[4096];
|
||||
char buf[1024];
|
||||
size_t size = 0;
|
||||
|
||||
va_start(args, fmt);
|
||||
npf_vsnprintf(buf, sizeof(buf), fmt, args);
|
||||
size = npf_vsnprintf(buf, sizeof(buf), fmt, args);
|
||||
va_end(args);
|
||||
|
||||
uart_sendstr(buf);
|
||||
|
||||
if (cfg.bootlog_filename != NULL) {
|
||||
vfs_write(cfg.bootlog_filename, (char *)&buf, size);
|
||||
}
|
||||
}
|
||||
|
||||
void debug(const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
char buf[4096];
|
||||
char buf[1024];
|
||||
|
||||
va_start(args, fmt);
|
||||
npf_vsnprintf(buf, sizeof(buf), fmt, args);
|
||||
|
|
|
@ -17,67 +17,190 @@
|
|||
/* SOFTWARE. */
|
||||
/*********************************************************************************/
|
||||
|
||||
#include <acpi/acpi.h>
|
||||
#include <proto/aurix.h>
|
||||
#include <loader/elf.h>
|
||||
#include <mm/mman.h>
|
||||
#include <mm/memmap.h>
|
||||
#include <mm/vmm.h>
|
||||
#include <lib/string.h>
|
||||
#include <ui/framebuffer.h>
|
||||
#include <vfs/vfs.h>
|
||||
#include <print.h>
|
||||
#include <axboot.h>
|
||||
#include <efi.h>
|
||||
#include <efilib.h>
|
||||
|
||||
extern __attribute__((noreturn)) void aurix_handoff(void *pagemap, void *stack, uint64_t entry, void *params);
|
||||
extern char _aurix_handoff_start[], _aurix_handoff_end[];
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define AURIX_STACK_SIZE 16*1024
|
||||
|
||||
bool aurix_get_memmap(struct aurix_parameters *params, axboot_memmap *mmap, uint32_t mmap_entries, pagetable *pm)
|
||||
{
|
||||
if (params == NULL || mmap == NULL || pm == NULL || mmap_entries == 0) {
|
||||
log("aurix_get_memmap(): Invalid parameter!\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
// UEFI returns an unnecessarily large memory map with regions of the same type
|
||||
// being split into multiple entries (probably due to memory attributes, which we do not care about).
|
||||
for (uint32_t i = 0; i < mmap_entries; i++) {
|
||||
if (i == mmap_entries - 1) {
|
||||
break;
|
||||
}
|
||||
if (mmap[i].base + mmap[i].size >= mmap[i+1].base && mmap[i].type == mmap[i+1].type) {
|
||||
mmap[i].size += mmap[i+1].size;
|
||||
for (uint32_t j = i+1; j < mmap_entries; j++) {
|
||||
mmap[j].base = mmap[j+1].base;
|
||||
mmap[j].size = mmap[j+1].size;
|
||||
mmap[j].type = mmap[j+1].type;
|
||||
}
|
||||
mmap_entries--;
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
// copy the memory map over to kernel parameters
|
||||
params->mmap = (struct aurix_memmap *)mem_alloc(sizeof(struct aurix_memmap) * mmap_entries);
|
||||
if (!(params->mmap)) {
|
||||
log("aurix_get_memmap(): Failed to allocate memory for storing memory map!\n");
|
||||
return false;
|
||||
}
|
||||
params->mmap_entries = mmap_entries;
|
||||
|
||||
for (uint32_t i = 0; i < mmap_entries; i++) {
|
||||
params->mmap[i].base = mmap[i].base;
|
||||
params->mmap[i].size = mmap[i].size;
|
||||
switch (mmap[i].type) {
|
||||
case MemMapReserved:
|
||||
case MemMapFaulty:
|
||||
case MemMapFirmware:
|
||||
params->mmap[i].type = AURIX_MMAP_RESERVED;
|
||||
break;
|
||||
case MemMapACPIReclaimable:
|
||||
params->mmap[i].type = AURIX_MMAP_ACPI_RECLAIMABLE;
|
||||
break;
|
||||
case MemMapACPIMappedIO:
|
||||
params->mmap[i].type = AURIX_MMAP_ACPI_MAPPED_IO;
|
||||
break;
|
||||
case MemMapACPIMappedIOPortSpace:
|
||||
params->mmap[i].type = AURIX_MMAP_ACPI_MAPPED_IO_PORTSPACE;
|
||||
break;
|
||||
case MemMapACPINVS:
|
||||
params->mmap[i].type = AURIX_MMAP_ACPI_NVS;
|
||||
break;
|
||||
case MemMapFreeOnLoad:
|
||||
params->mmap[i].type = AURIX_MMAP_BOOTLOADER_RECLAIMABLE;
|
||||
break;
|
||||
case MemMapUsable:
|
||||
params->mmap[i].type = AURIX_MMAP_USABLE;
|
||||
break;
|
||||
default:
|
||||
log("aurix_get_memmap(): Unknown memory type in entry %u (%u), setting as reserved.\n", i, mmap[i].type);
|
||||
params->mmap[i].type = AURIX_MMAP_RESERVED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool aurix_get_framebuffer(struct aurix_parameters *params)
|
||||
{
|
||||
struct fb_mode *modes;
|
||||
int current_mode;
|
||||
uint32_t *fb_addr;
|
||||
|
||||
params->framebuffer = (struct aurix_framebuffer *)mem_alloc(sizeof(struct aurix_framebuffer));
|
||||
if (!(params->framebuffer)) {
|
||||
log("aurix_get_framebuffer(): Failed to allocate memory for framebuffer information!\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!get_framebuffer(&fb_addr, &modes, NULL, ¤t_mode)) {
|
||||
log("aurix_get_framebuffer(): get_framebuffer() returned false, setting everything to 0.\n");
|
||||
memset(params->framebuffer, 0, sizeof(struct aurix_framebuffer));
|
||||
return false;
|
||||
}
|
||||
|
||||
params->framebuffer->addr = (uintptr_t)fb_addr;
|
||||
params->framebuffer->width = modes[current_mode].width;
|
||||
params->framebuffer->height = modes[current_mode].height;
|
||||
params->framebuffer->bpp = modes[current_mode].bpp;
|
||||
params->framebuffer->pitch = modes[current_mode].pitch;
|
||||
params->framebuffer->format = modes[current_mode].format;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void aurix_load(char *kernel_path)
|
||||
{
|
||||
// read kernel -> test read
|
||||
char *kbuf = NULL;
|
||||
vfs_read(kernel_path, &kbuf);
|
||||
|
||||
// TODO: Do something with the kernel :p
|
||||
pagetable *pm = create_pagemap();
|
||||
if (!pm) {
|
||||
debug("aurix_load(): Failed to create kernel pagemap! Halting...\n");
|
||||
log("aurix_load(): Failed to create kernel pagemap! Halting...\n");
|
||||
// TODO: Halt
|
||||
while (1);
|
||||
}
|
||||
|
||||
axboot_memmap *memmap = get_memmap(pm);
|
||||
(void)memmap;
|
||||
|
||||
axboot_memmap *mmap;
|
||||
uint32_t mmap_entries = get_memmap(&mmap, pm);
|
||||
|
||||
map_pages(pm, (uintptr_t)pm, (uintptr_t)pm, PAGE_SIZE, VMM_WRITABLE);
|
||||
map_pages(pm, (uintptr_t)_aurix_handoff_start, (uintptr_t)_aurix_handoff_start, (uint64_t)_aurix_handoff_end - (uint64_t)_aurix_handoff_start, 0);
|
||||
|
||||
void *stack = mem_alloc(16*1024); // 16 KiB stack should be well more than enough
|
||||
void *stack = mem_alloc(AURIX_STACK_SIZE); // 16 KiB stack should be well more than enough
|
||||
if (!stack) {
|
||||
debug("aurix_load(): Failed to allocate stack! Halting...\n");
|
||||
log("aurix_load(): Failed to allocate stack! Halting...\n");
|
||||
while (1);
|
||||
}
|
||||
memset(stack, 0, AURIX_STACK_SIZE);
|
||||
|
||||
map_pages(pm, (uintptr_t)stack, (uintptr_t)stack, 16*1024, VMM_WRITABLE | VMM_NX);
|
||||
map_pages(pm, (uintptr_t)stack, (uintptr_t)stack, AURIX_STACK_SIZE, VMM_WRITABLE | VMM_NX);
|
||||
|
||||
void *kernel_entry = (void *)elf_load(kbuf, pm);
|
||||
uintptr_t kernel_addr = 0;
|
||||
void *kernel_entry = (void *)elf_load(kbuf, &kernel_addr, pm);
|
||||
if (!kernel_entry) {
|
||||
debug("aurix_load(): Failed to load '%s'! Halting...\n", kernel_path);
|
||||
log("aurix_load(): Failed to load '%s'! Halting...\n", kernel_path);
|
||||
while (1);
|
||||
}
|
||||
// mem_free(kbuf);
|
||||
mem_free(kbuf);
|
||||
|
||||
void *parameters = NULL;
|
||||
(void)parameters;
|
||||
struct aurix_parameters parameters = {0};
|
||||
|
||||
debug("aurix_load(): Handoff state: pm=0x%llx, stack=0x%llx, kernel_entry=0x%llx\n", pm, stack, kernel_entry);
|
||||
// set current revision
|
||||
parameters.revision = AURIX_PROTOCOL_REVISION;
|
||||
|
||||
// this triggers a #GP ????
|
||||
// aurix_handoff(pm, stack, (uint64_t)kernel_entry, (void *)parameters);
|
||||
// __builtin_unreachable();
|
||||
// translate memory map
|
||||
if (!aurix_get_memmap(¶meters, mmap, mmap_entries, pm)) {
|
||||
log("aurix_load(): Failed to aqcuire memory map!");
|
||||
while (1);
|
||||
}
|
||||
|
||||
__asm__ volatile("movq %[pml4], %%cr3\n"
|
||||
"movq %[stack], %%rsp\n"
|
||||
"callq *%[entry]\n"
|
||||
:: [pml4]"r"(pm), [stack]"r"(stack + (16 * 1024)), [entry]"r"(kernel_entry) : "memory");
|
||||
parameters.kernel_addr = kernel_addr;
|
||||
|
||||
// get RSDP and SMBIOS
|
||||
#ifdef ARCH_ACPI_AVAILABLE
|
||||
parameters.rsdp_addr = platform_get_rsdp();
|
||||
#endif
|
||||
|
||||
#ifdef ARCH_SMBIOS_AVAILABLE
|
||||
parameters.smbios_addr = platform_get_smbios();
|
||||
#endif
|
||||
|
||||
// get framebuffer information
|
||||
if (!aurix_get_framebuffer(¶meters)) {
|
||||
log("aurix_load(): Failed to aqcuire framebuffer information!\n");
|
||||
}
|
||||
|
||||
// map framebuffer
|
||||
map_pages(pm, parameters.framebuffer->addr, parameters.framebuffer->addr, parameters.framebuffer->height * parameters.framebuffer->pitch, VMM_WRITABLE);
|
||||
|
||||
log("aurix_load(): Handoff state: pm=0x%llx, stack=0x%llx, kernel_entry=0x%llx\n", pm, stack, kernel_entry);
|
||||
#ifdef AXBOOT_UEFI
|
||||
uefi_exit_bs();
|
||||
#endif
|
||||
|
||||
aurix_arch_handoff(kernel_entry, pm, stack, AURIX_STACK_SIZE, ¶meters);
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
|
|
@ -36,19 +36,19 @@ int vfs_init(char *root_mountpoint)
|
|||
{
|
||||
boot_drive = mount_boot_volume(root_mountpoint);
|
||||
if (boot_drive == NULL) {
|
||||
debug("vfs_init(): Failed to allocate memory for VFS!\n");
|
||||
log("vfs_init(): Failed to allocate memory for VFS!\n");
|
||||
// fuck off and boot out early.
|
||||
return 0;
|
||||
}
|
||||
|
||||
debug("vfs_init(): Mounted boot drive to \"/\"\n");
|
||||
log("vfs_init(): Mounted boot drive to \"\\\"\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
size_t vfs_read(char *filename, char **buf)
|
||||
{
|
||||
if (boot_drive->fs->read == NULL) {
|
||||
debug("vfs_read(): Filesystem didn't set up a read function!");
|
||||
log("vfs_read(): Filesystem didn't set up a read function!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -57,9 +57,10 @@ size_t vfs_read(char *filename, char **buf)
|
|||
|
||||
int vfs_write(char *filename, char *buf, size_t len)
|
||||
{
|
||||
(void)filename;
|
||||
(void)buf;
|
||||
(void)len;
|
||||
if (boot_drive->fs->write == NULL) {
|
||||
log("vfs_read(): Filesystem didn't setup a write function!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return boot_drive->fs->write(filename, buf, len, boot_drive, boot_drive->fs->fsdata);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue