summaryrefslogtreecommitdiffstats
path: root/hal/obj.h
blob: 180b830687fdc164c11a3abf56a5de8884882af4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <stdbool.h>
#ifndef _JOVE_HAL_OBJ_H
#define _JOVE_HAL_OBJ_H 1

#include <stddef.h>

#include "api/obj.h"

#ifdef __x86_64__
#include "arch/x86_64/hal/obj.h"
#endif

/*Locks the mutex of the kernel object provided. Returns the locked version. */
jove_owned_obj_t *obj_take(jove_obj_t *obj);
jove_owned_obj_t *obj_trytake(jove_obj_t *obj);
jove_obj_t *obj_asunowned(jove_owned_obj_t *obj);
/*Unlocks the mutex of the kernel object provided. Returns the unlocked version. */
jove_obj_t *obj_release(jove_owned_obj_t *obj);

/*Converts the value pointer of the object into a pointer to kernel memory.*/
void *obj_deref(jove_owned_obj_t *obj);

/*Getters and setters for accessing the type field of the kernel object. */
uint8_t obj_gettype(jove_owned_obj_t *obj);
uint8_t obj_peektype(jove_obj_t obj);
void obj_settype(jove_owned_obj_t *obj, uint8_t type);

/*Getters and setters for accessing the value field of the kernel object. */
uintmax_t obj_getvalue(jove_owned_obj_t *obj);
void obj_setvalue(jove_owned_obj_t *obj, uintmax_t value);

bool obj_compare(jove_obj_t *a, jove_obj_t *b);


#endif