summaryrefslogtreecommitdiffstats
path: root/arch/x86_64/hal
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86_64/hal')
-rw-r--r--arch/x86_64/hal/idt.h2
-rw-r--r--arch/x86_64/hal/obj.c52
-rw-r--r--arch/x86_64/hal/obj.h4
-rw-r--r--arch/x86_64/hal/process.c2
-rw-r--r--arch/x86_64/hal/process.h2
5 files changed, 56 insertions, 6 deletions
diff --git a/arch/x86_64/hal/idt.h b/arch/x86_64/hal/idt.h
index 2aa759b..19c9e4c 100644
--- a/arch/x86_64/hal/idt.h
+++ b/arch/x86_64/hal/idt.h
@@ -66,7 +66,7 @@ struct int_stackframe
struct int_user_handle
{
uintmax_t pid;
- void *handle;
+ int (*handle)(struct int_stackframe*);
};
extern struct int_user_handle __int_user_handles[IDT_ENTRIES];
diff --git a/arch/x86_64/hal/obj.c b/arch/x86_64/hal/obj.c
index af0491a..cb0e13d 100644
--- a/arch/x86_64/hal/obj.c
+++ b/arch/x86_64/hal/obj.c
@@ -16,6 +16,18 @@ obj_take(jove_obj_t *obj)
return (jove_owned_obj_t*)obj;
}
+jove_owned_obj_t*
+obj_trytake(jove_obj_t *obj)
+{
+ if((uintptr_t)obj < IDENT_VIRT_BASE) {
+ reterr(EBADOBJ);
+ }
+ if(try_take_mutex(&obj->lock)) {
+ reterr(EBUSY);
+ }
+ return (jove_owned_obj_t*)obj;
+}
+
jove_obj_t*
obj_release(jove_owned_obj_t *obj)
{
@@ -97,16 +109,32 @@ objdir_getlocal(
}
jove_owned_obj_t*
+objdir_trygetlocal(
+ jove_owned_obj_t *objdir_obj,
+ uint16_t entry)
+{
+ if(obj_gettype_linked(objdir_obj) != JOVE_OBJ_OBJDIR) {
+ reterr(EBADOBJ);
+ }
+ if(entry >= JOVE_OBJDIR_ENTRIES) {
+ reterr(EBADPATH);
+ }
+
+ jove_objdir_t *objtab = obj_deref_linked(objdir_obj);
+ return obj_trytake(&objtab->entries[entry]);
+}
+
+jove_owned_obj_t*
objdir_getobj(
jove_owned_obj_t *objdir_obj,
const uint16_t *path,
size_t path_len)
{
+ errno = 0;
if(path_len == 0) {
return objdir_obj;
}
{
- errno = 0;
jove_owned_obj_t *child_objdir = objdir_getlocal(objdir_obj, path[0]);
if(child_objdir == 0) {
reterr(EBADPATH);
@@ -118,3 +146,25 @@ objdir_getobj(
}
}
+jove_owned_obj_t*
+objdir_trygetobj(
+ jove_owned_obj_t *objdir_obj,
+ const uint16_t *path,
+ size_t path_len)
+{
+ errno = 0;
+ if(path_len == 0) {
+ return objdir_obj;
+ }
+ {
+ jove_owned_obj_t *child_objdir = objdir_trygetlocal(objdir_obj, path[0]);
+ if(child_objdir == 0) {
+ return 0;
+ }
+
+ jove_owned_obj_t *target_obj = objdir_trygetobj(child_objdir, path + 1, path_len - 1);
+ obj_release(child_objdir);
+ return target_obj;
+ }
+}
+
diff --git a/arch/x86_64/hal/obj.h b/arch/x86_64/hal/obj.h
index deea2be..4364348 100644
--- a/arch/x86_64/hal/obj.h
+++ b/arch/x86_64/hal/obj.h
@@ -17,7 +17,7 @@ typedef union jove_obj
struct {
uint8_t type;
atomic_flag lock;
- /*Raw value or pointer to a data-structure located in kernel memory.*/
+ /*Raw value or pointer to a data-structure located in identity memory.*/
uint64_t value : 48;
};
uintmax_t data;
@@ -32,7 +32,7 @@ typedef struct jove_locked_obj
} jove_owned_obj_t;
/*Object directories are always 1 page wide. Since an object inside the directory
- * is a pointer width, on x86_64 that is 512 entries per directory.*/
+ * in this arch is a pointer width, that is 512 entries per directory.*/
#define JOVE_OBJDIR_SIZE 0x1000
#define JOVE_OBJDIR_ENTRIES (JOVE_OBJDIR_SIZE / sizeof(jove_obj_t))
diff --git a/arch/x86_64/hal/process.c b/arch/x86_64/hal/process.c
index 0155919..f30d703 100644
--- a/arch/x86_64/hal/process.c
+++ b/arch/x86_64/hal/process.c
@@ -37,7 +37,7 @@ pcb_pid(pcb_t *pcb)
jove_owned_obj_t*
pcb_rootdir(pcb_t *pcb)
{
- return pcb->rootdir;
+ return obj_take(pcb->rootdir);
}
void
diff --git a/arch/x86_64/hal/process.h b/arch/x86_64/hal/process.h
index c3530bf..f903153 100644
--- a/arch/x86_64/hal/process.h
+++ b/arch/x86_64/hal/process.h
@@ -7,7 +7,7 @@
typedef struct process_control_block
{
pid_t pid;
- jove_owned_obj_t *rootdir;
+ jove_obj_t *rootdir;
jove_owned_obj_t *iopb;
uintptr_t pml4;