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 
22 {
23  DEBUG("");
24 
25  // Register generic API handlers
26  m_apis.fill(ZERO);
33 }
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 }
Vector::get
virtual const T * get(Size position) const
Returns the item at the given position.
Definition: Vector.h:139
API::Handler
Result Handler(ulong, ulong, ulong, ulong, ulong)
Function which handles an kernel API (system call) request.
Definition: API.h:86
VMCopyHandler
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
Result
Enumeration of generic kernel API result codes.
Definition: API.h:68
API::Receive
@ Receive
Definition: API.h:96
API::invoke
Result invoke(Number number, ulong arg1, ulong arg2, ulong arg3, ulong arg4, ulong arg5)
Execute a generic API function.
Definition: API.cpp:35
ulong
unsigned long ulong
Unsigned long number.
Definition: Types.h:47
API::Operation
Operation
Various actions which may be performed inside an APIHandler.
Definition: API.h:91
API::InvalidArgument
@ InvalidArgument
Definition: API.h:74
API::m_apis
Vector< Handler * > m_apis
API handlers.
Definition: API.h:124
VMShareHandler
API::Result VMShareHandler(const ProcessID procID, const API::Operation op, ProcessShares::MemoryShare *share)
Kernel handler prototype.
Definition: VMShare.cpp:25
API::Write
@ Write
Definition: API.h:99
ProcessCtlHandler
API::Result ProcessCtlHandler(const ProcessID procID, const ProcessOperation action, const Address addr, const Address output)
Kernel handler prototype.
Definition: ProcessCtl.cpp:27
API::VMCtlNumber
@ VMCtlNumber
Definition: API.h:55
API::API
API()
Constructor.
Definition: API.cpp:21
Sequence::fill
virtual void fill(T value)
Fill the Sequence with the given value.
Definition: Sequence.h:73
Log.h
Log
Logging class.
Definition: Log.h:96
API::Read
@ Read
Definition: API.h:98
API::PrivExecNumber
@ PrivExecNumber
Definition: API.h:51
Log::append
void append(const char *str)
Append to buffered output.
Definition: Log.cpp:53
DEBUG
#define DEBUG(msg)
Output a debug message to standard output.
Definition: Log.h:89
API::Send
@ Send
Definition: API.h:95
operator<<
Log & operator<<(Log &log, API::Operation op)
Operator to print a Operation to a Log.
Definition: API.cpp:50
Vector::insert
virtual int insert(const T &item)
Adds the given item to the Vector, if possible.
Definition: Vector.h:93
API::ProcessCtlNumber
@ ProcessCtlNumber
Definition: API.h:52
API::VMShareNumber
@ VMShareNumber
Definition: API.h:56
VMCtlHandler
API::Result VMCtlHandler(const ProcessID procID, const MemoryOperation op, Memory::Range *range)
Kernel handler prototype.
Definition: VMCtl.cpp:24
API::Delete
@ Delete
Definition: API.h:94
PrivExecHandler
API::Result PrivExecHandler(const PrivOperation op, const Address param)
Prototype for kernel handler.
Definition: PrivExec.cpp:23
API::SystemInfoNumber
@ SystemInfoNumber
Definition: API.h:53
ZERO
#define ZERO
Zero value.
Definition: Macros.h:43
API::Create
@ Create
Definition: API.h:93
API::ReadPhys
@ ReadPhys
Definition: API.h:100
SystemInfoHandler
API::Result SystemInfoHandler(SystemInformation *info)
Kernel prototype.
Definition: SystemInfo.cpp:24
API::SendReceive
@ SendReceive
Definition: API.h:97
API::VMCopyNumber
@ VMCopyNumber
Definition: API.h:54
Number
Definition: Types.h:163