Diff markup
001 001
002 <<
003 002
004 003
005 004
006 005
007 006
008 007
009 008
010 009
011 010
012 011
013 012
014 013
015 014
016 015
017 016
018 017
019 018
>> 019 #include <sos/errno.h>
>> 020
020 021
021 #include <bootstrap/multiboot.h> 022 #include <bootstrap/multiboot.h>
022 #include <hwcore/idt.h> 023 #include <hwcore/idt.h>
023 #include <hwcore/gdt.h> 024 #include <hwcore/gdt.h>
024 #include <hwcore/irq.h> 025 #include <hwcore/irq.h>
025 #include <hwcore/exception.h> 026 #include <hwcore/exception.h>
026 #include <hwcore/i8254.h> 027 #include <hwcore/i8254.h>
027 #include <sos/list.h> 028 #include <sos/list.h>
028 #include <sos/physmem.h> 029 #include <sos/physmem.h>
029 #include <hwcore/paging.h> 030 #include <hwcore/paging.h>
>> 031 #include <hwcore/mm_context.h>
>> 032 #include <hwcore/swintr.h>
030 #include <sos/kmem_vmm.h> 033 #include <sos/kmem_vmm.h>
031 #include <sos/kmalloc.h> 034 #include <sos/kmalloc.h>
>> 035 #include <sos/time.h>
>> 036 #include <sos/thread.h>
>> 037 #include <sos/process.h>
>> 038 #include <sos/umem_vmm.h>
032 #include <sos/klibc.h> 039 #include <sos/klibc.h>
033 #include <sos/assert.h> 040 #include <sos/assert.h>
034 #include <drivers/x86_videomem.h> 041 #include <drivers/x86_videomem.h>
035 #include <drivers/bochs.h> 042 #include <drivers/bochs.h>
036 !! 043 #include <sos/calcload.h>
>> 044 #include <sos/umem_vmm.h>
>> 045 #include <sos/binfmt_elf32.h>
>> 046 #include <drivers/zero.h>
>> 047 #include <sos/fs.h>
>> 048 #include <drivers/fs_virtfs.h>
037 049
038 050
039 051
040 void display_bits(unsigned char row, unsigned 052 void display_bits(unsigned char row, unsigned char col,
041 unsigned char attribute, 053 unsigned char attribute,
042 sos_ui32_t integer) 054 sos_ui32_t integer)
043 { 055 {
044 int i; 056 int i;
045 057
046 for (i = 31 ; i >= 0 ; i--) 058 for (i = 31 ; i >= 0 ; i--)
047 { 059 {
048 060
049 int bit_i = (integer & (1 << i)); 061 int bit_i = (integer & (1 << i));
050 062
051 unsigned char ascii_code = bit_i?219:177 063 unsigned char ascii_code = bit_i?219:177;
052 sos_x86_videomem_putchar(row, col++, 064 sos_x86_videomem_putchar(row, col++,
053 attribute, 065 attribute,
054 ascii_code); 066 ascii_code);
055 } 067 }
056 } 068 }
057 069
058 <<
059 070
060 static void clk_it(int intid, !! 071 static void clk_it(int intid)
061 const struct sos_cpu_kstate <<
062 { 072 {
063 static sos_ui32_t clock_count = 0; 073 static sos_ui32_t clock_count = 0;
064 074
065 display_bits(0, 48, 075 display_bits(0, 48,
066 SOS_X86_VIDEO_FG_LTGREEN | SOS_ 076 SOS_X86_VIDEO_FG_LTGREEN | SOS_X86_VIDEO_BG_BLUE,
067 clock_count); 077 clock_count);
068 clock_count++; 078 clock_count++;
>> 079
>> 080
>> 081 sos_time_do_tick();
>> 082
>> 083
>> 084 sos_sched_do_timer_tick();
069 } 085 }
070 086
071 087
072 088
073 089
074 090
075 091
076 <<
077 static void dump_backtrace(const struct sos_cp <<
078 sos_vaddr_t stack_b <<
079 sos_size_t stack_s <<
080 sos_bool_t on_conso <<
081 sos_bool_t on_bochs <<
082 { <<
083 static void backtracer(sos_vaddr_t PC, <<
084 sos_vaddr_t params, <<
085 sos_ui32_t depth, <<
086 void *custom_arg) <<
087 { <<
088 sos_ui32_t invalid = 0xffffffff, *arg1, <<
089 <<
090 <<
091 <<
092 <<
093 <<
094 arg1 = (sos_ui32_t*)params; <<
095 arg2 = (sos_ui32_t*)(params+4); <<
096 arg3 = (sos_ui32_t*)(params+8); <<
097 arg4 = (sos_ui32_t*)(params+12); <<
098 <<
099 <<
100 <<
101 #define INTERVAL_OK(b,v,u) ( ((b) <= (sos_vadd <<
102 && ((sos_vaddr_t) <<
103 if (!INTERVAL_OK(stack_bottom, arg1, sta <<
104 arg1 = &invalid; <<
105 if (!INTERVAL_OK(stack_bottom, arg2, sta <<
106 arg2 = &invalid; <<
107 if (!INTERVAL_OK(stack_bottom, arg3, sta <<
108 arg3 = &invalid; <<
109 if (!INTERVAL_OK(stack_bottom, arg4, sta <<
110 arg4 = &invalid; <<
111 <<
112 <<
113 if (on_bochs) <<
114 sos_bochs_printf("[%d] PC=0x%x arg1=0x <<
115 (unsigned)depth, (uns <<
116 (unsigned)*arg1, (uns <<
117 (unsigned)*arg3); <<
118 <<
119 if (on_console) <<
120 sos_x86_videomem_printf(23-depth, 3, <<
121 SOS_X86_VIDEO_ <<
122 | SOS_X86_VI <<
123 "[%d] PC=0x%x <<
124 (unsigned)dept <<
125 (unsigned)*arg <<
126 (unsigned)*arg <<
127 <<
128 } <<
129 <<
130 sos_backtrace(cpu_kstate, 15, stack_bottom, <<
131 } <<
132 <<
133 092
134 093
135 static void pgflt_ex(int intid, const struct s !! 094 static void pgflt_ex(int intid, struct sos_cpu_state *ctxt)
136 { 095 {
137 static sos_ui32_t demand_paging_count = 0; 096 static sos_ui32_t demand_paging_count = 0;
138 sos_vaddr_t faulting_vaddr = sos_cpu_kstate_ !! 097 struct sos_thread * cur_thr = sos_thread_get_current();
>> 098 sos_vaddr_t faulting_vaddr = sos_cpu_context_get_EX_faulting_vaddr(ctxt);
139 sos_paddr_t ppage_paddr; 099 sos_paddr_t ppage_paddr;
140 100
>> 101 if (sos_cpu_context_is_in_user_mode(ctxt)
>> 102 || (cur_thr->fixup_uaccess.return_vaddr))
>> 103 {
>> 104 __label__ unforce_address_space;
>> 105 sos_bool_t need_to_setup_mmu;
>> 106 sos_ui32_t errcode = sos_cpu_context_get_EX_info(ctxt);
>> 107
>> 108
>> 109
>> 110 need_to_setup_mmu = (cur_thr->squatted_mm_context
>> 111 != sos_process_get_mm_context(cur_thr->process));
>> 112 if (need_to_setup_mmu)
>> 113 sos_thread_prepare_user_space_access(NULL, 0);
>> 114
>> 115 if (SOS_OK ==
>> 116 sos_umem_vmm_try_resolve_page_fault(faulting_vaddr,
>> 117 errcode & (1 << 1),
>> 118 TRUE))
>> 119 goto unforce_address_space;
>> 120
>> 121
>> 122
>> 123 if (! sos_cpu_context_is_in_user_mode(ctxt))
>> 124 {
>> 125 cur_thr->fixup_uaccess.faulted_uaddr = faulting_vaddr;
>> 126 sos_cpu_context_set_EX_return_address(ctxt,
>> 127 cur_thr->fixup_uaccess.return_vaddr);
>> 128 goto unforce_address_space;
>> 129 }
>> 130
>> 131 if (need_to_setup_mmu)
>> 132 sos_thread_end_user_space_access();
>> 133
>> 134 sos_bochs_printf("Unresolved USER page Fault at instruction 0x%x on access to address 0x%x (info=%x)!\n",
>> 135 sos_cpu_context_get_PC(ctxt),
>> 136 (unsigned)faulting_vaddr,
>> 137 (unsigned)sos_cpu_context_get_EX_info(ctxt));
>> 138 sos_bochs_printf("Terminating User thread\n");
>> 139 sos_thread_exit();
>> 140
>> 141 unforce_address_space:
>> 142 if (need_to_setup_mmu)
>> 143 sos_thread_end_user_space_access();
>> 144 return;
>> 145 }
>> 146
141 147
142 if (! sos_kmem_vmm_is_valid_vaddr(faulting_v 148 if (! sos_kmem_vmm_is_valid_vaddr(faulting_vaddr))
143 { 149 {
144 150
145 151
146 dump_backtrace(ctxt, !! 152 sos_display_fatal_error("Unresolved page Fault at instruction 0x%x on access to address 0x%x (info=%x)!",
147 bootstrap_stack_bottom, !! 153 sos_cpu_context_get_PC(ctxt),
148 bootstrap_stack_size, <<
149 TRUE, TRUE); <<
150 sos_display_fatal_error("Unresolved page <<
151 (unsigned)faulti 154 (unsigned)faulting_vaddr,
152 (unsigned)sos_cp !! 155 (unsigned)sos_cpu_context_get_EX_info(ctxt));
153 SOS_ASSERT_FATAL(! "Got page fault (note 156 SOS_ASSERT_FATAL(! "Got page fault (note: demand paging is disabled)");
154 } 157 }
155 158
156 159
157 160
158 !! 161
159 162
160 163
161 164
162 demand_paging_count ++; 165 demand_paging_count ++;
163 display_bits(0, 0, 166 display_bits(0, 0,
164 SOS_X86_VIDEO_FG_LTRED | SOS_X8 167 SOS_X86_VIDEO_FG_LTRED | SOS_X86_VIDEO_BG_BLUE,
165 demand_paging_count); 168 demand_paging_count);
166 169
167 170
168 ppage_paddr = sos_physmem_ref_physpage_new(F 171 ppage_paddr = sos_physmem_ref_physpage_new(FALSE);
169 if (! ppage_paddr) 172 if (! ppage_paddr)
170 SOS_ASSERT_FATAL(! "TODO: implement swap. 173 SOS_ASSERT_FATAL(! "TODO: implement swap. (Out of mem in demand paging because no swap for kernel yet !)");
171 SOS_ASSERT_FATAL(SOS_OK == sos_paging_map(pp 174 SOS_ASSERT_FATAL(SOS_OK == sos_paging_map(ppage_paddr,
172 SO 175 SOS_PAGE_ALIGN_INF(faulting_vaddr),
173 FA 176 FALSE,
174 SO 177 SOS_VM_MAP_PROT_READ
175 | 178 | SOS_VM_MAP_PROT_WRITE
176 | 179 | SOS_VM_MAP_ATOMIC));
177 sos_physmem_unref_physpage(ppage_paddr); 180 sos_physmem_unref_physpage(ppage_paddr);
178 181
179 182
180 } 183 }
181 184
182 185
183 186
184 187
185 !! 188
186 !! 189
187 <<
188 <<
189 <<
190 <<
191 190
192 struct sos_cpu_kstate *ctxt_hello1; !! 191 static void idle_thread()
193 struct sos_cpu_kstate *ctxt_hello2; <<
194 struct sos_cpu_kstate *ctxt_main; <<
195 sos_vaddr_t hello1_stack, hello2_stack; <<
196 <<
197 static void reclaim_stack(sos_vaddr_t stack_va <<
198 { <<
199 sos_kfree(stack_vaddr); <<
200 } <<
201 <<
202 <<
203 static void exit_hello12(sos_vaddr_t stack_vad <<
204 { <<
205 sos_cpu_kstate_exit_to(ctxt_main, <<
206 (sos_cpu_kstate_funct <<
207 stack_vaddr); <<
208 } <<
209 <<
210 <<
211 static void hello1 (char *str) <<
212 { 192 {
213 for ( ; *str != '\n' ; str++) !! 193 sos_ui32_t idle_twiddle = 0;
214 { <<
215 sos_bochs_printf("hello1: %c\n", *str); <<
216 sos_cpu_kstate_switch(& ctxt_hello1, ctx <<
217 } <<
218 <<
219 <<
220 <<
221 <<
222 <<
223 <<
224 } <<
225 194
226 !! 195 while (1)
227 static void hello2 (char *str) <<
228 { <<
229 for ( ; *str != '\n' ; str++) <<
230 { 196 {
231 sos_bochs_printf("hello2: %c\n", *str); !! 197
232 sos_cpu_kstate_switch(& ctxt_hello2, ctx !! 198
233 } !! 199 asm("hlt\n");
234 <<
235 <<
236 <<
237 <<
238 <<
239 <<
240 } <<
241 <<
242 <<
243 void print_hello_world () <<
244 { <<
245 #define DEMO_STACK_SIZE 1024 <<
246 <<
247 hello1_stack = sos_kmalloc(DEMO_STACK_SIZE, <<
248 hello2_stack = sos_kmalloc(DEMO_STACK_SIZE, <<
249 <<
250 <<
251 sos_cpu_kstate_init(&ctxt_hello1, <<
252 (sos_cpu_kstate_function <<
253 (sos_ui32_t) "Hlowrd", <<
254 (sos_vaddr_t) hello1_sta <<
255 (sos_cpu_kstate_function <<
256 (sos_ui32_t) hello1_stac <<
257 sos_cpu_kstate_init(&ctxt_hello2, <<
258 (sos_cpu_kstate_function <<
259 (sos_ui32_t) "el ol\n", <<
260 (sos_vaddr_t) hello2_sta <<
261 (sos_cpu_kstate_function <<
262 (sos_ui32_t) hello2_stac <<
263 <<
264 <<
265 sos_bochs_printf("Printing Hello World\\n... <<
266 sos_cpu_kstate_switch(& ctxt_main, ctxt_hell <<
267 <<
268 <<
269 sos_bochs_printf("Back in main !\n"); <<
270 } <<
271 <<
272 <<
273 <<
274 <<
275 <<
276 <<
277 <<
278 static void test_demand_paging(int nb_alloc_vp <<
279 { <<
280 int i; <<
281 sos_vaddr_t base_vaddr; <<
282 <<
283 sos_x86_videomem_printf(10, 0, <<
284 SOS_X86_VIDEO_BG_BLU <<
285 "Demand paging test <<
286 nb_alloc_vpages >> 8 <<
287 <<
288 <<
289 base_vaddr = sos_kmem_vmm_alloc(nb_alloc_vpa <<
290 <<
291 SOS_ASSERT_FATAL(base_vaddr != (sos_vaddr_t) <<
292 sos_x86_videomem_printf(11, 0, <<
293 SOS_X86_VIDEO_BG_BLU <<
294 "Allocated virtual r <<
295 base_vaddr, <<
296 base_vaddr + nb_allo <<
297 200
298 !! 201 idle_twiddle ++;
299 for (i = 0 ; (i < nb_alloc_ppages) && (i < n !! 202 display_bits(0, 0, SOS_X86_VIDEO_FG_GREEN | SOS_X86_VIDEO_BG_BLUE,
300 { !! 203 idle_twiddle);
301 !! 204
302 sos_ui32_t *value, j; !! 205
303 sos_vaddr_t vaddr = base_vaddr; !! 206 sos_thread_yield();
304 vaddr += (nb_alloc_vpages - (i + 1))*SOS <<
305 vaddr += 2345; <<
306 <<
307 sos_x86_videomem_printf(12, 0, <<
308 SOS_X86_VIDEO_BG <<
309 "Writing %d at v <<
310 i, vaddr); <<
311 <<
312 <<
313 value = (sos_ui32_t*)vaddr; <<
314 *value = i; <<
315 <<
316 <<
317 sos_x86_videomem_printf(13, 0, <<
318 SOS_X86_VIDEO_BG <<
319 "Value read at a <<
320 vaddr, (unsigned <<
321 } 207 }
322 <<
323 SOS_ASSERT_FATAL(SOS_OK == sos_kmem_vmm_free <<
324 <<
325 sos_x86_videomem_printf(14, 0, <<
326 SOS_X86_VIDEO_BG_BLU <<
327 "Done (area un-alloc <<
328 } 208 }
329 209
330 210
331 <<
332 211
333 !! 212
334 213
335 !! 214 static void stat_thread()
336 <<
337 static void test_backtrace(int i, int magic, s <<
338 sos_size_t stack_s <<
339 { 215 {
340 if (i <= 0) !! 216 while (1)
341 { 217 {
342 !! 218 sos_ui32_t flags;
343 !! 219 sos_ui32_t load1, load5, load15;
344 *((char*)0x42) = 12; !! 220 char str1[11], str5[11], str15[11];
345 !! 221 struct sos_time t;
346 !! 222 t.sec = 1;
347 !! 223 t.nanosec = 0;
>> 224
>> 225 sos_thread_sleep(& t);
>> 226
>> 227 sos_disable_IRQs(flags);
>> 228
>> 229
>> 230 sos_load_get_sload(&load1, &load5, &load15);
>> 231 sos_load_to_string(str1, load1);
>> 232 sos_load_to_string(str5, load5);
>> 233 sos_load_to_string(str15, load15);
>> 234 sos_x86_videomem_printf(16, 34,
>> 235 SOS_X86_VIDEO_FG_YELLOW | SOS_X86_VIDEO_BG_BLUE,
>> 236 "Kernel (- Idle): %s %s %s ",
>> 237 str1, str5, str15);
>> 238
>> 239 sos_load_get_uload(&load1, &load5, &load15);
>> 240 sos_load_to_string(str1, load1);
>> 241 sos_load_to_string(str5, load5);
>> 242 sos_load_to_string(str15, load15);
>> 243 sos_x86_videomem_printf(17, 34,
>> 244 SOS_X86_VIDEO_FG_YELLOW | SOS_X86_VIDEO_BG_BLUE,
>> 245 "User: %s %s %s ",
>> 246 str1, str5, str15);
>> 247
>> 248 sos_load_get_uratio(&load1, &load5, &load15);
>> 249 sos_load_to_string(str1, load1);
>> 250 sos_load_to_string(str5, load5);
>> 251 sos_load_to_string(str15, load15);
>> 252 sos_x86_videomem_printf(18, 34,
>> 253 SOS_X86_VIDEO_FG_YELLOW | SOS_X86_VIDEO_BG_BLUE,
>> 254 "User CPU %%: %s %s %s ",
>> 255 str1, str5, str15);
>> 256
>> 257
>> 258 sos_load_get_sratio(&load1, &load5, &load15);
>> 259 sos_load_to_string(str1, load1);
>> 260 sos_load_to_string(str5, load5);
>> 261 sos_load_to_string(str15, load15);
>> 262 sos_x86_videomem_printf(19, 34,
>> 263 SOS_X86_VIDEO_FG_YELLOW | SOS_X86_VIDEO_BG_BLUE,
>> 264 "Kernel CPU %% (+ Idle): %s %s %s ",
>> 265 str1, str5, str15);
>> 266 sos_restore_IRQs(flags);
348 } 267 }
349 else <<
350 test_backtrace(i-1, magic, stack_bottom, s <<
351 } 268 }
352 269
353 270
354 271
355 !! 272
356 <<
357 <<
358 <<
359 <<
360 <<
361 <<
362 <<
363 <<
364 <<
365 <<
366 <<
367 <<
368 <<
369 <<
370 <<
371 <<
372 <<
373 <<
374 <<
375 <<
376 <<
377 <<
378 <<
379 <<
380 <<
381 <<
382 <<
383 <<
384 <<
385 <<
386 <<
387 <<
388 <<
389 <<
390 <<
391 <<
392 <<
393 <<
394 <<
395 <<
396 <<
397 <<
398 <<
399 <<
400 <<
401 <<
402 <<
403 <<
404 <<
405 <<
406 <<
407 <<
408 <<
409 <<
410 <<
411 <<
412 <<
413 <<
414 <<
415 <<
416 <<
417 <<
418 <<
419 <<
420 <<
421 <<
422 <<
423 <<
424 <<
425 <<
426 <<
427 <<
428 <<
429 <<
430 <<
431 <<
432 <<
433 <<
434 <<
435 static char stack_reader[1024]; <<
436 static char stack_lexer[1024]; <<
437 static char deep_stack[65536]; <<
438 <<
439 <<
440 static struct sos_cpu_kstate *st_reader, *st_l <<
441 *st_eval, *st_free, *st_main; <<
442 <<
443 <<
444 <<
445 <<
446 <<
447 273
448 static void reclaim(int unused) !! 274 static sos_ret_t
449 { !! 275 start_init(struct sos_fs_manager_instance * rootfs)
450 } <<
451 static void func_exit(sos_ui32_t unused) <<
452 { 276 {
453 sos_cpu_kstate_exit_to(st_main, (sos_cpu_kst !! 277 sos_ret_t retval;
454 } !! 278 struct sos_umem_vmm_as *as_init;
455 !! 279 struct sos_process *proc_init;
>> 280 struct sos_thread *new_thr;
>> 281 sos_uaddr_t ustack, start_uaddr;
>> 282 struct sos_fs_opened_file * init_root, * init_cwd, * unused_of;
456 283
457 !! 284
458 !! 285 proc_init = sos_process_create("init", FALSE);
459 !! 286 if (! proc_init)
460 !! 287 return -SOS_ENOMEM;
461 !! 288 as_init = sos_process_get_address_space(proc_init);
462 static char data_reader_to_lexer; <<
463 <<
464 static void func_reader(const char *str) <<
465 { <<
466 for ( ; str && (*str != '\0') ; str++) <<
467 { <<
468 data_reader_to_lexer = *str; <<
469 sos_cpu_kstate_switch(& st_reader, st_le <<
470 } <<
471 <<
472 data_reader_to_lexer = '\0'; <<
473 sos_cpu_kstate_switch(& st_reader, st_lexer) <<
474 } <<
475 <<
476 <<
477 <<
478 <<
479 <<
480 <<
481 <<
482 <<
483 #define STR_VAR_MAXLEN 16 <<
484 static struct lex_elem <<
485 { <<
486 enum { LEX_IS_NUMBER, LEX_IS_OPER, LEX_IS_VA <<
487 LEX_IS_OPENPAR, LEX_IS_CLOSEPAR, LEX_ <<
488 union { <<
489 int number; <<
490 char operator; <<
491 char var[STR_VAR_MAXLEN]; <<
492 }; <<
493 } data_lexer_to_parser; <<
494 <<
495 static void func_lexer(sos_ui32_t unused) <<
496 { <<
497 char c; <<
498 enum { GOT_SPACE, GOT_NUM, GOT_OP, GOT_STR, <<
499 GOT_OPENPAR, GOT_CLOSEPAR } got_what, <<
500 <<
501 data_lexer_to_parser.number = 0; <<
502 got_what_before = GOT_SPACE; <<
503 do <<
504 { <<
505 <<
506 sos_cpu_kstate_switch(& st_lexer, st_rea <<
507 c = data_reader_to_lexer; <<
508 <<
509 <<
510 if ( (c >= '0') && (c <= '9') ) <<
511 got_what = GOT_NUM; <<
512 else if ( (c == '+') || (c == '-') || (c <<
513 got_what = GOT_OP; <<
514 else if ( ( (c >= 'a') && (c <= 'z') ) <<
515 || ( (c >= 'A') && (c <= 'Z') <<
516 got_what = GOT_STR; <<
517 else if (c == '(') <<
518 got_what = GOT_OPENPAR; <<
519 else if (c == ')') <<
520 got_what = GOT_CLOSEPAR; <<
521 else <<
522 got_what = GOT_SPACE; <<
523 <<
524 <<
525 if ( (got_what != got_what_before) <<
526 || (got_what_before == GOT_OP) <<
527 || (got_what_before == GOT_OPENPAR) <<
528 || (got_what_before == GOT_CLOSEPAR <<
529 { <<
530 <<
531 <<
532 if ( (got_what_before != GOT_SPACE) <<
533 sos_cpu_kstate_switch(& st_lexer, <<
534 <<
535 data_lexer_to_parser.number = 0; <<
536 } <<
537 <<
538 <<
539 if (got_what == GOT_OP) <<
540 { <<
541 data_lexer_to_parser.type = LEX_IS_O <<
542 data_lexer_to_parser.operator = c; <<
543 } <<
544 else if (got_what == GOT_NUM) <<
545 { <<
546 data_lexer_to_parser.type = LEX_IS_N <<
547 data_lexer_to_parser.number *= 10; <<
548 data_lexer_to_parser.number += (c - <<
549 } <<
550 else if (got_what == GOT_STR) <<
551 { <<
552 char to_cat[] = { c, '\0' }; <<
553 data_lexer_to_parser.type = LEX_IS_V <<
554 strzcat(data_lexer_to_parser.var, to <<
555 } <<
556 else if (got_what == GOT_OPENPAR) <<
557 data_lexer_to_parser.type = LEX_IS_OPE <<
558 else if (got_what == GOT_CLOSEPAR) <<
559 data_lexer_to_parser.type = LEX_IS_CLO <<
560 <<
561 got_what_before = got_what; <<
562 } <<
563 while (c != '\0'); <<
564 <<
565 <<
566 if ( (got_what_before != GOT_SPACE) ) <<
567 sos_cpu_kstate_switch(& st_lexer, st_parse <<
568 <<
569 <<
570 data_lexer_to_parser.type = LEX_END; <<
571 sos_cpu_kstate_switch(& st_lexer, st_parser) <<
572 <<
573 <<
574 <<
575 sos_bochs_printf("Error: end of string alrea <<
576 sos_cpu_kstate_switch(& st_lexer, st_main); <<
577 } <<
578 <<
579 <<
580 <<
581 <<
582 <<
583 struct syntax_node <<
584 { <<
585 enum { YY_IS_BINOP, YY_IS_UNAROP, YY_IS_NUM, <<
586 union <<
587 { <<
588 int number; <<
589 char var[STR_VAR_MAXLEN]; <<
590 struct <<
591 { <<
592 char op; <<
593 struct syntax_node *parm_left, *parm_rig <<
594 } binop; <<
595 struct <<
596 { <<
597 char op; <<
598 struct syntax_node *parm; <<
599 } unarop; <<
600 }; <<
601 }; <<
602 289
603 static void func_parser(struct syntax_node ** <<
604 { <<
605 static struct syntax_node *alloc_node_num(in <<
606 static struct syntax_node *alloc_node_var(co <<
607 static struct syntax_node *alloc_node_binop( <<
608 <<
609 <<
610 static struct syntax_node *alloc_node_unarop <<
611 <<
612 static struct syntax_node * get_expr(); <<
613 static struct syntax_node * get_expr_lr(stru <<
614 static struct syntax_node * get_term(); <<
615 static struct syntax_node * get_term_lr(stru <<
616 static struct syntax_node * get_factor(); <<
617 static struct syntax_node * get_scalar(); <<
618 290
619 !! 291
620 static struct syntax_node *alloc_node_num(in !! 292
621 { !! 293
622 struct syntax_node *n !! 294
623 = (struct syntax_node*) sos_kmalloc(si !! 295
624 n->type = YY_IS_NUM; !! 296 retval = sos_fs_new_opened_file(proc_init, rootfs->root,
625 n->number = val; !! 297 SOS_FS_OPEN_READ | SOS_FS_OPEN_WRITE,
626 return n; !! 298 & init_root);
627 } !! 299 if (SOS_OK != retval)
628 <<
629 static struct syntax_node *alloc_node_var(co <<
630 { <<
631 struct syntax_node *n <<
632 = (struct syntax_node*) sos_kmalloc(si <<
633 n->type = YY_IS_VAR; <<
634 strzcpy(n->var, name, STR_VAR_MAXLEN); <<
635 return n; <<
636 } <<
637 <<
638 static struct syntax_node *alloc_node_binop( <<
639 <<
640 <<
641 { <<
642 struct syntax_node *n <<
643 = (struct syntax_node*) sos_kmalloc(si <<
644 n->type = YY_IS_BINOP; <<
645 n->binop.op = op; <<
646 n->binop.parm_left = parm_left; <<
647 n->binop.parm_right = parm_right; <<
648 return n; <<
649 } <<
650 <<
651 static struct syntax_node *alloc_node_unarop <<
652 <<
653 { 300 {
654 struct syntax_node *n !! 301 sos_process_unref(proc_init);
655 = (struct syntax_node*) sos_kmalloc(si !! 302 return -SOS_ENOENT;
656 n->type = YY_IS_UNAROP; <<
657 n->unarop.op = op; <<
658 n->unarop.parm = parm; <<
659 return n; <<
660 } 303 }
661 304
662 !! 305
663 !! 306
664 static void parser_exception(const char *str !! 307 retval = sos_fs_duplicate_opened_file(init_root, proc_init,
>> 308 & init_cwd);
>> 309 if (SOS_OK != retval)
665 { 310 {
666 sos_bochs_printf("Parser exception: %s\n !! 311 sos_fs_close(init_root);
667 sos_cpu_kstate_switch(& st_parser, st_ma !! 312 sos_process_unref(proc_init);
>> 313 return -SOS_ENOENT;
668 } 314 }
669 315
670 !! 316
671 !! 317 if ( ( SOS_OK != sos_process_chroot(proc_init, init_root, & unused_of) )
672 static int get_number() !! 318 || ( SOS_OK != sos_process_chdir(proc_init, init_cwd, & unused_of) ) )
673 { <<
674 int v; <<
675 if (data_lexer_to_parser.type != LEX_IS_ <<
676 parser_exception("Expected number"); <<
677 v = data_lexer_to_parser.number; <<
678 sos_cpu_kstate_switch(& st_parser, st_le <<
679 return v; <<
680 } <<
681 <<
682 <<
683 static void get_str(char name[STR_VAR_MAXLEN <<
684 { 319 {
685 if (data_lexer_to_parser.type != LEX_IS_ !! 320 sos_fs_close(init_root);
686 parser_exception("Expected variable"); !! 321 sos_fs_close(init_cwd);
687 strzcpy(name, data_lexer_to_parser.var, !! 322 sos_process_chroot(proc_init, NULL, & unused_of);
688 sos_cpu_kstate_switch(& st_parser, st_le !! 323 sos_process_chdir(proc_init, NULL, & unused_of);
689 } !! 324 sos_process_unref(proc_init);
690 !! 325 return -SOS_ENOENT;
691 <<
692 static char get_op() <<
693 { <<
694 char op; <<
695 if (data_lexer_to_parser.type != LEX_IS_ <<
696 parser_exception("Expected operator"); <<
697 op = data_lexer_to_parser.operator; <<
698 sos_cpu_kstate_switch(& st_parser, st_le <<
699 return op; <<
700 } <<
701 <<
702 <<
703 static void get_par() <<
704 { <<
705 if ( (data_lexer_to_parser.type != LEX_I <<
706 && (data_lexer_to_parser.type != LE <<
707 parser_exception("Expected parenthese" <<
708 sos_cpu_kstate_switch(& st_parser, st_le <<
709 } 326 }
710 327
711 !! 328
712 static struct syntax_node * get_expr() !! 329 start_uaddr = sos_binfmt_elf32_map(as_init, "init");
713 { !! 330 if (0 == start_uaddr)
714 struct syntax_node *t = get_term(); <<
715 return get_expr_lr(t); <<
716 } <<
717 <<
718 static struct syntax_node * get_expr_lr(stru <<
719 { <<
720 if ( (data_lexer_to_parser.type == LEX_I <<
721 && ( (data_lexer_to_parser.operator <<
722 || (data_lexer_to_parser.opera <<
723 { <<
724 char op = get_op(); <<
725 struct syntax_node *term = get_term( <<
726 struct syntax_node *node_op = alloc_ <<
727 return get_expr_lr(node_op); <<
728 } <<
729 return n; <<
730 } <<
731 <<
732 static struct syntax_node * get_term() <<
733 { <<
734 struct syntax_node *f1 = get_factor(); <<
735 return get_term_lr(f1); <<
736 } <<
737 <<
738 static struct syntax_node * get_term_lr(stru <<
739 { <<
740 if ( (data_lexer_to_parser.type == LEX_I <<
741 && ( (data_lexer_to_parser.operator <<
742 || (data_lexer_to_parser.opera <<
743 { <<
744 char op = get_op(); <<
745 struct syntax_node *factor = get_fac <<
746 struct syntax_node *node_op = alloc_ <<
747 return get_term_lr(node_op); <<
748 } <<
749 return n; <<
750 } <<
751 <<
752 static struct syntax_node * get_factor() <<
753 { 331 {
754 if ( (data_lexer_to_parser.type == LEX_I !! 332 sos_process_unref(proc_init);
755 && ( (data_lexer_to_parser.operator !! 333 return -SOS_ENOENT;
756 || (data_lexer_to_parser.opera <<
757 { char op = data_lexer_to_parser.opera <<
758 get_op(); return alloc_node_unarop(op, <<
759 else if (data_lexer_to_parser.type == LE <<
760 { <<
761 struct syntax_node *expr; <<
762 get_par(); <<
763 expr = get_expr(); <<
764 if (data_lexer_to_parser.type != LEX <<
765 parser_exception("Mismatched paren <<
766 get_par(); <<
767 return expr; <<
768 } <<
769 <<
770 return get_scalar(); <<
771 } 334 }
772 <<
773 static struct syntax_node * get_scalar() <<
774 { <<
775 if (data_lexer_to_parser.type != LEX_IS_ <<
776 { <<
777 char var[STR_VAR_MAXLEN]; <<
778 get_str(var); <<
779 return alloc_node_var(var); <<
780 } <<
781 return alloc_node_num(get_number()); <<
782 } <<
783 <<
784 <<
785 <<
786 <<
787 <<
788 <<
789 <<
790 sos_cpu_kstate_switch(& st_parser, st_lexer) <<
791 <<
792 <<
793 *syntax_tree = get_expr(); <<
794 <<
795 } <<
796 335
797 !! 336
798 !! 337 ustack = (SOS_PAGING_TOP_USER_ADDRESS - SOS_DEFAULT_USER_STACK_SIZE) + 1;
799 !! 338 retval = sos_dev_zero_map(as_init, &ustack, SOS_DEFAULT_USER_STACK_SIZE,
800 !! 339 SOS_VM_MAP_PROT_READ | SOS_VM_MAP_PROT_WRITE,
801 static struct syntax_node * parse_expression(c !! 340 0);
802 { !! 341 if (SOS_OK != retval)
803 struct syntax_node *retval = NULL; <<
804 <<
805 <<
806 sos_cpu_kstate_init(& st_reader, <<
807 (sos_cpu_kstate_function <<
808 (sos_ui32_t)expr, <<
809 (sos_vaddr_t)stack_reade <<
810 (sos_cpu_kstate_function <<
811 sos_cpu_kstate_init(& st_lexer, <<
812 (sos_cpu_kstate_function <<
813 0, <<
814 (sos_vaddr_t)stack_lexer <<
815 (sos_cpu_kstate_function <<
816 sos_cpu_kstate_init(& st_parser, <<
817 (sos_cpu_kstate_function <<
818 (sos_ui32_t) <<
819 (sos_vaddr_t)deep_stack, <<
820 (sos_cpu_kstate_function <<
821 <<
822 <<
823 sos_cpu_kstate_switch(& st_main, st_parser); <<
824 return retval; <<
825 } <<
826 <<
827 <<
828 <<
829 <<
830 <<
831 struct func_eval_params <<
832 { <<
833 const struct syntax_node *e; <<
834 const char **var_name; <<
835 int *var_val; <<
836 int nb_vars; <<
837 <<
838 int result; <<
839 }; <<
840 <<
841 static void func_eval(struct func_eval_params <<
842 { <<
843 <<
844 <<
845 static int rec_eval(const struct syntax_node <<
846 const char* var_name[], <<
847 { 342 {
848 switch (n->type) !! 343 sos_process_unref(proc_init);
849 { !! 344 return -SOS_ENOMEM;
850 case YY_IS_NUM: <<
851 return n->number; <<
852 <<
853 case YY_IS_VAR: <<
854 { <<
855 int i; <<
856 for (i = 0 ; i < nb_vars ; i++) <<
857 if (0 == strcmp(var_name[i], n-> <<
858 return var_val[i]; <<
859 <<
860 <<
861 sos_bochs_printf("ERROR: unknown v <<
862 sos_cpu_kstate_switch(& st_eval, s <<
863 } <<
864 <<
865 case YY_IS_BINOP: <<
866 { <<
867 int left = rec_eval(n->binop.parm_ <<
868 var_name, var_ <<
869 int right = rec_eval(n->binop.parm <<
870 var_name, var <<
871 switch (n->binop.op) <<
872 { <<
873 case '+': return left + right; <<
874 case '-': return left - right; <<
875 case '*': return left * right; <<
876 case '/': return left / right; <<
877 default: <<
878 <<
879 sos_bochs_printf("ERROR: unkno <<
880 sos_cpu_kstate_switch(& st_eva <<
881 } <<
882 } <<
883 <<
884 case YY_IS_UNAROP: <<
885 { <<
886 int arg = rec_eval(n->unarop.parm, <<
887 switch (n->unarop.op) <<
888 { <<
889 case '-': return -arg; <<
890 case '+': return arg; <<
891 default: <<
892 <<
893 sos_bochs_printf("ERROR: unkno <<
894 sos_cpu_kstate_switch(& st_eva <<
895 } <<
896 } <<
897 } <<
898 <<
899 <<
900 sos_bochs_printf("ERROR: invalid node ty <<
901 sos_cpu_kstate_switch(& st_eval, st_main <<
902 return -1; <<
903 } 345 }
904 346
905 !! 347
906 !! 348 new_thr = sos_create_user_thread(NULL,
907 !! 349 proc_init,
908 !! 350 start_uaddr,
909 !! 351 0, 0,
910 parms->result !! 352 ustack + SOS_DEFAULT_USER_STACK_SIZE - 4,
911 = rec_eval(parms->e, parms->var_name, parm !! 353 SOS_SCHED_PRIO_TS_LOWEST);
912 } !! 354 if (! new_thr)
913 <<
914 <<
915 <<
916 <<
917 <<
918 static int eval_expression(const struct syntax <<
919 const char* var_nam <<
920 { <<
921 struct func_eval_params p <<
922 = (struct func_eval_params){ .e=e, <<
923 .var_name=var <<
924 .var_val=var_ <<
925 .nb_vars=nb_v <<
926 .result = 0 } <<
927 <<
928 sos_cpu_kstate_init(& st_eval, <<
929 (sos_cpu_kstate_function <<
930 (sos_ui32_t) <<
931 (sos_vaddr_t)deep_stack, <<
932 (sos_cpu_kstate_function <<
933 <<
934 <<
935 sos_cpu_kstate_switch(& st_main, st_eval); <<
936 return p.result; <<
937 } <<
938 <<
939 <<
940 <<
941 <<
942 <<
943 static void func_free(struct syntax_node *n) <<
944 { <<
945 switch (n->type) <<
946 { 355 {
947 case YY_IS_NUM: !! 356 sos_process_unref(proc_init);
948 case YY_IS_VAR: !! 357 return -SOS_ENOMEM;
949 break; <<
950 <<
951 case YY_IS_BINOP: <<
952 func_free(n->binop.parm_left); <<
953 func_free(n->binop.parm_right); <<
954 break; <<
955 <<
956 case YY_IS_UNAROP: <<
957 func_free(n->unarop.parm); <<
958 break; <<
959 } 358 }
960 <<
961 sos_kfree((sos_vaddr_t)n); <<
962 } <<
963 <<
964 <<
965 <<
966 <<
967 <<
968 static void free_syntax_tree(struct syntax_nod <<
969 { <<
970 sos_cpu_kstate_init(& st_free, <<
971 (sos_cpu_kstate_function <<
972 (sos_ui32_t)tree, <<
973 (sos_vaddr_t)deep_stack, <<
974 (sos_cpu_kstate_function <<
975 359
976 !! 360 sos_process_unref(proc_init);
977 sos_cpu_kstate_switch(& st_main, st_free); !! 361 return SOS_OK;
978 } 362 }
979 363
980 364
981 365
982 366
983 367
984 void sos_main(unsigned long magic, unsigned lo !! 368 void sos_main(unsigned long magic, unsigned long arg)
985 { 369 {
986 unsigned i; 370 unsigned i;
987 sos_paddr_t sos_kernel_core_base_paddr, sos_ 371 sos_paddr_t sos_kernel_core_base_paddr, sos_kernel_core_top_paddr;
988 struct syntax_node *syntax_tree; !! 372 struct sos_time tick_resolution;
>> 373 struct sos_fs_manager_instance * rootfs;
989 374
990 !! 375
991 !! 376 unsigned long int upper_mem = 0;
992 <<
993 multiboot_info_t *mbi; <<
994 mbi = (multiboot_info_t *) addr; <<
995 377
996 378
997 sos_bochs_setup(); 379 sos_bochs_setup();
998 380
999 sos_x86_videomem_setup(); 381 sos_x86_videomem_setup();
1000 sos_x86_videomem_cls(SOS_X86_VIDEO_BG_BLUE) 382 sos_x86_videomem_cls(SOS_X86_VIDEO_BG_BLUE);
1001 383
1002 384
1003 if (magic == MULTIBOOT_BOOTLOADER_MAGIC) 385 if (magic == MULTIBOOT_BOOTLOADER_MAGIC)
1004 !! 386 {
1005 sos_x86_videomem_printf(1, 0, !! 387
1006 SOS_X86_VIDEO_FG_ !! 388
1007 "Welcome From GRU !! 389
1008 "SOS", ',', !! 390 multiboot_info_t *mbi = (multiboot_info_t *) arg;
1009 (unsigned)(mbi->m !! 391
1010 (unsigned)mbi->me !! 392
>> 393
>> 394
>> 395
>> 396 upper_mem = mbi->mem_upper;
>> 397 sos_x86_videomem_printf(1, 0,
>> 398 SOS_X86_VIDEO_FG_YELLOW | SOS_X86_VIDEO_BG_BLUE,
>> 399 "Welcome From GRUB to %s%c RAM is %dMB (upper mem = 0x%x kB)",
>> 400 "SOS article 8", ',',
>> 401 (unsigned)(upper_mem >> 10) + 1,
>> 402 (unsigned)upper_mem);
>> 403 }
>> 404 else if (magic == 0x42244224)
>> 405 {
>> 406
>> 407 upper_mem = arg;
>> 408 sos_x86_videomem_printf(1, 0,
>> 409 SOS_X86_VIDEO_FG_YELLOW | SOS_X86_VIDEO_BG_BLUE,
>> 410 "Welcome to %s%c RAM is %dMB (upper mem = 0x%x kB)",
>> 411 "SOS article 8", ',',
>> 412 (unsigned)(upper_mem >> 10) + 1,
>> 413 (unsigned)upper_mem);
>> 414 }
1011 else 415 else
1012 !! 416
1013 sos_x86_videomem_printf(1, 0, 417 sos_x86_videomem_printf(1, 0,
1014 SOS_X86_VIDEO_FG_ 418 SOS_X86_VIDEO_FG_YELLOW | SOS_X86_VIDEO_BG_BLUE,
1015 "Welcome to SOS") !! 419 "Welcome to SOS article 8");
1016 420
1017 sos_bochs_putstring("Message in a bochs\n") !! 421 sos_bochs_putstring("Message in a bochs: This is SOS article 8.\n");
1018 422
1019 423
1020 sos_gdt_subsystem_setup(); 424 sos_gdt_subsystem_setup();
1021 sos_idt_subsystem_setup(); 425 sos_idt_subsystem_setup();
1022 426
1023 427
1024 sos_exception_subsystem_setup(); 428 sos_exception_subsystem_setup();
1025 sos_irq_subsystem_setup(); 429 sos_irq_subsystem_setup();
1026 430
1027 431
1028 sos_i8254_set_frequency(100); 432 sos_i8254_set_frequency(100);
1029 433
1030 !! 434
1031 if (magic != MULTIBOOT_BOOTLOADER_MAGIC) !! 435
>> 436 tick_resolution = (struct sos_time) { .sec=0, .nanosec=10000000UL };
>> 437 sos_time_subsysem_setup(& tick_resolution);
>> 438
>> 439
>> 440 if (upper_mem == 0)
1032 { 441 {
1033 sos_x86_videomem_putstring(20, 0, 442 sos_x86_videomem_putstring(20, 0,
1034 SOS_X86_VIDE 443 SOS_X86_VIDEO_FG_LTRED
1035 | SOS_X86_ 444 | SOS_X86_VIDEO_BG_BLUE
1036 | SOS_X86_ 445 | SOS_X86_VIDEO_FG_BLINKING,
1037 "I'm not loa !! 446 "I don't know RAM size ! Load me with Grub...");
1038 447
1039 for (;;) 448 for (;;)
1040 continue; 449 continue;
1041 } 450 }
1042 451
1043 452
1044 453
1045 454
1046 455
1047 456
1048 sos_irq_set_routine(SOS_IRQ_TIMER, 457 sos_irq_set_routine(SOS_IRQ_TIMER,
1049 clk_it); 458 clk_it);
1050 459
1051 460
1052 461
1053 462
1054 463
1055 !! 464 SOS_ASSERT_FATAL(SOS_OK
1056 !! 465 == sos_physmem_subsystem_setup((upper_mem<<10) + (1<<20),
1057 !! 466 &sos_kernel_core_base_paddr,
1058 sos_physmem_subsystem_setup((mbi->mem_upper !! 467 &sos_kernel_core_top_paddr));
1059 & sos_kernel_co <<
1060 & sos_kernel_co <<
1061 468
1062 469
1063 470
1064 471
1065 472
1066 473
1067 474
1068 SOS_ASSERT_FATAL(SOS_OK == 475 SOS_ASSERT_FATAL(SOS_OK ==
1069 sos_paging_subsystem_setup 476 sos_paging_subsystem_setup(sos_kernel_core_base_paddr,
1070 477 sos_kernel_core_top_paddr));
1071 478
1072 479
1073 sos_exception_set_routine(SOS_EXCEPT_PAGE_F 480 sos_exception_set_routine(SOS_EXCEPT_PAGE_FAULT,
1074 pgflt_ex); 481 pgflt_ex);
1075 482
1076 483
1077 484
1078 !! 485
1079 486
1080 if (sos_kmem_vmm_subsystem_setup(sos_kernel 487 if (sos_kmem_vmm_subsystem_setup(sos_kernel_core_base_paddr,
1081 sos_kernel 488 sos_kernel_core_top_paddr,
1082 bootstrap_ 489 bootstrap_stack_bottom,
1083 bootstrap_ 490 bootstrap_stack_bottom
1084 + bootstra 491 + bootstrap_stack_size))
1085 sos_bochs_printf("Could not setup the Ker 492 sos_bochs_printf("Could not setup the Kernel virtual space allocator\n");
1086 493
1087 if (sos_kmalloc_subsystem_setup()) 494 if (sos_kmalloc_subsystem_setup())
1088 sos_bochs_printf("Could not setup the Kma 495 sos_bochs_printf("Could not setup the Kmalloc subsystem\n");
1089 496
1090 497
1091 !! 498
1092 <<
1093 499
1094 asm volatile ("sti\n"); !! 500 sos_mm_context_subsystem_setup();
1095 501
1096 502
1097 !! 503
1098 504
1099 print_hello_world(); !! 505 sos_cpu_context_subsystem_setup();
1100 <<
1101 506
1102 507
1103 !! 508
1104 509
1105 sos_x86_videomem_printf(4, 0, !! 510 sos_swintr_subsystem_setup();
1106 SOS_X86_VIDEO_BG_BL <<
1107 "Coroutine test"); <<
1108 sos_x86_videomem_printf(5, 0, <<
1109 SOS_X86_VIDEO_BG_BL <<
1110 "Parsing..."); <<
1111 syntax_tree = parse_expression(" - ( (69/ <<
1112 511
1113 if (syntax_tree != NULL) <<
1114 { <<
1115 sos_x86_videomem_printf(6, 0, <<
1116 SOS_X86_VIDEO_B <<
1117 "Evaluating..." <<
1118 sos_x86_videomem_printf(7, 0, <<
1119 SOS_X86_VIDEO_B <<
1120 "Result=%d (if <<
1121 eval_expression <<
1122 <<
1123 <<
1124 <<
1125 free_syntax_tree(syntax_tree); <<
1126 sos_x86_videomem_printf(8, 0, <<
1127 SOS_X86_VIDEO_B <<
1128 "Done (un-alloc <<
1129 } <<
1130 else <<
1131 { <<
1132 sos_x86_videomem_printf(6, 0, <<
1133 SOS_X86_VIDEO_B <<
1134 "Error in parsi <<
1135 } <<
1136 512
1137 513
1138 !! 514
1139 515
1140 test_demand_paging(234567, 500); !! 516
>> 517
>> 518 sos_thread_subsystem_setup(bootstrap_stack_bottom,
>> 519 bootstrap_stack_size);
>> 520
>> 521
>> 522 sos_sched_subsystem_setup();
>> 523
>> 524
>> 525 SOS_ASSERT_FATAL(sos_create_kernel_thread("idle", idle_thread, NULL,
>> 526 SOS_SCHED_PRIO_TS_LOWEST) != NULL);
>> 527
>> 528
>> 529 sos_load_subsystem_setup();
>> 530
>> 531
>> 532 SOS_ASSERT_FATAL(sos_create_kernel_thread("stat_thread", stat_thread,
>> 533 NULL,
>> 534 SOS_SCHED_PRIO_TS_LOWEST) != NULL);
1141 535
1142 536
1143 537
1144 !! 538
1145 <<
1146 539
1147 test_backtrace(6, 0xdeadbeef, bootstrap_sta !! 540 sos_umem_vmm_subsystem_setup();
>> 541 sos_dev_zero_subsystem_setup();
1148 542
1149 543
1150 !! 544
1151 545
>> 546 sos_process_subsystem_setup();
1152 547
1153 548
1154 !! 549
1155 for (;;) !! 550
1156 { !! 551 asm volatile ("sti\n");
1157 <<
1158 <<
1159 asm("hlt\n"); <<
1160 552
1161 continue; !! 553
1162 } !! 554 SOS_ASSERT_FATAL(SOS_OK == sos_fs_virtfs_subsystem_setup());
>> 555 SOS_ASSERT_FATAL(SOS_OK == sos_fs_subsystem_setup(NULL,
>> 556 "virtfs",
>> 557 NULL,
>> 558 & rootfs));
>> 559
>> 560
>> 561
>> 562
>> 563 start_init(rootfs);
>> 564
>> 565
>> 566
>> 567
>> 568
>> 569
>> 570
>> 571
>> 572
>> 573
>> 574
>> 575
>> 576 sos_bochs_printf("Bye from primary thread !\n");
>> 577 sos_thread_exit();
>> 578 SOS_FATAL_ERROR("No trespassing !");
1163 } 579 }