FreeNOS
API.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2015 Niek Linnenbank
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include <FreeNOS/System.h>
19#include <Log.h>
20
34
36 ulong arg1,
37 ulong arg2,
38 ulong arg3,
39 ulong arg4,
40 ulong arg5)
41{
42 Handler **handler = (Handler **) m_apis.get(number);
43
44 if (handler && *handler)
45 return (*handler)(arg1, arg2, arg3, arg4, arg5);
46 else
47 return InvalidArgument;
48}
49
51{
52 switch (op)
53 {
54 case API::Create: log.append("Create"); break;
55 case API::Delete: log.append("Delete"); break;
56 case API::Send: log.append("Send"); break;
57 case API::Receive: log.append("Receive"); break;
58 case API::SendReceive: log.append("SendReceive"); break;
59 case API::Read: log.append("Read"); break;
60 case API::ReadPhys: log.append("ReadPhys"); break;
61 case API::Write: log.append("Write"); break;
62 }
63 return log;
64}
Log & operator<<(Log &log, API::Operation op)
Operator to print a Operation to a Log.
Definition API.cpp:50
Result
Enumeration of generic kernel API result codes.
Definition API.h:69
@ InvalidArgument
Definition API.h:74
Operation
Various actions which may be performed inside an APIHandler.
Definition API.h:92
@ ReadPhys
Definition API.h:100
@ Send
Definition API.h:95
@ Read
Definition API.h:98
@ Write
Definition API.h:99
@ Create
Definition API.h:93
@ SendReceive
Definition API.h:97
@ Delete
Definition API.h:94
@ Receive
Definition API.h:96
Result invoke(Number number, ulong arg1, ulong arg2, ulong arg3, ulong arg4, ulong arg5)
Execute a generic API function.
Definition API.cpp:35
API()
Constructor.
Definition API.cpp:21
Result Handler(ulong, ulong, ulong, ulong, ulong)
Function which handles an kernel API (system call) request.
Definition API.h:86
Vector< Handler * > m_apis
API handlers.
Definition API.h:124
@ VMCtlNumber
Definition API.h:55
@ VMCopyNumber
Definition API.h:54
@ VMShareNumber
Definition API.h:56
@ PrivExecNumber
Definition API.h:51
@ SystemInfoNumber
Definition API.h:53
@ ProcessCtlNumber
Definition API.h:52
Logging class.
Definition Log.h:97
void append(const char *str)
Append to buffered output.
Definition Log.cpp:53
virtual void fill(T value)
Fill the Sequence with the given value.
Definition Sequence.h:73
virtual const T * get(Size position) const
Returns the item at the given position.
Definition Vector.h:139
virtual int insert(const T &item)
Adds the given item to the Vector, if possible.
Definition Vector.h:93
API::Result VMShareHandler(const ProcessID procID, const API::Operation op, ProcessShares::MemoryShare *share)
Kernel handler prototype.
Definition VMShare.cpp:25
API::Result SystemInfoHandler(SystemInformation *info)
Kernel prototype.
API::Result VMCopyHandler(const ProcessID procID, const API::Operation how, const Address ours, const Address theirs, const Size sz)
Kernel handler prototype.
Definition VMCopy.cpp:24
API::Result ProcessCtlHandler(const ProcessID procID, const ProcessOperation action, const Address addr, const Address output)
Kernel handler prototype.
API::Result VMCtlHandler(const ProcessID procID, const MemoryOperation op, Memory::Range *range)
Kernel handler prototype.
Definition VMCtl.cpp:24
API::Result PrivExecHandler(const PrivOperation op, const Address param)
Prototype for kernel handler.
Definition PrivExec.cpp:23
unsigned long ulong
Unsigned long number.
Definition Types.h:47
#define ZERO
Zero value.
Definition Macros.h:43
#define DEBUG(msg)
Output a debug message to standard output.
Definition Log.h:89