forked from nieklinnenbank/FreeNOS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAPI.h
138 lines (120 loc) · 3.01 KB
/
API.h
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/*
* Copyright (C) 2015 Niek Linnenbank
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __KERNEL_API_H
#define __KERNEL_API_H
#ifndef __SYSTEM
#error Do not include FreeNOS/API.h directly, use FreeNOS/System.h instead
#endif
#include <Log.h>
#include <Types.h>
#include <Vector.h>
/**
* @defgroup kernel kernel (generic)
* @{
*/
/**
* Generic Kernel API implementation.
*/
class API
{
public:
/**
* Enumeration of supported generic kernel API functions.
*
* Architectures or System implementations can optionally
* introduce additional specific APIs.
*/
typedef enum Number
{
PrivExecNumber = 1,
ProcessCtlNumber,
SystemInfoNumber,
VMCopyNumber,
VMCtlNumber,
VMShareNumber,
IOCtlNumber
}
Number;
/**
* Enumeration of generic kernel API error codes.
*/
typedef enum Error
{
Success = 0,
AccessViolation = -1,
RangeError = -2,
NotFound = -3,
InvalidArgument = -4,
OutOfMemory = -5,
IOError = -6,
AlreadyExists = -7
}
Error;
/**
* Function which handles an kernel API (system call) request.
* @return Status code of the APIHandler execution.
*/
typedef ::Error Handler(ulong, ulong, ulong, ulong, ulong);
/**
* Various actions which may be performed inside an APIHandler.
*/
typedef enum Operation
{
Create = 0,
Delete = 1,
Send = 2,
Receive = 3,
SendReceive = 4,
Read = 5,
Write = 6,
ReadPhys = 7
}
Operation;
/**
* Constructor
*/
API();
/**
* Execute a generic API function.
*/
::Error invoke(Number number,
ulong arg1,
ulong arg2,
ulong arg3,
ulong arg4,
ulong arg5);
private:
/** API handlers */
Vector<Handler *> m_apis;
};
/** Operator to print a Operation to a Log */
Log & operator << (Log &log, API::Operation op);
/*
* Include generic kernel API functions.
*/
#include "API/PrivExec.h"
#include "API/ProcessCtl.h"
#include "API/SystemInfo.h"
#include "API/VMCopy.h"
#include "API/VMCtl.h"
#include "API/VMShare.h"
#include "API/IOCtl.h"
#include "API/ProcessID.h"
/**
* @}
*/
#endif /* __KERNEL_API_H */