aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/syscall
diff options
context:
space:
mode:
authorMarvin Borner2019-12-10 21:47:41 +0100
committerMarvin Borner2019-12-10 21:47:41 +0100
commit68915f46e66ed65ce2d32009fdfa2f5dca116842 (patch)
tree7d6df3e4dc6219422cc4b1faf909ff32a74b6edf /src/kernel/syscall
parent33bdf18dad2539aca21727e95e04bfedecd37a76 (diff)
Some syscalls and userspace stuff
sorry for the worse-getting commit messages...
Diffstat (limited to 'src/kernel/syscall')
-rw-r--r--src/kernel/syscall/actions/sys_paging_alloc.c10
-rw-r--r--src/kernel/syscall/actions/sys_paging_free.c8
-rw-r--r--src/kernel/syscall/actions/sys_read.c8
-rw-r--r--src/kernel/syscall/actions/sys_write.c8
-rw-r--r--src/kernel/syscall/syscall.c9
-rw-r--r--src/kernel/syscall/syscall.h8
6 files changed, 40 insertions, 11 deletions
diff --git a/src/kernel/syscall/actions/sys_paging_alloc.c b/src/kernel/syscall/actions/sys_paging_alloc.c
new file mode 100644
index 0000000..fb4e415
--- /dev/null
+++ b/src/kernel/syscall/actions/sys_paging_alloc.c
@@ -0,0 +1,10 @@
+#include <stdint.h>
+#include <kernel/paging/paging.h>
+#include <kernel/io/io.h>
+
+uint32_t sys_paging_alloc(uint32_t count)
+{
+ uint32_t ptr = paging_alloc_pages((uint32_t) count);
+ paging_set_user(ptr, count);
+ return ptr;
+} \ No newline at end of file
diff --git a/src/kernel/syscall/actions/sys_paging_free.c b/src/kernel/syscall/actions/sys_paging_free.c
new file mode 100644
index 0000000..cdf7bb1
--- /dev/null
+++ b/src/kernel/syscall/actions/sys_paging_free.c
@@ -0,0 +1,8 @@
+#include <stdint.h>
+#include <kernel/paging/paging.h>
+
+uint32_t sys_paging_free(uint32_t virt, uint32_t count)
+{
+ paging_set_free(virt, count);
+ return count;
+} \ No newline at end of file
diff --git a/src/kernel/syscall/actions/sys_read.c b/src/kernel/syscall/actions/sys_read.c
index f04f3ef..02960f6 100644
--- a/src/kernel/syscall/actions/sys_read.c
+++ b/src/kernel/syscall/actions/sys_read.c
@@ -3,6 +3,7 @@
#include <kernel/input/input.h>
#include <kernel/lib/lib.h>
#include <kernel/lib/string.h>
+#include <kernel/io/io.h>
uint32_t sys_read(char *buf)
{
@@ -15,7 +16,10 @@ uint32_t sys_read(char *buf)
return strlen(buf);
}
-uint32_t sys_readc()
+uint32_t sys_readc(char *ch)
{
- return getch();
+ char buf = getch();
+ ch = &buf;
+ serial_put(*ch);
+ return (uint32_t) ch;
} \ No newline at end of file
diff --git a/src/kernel/syscall/actions/sys_write.c b/src/kernel/syscall/actions/sys_write.c
index 554ac5f..8531e85 100644
--- a/src/kernel/syscall/actions/sys_write.c
+++ b/src/kernel/syscall/actions/sys_write.c
@@ -9,12 +9,10 @@ uint32_t sys_write(char *buf)
return strlen((const char *) buf);
}
-uint32_t sys_writec(char ch)
+uint32_t sys_writec(char *ch)
{
- serial_write_hex(ch);
- serial_write("\n");
- serial_put(ch);
+ serial_write_hex(*ch);
serial_write("\n\n");
- writec(ch);
+ writec((char) *ch);
return 0;
} \ No newline at end of file
diff --git a/src/kernel/syscall/syscall.c b/src/kernel/syscall/syscall.c
index 89b70eb..3a1b011 100644
--- a/src/kernel/syscall/syscall.c
+++ b/src/kernel/syscall/syscall.c
@@ -2,14 +2,19 @@
#include <kernel/syscall/syscall.h>
#include <kernel/interrupts/interrupts.h>
#include <kernel/io/io.h>
+#include <kernel/paging/paging.h>
+#include <kernel/system.h>
typedef uint32_t (*syscall_func)(unsigned int, ...);
uint32_t (*syscalls[])() = {
+ [0] = (uint32_t (*)()) halt_loop, // DEBUG!
[1] = sys_write,
[2] = sys_read,
- [3] = (uint32_t (*)()) sys_writec,
- [4] = sys_readc
+ [3] = sys_writec,
+ [4] = sys_readc,
+ [5] = sys_paging_alloc,
+ [6] = sys_paging_free
};
void syscall_handler(struct regs *r)
diff --git a/src/kernel/syscall/syscall.h b/src/kernel/syscall/syscall.h
index 046d702..a037d7f 100644
--- a/src/kernel/syscall/syscall.h
+++ b/src/kernel/syscall/syscall.h
@@ -7,10 +7,14 @@ void syscalls_install();
uint32_t sys_write(char *buf);
-uint32_t sys_writec(char ch);
+uint32_t sys_writec(char *ch);
uint32_t sys_read(char *buf);
-uint32_t sys_readc();
+uint32_t sys_readc(char *ch);
+
+uint32_t sys_paging_alloc(uint32_t count);
+
+uint32_t sys_paging_free(uint32_t virt, uint32_t count);
#endif \ No newline at end of file