]> rtime.felk.cvut.cz Git - l4.git/blob - kernel/fiasco/src/kern/config.cpp
update
[l4.git] / kernel / fiasco / src / kern / config.cpp
1 /*
2  * Global kernel configuration
3  */
4
5 INTERFACE:
6
7 #include <globalconfig.h>
8 #include "config_tcbsize.h"
9 #include "l4_types.h"
10
11 // special magic to allow old compilers to inline constants
12
13 #define STRINGIFY_(x) #x
14 #define STRINGIFY(x) STRINGIFY_(x)
15
16 #if defined(__GNUC__)
17 # if defined(__GNUC_PATCHLEVEL__)
18 #  define COMPILER STRINGIFY(__GNUC__) "." STRINGIFY(__GNUC_MINOR__) "." STRINGIFY(__GNUC_PATCHLEVEL__)
19 # else
20 #  define COMPILER STRINGIFY(__GNUC__) "." STRINGIFY(__GNUC_MINOR__)
21 # endif
22 # define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
23 #else
24 # define COMPILER "Non-GCC"
25 # define GCC_VERSION 0
26 #endif
27
28 #define GREETING_COLOR_ANSI_OFF    "\033[0m"
29
30 #define FIASCO_KERNEL_SUBVERSION 0
31
32 class Config
33 {
34 public:
35
36   static const char *const kernel_warn_config_string;
37
38   enum {
39     SERIAL_ESC_IRQ      = 2,
40     SERIAL_ESC_NOIRQ    = 1,
41     SERIAL_NO_ESC       = 0,
42   };
43
44   static void init();
45   static void init_arch();
46
47   // global kernel configuration
48   static const unsigned kernel_version_id
49      = 0x87004444 | (FIASCO_KERNEL_SUBVERSION << 16); // "DD....."
50
51   static const Mword thread_block_size = THREAD_BLOCK_SIZE;
52
53   static const bool conservative = false;
54
55 #ifdef CONFIG_FINE_GRAINED_CPUTIME
56   static const bool fine_grained_cputime = true;
57 #else
58   static const bool fine_grained_cputime = false;
59 #endif
60
61   static bool irq_ack_in_kernel;
62   static bool esc_hack;
63
64   static unsigned tbuf_entries;
65
66 #ifdef CONFIG_PROFILE
67   static bool profiling;
68 #else
69   static const bool profiling = false;
70 #endif
71 #ifdef CONFIG_STACK_DEPTH
72   static const bool stack_depth = true;
73 #else
74   static const bool stack_depth = false;
75 #endif
76   static const int profiling_rate = 100;
77   static const int profile_irq = 0;
78
79   // kernel (idle) thread prio
80   static const unsigned kernel_prio = 0;
81
82   // default prio
83   static const unsigned default_prio = 1;
84
85   static const int warn_level = CONFIG_WARN_LEVEL;
86
87   enum {
88     Kip_syscalls = 1,
89
90     One_shot_min_interval_us =   200,
91     One_shot_max_interval_us = 10000,
92
93 #ifdef CONFIG_ASSEMBLER_IPC_SHORTCUT
94     Assembler_ipc_shortcut = 1,
95 #else
96     Assembler_ipc_shortcut = 0,
97 #endif
98 #ifdef CONFIG_NO_FRAME_PTR
99     Have_frame_ptr = 0,
100 #else
101     Have_frame_ptr = 1,
102 #endif
103     Mapdb_ram_only = 0,
104 #ifdef CONFIG_DEBUG_KERNEL_PAGE_FAULTS
105     Log_kernel_page_faults = 1,
106 #else
107     Log_kernel_page_faults = 0,
108 #endif
109
110 #ifdef CONFIG_JDB
111     Jdb = 1,
112 #else
113     Jdb = 0,
114 #endif
115 #ifdef CONFIG_JDB_LOGGING
116     Jdb_logging = 1,
117 #else
118     Jdb_logging = 0,
119 #endif
120 #ifdef CONFIG_JDB_ACCOUNTING
121     Jdb_accounting = 1,
122 #else
123     Jdb_accounting = 0,
124 #endif
125 #ifdef CONFIG_MP
126     Max_num_cpus = CONFIG_MP_MAX_CPUS,
127 #else
128     Max_num_cpus = 1,
129 #endif
130   };
131 };
132
133 #define GREETING_COLOR_ANSI_TITLE  "\033[1;32m"
134 #define GREETING_COLOR_ANSI_INFO   "\033[0;32m"
135
136 INTERFACE[ia32,ux]:
137 #define ARCH_NAME "ia32"
138 #define TARGET_NAME CONFIG_IA32_TARGET
139
140 INTERFACE[arm]:
141 #define ARCH_NAME "arm"
142
143 INTERFACE[amd64]:
144 #define ARCH_NAME "amd64"
145 #define TARGET_NAME CONFIG_IA32_TARGET
146
147 INTERFACE[ppc32]:
148 #define ARCH_NAME "ppc32"
149
150 INTERFACE:
151 #define CONFIG_KERNEL_VERSION_STRING \
152   GREETING_COLOR_ANSI_TITLE "Welcome to Fiasco.OC ("CONFIG_XARCH")!\\n"            \
153   GREETING_COLOR_ANSI_INFO "L4/Fiasco.OC " ARCH_NAME " "                \
154                            "microkernel (C) 1998-2010 TU Dresden\\n"           \
155                            "Rev: " CODE_VERSION " compiled with gcc " COMPILER \
156                             " for " TARGET_NAME "    [" CONFIG_LABEL "]\\n"    \
157                            "Build: #" BUILD_NR " " BUILD_DATE "\\n"            \
158   GREETING_COLOR_ANSI_OFF
159
160
161 //---------------------------------------------------------------------------
162 INTERFACE [ux]:
163
164 EXTENSION class Config
165 {
166 public:
167   // 32MB RAM => 2.5MB kmem, 128MB RAM => 16MB kmem, >=512MB RAM => 64MB kmem
168   static const unsigned kernel_mem_per_cent = 8;
169   enum
170   {
171     kernel_mem_max      = 64 << 20
172   };
173 };
174
175 //---------------------------------------------------------------------------
176 INTERFACE [!ux]:
177
178 EXTENSION class Config
179 {
180 public:
181   // 32MB RAM => 2.5MB kmem, 128MB RAM => 16MB kmem, >=512MB RAM => 60MB kmem
182   static const unsigned kernel_mem_per_cent = 8;
183   enum
184   {
185     kernel_mem_max      = 60 << 20
186   };
187 };
188
189 //---------------------------------------------------------------------------
190 INTERFACE [serial]:
191
192 EXTENSION class Config
193 {
194 public:
195   static int  serial_esc;
196 };
197
198 //---------------------------------------------------------------------------
199 INTERFACE [!serial]:
200
201 EXTENSION class Config
202 {
203 public:
204   static const int serial_esc = 0;
205 };
206
207 //---------------------------------------------------------------------------
208 IMPLEMENTATION:
209
210 #include <cstring>
211 #include <cstdlib>
212 #include "cmdline.h"
213 #include "feature.h"
214 #include "initcalls.h"
215 #include "panic.h"
216
217 KIP_KERNEL_ABI_VERSION(STRINGIFY(FIASCO_KERNEL_SUBVERSION));
218
219 // class variables
220 bool Config::esc_hack = false;
221 #ifdef CONFIG_SERIAL
222 int  Config::serial_esc = Config::SERIAL_NO_ESC;
223 #endif
224 bool Config::irq_ack_in_kernel = false;
225
226 #ifdef CONFIG_PROFILE
227 bool Config::profiling = false;
228 #endif
229
230 unsigned Config::tbuf_entries = 0x20000 / sizeof(Mword); //1024;
231
232 //-----------------------------------------------------------------------------
233 IMPLEMENTATION [!arm && !ppc32]:
234
235 IMPLEMENT FIASCO_INIT
236 void Config::init()
237 {
238   char const *cmdline = Cmdline::cmdline();
239
240   init_arch();
241
242   if (strstr(cmdline, " -esc"))
243     esc_hack = true;
244
245 #ifdef CONFIG_PROFILE
246   if (strstr(cmdline, " -profile"))
247     profiling = true;
248 #endif
249
250   if (strstr(cmdline, " -always_irqack"))
251     irq_ack_in_kernel = true;
252
253 #ifdef CONFIG_SERIAL
254   if (    strstr(cmdline, " -serial_esc")
255       && !strstr(cmdline, " -noserial")
256 # ifdef CONFIG_KDB
257       &&  strstr(cmdline, " -nokdb")
258 # endif
259       && !strstr(cmdline, " -nojdb"))
260     {
261       serial_esc = SERIAL_ESC_IRQ;
262     }
263 #endif
264 }
265
266
267 //----------------------------------------------------------------------------
268 IMPLEMENTATION[rotext]:
269
270 PUBLIC static
271 bool
272 Config::rotext()
273 { return strstr(Cmdline::cmdline()," -rotext"); }
274
275 //----------------------------------------------------------------------------
276 IMPLEMENTATION[!rotext]:
277
278 PUBLIC static inline
279 bool
280 Config::rotext()
281 { return false; }
282