[USER] Temporary write syscall

This commit is contained in:
2016-12-11 19:50:01 +01:00
parent 1693baaf6b
commit 19df873615
7 changed files with 76 additions and 0 deletions

View File

@@ -2,11 +2,14 @@
#include <string.h>
#include <int.h>
#include <sync.h>
#include <stddef.h>
#ifndef NDEBUG
#define debug(...) ({spin_lock(&debug_lock);debug_printf(__VA_ARGS__);spin_unlock(&debug_lock);})
#define debugn(str, n) ({spin_lock(&debug_lock);debug_putsn((str), (n)); spin_unlock(&debug_lock);})
#else
#define debug(...) ((void)0)
#define debugn(...) ((void)0)
#endif
#define debug_info(...) do{debug("[INFO] ");debug(__VA_ARGS__);}while(0)
#define debug_ok(...) do{debug("[OK] ");debug(__VA_ARGS__);}while(0)

View File

@@ -39,3 +39,5 @@ typedef long (*syscall_handler_t)(long num, long, long, long, long, long, long);
#define SYSCALL_INIT(...) _SYSCALL_INIT(_SYSCALL_INIT,__VA_ARGS__)
#define SYSCALL_REGISTER(name, num) syscall_handlers[num] = syscall_##name
SYSCALL_DECL(write);

20
kernel/syscall/sys_fs.c Normal file
View File

@@ -0,0 +1,20 @@
#include <syscall.h>
#include <stdint.h>
#include <stddef.h>
#include <debug.h>
#include <mem.h>
#include <string.h>
SYSCALL_DEF(write)
{
SYSCALL_INIT(int, fd, void *, buffer, size_t, nbyte);
if(fd == 1)
{
debugn(buffer, nbyte);
return nbyte;
}
return 0;
}

View File

@@ -5,6 +5,7 @@
#include <gdt.h>
#include <registers.h>
#include "../../libc/syscall_num.h"
#include <string.h>
extern void syscall_entry();
@@ -34,6 +35,7 @@ registers_t *syscall_handler(registers_t *r)
}
debug_error("Unknown syscall, No:%d\n", r->rax);
debug("syscall_%d(%x, %x, %x, %x, %x, %x)\n", r->rax, r->rdi, r->rsi, r->rdx, r->r10, r->r8, r->r9);
for(;;);
}
@@ -54,6 +56,7 @@ void syscall_init()
memset(syscall_handlers, 0, 1024*sizeof(syscall_handler_t));
SYSCALL_REGISTER(debug, SYS_DEBUG);
SYSCALL_REGISTER(write, SYS_WRITE);
}
}