root/Whitix/trunk/include/sys.h

Revision 2057, 1.9 KB (checked in by mwhitworth, 3 years ago)

Add SYS_SAVE_BASE, fix condition in SysGetCall.

Line 
1/*  This file is part of Whitix.
2 *
3 *  Whitix is free software; you can redistribute it and/or modify
4 *  it under the terms of the GNU General Public License as published by
5 *  the Free Software Foundation; either version 2 of the License, or
6 *  (at your option) any later version.
7 *
8 *  Whitix is distributed in the hope that it will be useful,
9 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 *  GNU General Public License for more details.
12 *
13 *  You should have received a copy of the GNU General Public License
14 *  along with Whitix; if not, write to the Free Software
15 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
16 *
17 */
18
19#ifndef SYS_H
20#define SYS_H
21
22#include <typedefs.h>
23#include <types.h>
24
25struct SysCall
26{
27        DWORD addr;
28        DWORD numBytes;
29};
30
31/* System call offsets. */
32
33#define SYS_FS_BASE                             0
34#define SYS_MMAP_BASE                   25
35#define SYS_SHMEM_BASE                  29
36#define SYS_THREAD_BASE                 33
37#define SYS_LOAD_BASE                   38
38#define SYS_PROCESS_BASE                39
39
40#define SYS_SCHED_BASE                  42
41#define SYS_TIME_BASE                   43
42#define NET_SYS_BASE                    44
43#define SYS_MODULE_BASE                 53
44#define SYS_CONFIG_BASE                 55
45#define SYS_SHUTDOWN_BASE               57
46#define SYS_IO_BASE                             58
47
48#define SYS_TLS_BASE                    59
49#define SYS_SAVE_BASE                   60
50#define SYSCALL_MAX             61
51
52#define SysEntry(addr, bytes) { (DWORD)addr, bytes }
53#define SysEntryEnd() SysEntry(0, 0)
54
55void SysRegisterCall(int index, struct SysCall* call);
56void SysRegisterRange(int index, struct SysCall* calls);
57
58extern struct SysCall sysCallTable[SYSCALL_MAX];
59
60__attribute__((fastcall))
61static inline addr_t SysGetCall(DWORD index, DWORD argBytes)
62{
63        if (index >= SYSCALL_MAX)
64                return 0;
65
66        /* The number of argument bytes past can be greater than the number of bytes
67         * needed by the function's parameters; it allows for future compatability.
68         */
69         
70        if (sysCallTable[index].numBytes < argBytes)
71                return 0;
72
73        return sysCallTable[index].addr;
74}
75
76#endif
Note: See TracBrowser for help on using the browser.