123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218 |
- .section .text
- .global _start
- _start:
-
- mov $0x10, %ax
- mov %ax, %ds
- mov %ax, %es
- mov %ax, %fs
- mov %ax, %ss
- mov $0x7e00, %esp
- lgdt GDT_POINTER(%rip)
- lidt IDT_POINTER(%rip)
- mov $0x10, %ax
- mov %ax, %ds
- mov %ax, %es
- mov %ax, %fs
- mov %ax, %ss
- mov %ax, %gs
- movq $0x7e00, %rsp
- movq $0x101000, %rax
- movq %rax, %cr3
- movq switch_seg(%rip), %rax
-
-
- pushq $0x08
- pushq %rax
- lretq
- switch_seg:
- .quad entry64
- entry64:
- movq $0x10, %rax
- movq %rax, %ds
- movq %rax, %es
- movq %rax, %gs
- movq %rax, %ss
- movq $0xffff800000007e00, %rsp
- setup_IDT:
- leaq m_ignore_int(%rip), %rdx
- movq $(0x08 << 16), %rax
- movw %dx, %ax
- movq $ (0x8e00 << 32), %rcx
- addq %rcx, %rax
-
- movl %edx, %ecx
- shrl $16, %ecx
- shlq $48, %rcx
- addq %rcx, %rax
- shrq $32, %rdx
- leaq IDT_Table(%rip), %rdi
- mov $256, %rcx
- repeat_set_idt:
-
- movq %rax, (%rdi)
- movq %rdx, 8(%rdi)
- addq $0x10, %rdi
- dec %rcx
- jne repeat_set_idt
- SetUp_TSS64:
-
-
- leaq TSS64_Table(%rip), %rdx
- xorq %rax, %rax
- xorq %rcx, %rcx
-
- movq $0x89, %rax
- shlq $40, %rax
-
- movl %edx, %ecx
- shrl $24, %ecx
- shlq $56, %rcx
- addq %rcx, %rax
- xorq %rcx, %rcx
-
- movl %edx, %ecx
- andl $0xffffff, %ecx
- shlq $16, %rcx
- addq %rcx, %rax
- addq $103, %rax
- leaq GDT_Table(%rip), %rdi
- movq %rax, 64(%rdi)
- shrq $32, %rdx
- movq %rdx, 72(%rdi)
-
-
-
-
- movq go_to_kernel(%rip), %rax
- pushq $0x08
- pushq %rax
- lretq
- go_to_kernel:
- .quad Start_Kernel
- m_ignore_int:
- movq go_to_ignore_int(%rip), %rax
- pushq $0x08
- pushq %rax
- lretq
- lretq
- go_to_ignore_int:
- .quad ignore_int
- .align 8
- .org 0x1000
- __PML4E:
- .quad 0x102007
- .fill 255,8,0
- .quad 0x102007
- .fill 255,8,0
- .org 0x2000
- __PDPTE:
- .quad 0x103003
- .fill 511,8,0
- .org 0x3000
- __PDE:
- .quad 0x000083
- .quad 0x200083
- .quad 0x400083
- .quad 0x600083
- .quad 0x800083
- .quad 0xe0000083
- .quad 0xe0200083
- .quad 0xe0400083
- .quad 0xe0600083
- .quad 0xe0800083
- .quad 0xe0a00083
- .quad 0xe0c00083
- .quad 0xe0e00083
- .fill 499,8,0
- .section .data
- .global GDT_Table
- GDT_Table:
- .quad 0x0000000000000000
- .quad 0x0020980000000000
- .quad 0x0000920000000000
- .quad 0x0020f80000000000
- .quad 0x0000f20000000000
- .quad 0x00cf9a000000ffff
- .quad 0x00cf92000000ffff
- .fill 10, 8, 0
- GDT_END:
- GDT_POINTER:
- GDT_LIMIT: .word GDT_END - GDT_Table - 1
- GDT_BASE: .quad GDT_Table
- .global IDT_Table
- IDT_Table:
- .fill 512, 8, 0
- IDT_END:
- IDT_POINTER:
- IDT_LIMIT: .word IDT_END - IDT_Table - 1
- IDT_BASE: .quad IDT_Table
- .global TSS64_Table
- TSS64_Table:
- .fill 13, 8, 0
- TSS64_END:
- TSS64_POINTER:
- TSS64_LIMIT: .word TSS64_END - TSS64_Table - 1
- TSS64_BASE: .quad TSS64_Table
|