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:
41  cpu_shutdown();
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  }
56  return API::InvalidArgument;
57 }
PrivExec.h
ProcessManager
Represents a process which may run on the host.
Definition: ProcessManager.h:44
API::Result
Result
Enumeration of generic kernel API result codes.
Definition: API.h:68
API::InvalidArgument
@ InvalidArgument
Definition: API.h:74
Panic
@ Panic
Definition: PrivExec.h:40
Address
unsigned long Address
A memory address.
Definition: Types.h:131
param
void param(Terminal *term, int key, int value)
Set terminal parameters.
Definition: Terminal.cpp:305
Idle
@ Idle
Definition: PrivExec.h:36
Kernel::getProcessManager
ProcessManager * getProcessManager()
Get process manager.
Definition: Kernel.cpp:143
Log.h
RebootSystem
@ RebootSystem
Definition: PrivExec.h:37
FATAL
#define FATAL(msg)
Output a critical message and terminate program immediatly.
Definition: Log.h:50
DEBUG
#define DEBUG(msg)
Output a debug message to standard output.
Definition: Log.h:89
cpu_reboot
#define cpu_reboot()
Reboot the system.
Definition: ARMCore.h:102
WeakSingleton< Kernel >::instance
static Kernel * instance()
Retrieve the instance.
Definition: Singleton.h:86
assert
#define assert(exp)
Insert program diagnostics.
Definition: assert.h:60
API::Success
@ Success
Definition: API.h:70
PrivExecHandler
API::Result PrivExecHandler(const PrivOperation op, const Address param)
Prototype for kernel handler.
Definition: PrivExec.cpp:23
PrivOperation
PrivOperation
Available operations to perform using PrivExec().
Definition: PrivExec.h:34
ProcessManager::current
Process * current()
Current process running.
Definition: ProcessManager.cpp:203
ZERO
#define ZERO
Zero value.
Definition: Macros.h:43
WriteConsole
@ WriteConsole
Definition: PrivExec.h:39
ProcessManager::setIdle
void setIdle(Process *proc)
Set the idle process.
Definition: ProcessManager.cpp:208
ShutdownSystem
@ ShutdownSystem
Definition: PrivExec.h:38
cpu_shutdown
#define cpu_shutdown()
Shutdown the machine via ACPI.
Definition: ARMCore.h:110