*--------------------------------------------------------------------------
*/
#define ASM
+
#include "boot.h"
-#include "system.h"
#include "task.h"
.global kernel_entry
.extern setup_kernel
.extern root_task
.extern root_task_entry
+.extern kernel_virtual_addr_start
#define MULTIBOOT_STACK_SIZE 0x4000
# Save Multiboot Infomation...
pushl %eax
- addl $KRNLADDR,%ebx
+ addl $kernel_virtual_addr_start,%ebx
pushl %ebx
call boot_paging
- #movl $init_pgd-KRNLADDR,%ebx
- #movl %ebx,%cr3
-
# enable PG WP
movl %cr0,%eax
orl $0x80010000,%eax
jmp 4f
4:
# 准备切保护模式
+
# 此时esp的地址还需要再调整一下
- addl $KRNLADDR, %esp
- ljmp $0x08,$p_label+KRNLADDR
+ addl $kernel_virtual_addr_start, %esp
+
+
+ # 由于编译器不支持下面这种写法
+ # ljmp $0x08, $p_label + kernel_virtual_addr_start
+
+ # 所以采用下面的方法跳转
+ leal p_label,%eax
+ addl $kernel_virtual_addr_start, %eax
+ movl %eax, p_label_far_ptr
+ ljmp *p_label_far_ptr
p_label:
leal check_kernel, %eax
die:
jmp die # Should never come to here.
+
+.align 4
+p_label_far_ptr:
+ .long 0x00
+ .word 0x08, 0x00
+
.align 32
boot_gdt:
empty: .long 0x00000000, 0x00000000
boot_gdtr_limit: .word boot_gdt_end-boot_gdt
boot_gdtr_base: .long boot_gdt
- .comm stack, MULTIBOOT_STACK_SIZE
+.comm stack, MULTIBOOT_STACK_SIZE