diff options
| author | Jon Santmyer <jon@jonsantmyer.com> | 2026-09-13 11:45:31 -0400 |
|---|---|---|
| committer | Jon Santmyer <jon@jonsantmyer.com> | 2026-09-13 11:45:31 -0400 |
| commit | 24136157aae8c88f9397903157adf8f6237d73c0 (patch) | |
| tree | 97555b8bd455ebfe13e3a08b96d3c370b7021d15 /arch | |
| parent | 53fa3cd2bfdb122d773024612d8c1d71f0dd8188 (diff) | |
| download | jove-kernel-24136157aae8c88f9397903157adf8f6237d73c0.tar.gz jove-kernel-24136157aae8c88f9397903157adf8f6237d73c0.tar.bz2 jove-kernel-24136157aae8c88f9397903157adf8f6237d73c0.zip | |
add barebones uacpi support. just gets tables
Diffstat (limited to 'arch')
| -rw-r--r-- | arch/x86_64/hal/msr.c | 15 | ||||
| -rw-r--r-- | arch/x86_64/hal/msr.h | 2 | ||||
| -rw-r--r-- | arch/x86_64/hal/process.c | 2 | ||||
| -rw-r--r-- | arch/x86_64/hal/uacpi.c | 15 | ||||
| -rw-r--r-- | arch/x86_64/main.c | 7 |
5 files changed, 40 insertions, 1 deletions
diff --git a/arch/x86_64/hal/msr.c b/arch/x86_64/hal/msr.c index f27e303..849f0ff 100644 --- a/arch/x86_64/hal/msr.c +++ b/arch/x86_64/hal/msr.c @@ -44,6 +44,21 @@ msr_enable_sce(void) } void +msr_enable_sse(void) +{ + uint64_t cr4 = 0; + __asm__ volatile("mov %%cr4, %0": "=r"(cr4)); + + cr4 &= 0xFFFFFFFFFFFFFFFB; + cr4 |= 0x2; + __asm__ volatile("mov %0, %%cr4":: "r"(cr4)); + __asm__ volatile("mov %%cr4, %0": "=r"(cr4)); + + cr4 |= (3 << 9); + __asm__ volatile("mov %0, %%cr4":: "r"(cr4)); +} + +void msr_set_lstar(void *lstar_value) { union msr_lstar lstar; diff --git a/arch/x86_64/hal/msr.h b/arch/x86_64/hal/msr.h index 69d96be..f65b621 100644 --- a/arch/x86_64/hal/msr.h +++ b/arch/x86_64/hal/msr.h @@ -40,6 +40,8 @@ void msr_set_gs_base(uintptr_t gs_base); uintptr_t msr_get_gs_base(void); void msr_enable_sce(void); +void msr_enable_sse(void); + void msr_set_lstar(void *syscall_entry); void msr_read(uint32_t msr, uint32_t *lo, uint32_t *hi); diff --git a/arch/x86_64/hal/process.c b/arch/x86_64/hal/process.c index 872be5a..6cc9372 100644 --- a/arch/x86_64/hal/process.c +++ b/arch/x86_64/hal/process.c @@ -41,7 +41,7 @@ pcb_rootdir(pcb_t *pcb) void processing_setup(void (*process_main)) { - uintptr_t ksp = ((uintptr_t)&s_init_pcb_bytes) + 0xFF0; + uintptr_t ksp = ((uintptr_t)&s_init_pcb_bytes) + 0xFF8; s_init_pcb->pid = 1; s_init_pcb->ksp = (void*)ksp; diff --git a/arch/x86_64/hal/uacpi.c b/arch/x86_64/hal/uacpi.c new file mode 100644 index 0000000..052f849 --- /dev/null +++ b/arch/x86_64/hal/uacpi.c @@ -0,0 +1,15 @@ +#include "lib/printf.h" +#include "uacpi/kernel_api.h" +#include "paging.h" + +void *uacpi_kernel_map(uacpi_phys_addr addr, uacpi_size len) +{ + //kprintf("UACPI kernel map %p -> %p\n", addr, (uintptr_t)addr | IDENT_VIRT_BASE); + return (void*)(addr | IDENT_VIRT_BASE); +} + +void uacpi_kernel_unmap(void *addr, uacpi_size len) +{ + (void)addr; + (void)len; +} diff --git a/arch/x86_64/main.c b/arch/x86_64/main.c index 2d4599e..d688fa0 100644 --- a/arch/x86_64/main.c +++ b/arch/x86_64/main.c @@ -4,6 +4,7 @@ #include "lib/virtterm.h" #include "lib/panic.h" #include "../../hal/obj.h" +#include "hal/msr.h" #include "hal/serial_com.h" #include "hal/smp.h" #include "hal/memory.h" @@ -11,6 +12,7 @@ #include "hal/process.h" #include "boot/initrd.h" #include "boot/cmdline.h" +#include "uacpi/uacpi.h" int errno = 0; @@ -23,6 +25,8 @@ static void kernel_process_entry(void); void kernel_entry(void) { + msr_enable_sse(); + obj_settype(_rootdir_obj, JOVE_OBJ_OBJDIR); serial_com_init(); @@ -45,6 +49,9 @@ kernel_entry(void) static void kernel_process_entry(void) { + uint8_t uacpi_buffer[1024]; + uacpi_setup_early_table_access(uacpi_buffer, 1024); + init_setup(); kpanic("Reached the end of kernel main!\n"); } |
