optimize the menuconfig redrawing
[lunaix-os.git] / lunaix-os / arch / x86 / boot / i386 / prologue32.S
1 /* 高半核入口点 - 0xC0000000 */
2
3 #define __ASM__
4 #include <sys/abi.h>
5 #include <sys/failsafe.h>
6
7 .section .bss.kstack
8     .global __kinit_stack_end
9     
10     .align 16
11     __kinit_stack_end:
12         .skip 2048, 0
13     __kinit_stack_top:
14
15
16 .section .text
17     .global hhk_entry_
18     hhk_entry_:
19         /*
20             欢迎来到虚拟内存的世界! :D
21          */
22         movl $__kinit_stack_top, %esp
23         andl $stack_alignment, %esp
24
25         movl $__kinit_stack_end, %eax
26         movl $STACK_SANITY, (%eax)
27         movl $STACK_SANITY, 4(%eax)
28         movl $STACK_SANITY, 8(%eax)
29         movl $STACK_SANITY, 12(%eax)
30
31         subl $16, %esp
32
33         /* 
34             加载 GDT 
35             P.s. 虽然GDT在分页后已变得不重要,甚至可以忽略不作。但为了保持完整性,还是选择加载他
36                     这主要是为了保险起见,让GDTR有一个合法的值,否则多咱的粗心大意,容易出#GP
37         */
38         call _init_gdt
39
40         movl $_gdt, 2(%esp)
41         movw _gdt_limit, %ax
42         movw %ax, (%esp)
43         lgdt (%esp)
44
45         /* 更新段寄存器 */
46         movw $KDATA_SEG, %cx
47         movw %cx, %es
48         movw %cx, %ds
49         movw %cx, %fs
50         movw %cx, %gs
51         movw %cx, %ss
52         
53         /* 更新 CS:EIP */
54         pushl $KCODE_SEG
55         pushl $_after_gdt
56         retf
57
58     _after_gdt:
59         subl $16, %esp
60
61         # 加载 IDT
62         movl $_idt, 2(%esp)
63         movw _idt_limit, %ax
64         movw %ax, (%esp)
65         lidt (%esp)
66
67         # perform arch-specific initialization before diving into kernel
68         call arch_preinit
69
70         /* 加载TSS段选择器 */
71         movw $TSS_SEG, %ax
72         ltr %ax
73
74         movl $bhctx_buffer, (%esp)       # mb_parser.c
75         call kernel_bootstrap
76
77     1:
78         hlt
79         jmp 1b