diff --git a/guest/console/console.h b/guest/console/console.h new file mode 100644 index 0000000000000000000000000000000000000000..64d693a9a3b8ed9151ac14056e6bb79553cc135e --- /dev/null +++ b/guest/console/console.h @@ -0,0 +1,12 @@ +#ifndef _CONSOLE_H_ +#define _CONSOLE_H_ + +// --- DEFINE --- + +// ... + +// --- FUNCTION --- + +void console_send_pv(char *str); + +#endif // _CONSOLE_H_ diff --git a/guest/console/console_pv.c b/guest/console/console_pv.c new file mode 100644 index 0000000000000000000000000000000000000000..5a6b9de69a5adc144cb4ac4bd9bf96fd16e3c86a --- /dev/null +++ b/guest/console/console_pv.c @@ -0,0 +1,21 @@ +#include "console.h" + +#include "guest/utils.h" +#include "guest/pmio.h" +#include "shared/hypercall_params.h" + +// --- DEFINE --- + +// ... + +// --- FUNCTION --- + +void console_send_pv(char *str) { + + 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); +} + diff --git a/guest/gfx/gfx.h b/guest/gfx/gfx.h new file mode 100644 index 0000000000000000000000000000000000000000..6aed69cc087812f9fdbf341ddfb4d227246456dc --- /dev/null +++ b/guest/gfx/gfx.h @@ -0,0 +1,16 @@ +#ifndef _GFX_H_ +#define _GFX_H_ + +#include <stdint.h> + +// --- DEFINE --- + +// ... + +// --- FUNCTION --- + +void gfx_pv_init(uint32_t width, uint32_t height); + +void gfx_phys_init(uint32_t width, uint32_t height); + +#endif // !_TIMER_H_ diff --git a/guest/gfx/gfx_phys.c b/guest/gfx/gfx_phys.c new file mode 100644 index 0000000000000000000000000000000000000000..84602d0536401b7290245e2c54e54db657b971e4 --- /dev/null +++ b/guest/gfx/gfx_phys.c @@ -0,0 +1,16 @@ +#include "gfx.h" + +#include "guest/utils.h" +#include "guest/pmio.h" +#include "shared/hypercall_params.h" + +// --- DEFINE --- + +// ... + +// --- FUNCTION --- + +void gfx_phys_init(uint32_t width, uint32_t height) { + + // TODO: +} diff --git a/guest/gfx/gfx_pv.c b/guest/gfx/gfx_pv.c new file mode 100644 index 0000000000000000000000000000000000000000..c92aca1c884d7c6ca3b2c2d578ba51fc27ad6b45 --- /dev/null +++ b/guest/gfx/gfx_pv.c @@ -0,0 +1,22 @@ +#include "gfx.h" + +#include "guest/utils.h" +#include "guest/pmio.h" +#include "shared/hypercall_params.h" + +// --- DEFINE --- + +// ... + +// --- FUNCTION --- + +void gfx_pv_init(uint32_t width, uint32_t height) { + + hyper_init_gfx_params_t param_gfx; + param_gfx.width = width; + param_gfx.height = height; + memcpy((void *)HYPERCALL_SHARED_ADDR, (void *)¶m_gfx, sizeof(param_gfx)); + + outb(HYPERCALL_PMIO_ADDR, HYPERCALL_CODE_GFX_INIT); +} + diff --git a/guest/guest_main.c b/guest/guest_main.c index 7e342105eb2a6d4e20fecdd929b4794cbc4b8143..be271eb3b4cefe0913e87329febb9379385349ca 100644 --- a/guest/guest_main.c +++ b/guest/guest_main.c @@ -6,6 +6,11 @@ #include "pmio.h" #include "shared/hypercall_params.h" +#include "ide/ide.h" +#include "gfx/gfx.h" +#include "timer/timer.h" +#include "console/console.h" + // If PV == 1 => uses paravirtualized drivers (when available) // If PV == 0 => uses physical (hardware) drivers (when available) #if PV == 1 @@ -23,40 +28,22 @@ void guest_main() { idt_init(); // Initialize interrupt subsystem sti(); // Enable hardware interrupts - // 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)); + // - pv console - + char *str = "Hi from the guest !"; + console_send_pv(str); - outb(HYPERCALL_PMIO_ADDR, HYPERCALL_CODE_TIMER); + // - pv timer - + timer_pv_wait(1e6); - // emulated timer + // - phys timer - + timer_phys_wait(1e6); - outw(REG_TIMER_CMD, 20); - outd(REG_TIMER_DATA, 1e6); + // - pv gfx init - + gfx_pv_init(1920, 1080); - // 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: + // - phys gfx init - + /* gfx_phys_init(1920, 1080); */ // timer_sleep(100000); } + diff --git a/guest/timer/timer.h b/guest/timer/timer.h new file mode 100644 index 0000000000000000000000000000000000000000..9e44db03aa85a930a05d05196007472bc9150c2f --- /dev/null +++ b/guest/timer/timer.h @@ -0,0 +1,16 @@ +#ifndef _TIMER_H_ +#define _TIMER_H_ + +#include <stdint.h> + +// --- DEFINE --- + +// ... + +// --- FUNCTION --- + +void timer_pv_wait(uint32_t us); + +void timer_phys_wait(uint32_t us); + +#endif // !_TIMER_H_ diff --git a/guest/timer/timer_phys.c b/guest/timer/timer_phys.c new file mode 100644 index 0000000000000000000000000000000000000000..3e95ebe0004e2f3701727f95009be75a43ef4df6 --- /dev/null +++ b/guest/timer/timer_phys.c @@ -0,0 +1,17 @@ +#include "timer.h" + +#include "guest/pmio.h" +#include "shared/hypercall_params.h" + +// --- DEFINE --- + +// ... + +// --- FUNCTION --- + +void timer_phys_wait(uint32_t us) { + + outw(REG_TIMER_CMD, 20); + outd(REG_TIMER_DATA, us); +} + diff --git a/guest/timer/timer_pv.c b/guest/timer/timer_pv.c new file mode 100644 index 0000000000000000000000000000000000000000..5770f5e5a1322b5dc3ce511e69295963a0ef1017 --- /dev/null +++ b/guest/timer/timer_pv.c @@ -0,0 +1,21 @@ +#include "timer.h" + +#include "guest/utils.h" +#include "guest/pmio.h" +#include "shared/hypercall_params.h" + +// --- DEFINE --- + +// ... + +// --- FUNCTION --- + +void timer_pv_wait(uint32_t us) { + + hyper_timer_sleep_params_t param_timer; + param_timer.us = us; + memcpy((void *)HYPERCALL_SHARED_ADDR, (void *)¶m_timer, sizeof(param_timer)); + + outb(HYPERCALL_PMIO_ADDR, HYPERCALL_CODE_TIMER); +} +