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

int
_syscall_invoke_untyped_size(KernelObjectUntyped *untyped, size_t *bytes)
{
    uint8_t *syscallData = __jove_syscall_ptr;
    int syscall_at = 0;
    size_t *syscall_bytes;

    SYSCALL_PAYLOAD_PUTOBJ(syscallData, syscall_at, untyped);
    SYSCALL_PAYLOAD_PUTL(syscallData, syscall_at, INVOKE_UNTYPED_SIZE, uint8_t);
    SYSCALL_PAYLOAD_SAVEPTR(syscallData, syscall_at, size_t, syscall_bytes);

    int status = _syscall_invoke();
    *bytes = *syscall_bytes;
    return status;
}

int
_syscall_invoke_untyped_split(KernelObjectUntyped *untyped, size_t bytes, KernelObjectUntyped *dest)
{
    uint8_t *syscallData = __jove_syscall_ptr;
    int syscall_at = 0;
    
    SYSCALL_PAYLOAD_PUTOBJ(syscallData, syscall_at, untyped);
    SYSCALL_PAYLOAD_PUTL(syscallData, syscall_at, INVOKE_UNTYPED_SPLIT, uint8_t);
    SYSCALL_PAYLOAD_PUTOBJ(syscallData, syscall_at, dest);
    SYSCALL_PAYLOAD_PUTL(syscallData, syscall_at, bytes, size_t);

    return _syscall_invoke();
}

int
_syscall_invoke_untyped_alignment(KernelObjectUntyped *untyped, size_t *alignment)
{
    uint8_t *syscallData = __jove_syscall_ptr;
    int syscall_at = 0;
    size_t *syscall_alignment;

    SYSCALL_PAYLOAD_PUTOBJ(syscallData, syscall_at, untyped);
    SYSCALL_PAYLOAD_PUTL(syscallData, syscall_at, INVOKE_UNTYPED_ALIGNMENT, uint8_t);
    SYSCALL_PAYLOAD_SAVEPTR(syscallData, syscall_at, size_t, syscall_alignment);

    int status = _syscall_invoke();
    *alignment = *syscall_alignment;
    return status;
}