FreeNOS
PrivExec.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2009 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 <FreeNOS/ProcessManager.h>
20#include <Log.h>
21#include "PrivExec.h"
22
24 const Address param)
25{
26 DEBUG("");
27
28 switch (op)
29 {
30 case Idle: {
32 procs->setIdle(procs->current());
33 return API::Success;
34 }
35
36 case RebootSystem:
37 cpu_reboot();
38 while (true) ;
39
40 case ShutdownSystem:
42 return API::Success;
43
44 case WriteConsole:
46 (*Log::instance()) << (char *) param;
47 return API::Success;
48
49 case Panic:
50 FATAL("panic in PID " << Kernel::instance()->getProcessManager()->current()->getID());
51 return API::Success;
52
53 default:
54 ;
55 }
57}
Result
Enumeration of generic kernel API result codes.
Definition API.h:69
@ Success
Definition API.h:70
@ InvalidArgument
Definition API.h:74
ProcessManager * getProcessManager()
Get process manager.
Definition Kernel.cpp:143
Represents a process which may run on the host.
void setIdle(Process *proc)
Set the idle process.
Process * current()
Current process running.
static Kernel * instance()
Retrieve the instance.
Definition Singleton.h:86
API::Result PrivExecHandler(const PrivOperation op, const Address param)
Prototype for kernel handler.
Definition PrivExec.cpp:23
PrivOperation
Available operations to perform using PrivExec().
Definition PrivExec.h:35
@ WriteConsole
Definition PrivExec.h:39
@ RebootSystem
Definition PrivExec.h:37
@ Panic
Definition PrivExec.h:40
@ ShutdownSystem
Definition PrivExec.h:38
@ Idle
Definition PrivExec.h:36
#define cpu_reboot()
Reboot the system.
Definition ARMCore.h:102
#define cpu_shutdown()
Shutdown the machine via ACPI.
Definition ARMCore.h:110
#define assert(exp)
Insert program diagnostics.
Definition assert.h:60
unsigned long Address
A memory address.
Definition Types.h:131
#define FATAL(msg)
Output a critical message and terminate program immediatly.
Definition Log.h:50
#define ZERO
Zero value.
Definition Macros.h:43
#define DEBUG(msg)
Output a debug message to standard output.
Definition Log.h:89
void param(Terminal *term, int key, int value)
Set terminal parameters.
Definition Terminal.cpp:305