net: udp sending data routine
[quarnos.git] / services / kernel_state.h
blobf0b6149f094f9edcdd0a618ef97998cf5af5a167
1 /* Quarn OS
3 * Kernel state controller
5 * Copyright (C) 2008-2009 Pawel Dziepak
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 /* Interface for kernel state controller. Manes has to inform instance of this
24 * class when any change of the kernel state happens. Functions that want to
25 * monitor changes has to be hardcoded into set_state() procedure.
28 #ifndef _KERNEL_STATE_H_
29 #define _KERNEL_STATE_H_
31 #include "manes/cds/component.h"
33 #include "libs/list.h"
34 #include "libs/delegate.h"
36 namespace manes {
37 class error;
40 namespace services {
42 /**
43 * All information about current kernel state
44 * This class stores all information about current kernel state that
45 * might be useful for other parts of the kernel. This information
46 * should be transported by Manes. This class does not support
47 * multiprocessors machines.
49 class kernel_state : public manes::cds::component {
50 public:
51 /** Types of execution environment */
52 typedef enum {
53 starting, /**< kernel is launching */
54 kernel, /**< cpu operates in kernel mode */
55 user, /**< cpu operates in user mode */
56 iowait, /**< cpu waits for hardware */
57 frozen, /**< cpu waits for any action */
58 halting /**< system is being halted */
59 } state;
61 private:
62 /**
63 * Current execution environment
64 * This variable stores information about current state of the
65 * kernel and cpu.
67 state _state;
69 /**
70 * Time count
71 * Number of pit ticks since starting Quarn OS.
73 int time;
75 /**
76 * Timers methods
77 * Delegates that have to be called on each pit tick.
79 list<delegate<void> > time_tick_call;
81 public:
82 kernel_state();
84 virtual void add_time_tick_call(delegate<void>);
85 virtual void del_time_tick_call(delegate<void>);
86 virtual void increase_time();
87 virtual int get_time() const;
89 virtual bool set_state(state new_state);
90 virtual state get_state() const;
92 virtual unsigned int get_memory_size() const;
94 virtual manes::error *new_error(const char *x);
96 static void register_type();
100 #endif