summaryrefslogtreecommitdiffstats
path: root/lib/libjove/syscall/invoke-objdir.c
blob: 6558d6d610709ce8c6c5624515c81969bf21d8df (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
#include <jove.h>
#include <object.h>
#include <path-fromobj.h>
#include <syscall.h>
#include <kernel/syscall.h>

int
_syscall_invoke_objdir_getmemb(KernelObjectDirectory *dir, uint8_t member, obj_type_t *result)
{
    uint8_t *syscallData = __jove_syscall_ptr;
    int syscall_at = 0;
    obj_type_t *syscall_result;

    SYSCALL_PAYLOAD_PUTOBJ(syscallData, syscall_at, dir);
    SYSCALL_PAYLOAD_PUTL(syscallData, syscall_at, INVOKE_OBJDIR_GETMEMB, uint8_t);
    SYSCALL_PAYLOAD_PUTL(syscallData, syscall_at, member, uint8_t);
    SYSCALL_PAYLOAD_SAVEPTR(syscallData, syscall_at, obj_type_t, syscall_result);

    int status = _syscall_invoke();
    *result = *syscall_result;
    return status;
}

int
_syscall_invoke_objdir_lastmemb(KernelObjectDirectory *dir, uint8_t *result)
{
    uint8_t *syscallData = __jove_syscall_ptr;
    int syscall_at = 0;
    uint8_t *syscall_result;

    SYSCALL_PAYLOAD_PUTOBJ(syscallData, syscall_at, dir);
    SYSCALL_PAYLOAD_PUTL(syscallData, syscall_at, INVOKE_OBJDIR_LASTMEMB, uint8_t);
    SYSCALL_PAYLOAD_SAVEPTR(syscallData, syscall_at, uint8_t, syscall_result);

    int status = _syscall_invoke();
    *result = *syscall_result;
    return status;
}

int
_syscall_invoke_objdir_move(
        KernelObjectDirectory *dir, 
        uint8_t memb,
        KernelObjectDirectory *dest_dir,
        uint8_t dest_memb)
{
    uint8_t *syscallData = __jove_syscall_ptr;
    int syscall_at = 0;

    SYSCALL_PAYLOAD_PUTOBJ(syscallData, syscall_at, dir);
    SYSCALL_PAYLOAD_PUTL(syscallData, syscall_at, INVOKE_OBJDIR_MOVE, uint8_t);
    SYSCALL_PAYLOAD_PUTL(syscallData, syscall_at, memb, uint8_t);

    size_t *dest_pathw = (size_t*)(syscallData + syscall_at);
    SYSCALL_PAYLOAD_PUTOBJ(syscallData, syscall_at, dest_dir);
    (*dest_pathw)++;
    SYSCALL_PAYLOAD_PUTL(syscallData, syscall_at, dest_memb, uint8_t);

    return _syscall_invoke();
}