blob: 27e1c60a22d16a68a13a43c3f6e77d3e0a5853aa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#include <kernel/syscall.h>
#include <kernel/panic.h>
#include <kernel/framebuffer.h>
#include <kernel/keyboard.h>
#include <kernel/string.h>
#include <kernel/io.h>
#include <stddef.h>
extern char *keyboard_buffer;
extern uint32_t kbuf_pos;
void sys_read(struct regs *regs) {
if (regs->ebx == 1) {
while (kbuf_pos > regs->edx);
memcpy((char*)regs->ecx, keyboard_buffer, regs->edx);
}
}
void sys_write(struct regs *regs) {
if (regs->ebx == 0)
fb_write((char*)regs->ecx, regs->edx);
}
int handle_syscall(struct regs *regs) {
switch (regs->eax) {
case SYS_READ:
sys_read(regs);
break;
case SYS_WRITE:
sys_write(regs);
break;
default:
panic("Invalid system call number");
}
return 0;
}
|