summaryrefslogtreecommitdiffstats
path: root/sys/syscall.h
diff options
context:
space:
mode:
Diffstat (limited to 'sys/syscall.h')
-rw-r--r--sys/syscall.h45
1 files changed, 29 insertions, 16 deletions
diff --git a/sys/syscall.h b/sys/syscall.h
index 9f56447..e6358cb 100644
--- a/sys/syscall.h
+++ b/sys/syscall.h
@@ -1,8 +1,11 @@
#ifndef _JOVE_SYS_SYSCALL_H
#define _JOVE_SYS_SYSCALL_H 1
+#include "config.h"
#include "api/syscall.h"
#include "hal/obj.h"
+#include "lockstack.h"
+#include "link.h"
#include <stdint.h>
#define CHECK_TOOSMALL(required, present, fail_msg) \
@@ -20,29 +23,39 @@ do { if(obj == NULL) { \
#define CHECK_OBJTYPE(obj, type, fail_msg) \
do { if(obj_gettype(obj) != type) { \
kprintf("%s: %s\n", __func__, fail_msg); \
- obj_release(obj); \
return -EBADOBJ; \
} } while(0)
-#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.*/
+#define CHECK_OBJPERM(obj, perms, fail_msg) \
+ do { if((obj.permissions & perms) == 0) { \
+ kprintf("%s: %s\n", __func__, fail_msg); \
+ return -EPERM; \
+ } } while(0)
-typedef int (*syscall_handle_t)(SYSCALL_FUNCTION_ARGS);
+typedef struct syscall_state
+{
+ lockstack_t lockstack;
+ jove_owned_obj_t *pcb;
+ jove_owned_obj_t *objdir;
+ jove_perm_obj_t message;
+ jove_perm_obj_t target;
+ struct syscall_header *header;
+ size_t bytes_left;
+ void *payload;
+} syscall_context_t;
+
+typedef int (*syscall_handle_t)(syscall_context_t*);
int __syscall_generic_objpath(jove_owned_obj_t *objdir, size_t bytes_left, void *payload_data, jove_owned_obj_t **retobj);
-int _syscall_handle_generic(SYSCALL_FUNCTION_ARGS);
-int _syscall_handle_arch(SYSCALL_FUNCTION_ARGS);
+int _syscall_handle_switch(syscall_context_t *ctx);
+
+int _syscall_handle_generic(syscall_context_t *ctx);
+int _syscall_handle_arch(syscall_context_t *ctx);
-int _syscall_handle_vtt(SYSCALL_FUNCTION_ARGS);
-int _syscall_handle_objdir(SYSCALL_FUNCTION_ARGS);
-int _syscall_handle_untyped(SYSCALL_FUNCTION_ARGS);
-int _syscall_handle_pagedir(SYSCALL_FUNCTION_ARGS);
+int _syscall_handle_vtt(syscall_context_t *ctx);
+int _syscall_handle_objdir(syscall_context_t *ctx);
+int _syscall_handle_untyped(syscall_context_t *ctx);
+int _syscall_handle_pagedir(syscall_context_t *ctx);
#endif