Mercurial > hg > Members > taiki > original_os
comparison bootstrap.S @ 10:50e4b9ca4867
add bootstrap source. Go to 64bit mode.
author | Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 27 Aug 2012 23:45:31 +0900 |
parents | bd2f9ba6f5f8 |
children | 26b76ada8c13 |
comparison
equal
deleted
inserted
replaced
9:bd2f9ba6f5f8 | 10:50e4b9ca4867 |
---|---|
2 * This program is boot to kernel. | 2 * This program is boot to kernel. |
3 * Change mode to 64bit mode and go to CbC kernel. | 3 * Change mode to 64bit mode and go to CbC kernel. |
4 */ | 4 */ |
5 | 5 |
6 #include "multiboot2.h" | 6 #include "multiboot2.h" |
7 #include "boot_header.h" | |
7 | 8 |
8 .file "bootstrap.S" | 9 .file "bootstrap.S" |
9 | 10 |
10 .text | 11 .text |
11 .code32 | 12 .code32 |
53 /* | 54 /* |
54 * Initialize page tables to 0 | 55 * Initialize page tables to 0 |
55 * 6144 = 512*8*6/4 | 56 * 6144 = 512*8*6/4 |
56 */ | 57 */ |
57 | 58 |
59 movl $0x01fe9000, %ebx | |
58 leal pgtable(%ebx), %edi | 60 leal pgtable(%ebx), %edi |
59 xorl %eax, %eax | 61 xorl %eax, %eax |
60 movl $6144, %ecx | 62 movl $6144, %ecx |
61 rep stosl | 63 rep stosl |
62 | 64 |
63 /* Build Level 4 */ | 65 /* Build Level 4 */ |
64 leal pgtable + 0(%ebx), %edi | 66 leal pgtable + 0(%ebx), %edi |
65 leal 0x1007(%edi), %eax | 67 leal 0x1007(%edi), %eax |
66 movl %eax, 0(%edi) | 68 movl %eax, 0(%edi) |
67 | 69 |
70 /* Build Level 3 */ | |
71 leal pgtable + 0x1000(%ebx), %edi | |
72 leal 0x1007(%edi), %eax | |
73 movl $4, %ecx | |
74 1: movl %eax, 0x00(%edi) | |
75 addl $0x00001000, %eax | |
76 addl $8, %edi | |
77 decl %ecx | |
78 jnz 1b | |
68 | 79 |
80 /* Build level 2 */ | |
81 leal pgtable + 0x2000(%ebx), %edi | |
82 movl $0x00000183, %eax | |
83 movl $2048, %ecx | |
84 1: movl %eax, 0(%edi) | |
85 addl $0x00200000, %eax | |
86 addl $8, %edi | |
87 decl %ecx | |
88 jnz 1b | |
89 | |
90 /* Enable the boot page talbes */ | |
91 leal pgtable(%ebx), %eax | |
92 movl %eax, %cr3 | |
93 | |
94 /* Enable Long mode */ | |
95 movl $MSR_EFER, %ecx | |
96 rdmsr | |
97 btsl $EFER_LME, %eax | |
98 wrmsr | |
99 | |
100 | |
69 jmp start_kernel | 101 jmp start_kernel |
70 | 102 |
103 | |
104 /* jump to kernel. | |
105 * push ebx and eax send argument to kernel. | |
106 */ | |
71 start_kernel: | 107 start_kernel: |
72 pushl %ebx | 108 pushl %ebx |
73 pushl %eax | 109 pushl %eax |
74 call kmain | 110 call kmain |
75 | 111 |