summaryrefslogtreecommitdiffstats
path: root/api/syscall.h
blob: 1cdc9419245232ea0325842f45350f4a260722ae (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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#ifndef _JOVE_API_SYSCALL_H
#define _JOVE_API_SYSCALL_H 1

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

#include "obj.h"

/* General syscall behavior:
 * If the message passed is not a JOVE_OBJ_MESSAGE type, the kernel will return EBADOBJ.
 * If the message is too small to hold the target path, the kernel will return ETOOSMALL.
 * If the target path does not target a real object, the kernel will return EBADPATH.
 * If the target does not support the callid, the kernel will return EBADARG.
 * Otherwise, behavior depends on the syscall specified in callid.
 * */

struct syscall_header
{
    uint16_t callid;
    uint16_t pathlen;
    objpath_part_t path[];
};

/* If the message is too small for data, the kernel will return ETOOSMALL.
 * */
struct syscall_generic_write
{
    size_t len;
    char data[];
};

/* If the message is too small for path, the kernel will return ETOOSMALL.
 * If the path does not point to an object, the kernel will return EBADPATH.
 * */
struct syscall_generic_objpath
{
    uint16_t pathlen;
    objpath_part_t path[];
};

enum
{
    _SYSCALL_UNTYPED_BADCALL = 0,
    SYSCALL_UNTYPED_ADDRESS,
    SYSCALL_UNTYPED_SIZE,
    SYSCALL_UNTYPED_SPLIT,
    SYSCALL_UNTYPED_MERGE,
    SYSCALL_UNTYPED_RETYPE,
};

#define SYSCALL_PERM_UNTYPED_ADDRESS JOVE_PERM_READ
#define SYSCALL_PERM_UNTYPED_SIZE JOVE_PERM_READ
#define SYSCALL_PERM_UNTYPED_SPLIT (JOVE_PERM_WRITE | JOVE_PERM_MUTATE)
#define SYSCALL_PERM_UNTYPED_MERGE (JOVE_PERM_WRITE | JOVE_PERM_MUTATE)

struct syscall_untyped_split
{
    size_t bytes;
    uint16_t dest_pathlen;
    objpath_part_t dest_path[];
};

enum
{
    _SYSCALL_OBJDIR_BADCALL = 0,
    SYSCALL_OBJDIR_OBJTYPE,
};

#define SYSCALL_PERM_OBJDIR_OBJTYPE JOVE_PERM_READ

enum
{
    _SYSCALL_PAGEDIR_NONE = 0,
    SYSCALL_PAGEDIR_MAP_FRAME,
    SYSCALL_PAGEDIR_MAP_TABLE,
    SYSCALL_PAGEDIR_MAP_SHMEM,
    SYSCALL_PAGEDIR_UNMAP_FRAME,
    SYSCALL_PAGEDIR_UNMAP_TABLE,
    SYSCALL_PAGEDIR_UNMAP_SHMEM,
};

#define SYSCALL_PERM_PAGEDIR_MAP_FRAME (JOVE_PERM_READ | JOVE_PERM_WRITE)
#define SYSCALL_PERM_PAGEDIR_MAP_TABLE (JOVE_PERM_READ | JOVE_PERM_WRITE)
#define SYSCALL_PERM_PAGEDIR_MAP_SHMEM (JOVE_PERM_READ | JOVE_PERM_WRITE)
#define SYSCALL_PERM_PAGEDIR_UNMAP_FRAME (JOVE_PERM_READ | JOVE_PERM_WRITE)
#define SYSCALL_PERM_PAGEDIR_UNMAP_TABLE (JOVE_PERM_READ | JOVE_PERM_WRITE)
#define SYSCALL_PERM_PAGEDIR_UNMAP_SHMEM (JOVE_PERM_READ | JOVE_PERM_WRITE)

struct syscall_pagedir_flags
{
    uint8_t writeable : 1;
    uint8_t executable : 1;
    uint8_t flg_unused : 6;
};

struct syscall_pagedir_map
{
    struct syscall_pagedir_flags page_flags;
    uint16_t untyped_pathlen;
    uintptr_t virtual_address;
    objpath_part_t untyped_path[];
};

struct syscall_pagedir_map_shmem
{
    struct syscall_pagedir_flags page_flags;
    uint8_t page_offset;
    uint16_t shmem_pathlen;
    uintptr_t virtual_address;
    objpath_part_t shmem_path[];
};

struct syscall_pagedir_unmap
{
    uintptr_t virtual_address;
    uint16_t none_pathlen;
    objpath_part_t none_path[];
};

enum
{
    _SYSCALL_VTT_NONE = 0,
    SYSCALL_VTT_WRITE
};

#endif