From f0d3982a59d0cfb6e8b778c038ef4d65d5cd3f51 Mon Sep 17 00:00:00 2001 From: Baptiste Wicht Date: Sun, 7 Aug 2016 13:20:42 +0200 Subject: [PATCH] System calls for mouse position --- kernel/src/system_calls.cpp | 17 +++++++++++++++++ tlib/include/graphics.hpp | 3 +++ tlib/src/graphics.cpp | 8 ++++++++ 3 files changed, 28 insertions(+) diff --git a/kernel/src/system_calls.cpp b/kernel/src/system_calls.cpp index b2e68ad5..9bb3ac0d 100644 --- a/kernel/src/system_calls.cpp +++ b/kernel/src/system_calls.cpp @@ -14,6 +14,7 @@ #include "rtc.hpp" #include "kernel_utils.hpp" #include "vesa.hpp" +#include "mouse.hpp" #include "vfs/vfs.hpp" namespace { @@ -257,6 +258,14 @@ void sc_vesa_redraw(interrupt::syscall_regs* regs){ vesa::redraw(new_buffer); } +void sc_mouse_x(interrupt::syscall_regs* regs){ + regs->rax = mouse::x(); +} + +void sc_mouse_y(interrupt::syscall_regs* regs){ + regs->rax = mouse::y(); +} + } //End of anonymous namespace void system_call_entry(interrupt::syscall_regs* regs){ @@ -416,6 +425,14 @@ void system_call_entry(interrupt::syscall_regs* regs){ sc_vesa_redraw(regs); break; + case 0x1100: + sc_mouse_x(regs); + break; + + case 0x1101: + sc_mouse_y(regs); + break; + default: k_print_line("Invalid system call"); break; diff --git a/tlib/include/graphics.hpp b/tlib/include/graphics.hpp index cbb8b137..72a0b92b 100644 --- a/tlib/include/graphics.hpp +++ b/tlib/include/graphics.hpp @@ -24,6 +24,9 @@ uint64_t get_red_shift(); uint64_t get_green_shift(); uint64_t get_blue_shift(); +uint64_t mouse_x(); +uint64_t mouse_y(); + void redraw(char* buffer); } // end of namespace graphics diff --git a/tlib/src/graphics.cpp b/tlib/src/graphics.cpp index 5c8c8d91..69366abb 100644 --- a/tlib/src/graphics.cpp +++ b/tlib/src/graphics.cpp @@ -58,3 +58,11 @@ void graphics::redraw(char* buffer){ : [buffer] "g" (buffer) : "rax", "rbx"); } + +uint64_t graphics::mouse_x(){ + return syscall_get(0x1100); +} + +uint64_t graphics::mouse_y(){ + return syscall_get(0x1101); +}