summaryrefslogtreecommitdiffstats
path: root/include/object.h
blob: 0a71b5f11fb1c7326bbe7ef0955384f3852739f0 (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef _JOVE_OBJECT_H
#define _JOVE_OBJECT_H 

#include <stdint.h>

#if defined(__x86_64__)
#include "arch/x86_64/object.h"
#endif

enum
{
    /* Generic objects */
    KO_NONE = 0,
    KO_OBJECT_DIRECTORY,
    KO_INIT_DATA,
    KO_MEMORY_UNTYPED,
    KO_MEMORY_MAPPED_PAGE, //4KiB Fixed Width
    KO_MEMORY_MAPPING_PAGE, //4Kib Fixed Width
    KO_INITRD_FILE,
    KO_TCB,
    KO_KERNEL_STACK,
    KO_MESSAGE,
    /* Device objects*/
    KO_DEV_INVALID = 0x100,
    KO_DEV_PROCESSOR,
    KO_DEV_UART
};

typedef uintmax_t obj_path_t;
typedef uint16_t obj_type_t;

typedef struct jove_ObjectDirectoryEntry
{
    obj_type_t type;
    union {
        struct {
            char lock : 1;
            char u0 : 7;
            char u1;
};
        unsigned short flg;
    };
    uintmax_t data;
} objdir_entry_t;

#define OBJECT_DIRECTORY_MAX_ENTRIES 256

//The first entry always represents itself, which allows the kernel to ignore
//some checks.
//The data variable also contains the next free index for this directory.
typedef struct jove_ObjectDirectory
{
    union {
        objdir_entry_t self;
        objdir_entry_t entries[OBJECT_DIRECTORY_MAX_ENTRIES];
    };
} objdir_t;

objdir_entry_t *objdir_seek(objdir_t *dir, uintmax_t index);

#endif