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