summaryrefslogtreecommitdiffstats
path: root/arch/x86_64/hal/obj.h
blob: deea2bee66209cdbd47972de9ff64b930778504d (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
36
37
38
39
#ifndef _JOVE_ARCH_HAL_OBJ_H
#define _JOVE_ARCH_HAL_OBJ_H 1

#include <stdatomic.h>
#include <stdint.h>
#include <stddef.h>

enum
{
    JOVE_OBJ_SERIAL_COM = 0x80,
    JOVE_OBJ_IOPB
};

/*Represents a locked kernel object pointer inside of a object directory.*/
typedef union jove_obj
{
    struct {
        uint8_t type;
        atomic_flag lock;
        /*Raw value or pointer to a data-structure located in kernel memory.*/
        uint64_t value : 48;
    };
    uintmax_t data;
} jove_obj_t;

/*Represents an unlocked kernel object pointer.
 *This object should only exist temporarily while accessing the underlying
 *structure this object points to.*/
typedef struct jove_locked_obj
{
    jove_obj_t locked;
} 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.*/
#define JOVE_OBJDIR_SIZE 0x1000
#define JOVE_OBJDIR_ENTRIES (JOVE_OBJDIR_SIZE / sizeof(jove_obj_t))

#endif