]> rtime.felk.cvut.cz Git - l4.git/blob - kernel/fiasco/src/kern/ia32/config-ia32.cpp
6fae4713005d3d93ffc18fb10843232d3bd6b452
[l4.git] / kernel / fiasco / src / kern / ia32 / config-ia32.cpp
1 /* IA32/AMD64 specific */
2 INTERFACE[ia32,amd64]:
3
4 #include "idt_init.h"
5
6 EXTENSION class Config
7 {
8 public:
9
10   enum
11   {
12     // can access user memory directly
13     Access_user_mem = Access_user_mem_direct,
14
15     Max_num_dirqs       = 128,
16
17     /// Timer vector used with APIC timer or IOAPIC
18     Apic_timer_vector = APIC_IRQ_BASE + 0,
19   };
20
21   enum
22   {
23     SCHED_PIT = 0,
24     SCHED_RTC,
25     SCHED_APIC,
26     SCHED_HPET,
27   };
28
29   static unsigned scheduler_irq_vector;
30
31 #ifdef CONFIG_IO_PROT
32   static const bool enable_io_protection        = true;
33 #else
34   static const bool enable_io_protection        = false;
35 #endif
36
37 #ifdef CONFIG_SCHED_PIT
38   static const unsigned scheduler_mode          = SCHED_PIT;
39   static const unsigned scheduler_granularity   = 1000U;
40   static const unsigned default_time_slice      = 10 * scheduler_granularity;
41 #endif
42
43 #ifdef CONFIG_SCHED_RTC
44   static const unsigned scheduler_mode          = SCHED_RTC;
45 #  ifdef CONFIG_SLOW_RTC
46   static const unsigned scheduler_granularity   = 15625U;
47   static const unsigned default_time_slice      = 10 * scheduler_granularity;
48 #  else
49   static const unsigned scheduler_granularity   = 976U;
50   static const unsigned default_time_slice      = 10 * scheduler_granularity;
51 #  endif
52 #endif
53
54 #ifdef CONFIG_ONE_SHOT
55   static const bool scheduler_one_shot          = true;
56 #else
57   static const bool scheduler_one_shot          = false;
58 #endif
59
60 #ifdef CONFIG_SCHED_APIC
61   static const unsigned scheduler_mode          = SCHED_APIC;
62 #  ifdef CONFIG_ONE_SHOT
63   static const unsigned scheduler_granularity   = 1U;
64   static const unsigned default_time_slice      = 10000 * scheduler_granularity;
65 #  else
66   static const unsigned scheduler_granularity   = 1000U;
67   static const unsigned default_time_slice      = 10 * scheduler_granularity;
68 #  endif
69 #endif
70
71 #ifdef CONFIG_SCHED_HPET
72   static const unsigned scheduler_mode          = SCHED_HPET;
73   static const unsigned scheduler_granularity   = 1000U;
74   static const unsigned default_time_slice      = 10 * scheduler_granularity;
75 #endif
76
77 #ifdef CONFIG_POWERSAVE_GETCHAR
78   static const bool getchar_does_hlt = true;
79 #else
80   static const bool getchar_does_hlt = false;
81 #endif
82
83   static bool getchar_does_hlt_works_ok;
84   static bool apic;
85
86 #ifdef CONFIG_WATCHDOG
87   static bool watchdog;
88 #else
89   static const bool watchdog = false;
90 #endif
91
92 //  static const bool hlt_works_ok = false;
93   static bool hlt_works_ok;
94   static const bool pic_prio_modify = true;
95 #ifdef CONFIG_SYNC_TSC
96   static const bool kinfo_timer_uses_rdtsc = true;
97 #else
98   static const bool kinfo_timer_uses_rdtsc = false;
99 #endif
100
101   static const bool old_sigma0_adapter_hack = false;
102
103   // the default uart to use for serial console
104   static const unsigned default_console_uart = 1;
105   static const unsigned default_console_uart_baudrate = 115200;
106
107   static char const char_micro;
108
109   static bool found_vmware;
110
111   enum {
112     Is_ux = 0,
113   };
114 };
115
116 IMPLEMENTATION[ia32,amd64]:
117
118 #include <cstring>
119 #include "cmdline.h"
120
121 bool Config::hlt_works_ok = true;
122
123 bool Config::found_vmware = false;
124 char const Config::char_micro = '\265';
125 bool Config::apic = false;
126 bool Config::getchar_does_hlt_works_ok = false;
127
128 #ifdef CONFIG_WATCHDOG
129 bool Config::watchdog = false;
130 #endif
131
132 const char *const Config::kernel_warn_config_string =
133 #ifdef CONFIG_SCHED_RTC
134   "  CONFIG_SCHED_RTC is on\n"
135 #endif
136 #ifndef CONFIG_INLINE
137   "  CONFIG_INLINE is off\n"
138 #endif
139 #ifndef CONFIG_NDEBUG
140   "  CONFIG_NDEBUG is off\n"
141 #endif
142 #ifdef CONFIG_PROFILE
143   "  CONFIG_PROFILE is on\n"
144 #endif
145 #ifndef CONFIG_NO_FRAME_PTR
146   "  CONFIG_NO_FRAME_PTR is off\n"
147 #endif
148 #ifdef CONFIG_LIST_ALLOC_SANITY
149   "  CONFIG_LIST_ALLOC_SANITY is on\n"
150 #endif
151 #ifdef CONFIG_BEFORE_IRET_SANITY
152   "  CONFIG_BEFORE_IRET_SANITY is on\n"
153 #endif
154 #ifdef CONFIG_FINE_GRAINED_CPUTIME
155   "  CONFIG_FINE_GRAINED_CPUTIME is on\n"
156 #endif
157 #ifdef CONFIG_JDB_ACCOUNTING
158   "  CONFIG_JDB_ACCOUNTING is on\n"
159 #endif
160   "";
161
162 IMPLEMENT FIASCO_INIT
163 void
164 Config::init_arch()
165 {
166   char const *cmdline = Cmdline::cmdline();
167
168 #ifdef CONFIG_WATCHDOG
169   if (strstr(cmdline, " -watchdog"))
170     {
171       watchdog = true;
172       apic = true;
173     }
174 #endif
175
176   if (strstr(cmdline, " -nohlt"))
177     hlt_works_ok = false;
178
179   if (strstr(cmdline, " -apic"))
180     apic = true;
181
182   if (scheduler_mode == SCHED_APIC)
183     apic = true;
184 }
185
186 #ifdef CONFIG_IO_PROT
187 #include <feature.h>
188 KIP_KERNEL_FEATURE("io_prot");
189 #endif
190   
191
192 IMPLEMENTATION[(ia32 | amd64) && pit_timer]:
193
194 unsigned Config::scheduler_irq_vector = 0x20U;
195
196
197 IMPLEMENTATION[(ia32 | amd64) && rtc_timer]:
198
199 unsigned Config::scheduler_irq_vector = 0x28U;
200
201
202 IMPLEMENTATION[(ia32 | amd64) && apic_timer]:
203
204 unsigned Config::scheduler_irq_vector = Config::Apic_timer_vector;
205
206 IMPLEMENTATION[(ia32 | amd64) && hpet_timer]:
207
208 unsigned Config::scheduler_irq_vector;