aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/kernel/paging/paging.c6
-rw-r--r--src/kernel/syscall/actions/sys_read.c7
-rw-r--r--src/kernel/syscall/actions/sys_write.c6
-rw-r--r--src/kernel/syscall/syscall.c5
-rw-r--r--src/kernel/syscall/syscall.h4
-rw-r--r--src/userspace/main.c14
-rw-r--r--src/userspace/mlibc/stdio/getch.c5
-rw-r--r--src/userspace/mlibc/stdio/writec.c4
-rw-r--r--src/userspace/syscall.c4
-rw-r--r--src/userspace/syscall.h4
10 files changed, 27 insertions, 32 deletions
diff --git a/src/kernel/paging/paging.c b/src/kernel/paging/paging.c
index be7e264..5797940 100644
--- a/src/kernel/paging/paging.c
+++ b/src/kernel/paging/paging.c
@@ -124,17 +124,17 @@ void paging_set_user(uint32_t virt, uint32_t count)
uint32_t paging_find_pages(uint32_t count)
{
- uint32_t continous = 0;
+ uint32_t continuous = 0;
uint32_t startDir = 0;
uint32_t startPage = 0;
for (uint32_t i = 0; i < 1024; i++) {
for (uint32_t j = 0; j < 1024; j++) {
if (!(page_tables[i][j] & PT_PRESENT) || (page_tables[i][j] & PT_USED)) {
- continous = 0;
+ continuous = 0;
startDir = i;
startPage = j + 1;
} else {
- if (++continous == count)
+ if (++continuous == count)
return (startDir * 0x400000) + (startPage * 0x1000);
}
}
diff --git a/src/kernel/syscall/actions/sys_read.c b/src/kernel/syscall/actions/sys_read.c
index 02960f6..83e645c 100644
--- a/src/kernel/syscall/actions/sys_read.c
+++ b/src/kernel/syscall/actions/sys_read.c
@@ -16,10 +16,7 @@ uint32_t sys_read(char *buf)
return strlen(buf);
}
-uint32_t sys_readc(char *ch)
+uint32_t sys_readc()
{
- char buf = getch();
- ch = &buf;
- serial_put(*ch);
- return (uint32_t) ch;
+ 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
index 8531e85..6377473 100644
--- a/src/kernel/syscall/actions/sys_write.c
+++ b/src/kernel/syscall/actions/sys_write.c
@@ -9,10 +9,8 @@ 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\n");
- writec((char) *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 24f2445..16d1ce4 100644
--- a/src/kernel/syscall/syscall.c
+++ b/src/kernel/syscall/syscall.c
@@ -11,7 +11,7 @@ uint32_t (*syscalls[])() = {
[0] = (uint32_t (*)()) halt_loop, // DEBUG!
[1] = sys_write,
[2] = sys_read,
- [3] = sys_writec,
+ [3] = (uint32_t (*)()) sys_writec,
[4] = sys_readc,
[5] = sys_get_pointers,
[6] = sys_paging_alloc,
@@ -29,7 +29,8 @@ void syscall_handler(struct regs *r)
if (!location)
return;
- location(r->ebx, r->ecx, r->edx, r->esi, r->edi);
+ uint32_t ret = location(r->ebx, r->ecx, r->edx, r->esi, r->edi);
+ r->eax = ret;
}
void syscalls_install()
diff --git a/src/kernel/syscall/syscall.h b/src/kernel/syscall/syscall.h
index 378b5e3..ae69800 100644
--- a/src/kernel/syscall/syscall.h
+++ b/src/kernel/syscall/syscall.h
@@ -7,9 +7,9 @@ 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_read();
uint32_t sys_readc(char *ch);
diff --git a/src/userspace/main.c b/src/userspace/main.c
index 9341bd0..0bea7fa 100644
--- a/src/userspace/main.c
+++ b/src/userspace/main.c
@@ -1,18 +1,16 @@
#include <syscall.h>
#include <graphics/graphics.h>
+#include <mlibc/stdio.h>
void user_main()
{
char hello[] = "> Successfully switched to usermode!\n";
syscall_write(hello);
- init_framebuffer();
+ // init_framebuffer();
- while (1) {};
-
- /*while (1) {
- char *key = malloc(1);
- syscall_readc(key);
- syscall_writec(key);
- };*/
+ while (1) {
+ char key = getch();
+ writec(key);
+ };
} \ No newline at end of file
diff --git a/src/userspace/mlibc/stdio/getch.c b/src/userspace/mlibc/stdio/getch.c
index 114b6e0..dc9c40e 100644
--- a/src/userspace/mlibc/stdio/getch.c
+++ b/src/userspace/mlibc/stdio/getch.c
@@ -1,7 +1,6 @@
-// #include <syscall.h>
+#include <syscall.h>
char getch()
{
- // return ((char *) syscall_read())[0];
- return 0;
+ return (char) syscall_readc();
} \ No newline at end of file
diff --git a/src/userspace/mlibc/stdio/writec.c b/src/userspace/mlibc/stdio/writec.c
index 9ffb1a1..ee588e5 100644
--- a/src/userspace/mlibc/stdio/writec.c
+++ b/src/userspace/mlibc/stdio/writec.c
@@ -1,4 +1,6 @@
+#include <syscall.h>
+
void writec(char c)
{
- //
+ syscall_writec(c);
} \ No newline at end of file
diff --git a/src/userspace/syscall.c b/src/userspace/syscall.c
index b398728..35e6d50 100644
--- a/src/userspace/syscall.c
+++ b/src/userspace/syscall.c
@@ -9,9 +9,9 @@ DEFN_SYSCALL1(write, 1, char *);
DEFN_SYSCALL1(read, 2, char *);
-DEFN_SYSCALL1(writec, 3, char *);
+DEFN_SYSCALL1(writec, 3, char);
-DEFN_SYSCALL1(readc, 4, char *);
+DEFN_SYSCALL0(readc, 4);
DEFN_SYSCALL0(get_pointers, 5);
diff --git a/src/userspace/syscall.h b/src/userspace/syscall.h
index c46bb54..8dd647f 100644
--- a/src/userspace/syscall.h
+++ b/src/userspace/syscall.h
@@ -70,9 +70,9 @@ DECL_SYSCALL1(write, char *);
DECL_SYSCALL1(read, char *);
-DECL_SYSCALL1(writec, char *);
+DECL_SYSCALL1(writec, char);
-DECL_SYSCALL1(readc, char *);
+DECL_SYSCALL0(readc);
DECL_SYSCALL0(get_pointers);