summaryrefslogtreecommitdiffstats
path: root/arch/x86_64/sys/syscall_serial.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86_64/sys/syscall_serial.c')
-rw-r--r--arch/x86_64/sys/syscall_serial.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/arch/x86_64/sys/syscall_serial.c b/arch/x86_64/sys/syscall_serial.c
new file mode 100644
index 0000000..786a78b
--- /dev/null
+++ b/arch/x86_64/sys/syscall_serial.c
@@ -0,0 +1,33 @@
+#include "jove.h"
+#include "lib/printf.h"
+#include "sys/syscall.h"
+#include "syscall.h"
+#include "arch/x86_64/hal/serial_com.h"
+
+static int
+s_syscall_serial_write(
+ jove_owned_obj_t *serial_com,
+ size_t payload_bytes,
+ void *payload_data)
+{
+ size_t bytes_needed = sizeof(struct syscall_generic_write);
+ CHECK_TOOSMALL(bytes_needed, payload_bytes, "Message is too small for this syscall!");
+
+ struct syscall_generic_write *payload = payload_data;
+ bytes_needed += payload->len * 2;
+ CHECK_TOOSMALL(bytes_needed, payload_bytes, "Message is too small for write buffer!");
+
+ return serial_com_write(serial_com, payload->data, payload->len);
+}
+
+int
+_syscall_handle_serial(syscall_context_t *ctx)
+{
+ switch(ctx->header->callid) {
+ case SYSCALL_SERIAL_COM_WRITE:
+ return s_syscall_serial_write(ctx->target.obj, ctx->bytes_left, ctx->payload);
+ default:
+ kprintf("syscall_serial: serial com object does not support syscall %i\n", ctx->header->callid);
+ return -EBADCALL;
+ }
+}