Kernel: x86_64 boot script now makes GDT with null, kernel code and data
This commit is contained in:
parent
ba8c4dbc7f
commit
7f8cad83b1
|
@ -10,19 +10,6 @@
|
||||||
.set PG_READ_WRITE, 1<<1
|
.set PG_READ_WRITE, 1<<1
|
||||||
.set PG_PAGE_SIZE, 1<<7
|
.set PG_PAGE_SIZE, 1<<7
|
||||||
|
|
||||||
# GDT access byte
|
|
||||||
.set GDT_A_A, 1<<40
|
|
||||||
.set GDT_A_RW, 1<<41
|
|
||||||
.set GDT_A_DC, 1<<42
|
|
||||||
.set GDT_A_E, 1<<43
|
|
||||||
.set GDT_A_S, 1<<44
|
|
||||||
.set GDT_A_DPL, 1<<45
|
|
||||||
.set GDT_A_P, 1<<47
|
|
||||||
# GDT flags
|
|
||||||
.set GDT_F_L, 1<<53
|
|
||||||
.set GDT_F_DB, 1<<54
|
|
||||||
.set GDT_F_G, 1<<55
|
|
||||||
|
|
||||||
.code32
|
.code32
|
||||||
|
|
||||||
# Multiboot header
|
# Multiboot header
|
||||||
|
@ -40,9 +27,11 @@
|
||||||
|
|
||||||
.section .bss, "aw", @nobits
|
.section .bss, "aw", @nobits
|
||||||
# Create stack
|
# Create stack
|
||||||
stack_bottom:
|
.global g_boot_stack_bottom
|
||||||
|
g_boot_stack_bottom:
|
||||||
.skip 16384
|
.skip 16384
|
||||||
stack_top:
|
.global g_boot_stack_top
|
||||||
|
g_boot_stack_top:
|
||||||
|
|
||||||
.global g_kernel_cmdline
|
.global g_kernel_cmdline
|
||||||
g_kernel_cmdline:
|
g_kernel_cmdline:
|
||||||
|
@ -73,8 +62,9 @@ g_multiboot_magic:
|
||||||
.skip 8
|
.skip 8
|
||||||
|
|
||||||
boot_gdt:
|
boot_gdt:
|
||||||
.quad 0 # null descriptor
|
.quad 0x0000000000000000 # null descriptor
|
||||||
.quad (GDT_F_G | GDT_F_L ) | (GDT_A_P | (0 * GDT_A_DPL) | GDT_A_S | GDT_A_E | GDT_A_RW) | (0xF << 48 | 0xFFFF) # kernel code
|
.quad 0x00AF9A000000FFFF # kernel code
|
||||||
|
.quad 0x00AF92000000FFFF # kernel data
|
||||||
boot_gdtr:
|
boot_gdtr:
|
||||||
.short . - boot_gdt - 1
|
.short . - boot_gdt - 1
|
||||||
.quad boot_gdt
|
.quad boot_gdt
|
||||||
|
@ -171,7 +161,7 @@ initialize_paging:
|
||||||
.type _start, @function
|
.type _start, @function
|
||||||
_start:
|
_start:
|
||||||
# Initialize stack and multiboot info
|
# Initialize stack and multiboot info
|
||||||
movl $stack_top, %esp
|
movl $g_boot_stack_top, %esp
|
||||||
movl %eax, g_multiboot_magic
|
movl %eax, g_multiboot_magic
|
||||||
movl %ebx, g_multiboot_info
|
movl %ebx, g_multiboot_info
|
||||||
|
|
||||||
|
@ -187,9 +177,11 @@ _start:
|
||||||
|
|
||||||
.code64
|
.code64
|
||||||
long_mode:
|
long_mode:
|
||||||
# clear segment registers
|
movw $0x10, %ax
|
||||||
movw $0x00, %ax
|
|
||||||
movw %ax, %ss
|
movw %ax, %ss
|
||||||
|
|
||||||
|
# clear segment registers (unused in x86_64?)
|
||||||
|
movw $0x00, %ax
|
||||||
movw %ax, %ds
|
movw %ax, %ds
|
||||||
movw %ax, %es
|
movw %ax, %es
|
||||||
movw %ax, %fs
|
movw %ax, %fs
|
||||||
|
|
Loading…
Reference in New Issue