Beginning of refactor

This commit is contained in:
Jozef Nagy 2025-06-07 14:12:21 +02:00
parent 02e846f1ab
commit 860c9ea53c
Signed by untrusted user who does not match committer: crz
GPG key ID: 459A4811CEAC7068
5 changed files with 52 additions and 17 deletions

View file

@ -45,7 +45,7 @@ LIVECD := $(RELEASE_DIR)/aurix-$(GITREV)-livecd_$(ARCH)-$(PLATFORM).iso
LIVEHDD := $(RELEASE_DIR)/aurix-$(GITREV)-livehdd_$(ARCH)-$(PLATFORM).img LIVEHDD := $(RELEASE_DIR)/aurix-$(GITREV)-livehdd_$(ARCH)-$(PLATFORM).img
LIVESD := $(RELEASE_DIR)/aurix-$(GITREV)-livesd_$(ARCH)-$(PLATFORM).img LIVESD := $(RELEASE_DIR)/aurix-$(GITREV)-livesd_$(ARCH)-$(PLATFORM).img
QEMU_FLAGS := -m 512m -smp 4 -rtc base=localtime -serial stdio QEMU_FLAGS := -m 2G -smp 4 -rtc base=localtime -serial stdio
# QEMU Audio support # QEMU Audio support
#QEMU_FLAGS += -audiodev coreaudio,id=coreaudio0 -device ich9-intel-hda -device hda-output,audiodev=coreaudio0 #QEMU_FLAGS += -audiodev coreaudio,id=coreaudio0 -device ich9-intel-hda -device hda-output,audiodev=coreaudio0

View file

@ -21,6 +21,7 @@
#include <arch/cpu/idt.h> #include <arch/cpu/idt.h>
#include <proto/aurix.h> #include <proto/aurix.h>
#include <mm/vmm.h> #include <mm/vmm.h>
#include <print.h>
#include <stdint.h> #include <stdint.h>
struct gdt { struct gdt {
@ -68,21 +69,21 @@ void aurix_arch_handoff(void *kernel_entry, pagetable *pm, void *stack, uint32_t
__asm__ volatile( __asm__ volatile(
"cli\n" "cli\n"
"lgdt %[gdtr]\n" //"lgdt %[gdtr]\n"
"ltr %[tss]\n" //"ltr %[tss]\n"
"pushq $0x08\n" //"pushq $0x08\n"
"lea 1f(%%rip), %%rax\n" //"lea 1f(%%rip), %%rax\n"
"pushq %%rax\n" //"pushq %%rax\n"
"lretq\n" //"lretq\n"
"1:\n" //"1:\n"
"movq $0x10, %%rax\n" //"movq $0x10, %%rax\n"
"movq %%rax, %%ds\n" //"movq %%rax, %%ds\n"
"movq %%rax, %%es\n" //"movq %%rax, %%es\n"
"movq %%rax, %%ss\n" //"movq %%rax, %%ss\n"
"movq %%rax, %%fs\n" //"movq %%rax, %%fs\n"
"movq %%rax, %%gs\n" //"movq %%rax, %%gs\n"
"lidt %[idt]\n" //"lidt %[idt]\n"
"movq %[pml4], %%cr3\n" "movq %[pml4], %%cr3\n"
"movq %[stack], %%rsp\n" "movq %[stack], %%rsp\n"

View file

@ -38,6 +38,16 @@ void axboot_init()
config_init(); config_init();
#if defined(__aarch64__) && !defined(AXBOOT_UEFI)
struct axboot_entry rpi_kernel = {
.name = "AurixOS for Raspberry Pi",
.image_path = "\\System\\axkrnl",
.protocol = PROTO_AURIX
};
loader_load(&rpi_kernel);
UNREACHABLE();
#endif
#ifdef AXBOOT_UEFI #ifdef AXBOOT_UEFI
#include <driver.h> #include <driver.h>
load_drivers(); load_drivers();

View file

@ -36,12 +36,19 @@
#include <stdarg.h> #include <stdarg.h>
#include <stdbool.h> #include <stdbool.h>
#include <efi.h>
#include <efilib.h>
#include <mm/mman.h>
#include <lib/string.h>
int32_t _fltused = 0; int32_t _fltused = 0;
int32_t __eqdf2 = 0; int32_t __eqdf2 = 0;
int32_t __ltdf2 = 0; int32_t __ltdf2 = 0;
extern struct axboot_cfg cfg; extern struct axboot_cfg cfg;
CHAR16 wstr[1024];
void log(const char *fmt, ...) void log(const char *fmt, ...)
{ {
va_list args; va_list args;
@ -57,6 +64,15 @@ void log(const char *fmt, ...)
if (cfg.bootlog_filename != NULL) { if (cfg.bootlog_filename != NULL) {
vfs_write(cfg.bootlog_filename, (char *)&buf, size); vfs_write(cfg.bootlog_filename, (char *)&buf, size);
} }
#ifdef AXBOOT_UEFI
char *bufp = &buf;
size_t n = mbstowcs((wchar_t *)&wstr, (const char **)&bufp, 1024);
wstr[n] = L'\r';
wstr[n+1] = L'\0';
gSystemTable->ConOut->OutputString(gSystemTable->ConOut, wstr);
gBootServices->Stall(100000);
#endif
} }
void debug(const char *fmt, ...) void debug(const char *fmt, ...)
@ -68,6 +84,14 @@ void debug(const char *fmt, ...)
npf_vsnprintf(buf, sizeof(buf), fmt, args); npf_vsnprintf(buf, sizeof(buf), fmt, args);
va_end(args); va_end(args);
#ifdef AXBOOT_UEFI
char *bufp = &buf;
size_t n = mbstowcs((wchar_t *)&wstr, (const char **)&bufp, 1024);
wstr[n] = L'\r';
wstr[n+1] = L'\0';
gSystemTable->ConOut->OutputString(gSystemTable->ConOut, wstr);
gBootServices->Stall(100000);
#endif
uart_sendstr(buf); uart_sendstr(buf);
} }

View file

@ -107,6 +107,8 @@ void uefi_exit_bs(void)
int tries = 0; int tries = 0;
log("uefi_exit_bs(): Calling ExitBootServices(), this will be the last log you'll see before handoff!\n");
do { do {
map_key = 0; map_key = 0;
map_size = 0; map_size = 0;
@ -137,6 +139,4 @@ void uefi_exit_bs(void)
platform_reboot(); platform_reboot();
UNREACHABLE(); UNREACHABLE();
} }
debug("uefi_exit_bs(): ExitBootServices() success!\n");
} }