c18a763f914914c1ace528fa0e2aad347564598b
[monolithium.git] / kernel / include / syscalls.h
1 /*
2  * syscalls.h
3  *
4  * Copyright (C) 2013 Aleksandar Andrejevic <theflash@sdf.lonestar.org>
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Affero General Public License as
8  * published by the Free Software Foundation, either version 3 of the
9  * License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU Affero General Public License for more details.
15  *
16  * You should have received a copy of the GNU Affero General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19
20 #ifndef _SYSCALLS_H_
21 #define _SYSCALLS_H_
22
23 #include <common.h>
24
25 #define MAX_PARAMETERS 16
26 #define SYSCALL_INTERRUPT 0xE5
27
28 typedef enum
29 {
30     SYSCALL_ALLOC_MEMORY,
31     SYSCALL_CLOCK_GET_TIME,
32     SYSCALL_CLOCK_SET_TIME,
33     SYSCALL_CLOSE_OBJECT,
34     SYSCALL_COMMIT_MEMORY,
35     SYSCALL_CREATE_MEMORY_SECTION,
36     SYSCALL_CREATE_PROCESS,
37     SYSCALL_CREATE_SEMAPHORE,
38     SYSCALL_CREATE_THREAD,
39     SYSCALL_CREATE_USER,
40     SYSCALL_DELETE_FILE,
41     SYSCALL_DELETE_USER,
42     SYSCALL_DEVICE_IOCTL,
43     SYSCALL_DUPLICATE_HANDLE,
44     SYSCALL_ENUM_PROCESSES,
45     SYSCALL_FLUSH_MEMORY_SECTION,
46     SYSCALL_FREE_MEMORY,
47     SYSCALL_GET_EXCEPTION_INFO,
48     SYSCALL_GET_MILLISECONDS,
49     SYSCALL_GET_NANOSECONDS,
50     SYSCALL_GET_PROCESS_ID,
51     SYSCALL_GET_THREAD_ID,
52     SYSCALL_GET_USER_ID,
53     SYSCALL_LIST_DIRECTORY,
54     SYSCALL_LOGON_USER,
55     SYSCALL_MAP_MEMORY_SECTION,
56     SYSCALL_MOUNT,
57     SYSCALL_OPEN_FILE,
58     SYSCALL_OPEN_MEMORY_SECTION,
59     SYSCALL_OPEN_PIPE,
60     SYSCALL_OPEN_PROCESS,
61     SYSCALL_OPEN_THREAD,
62     SYSCALL_POWER_CONTROL,
63     SYSCALL_QUERY_FILE,
64     SYSCALL_QUERY_HANDLE,
65     SYSCALL_QUERY_PROCESS,
66     SYSCALL_QUERY_THREAD,
67     SYSCALL_QUERY_USER,
68     SYSCALL_RAISE_EXCEPTION,
69     SYSCALL_READ_FILE,
70     SYSCALL_READ_MEMORY,
71     SYSCALL_READ_PIPE,
72     SYSCALL_RELEASE_SEMAPHORE,
73     SYSCALL_RESTORE_EXCEPTION_HANDLER,
74     SYSCALL_REVERT_USER,
75     SYSCALL_SAVE_EXCEPTION_HANDLER,
76     SYSCALL_SET_MEMORY_FLAGS,
77     SYSCALL_SET_USER_ID,
78     SYSCALL_SLEEP,
79     SYSCALL_TERMINATE,
80     SYSCALL_TERMINATE_THREAD,
81     SYSCALL_UNCOMMIT_MEMORY,
82     SYSCALL_UNMOUNT,
83     SYSCALL_WAIT_DIRECTORY_EVENT,
84     SYSCALL_WAIT_PROCESS,
85     SYSCALL_WAIT_SEMAPHORE,
86     SYSCALL_WAIT_THREAD,
87     SYSCALL_WRITE_FILE,
88     SYSCALL_WRITE_MEMORY,
89     SYSCALL_WRITE_PIPE,
90     SYSCALL_YIELD_QUANTUM,
91
92     SERVICE_COUNT
93 } syscall_number_t;
94
95 typedef enum
96 {
97     KERNEL_MODE = 0,
98     USER_MODE = 1
99 } processor_mode_t;
100
101 char *copy_user_string(const char *string);
102 processor_mode_t get_previous_mode();
103 bool_t check_usermode(const void *pointer, dword_t size);
104 qword_t syscall(dword_t num, ...);
105 void syscalls_init();
106
107 #endif