aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/syscall
diff options
context:
space:
mode:
authorMarvin Borner2020-04-28 20:59:57 +0200
committerMarvin Borner2020-04-28 20:59:57 +0200
commit5f8b5ce7efb7738eaebad43f9648975788ae19ff (patch)
treeab8fc4d4baa4adb99dc90461df689650acf34cef /src/kernel/syscall
parentbfe16de4be67565f1a1e7b1331fcbe3aedf9c54e (diff)
Fixed userspace entering...
Many other fixes too, but I won't mention them because I don't want to :)
Diffstat (limited to 'src/kernel/syscall')
-rw-r--r--src/kernel/syscall/actions/sys_alloc.c6
-rw-r--r--src/kernel/syscall/actions/sys_free.c2
-rw-r--r--src/kernel/syscall/actions/sys_get_pointers.c18
-rw-r--r--src/kernel/syscall/actions/sys_getch.c10
-rw-r--r--src/kernel/syscall/actions/sys_malloc.c7
-rw-r--r--src/kernel/syscall/actions/sys_putch.c9
-rw-r--r--src/kernel/syscall/actions/sys_read.c21
-rw-r--r--src/kernel/syscall/actions/sys_write.c15
-rw-r--r--src/kernel/syscall/syscall.c17
-rw-r--r--src/kernel/syscall/syscall.h14
10 files changed, 40 insertions, 79 deletions
diff --git a/src/kernel/syscall/actions/sys_alloc.c b/src/kernel/syscall/actions/sys_alloc.c
deleted file mode 100644
index 65269de..0000000
--- a/src/kernel/syscall/actions/sys_alloc.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <stdint.h>
-
-uint32_t sys_alloc(uint32_t count)
-{
- return 0; // (uint32_t) umalloc(count);
-} \ No newline at end of file
diff --git a/src/kernel/syscall/actions/sys_free.c b/src/kernel/syscall/actions/sys_free.c
index cbd4c70..480cd53 100644
--- a/src/kernel/syscall/actions/sys_free.c
+++ b/src/kernel/syscall/actions/sys_free.c
@@ -3,6 +3,6 @@
uint32_t sys_free(uint32_t ptr)
{
- kfree((void *)ptr);
+ ufree((void *)ptr);
return 0;
} \ No newline at end of file
diff --git a/src/kernel/syscall/actions/sys_get_pointers.c b/src/kernel/syscall/actions/sys_get_pointers.c
deleted file mode 100644
index 181630b..0000000
--- a/src/kernel/syscall/actions/sys_get_pointers.c
+++ /dev/null
@@ -1,18 +0,0 @@
-#include <stdint.h>
-#include <kernel/graphics/vesa.h>
-#include <kernel/fs/load.h>
-#include <kernel/memory/alloc.h>
-
-struct userspace_pointers {
- unsigned char *fb;
- struct font *font;
-};
-
-uint32_t sys_get_pointers()
-{
- struct userspace_pointers *pointers =
- (struct userspace_pointers *)kmalloc(sizeof(struct userspace_pointers));
- pointers->fb = fb;
- pointers->font = font;
- return (uint32_t)pointers;
-} \ No newline at end of file
diff --git a/src/kernel/syscall/actions/sys_getch.c b/src/kernel/syscall/actions/sys_getch.c
new file mode 100644
index 0000000..f1e4dfb
--- /dev/null
+++ b/src/kernel/syscall/actions/sys_getch.c
@@ -0,0 +1,10 @@
+#include <stdint.h>
+#include <kernel/lib/stdio.h>
+#include <kernel/input/input.h>
+#include <kernel/lib/lib.h>
+#include <kernel/lib/string.h>
+
+uint32_t sys_getch()
+{
+ return (uint32_t)getch();
+} \ No newline at end of file
diff --git a/src/kernel/syscall/actions/sys_malloc.c b/src/kernel/syscall/actions/sys_malloc.c
new file mode 100644
index 0000000..8adc362
--- /dev/null
+++ b/src/kernel/syscall/actions/sys_malloc.c
@@ -0,0 +1,7 @@
+#include <stdint.h>
+#include <kernel/memory/alloc.h>
+
+uint32_t sys_malloc(uint32_t count)
+{
+ return (uint32_t)umalloc(count);
+} \ No newline at end of file
diff --git a/src/kernel/syscall/actions/sys_putch.c b/src/kernel/syscall/actions/sys_putch.c
new file mode 100644
index 0000000..beaa4a2
--- /dev/null
+++ b/src/kernel/syscall/actions/sys_putch.c
@@ -0,0 +1,9 @@
+#include <stdint.h>
+#include <kernel/lib/stdio.h>
+#include <kernel/lib/string.h>
+
+uint32_t sys_putch(char ch)
+{
+ putch(ch);
+ return 0;
+} \ No newline at end of file
diff --git a/src/kernel/syscall/actions/sys_read.c b/src/kernel/syscall/actions/sys_read.c
deleted file mode 100644
index 24d83d1..0000000
--- a/src/kernel/syscall/actions/sys_read.c
+++ /dev/null
@@ -1,21 +0,0 @@
-#include <stdint.h>
-#include <kernel/lib/stdio.h>
-#include <kernel/input/input.h>
-#include <kernel/lib/lib.h>
-#include <kernel/lib/string.h>
-
-uint32_t sys_read(char *buf)
-{
- keyboard_clear_buffer();
- keyboard_char_buffer = 0;
- while (keyboard_char_buffer != '\n') {
- getch();
- }
- memcpy(buf, keyboard_buffer, strlen(keyboard_buffer));
- return strlen(buf);
-}
-
-uint32_t sys_readc()
-{
- return (uint32_t)getch();
-} \ No newline at end of file
diff --git a/src/kernel/syscall/actions/sys_write.c b/src/kernel/syscall/actions/sys_write.c
deleted file mode 100644
index f15004f..0000000
--- a/src/kernel/syscall/actions/sys_write.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <stdint.h>
-#include <kernel/lib/stdio.h>
-#include <kernel/lib/string.h>
-
-uint32_t sys_write(char *buf)
-{
- printf(buf);
- return strlen((const char *)buf);
-}
-
-uint32_t sys_writec(char ch)
-{
- writec(ch);
- return 0;
-} \ No newline at end of file
diff --git a/src/kernel/syscall/syscall.c b/src/kernel/syscall/syscall.c
index f883f2e..a106f07 100644
--- a/src/kernel/syscall/syscall.c
+++ b/src/kernel/syscall/syscall.c
@@ -3,20 +3,19 @@
#include <kernel/interrupts/interrupts.h>
#include <kernel/system.h>
#include <kernel/lib/stdio.h>
+#include <kernel/io/io.h>
-typedef uint32_t (*syscall_func)(unsigned int, ...);
+typedef uint32_t (*syscall_func)(uint32_t, ...);
uint32_t (*syscalls[])() = { [0] = (uint32_t(*)())halt_loop, // DEBUG!
- [1] = sys_write,
- [2] = sys_read,
- [3] = (uint32_t(*)())sys_writec,
- [4] = sys_readc,
- [5] = sys_get_pointers,
- [6] = sys_alloc,
- [7] = sys_free };
+ [1] = sys_putch,
+ [2] = sys_getch,
+ [3] = sys_malloc,
+ [4] = sys_free };
void syscall_handler(struct regs *r)
{
+ sti();
log("Received syscall!");
if (r->eax >= sizeof(syscalls) / sizeof(*syscalls))
@@ -35,4 +34,4 @@ void syscall_handler(struct regs *r)
void syscalls_install()
{
isr_install_handler(0x80, syscall_handler);
-}
+} \ No newline at end of file
diff --git a/src/kernel/syscall/syscall.h b/src/kernel/syscall/syscall.h
index 229cf04..b2bdc6d 100644
--- a/src/kernel/syscall/syscall.h
+++ b/src/kernel/syscall/syscall.h
@@ -1,21 +1,17 @@
#ifndef MELVIX_SYSCALL_H
#define MELVIX_SYSCALL_H
+#include <stdint.h>
+
extern void idt_syscall();
void syscalls_install();
-uint32_t sys_write(char *buf);
-
-uint32_t sys_writec(char ch);
-
-uint32_t sys_read();
-
-uint32_t sys_readc(char *ch);
+uint32_t sys_putch(char ch);
-uint32_t sys_get_pointers();
+uint32_t sys_getch();
-uint32_t sys_alloc(uint32_t count);
+uint32_t sys_malloc(uint32_t count);
uint32_t sys_free(uint32_t ptr);