summaryrefslogtreecommitdiff
path: root/kernel/syscalls
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/syscalls')
-rw-r--r--kernel/syscalls/install_irq.c26
-rw-r--r--kernel/syscalls/map_frames.c6
-rw-r--r--kernel/syscalls/port.c14
-rw-r--r--kernel/syscalls/virtual_to_physical.c6
4 files changed, 52 insertions, 0 deletions
diff --git a/kernel/syscalls/install_irq.c b/kernel/syscalls/install_irq.c
new file mode 100644
index 0000000..c50c6e0
--- /dev/null
+++ b/kernel/syscalls/install_irq.c
@@ -0,0 +1,26 @@
+#include <sched/scheduler.h>
+#include <syscalls.h>
+
+process_t *tmp;
+void *handler;
+
+void jump_signal_handler(void *func, u32 esp);
+
+void test_handler(reg_t *regs) {
+ kprintf("IRQ FIRED\n");
+ kprintf("handler: %x\n", handler);
+ tmp->interrupt_handler = handler;
+ signal_t sig;
+ sig.handler_ip = (uintptr_t)handler;
+ process_push_signal(tmp, sig);
+ return;
+}
+
+int syscall_install_irq(void (*irq_handler)(), u8 irq) {
+ // TODO: This should be able to fail if the handler is already set
+ tmp = get_current_task();
+ handler = irq_handler;
+ kprintf("IRQ INSTALLED\n");
+ install_handler(test_handler, INT_32_INTERRUPT_GATE(0x0), 0x20 + irq);
+ return 1;
+}
diff --git a/kernel/syscalls/map_frames.c b/kernel/syscalls/map_frames.c
new file mode 100644
index 0000000..1b0d097
--- /dev/null
+++ b/kernel/syscalls/map_frames.c
@@ -0,0 +1,6 @@
+#include <mmu.h>
+#include <syscalls.h>
+
+u32 syscall_map_frames(u32 address, u32 size) {
+ return (u32)mmu_map_user_frames((void *)address, size);
+}
diff --git a/kernel/syscalls/port.c b/kernel/syscalls/port.c
new file mode 100644
index 0000000..0a27a5e
--- /dev/null
+++ b/kernel/syscalls/port.c
@@ -0,0 +1,14 @@
+#include <syscalls.h>
+
+// FIXME: PERMISSION CHECKS
+void syscall_outw(u16 port, u16 word) {
+ outw(port, word);
+}
+
+void syscall_outl(u16 port, u32 l) {
+ outl(port, l);
+}
+
+u32 syscall_inl(u16 port) {
+ return inl(port);
+}
diff --git a/kernel/syscalls/virtual_to_physical.c b/kernel/syscalls/virtual_to_physical.c
new file mode 100644
index 0000000..e5b3eba
--- /dev/null
+++ b/kernel/syscalls/virtual_to_physical.c
@@ -0,0 +1,6 @@
+#include <mmu.h>
+#include <syscalls.h>
+
+u32 syscall_virtual_to_physical(u32 virtual) {
+ return (u32)virtual_to_physical((void *)virtual, NULL);
+}