From 79eaf39584347082ca4caf1edf30e3a99fdc1b2e Mon Sep 17 00:00:00 2001 From: "adrian.spycher" <adrian.spycher@etu.hesge.ch> Date: Tue, 22 Oct 2024 15:57:39 +0200 Subject: [PATCH] feat: modfiy guest to test until gfx init emulated --- guest/guest_main.c | 45 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/guest/guest_main.c b/guest/guest_main.c index 244e224..7e34210 100644 --- a/guest/guest_main.c +++ b/guest/guest_main.c @@ -1,7 +1,10 @@ #include <stdint.h> + #include "idt.h" #include "utils.h" #include "x86.h" +#include "pmio.h" +#include "shared/hypercall_params.h" // If PV == 1 => uses paravirtualized drivers (when available) // If PV == 0 => uses physical (hardware) drivers (when available) @@ -12,12 +15,48 @@ #endif // Dummy examples -void timer_sleep_pv(int usec) {} -void timer_sleep_phys(int usec) {} +// void timer_sleep_pv(int usec) {} +// void timer_sleep_phys(int usec) {} void guest_main() { + idt_init(); // Initialize interrupt subsystem sti(); // Enable hardware interrupts - timer_sleep(100000); + // paravirtualized console + + char *str = "abcdefgh"; + hyper_virtual_console_params_t param_console; + param_console.msg = (uint64_t)str; + memcpy((void *)HYPERCALL_SHARED_ADDR, (void *)¶m_console, sizeof(param_console)); + + outb(HYPERCALL_PMIO_ADDR, HYPERCALL_CODE_CONSOLE); + + // paravirtualized timer + + hyper_timer_sleep_params_t param_timer; + param_timer.us = 1e6; + memcpy((void *)HYPERCALL_SHARED_ADDR, (void *)¶m_timer, sizeof(param_timer)); + + outb(HYPERCALL_PMIO_ADDR, HYPERCALL_CODE_TIMER); + + // emulated timer + + outw(REG_TIMER_CMD, 20); + outd(REG_TIMER_DATA, 1e6); + + // paravirtualized gfx init + + hyper_init_gfx_params_t param_gfx; + param_gfx.width = 1920; + param_gfx.height = 1080; + memcpy((void *)HYPERCALL_SHARED_ADDR, (void *)¶m_gfx, sizeof(param_gfx)); + + outb(HYPERCALL_PMIO_ADDR, HYPERCALL_CODE_GFX_INIT); + + // emulated gfx init + + // TODO: + + // timer_sleep(100000); } -- GitLab