diff --git a/guest/guest_main.c b/guest/guest_main.c index 244e224ae9f5c75c07765ad16302abc683ca1300..7e342105eb2a6d4e20fecdd929b4794cbc4b8143 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); }