Changeset 29 for trunk/hal/x86_64/hal_boot.S
- Timestamp:
- Jun 21, 2017, 8:35:30 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/hal/x86_64/hal_boot.S
r25 r29 2 2 * hal_boot.S - Kernel boot entry point 3 3 * 4 * Author Maxime Villard (2017) 5 * This code is inspired a lot from the NetBSD boot procedure, 6 * written by Maxime Villard too. 7 * 8 * Copyright (c) UPMC Sorbonne Universites 9 * 10 * This file is part of ALMOS-kernel. 11 * 12 * ALMOS-kernel is free software; you can redistribute it and/or modify it 4 * Copyright (c) 2017 Maxime Villard 5 * This code is inspired a lot from the NetBSD boot procedure, written by 6 * Maxime Villard too. XXX copyright 7 * 8 * This file is part of ALMOS-MKH. 9 * 10 * ALMOS-MKH is free software; you can redistribute it and/or modify it 13 11 * under the terms of the GNU General Public License as published by 14 12 * the Free Software Foundation; version 2.0 of the License. 15 13 * 16 * ALMOS- kernelis distributed in the hope that it will be useful, but14 * ALMOS-MKH is distributed in the hope that it will be useful, but 17 15 * WITHOUT ANY WARRANTY; without even the implied warranty of 18 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU … … 20 18 * 21 19 * You should have received a copy of the GNU General Public License 22 * along with ALMOS- kernel; if not, write to the Free Software Foundation,20 * along with ALMOS-MKH.; if not, write to the Free Software Foundation, 23 21 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 24 22 */ 25 23 24 #define x86_ASM 26 25 #include <hal_boot.h> 27 26 #include <hal_register.h> … … 99 98 2: ; 100 99 100 /* 101 * killkpt - Destroy a kernel page table (long mode) 102 * rbx = page table address 103 * rcx = number of pages to destroy 104 */ 105 #define killkpt \ 106 1: movq $0,(%rbx) ; \ 107 addq $PDE_SIZE,%rbx ; \ 108 loop 1b ; 109 101 110 /* 32bit version of PG_NX */ 102 111 #define PG_NX32 0x80000000 … … 106 115 .globl start_x86_64 107 116 .globl L4paddr 117 .globl iom_base 108 118 109 119 /* … … 125 135 .type L4paddr, @object 126 136 L4paddr: .quad 0 /* paddr of L4 */ 137 138 .type iom_base, @object 139 iom_base: .quad 0 /* virt. addr. of ISA I/O MEM */ 140 127 141 128 142 #define GDT64_LIMIT gdt64_end-gdt64_start-1 … … 152 166 farjmp64: 153 167 .long RELOC(longmode) 154 .word G SEL(GCODE_SEL, SEL_KPL)168 .word GDT_FIXED_SEL(GDT_KCODE_SEL, SEL_KPL) 155 169 .align 64 156 170 … … 169 183 170 184 /* Make sure it is a multiboot-compliant bootloader. */ 171 cmpl $MULTIBOOT_INFO_MAGIC,%eax172 jne boot_panic185 // cmpl $MULTIBOOT_INFO_MAGIC,%eax 186 // jne boot_panic 173 187 174 188 movl $RELOC(tmpstk),%esp … … 246 260 subl %eax,%ecx 247 261 shrl $PGSHIFT,%ecx 248 orl $(PG_V|PG_KR ),%eax262 orl $(PG_V|PG_KR|PG_G),%eax 249 263 fillkpt 250 264 … … 254 268 subl %eax,%ecx 255 269 shrl $PGSHIFT,%ecx 256 orl $(PG_V|PG_KW ),%eax270 orl $(PG_V|PG_KW|PG_G),%eax 257 271 fillkpt_nox 258 272 … … 261 275 movl $TABLESIZE,%ecx /* length of BOOTSTRAP TABLES */ 262 276 shrl $PGSHIFT,%ecx 263 orl $(PG_V|PG_KW ),%eax277 orl $(PG_V|PG_KW|PG_G),%eax 264 278 fillkpt_nox 265 279 … … 268 282 movl $IOM_SIZE,%ecx /* size of ISA I/O MEM */ 269 283 shrl $PGSHIFT,%ecx 270 orl $(PG_V|PG_KW /*|PG_N*/),%eax284 orl $(PG_V|PG_KW|PG_G),%eax 271 285 fillkpt_nox 272 286 … … 335 349 */ 336 350 movl %cr4,%eax 337 orl $(CR4_PAE|CR4_OSFXSR|CR4_OSXMMEXCPT ),%eax351 orl $(CR4_PAE|CR4_OSFXSR|CR4_OSXMMEXCPT|CR4_PGE),%eax 338 352 movl %eax,%cr4 339 353 … … 381 395 */ 382 396 movabsq $longmode_hi,%rax 383 jmp *%rax /* XXX XXX: <------ this instruction faults */397 jmp *%rax 384 398 385 399 longmode_hi: … … 397 411 movq $KERNBASE,%r8 398 412 399 400 /* 401 * STOP HERE FOR NOW 402 */ 403 1: nop 404 jmp 1b 405 406 407 boot_panic: 408 jmp boot_panic 409 413 #if L2_SLOT_KERNBASE > 0 414 movq $(NKL2_KIMG_ENTRIES+1),%rcx 415 leaq (PROC0_PTP2_OFF)(%rsi),%rbx /* old, phys address */ 416 addq %r8,%rbx /* new, virt address */ 417 killkpt 418 #endif 419 420 #if L3_SLOT_KERNBASE > 0 421 movq $NKL3_KIMG_ENTRIES,%rcx 422 leaq (PROC0_PTP3_OFF)(%rsi),%rbx /* old, phys address */ 423 addq %r8,%rbx /* new, virt address */ 424 killkpt 425 #endif 426 427 movq $NKL4_KIMG_ENTRIES,%rcx 428 leaq (PROC0_PML4_OFF)(%rsi),%rbx /* old, phys address of PML4 */ 429 addq %r8,%rbx /* new, virt address of PML4 */ 430 killkpt 431 432 /* Relocate atdevbase. */ 433 movq $(TABLESIZE+KERNBASE),%rdx 434 addq %rsi,%rdx 435 movq %rdx,iom_base(%rip) 436 437 /* Set up bootstrap stack. */ 438 leaq (PROC0_STK_OFF)(%rsi),%rax 439 addq %r8,%rax 440 leaq (STKSIZE)(%rax),%rsp 441 xorq %rbp,%rbp /* mark end of frames */ 442 443 xorw %ax,%ax 444 movw %ax,%gs 445 movw %ax,%fs 446 447 /* The first physical page available. */ 448 leaq (TABLESIZE)(%rsi),%rdi 449 450 call init_x86_64 451
Note: See TracChangeset
for help on using the changeset viewer.