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
/*
 * Copyright (C) 2018, The Pebble Developers.
 * See LICENCE.md
 */

#![no_std]

#[derive(Clone,Copy,Debug)]
#[cfg_attr(target_arch="x86_64", repr(packed))]
pub struct SyscallInfo
{
    /*
     * XXX: All fields except `syscall_number` are only defined for system calls that actually use
     *      them!
     */
    pub syscall_number  : usize,
    pub a               : usize,
    pub b               : usize,
    pub c               : usize,
    pub d               : usize,
    pub e               : usize,
}

#[repr(usize)]
pub enum SyscallResult
{
    Success,
    ErrUnknownSyscall,
}

pub enum SyscallType
{
    /*
     * Unknown(0)
     *      No params
     *      Will always error with ErrUnknownSyscall
     */
    Unknown,

     /*
     *  DebugMsg(1)
     *      A(VirtualAddress)   - pointer to the string slice
     *      B(usize)            - length of the string slice
     */
    DebugMsg,

    /*
     * Write(2)
     *      A(FileDescriptor)   - the file to write to
     *      B(VirtualAddress)   - pointer to the data
     *      C(usize)            - length of data
     */
    Write,
}

impl From<usize> for SyscallType
{
    fn from(number : usize) -> SyscallType
    {
        match number
        {
            0 => SyscallType::Unknown,
            1 => SyscallType::DebugMsg,
            2 => SyscallType::Write,

            _ => SyscallType::Unknown,
        }
    }
}