Beginning of refactor
This commit is contained in:
parent
02e846f1ab
commit
860c9ea53c
5 changed files with 52 additions and 17 deletions
|
@ -21,6 +21,7 @@
|
|||
#include <arch/cpu/idt.h>
|
||||
#include <proto/aurix.h>
|
||||
#include <mm/vmm.h>
|
||||
#include <print.h>
|
||||
#include <stdint.h>
|
||||
|
||||
struct gdt {
|
||||
|
@ -68,21 +69,21 @@ void aurix_arch_handoff(void *kernel_entry, pagetable *pm, void *stack, uint32_t
|
|||
|
||||
__asm__ volatile(
|
||||
"cli\n"
|
||||
"lgdt %[gdtr]\n"
|
||||
"ltr %[tss]\n"
|
||||
"pushq $0x08\n"
|
||||
"lea 1f(%%rip), %%rax\n"
|
||||
"pushq %%rax\n"
|
||||
"lretq\n"
|
||||
"1:\n"
|
||||
"movq $0x10, %%rax\n"
|
||||
"movq %%rax, %%ds\n"
|
||||
"movq %%rax, %%es\n"
|
||||
"movq %%rax, %%ss\n"
|
||||
"movq %%rax, %%fs\n"
|
||||
"movq %%rax, %%gs\n"
|
||||
//"lgdt %[gdtr]\n"
|
||||
//"ltr %[tss]\n"
|
||||
//"pushq $0x08\n"
|
||||
//"lea 1f(%%rip), %%rax\n"
|
||||
//"pushq %%rax\n"
|
||||
//"lretq\n"
|
||||
//"1:\n"
|
||||
//"movq $0x10, %%rax\n"
|
||||
//"movq %%rax, %%ds\n"
|
||||
//"movq %%rax, %%es\n"
|
||||
//"movq %%rax, %%ss\n"
|
||||
//"movq %%rax, %%fs\n"
|
||||
//"movq %%rax, %%gs\n"
|
||||
|
||||
"lidt %[idt]\n"
|
||||
//"lidt %[idt]\n"
|
||||
|
||||
"movq %[pml4], %%cr3\n"
|
||||
"movq %[stack], %%rsp\n"
|
||||
|
|
|
@ -38,6 +38,16 @@ void axboot_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
|
||||
#include <driver.h>
|
||||
load_drivers();
|
||||
|
|
|
@ -36,12 +36,19 @@
|
|||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <efi.h>
|
||||
#include <efilib.h>
|
||||
#include <mm/mman.h>
|
||||
#include <lib/string.h>
|
||||
|
||||
int32_t _fltused = 0;
|
||||
int32_t __eqdf2 = 0;
|
||||
int32_t __ltdf2 = 0;
|
||||
|
||||
extern struct axboot_cfg cfg;
|
||||
|
||||
CHAR16 wstr[1024];
|
||||
|
||||
void log(const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
@ -57,6 +64,15 @@ void log(const char *fmt, ...)
|
|||
if (cfg.bootlog_filename != NULL) {
|
||||
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, ...)
|
||||
|
@ -68,6 +84,14 @@ void debug(const char *fmt, ...)
|
|||
npf_vsnprintf(buf, sizeof(buf), fmt, 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);
|
||||
}
|
||||
|
||||
|
|
|
@ -107,6 +107,8 @@ void uefi_exit_bs(void)
|
|||
|
||||
int tries = 0;
|
||||
|
||||
log("uefi_exit_bs(): Calling ExitBootServices(), this will be the last log you'll see before handoff!\n");
|
||||
|
||||
do {
|
||||
map_key = 0;
|
||||
map_size = 0;
|
||||
|
@ -137,6 +139,4 @@ void uefi_exit_bs(void)
|
|||
platform_reboot();
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
debug("uefi_exit_bs(): ExitBootServices() success!\n");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue