creator-level saving new files in fat
[quarnos.git] / manes / kernel_state.h
blobc16e7c017532633e8d5f84b366b09858e259c450
1 /* Quarn OS
3 * Kernel state controller
5 * Copyright (C) 2008 Pawel Dziepak
7 * Interface for kernel state controller. Manes has to inform instance of this
8 * class when any change of the kernel state happens. Functions that want to
9 * monitor changes has to be hardcoded into set_state() procedure.
12 #ifndef _KERNEL_STATE_H_
13 #define _KERNEL_STATE_H_
15 #include "resources/memm.h"
17 #include "libs/list.h"
18 #include "libs/delegate.h"
20 namespace manes {
21 /**
22 * All information about current kernel state
23 * This class stores all information about current kernel state that
24 * might be useful for other parts of the kernel. This information
25 * should be transported by Manes. This class does not support
26 * multiprocessors machines.
28 class kernel_state {
29 public:
30 /** Types of execution environment */
31 typedef enum {
32 starting, /**< kernel is launching */
33 kernel, /**< cpu operates in kernel mode */
34 user, /**< cpu operates in user mode */
35 iowait, /**< cpu waits for hardware */
36 frozen, /**< cpu waits for any action */
37 halting /**< system is being halted */
38 } state;
40 private:
41 /**
42 * Current execution environment
43 * This variable stores information about current state of the
44 * kernel and cpu.
46 state _state;
48 /**
49 * Time count
50 * Number of pit ticks since starting Quarn OS.
52 int time;
54 /**
55 * Timers methods
56 * Delegates that have to be called on each pit tick.
58 list<delegate<void> > time_tick_call;
60 resources::memm *memory_allocator;
62 public:
63 kernel_state();
65 void add_time_tick_call(delegate<void>);
66 void del_time_tick_call(delegate<void>&);
67 void increase_time();
68 int get_time() const;
70 bool set_state(state new_state);
71 state get_state() const;
73 unsigned int get_memory_size() const;
74 resources::memm *get_memalloc() const;
75 void set_memory_allocator(resources::memm*);
77 //friend void *operator new(unsigned int);
78 //friend void operator delete(void *);
82 #endif