summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Santmyer <jon@jonsantmyer.com>2026-09-06 16:50:28 -0400
committerJon Santmyer <jon@jonsantmyer.com>2026-09-06 16:50:28 -0400
commit4ca0bdf61196d0c3fd3f0fdbfb2d72481025cca2 (patch)
tree6b4a16ec7300ef0dfb2e45224fb199b67028684f
parent779b7fc1fe91e5a355b6e15de882d46b26ab2270 (diff)
downloadjove-kernel-4ca0bdf61196d0c3fd3f0fdbfb2d72481025cca2.tar.gz
jove-kernel-4ca0bdf61196d0c3fd3f0fdbfb2d72481025cca2.tar.bz2
jove-kernel-4ca0bdf61196d0c3fd3f0fdbfb2d72481025cca2.zip
add syscall for vtt_write
-rw-r--r--arch/x86_64/sys/syscall.c2
-rw-r--r--arch/x86_64/sys/syscall.h10
-rw-r--r--sys/syscall.c12
-rw-r--r--sys/syscall.h45
-rw-r--r--sys/syscall_vtt.c42
5 files changed, 69 insertions, 42 deletions
diff --git a/arch/x86_64/sys/syscall.c b/arch/x86_64/sys/syscall.c
index b2d3e7f..53351e7 100644
--- a/arch/x86_64/sys/syscall.c
+++ b/arch/x86_64/sys/syscall.c
@@ -10,7 +10,7 @@ syscall_handle_t s_arch_handles[128] = {
};
int
-syscall_handle_arch(
+_syscall_handle_arch(
jove_owned_obj_t *pcb_obj,
jove_owned_obj_t *objdir,
jove_owned_obj_t *message_obj,
diff --git a/arch/x86_64/sys/syscall.h b/arch/x86_64/sys/syscall.h
index 1368897..9138101 100644
--- a/arch/x86_64/sys/syscall.h
+++ b/arch/x86_64/sys/syscall.h
@@ -3,20 +3,12 @@
#include "sys/syscall.h"
-int
-_syscall_handle_serial(
- jove_owned_obj_t *pcb_obj,
- jove_owned_obj_t *objdir,
- jove_owned_obj_t *message_obj,
- jove_owned_obj_t *target_obj,
- struct syscall_header *header,
- size_t bytes_left,
- void *payload);
struct syscall_serial_write
{
size_t len;
char data[];
};
+int _syscall_handle_serial(SYSCALL_FUNCTION_ARGS);
#define SYSCALL_SERIAL_COM_WRITE 0
diff --git a/sys/syscall.c b/sys/syscall.c
index 1eadf50..6c3fa33 100644
--- a/sys/syscall.c
+++ b/sys/syscall.c
@@ -31,7 +31,7 @@ static const syscall_handle_t s_syscall_handles[128] = {
[JOVE_OBJ_PAGEFRAME] = _syscall_handle_generic,
[JOVE_OBJ_INITRD_FILE] = _syscall_handle_generic,
[JOVE_OBJ_FRAMEBUFFER] = _syscall_handle_generic,
- [JOVE_OBJ_VIRTTERM] = _syscall_handle_generic,
+ [JOVE_OBJ_VIRTTERM] = _syscall_handle_vtt,
[JOVE_OBJ_MESSAGE] = _syscall_handle_generic,
};
@@ -47,7 +47,6 @@ syscall_handler(uintmax_t message_path_raw, uint16_t message_pathlen)
pcb_t *pcb = obj_deref(pcb_obj);
jove_owned_obj_t *objdir = pcb_rootdir(pcb);
- kprintf("Syscall: %p : %P \n", objdir, message_path, message_pathlen);
jove_owned_obj_t *message_obj = objdir_getobj(objdir, message_path, message_pathlen);
if(message_obj == 0) {
@@ -73,7 +72,6 @@ syscall_handler(uintmax_t message_path_raw, uint16_t message_pathlen)
size_t header_bytes = sizeof(struct syscall_header) + header->pathlen * 2;
int bytes_left = messagelen - header_bytes;
- kprintf("syscall: Payload %p len %i\n", messagedata, header->pathlen);
if(bytes_left < 0) {
//Target path exceeds message length.
kprintf("syscall: Process %i tried to call syscall with OOB target path.\n", pcb_pid(pcb));
@@ -92,7 +90,8 @@ syscall_handler(uintmax_t message_path_raw, uint16_t message_pathlen)
uint8_t target_type = obj_gettype(target);
if(target_type > 0x7F) {
- sysret = syscall_handle_arch(pcb_obj, objdir, message_obj, target,
+ sysret = _syscall_handle_arch(
+ pcb_obj, objdir, message_obj, target,
header, bytes_left, messagedata + header_bytes);
}else{
syscall_handle_t call_handle = s_syscall_handles[obj_gettype(target)];
@@ -101,8 +100,9 @@ syscall_handler(uintmax_t message_path_raw, uint16_t message_pathlen)
pcb_pid(pcb), header->path, header->pathlen);
sysret = EBADOBJ;
}else
- sysret = call_handle(pcb_obj, objdir, message_obj, target,
- header, bytes_left, message_data + header_bytes);
+ sysret = call_handle(
+ pcb_obj, objdir, message_obj, target,
+ header, bytes_left, messagedata + header_bytes);
}
obj_release(target);
diff --git a/sys/syscall.h b/sys/syscall.h
index efd3f64..6ad221f 100644
--- a/sys/syscall.h
+++ b/sys/syscall.h
@@ -11,33 +11,26 @@ struct syscall_header
uint16_t path[];
};
-typedef int (*syscall_handle_t)(
- jove_owned_obj_t*, //PCB object
- jove_owned_obj_t*, //Objdir object
- jove_owned_obj_t*, //Message object
- jove_owned_obj_t*, //Target object
- struct syscall_header*, //Syscall header
- size_t, //How many bytes are left in the message
- void*); //The bytes left in the message.
+#define SYSCALL_FUNCTION_ARGS \
+ jove_owned_obj_t*, /*PCB object*/ \
+ jove_owned_obj_t*, /*Objdir object*/ \
+ jove_owned_obj_t*, /*Message object*/ \
+ jove_owned_obj_t*, /*Target object*/ \
+ struct syscall_header*, /*Syscall header*/ \
+ size_t, /*How many bytes are left in the message*/ \
+ void* /*The bytes left in the message.*/
-int
-_syscall_handle_generic(
- jove_owned_obj_t *pcb_obj,
- jove_owned_obj_t *objdir,
- jove_owned_obj_t *message_obj,
- jove_owned_obj_t *target_obj,
- struct syscall_header *header,
- size_t bytes_left,
- void *payload);
+typedef int (*syscall_handle_t)(SYSCALL_FUNCTION_ARGS);
-int
-syscall_handle_arch(
- jove_owned_obj_t *pcb_obj,
- jove_owned_obj_t *objdir,
- jove_owned_obj_t *message_obj,
- jove_owned_obj_t *target_obj,
- struct syscall_header *header,
- size_t bytes_left,
- void *payload);
+int _syscall_handle_generic(SYSCALL_FUNCTION_ARGS);
+int _syscall_handle_arch(SYSCALL_FUNCTION_ARGS);
+
+#define SYSCALL_VTT_WRITE 0
+struct syscall_vtt_write
+{
+ size_t len;
+ char data[];
+};
+int _syscall_handle_vtt(SYSCALL_FUNCTION_ARGS);
#endif
diff --git a/sys/syscall_vtt.c b/sys/syscall_vtt.c
new file mode 100644
index 0000000..4b58b2c
--- /dev/null
+++ b/sys/syscall_vtt.c
@@ -0,0 +1,42 @@
+#include "jove.h"
+#include "lib/printf.h"
+#include "lib/virtterm.h"
+#include "syscall.h"
+
+static int
+s_syscall_vtt_write(
+ jove_owned_obj_t *vtt,
+ size_t payload_bytes,
+ void *payload_data)
+{
+ if(payload_bytes < sizeof(struct syscall_vtt_write)) {
+ kprintf("syscall_vtt_write: message is too small for this syscall!\n");
+ return EOOB;
+ }
+ struct syscall_vtt_write *payload = payload_data;
+ if(payload_bytes < sizeof(struct syscall_vtt_write) + payload->len) {
+ kprintf("syscall_vtt_write: message is to small for payload! (%i vs %i)\n",
+ payload->len, payload_bytes);
+ return EOOB;
+ }
+ return vt_write(vtt, payload->data, payload->len);
+}
+
+int
+_syscall_handle_vtt(
+ jove_owned_obj_t *pcb_obj,
+ jove_owned_obj_t *objdir,
+ jove_owned_obj_t *message_obj,
+ jove_owned_obj_t *target_obj,
+ struct syscall_header *header,
+ size_t bytes_left,
+ void *payload_data)
+{
+ switch(header->callid) {
+ case 0:
+ return s_syscall_vtt_write(target_obj, bytes_left, payload_data);
+ default:
+ kprintf("syscall_vtt: vtt object does not support syscall %i\n", header->callid);
+ return EOOB;
+ }
+}