Changeset b112055 in mainline
- Timestamp:
- 2011-08-17T19:10:44Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f4fa6d9
- Parents:
- 16dc887
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/ia32/src/boot/boot.S
r16dc887 rb112055 140 140 jmp hlt0 141 141 142 /** Calculate unmapped address of the end of the kernel. */ 143 calc_end_of_kernel: 144 movl $hardcoded_load_address, %edi 145 andl $0x7fffffff, %edi 146 movl (%edi), %esi 147 andl $0x7fffffff, %esi 148 149 movl $hardcoded_ktext_size, %edi 150 andl $0x7fffffff, %edi 151 addl (%edi), %esi 152 andl $0x7fffffff, %esi 153 154 movl $hardcoded_kdata_size, %edi 155 andl $0x7fffffff, %edi 156 addl (%edi), %esi 157 andl $0x7fffffff, %esi 158 movl %esi, end_of_kernel 159 ret 160 161 /** Find free 2M (+4k for alignment) region where to store page tables */ 162 find_mem_for_pt: 163 /* Check if multiboot info is present */ 164 cmpl $0x2BADB002, grub_eax 165 je check_multiboot_map 166 ret 167 check_multiboot_map: 168 /* Copy address of the multiboot info to ebx */ 169 movl grub_ebx, %ebx 170 /* Check if memory map flag is present */ 171 movl (%ebx), %edx 172 andl $(1 << 6), %edx 173 jnz use_multiboot_map 174 ret 175 use_multiboot_map: 176 /* Copy address of the memory map to edx */ 177 movl 48(%ebx), %edx 178 movl %edx, %ecx 179 addl 44(%ebx), %ecx 180 /* Find a free region at least 2M in size */ 181 check_memmap_loop: 182 /* Is this a free region? */ 183 cmp $1, 20(%edx) 184 jnz next_region 185 /* Check size */ 186 cmp $0, 16(%edx) 187 jnz next_region 188 cmpl $(2 * 1024 * 1024 + 4 * 1024), 12(%edx) 189 jbe next_region 190 cmp $0, 8(%edx) 191 jz found_region 192 next_region: 193 cmp %ecx, %edx 194 jbe next_region_do 195 ret 196 next_region_do: 197 addl (%edx), %edx 198 addl $4, %edx 199 jmp check_memmap_loop 200 found_region: 201 /* Use end of the found region */ 202 mov 4(%edx), %ecx 203 add 12(%edx), %ecx 204 sub $(2 * 1024 * 1024), %ecx 205 mov %ecx, free_area 206 ret 207 208 142 209 /** Setup mapping for the kernel. 143 210 * … … 148 215 .global map_kernel 149 216 map_kernel: 217 /* Paging features */ 150 218 movl %cr4, %ecx 151 orl $(1 << 4), %ecx /* PSE on */152 219 andl $(~(1 << 5)), %ecx /* PAE off */ 153 220 movl %ecx, %cr4 154 221 222 call calc_end_of_kernel 223 call find_mem_for_pt 224 mov end_of_kernel, %esi 225 mov free_area, %ecx 226 cmpl %esi, %ecx 227 jbe use_end_of_kernel 228 mov %ecx, %esi 229 /* Align address down to 4k */ 230 andl $(~4095), %esi 231 use_end_of_kernel: 232 233 /* Align address to 4k */ 234 addl $4095, %esi 235 andl $(~4095), %esi 236 237 /* Allocate space for page tables*/ 238 movl %esi, pt_loc 239 movl $ballocs, %edi 240 andl $0x7fffffff, %edi 241 movl %esi, (%edi) 242 addl $4, %edi 243 movl $(2*1024*1024), (%edi) 244 245 /* Fill page tables */ 246 xorl %ecx, %ecx 247 xorl %ebx, %ebx 248 249 floop_pt: 250 movl $((1 << 1) | (1 << 0)), %eax 251 orl %ebx, %eax 252 movl %eax, (%esi, %ecx, 4) 253 addl $(4 * 1024), %ebx 254 255 incl %ecx 256 cmpl $(512 * 1024), %ecx 257 jl floop_pt 258 259 /* Fill page directory */ 155 260 movl $(page_directory + 0), %esi 156 261 movl $(page_directory + 2048), %edi 157 262 xorl %ecx, %ecx 158 xorl %ebx, %ebx263 movl pt_loc, %ebx 159 264 160 265 floop: 161 movl $((1 << 7) | (1 <<1) | (1 << 0)), %eax266 movl $((1 << 1) | (1 << 0)), %eax 162 267 orl %ebx, %eax 163 268 /* Mapping 0x00000000 + %ecx * 4M => 0x00000000 + %ecx * 4M */ … … 165 270 /* Mapping 0x80000000 + %ecx * 4M => 0x00000000 + %ecx * 4M */ 166 271 movl %eax, (%edi, %ecx, 4) 167 addl $(4 * 1024 * 1024), %ebx272 addl $(4 * 1024), %ebx 168 273 169 274 incl %ecx … … 523 628 524 629 grub_ebx: 630 .long 0 631 632 pt_loc: 633 .long 0 634 end_of_kernel: 635 .long 0 636 free_area: 525 637 .long 0 526 638
Note:
See TracChangeset
for help on using the changeset viewer.