...
This commit is contained in:
27
src/boot.s
27
src/boot.s
@@ -12,22 +12,43 @@
|
|||||||
.long FLAGS
|
.long FLAGS
|
||||||
.long CHECKSUM
|
.long CHECKSUM
|
||||||
|
|
||||||
|
.section .bss
|
||||||
|
.align 4096
|
||||||
|
pml4_table:
|
||||||
|
.zero 4096
|
||||||
|
pdpt_table:
|
||||||
|
.zero 4096
|
||||||
|
pd_table:
|
||||||
|
.zero 4096
|
||||||
|
|
||||||
.section .bss
|
.section .bss
|
||||||
.align 16
|
.align 16
|
||||||
stack_bottom:
|
stack_bottom:
|
||||||
.skip 16384
|
.skip 16384
|
||||||
stack_top:
|
stack_top:
|
||||||
|
|
||||||
.set BOOTLOADER_MAGIC, 0x2BADB002
|
.section .data
|
||||||
|
.align 8
|
||||||
|
gdt64:
|
||||||
|
.quad 0x0000000000000000
|
||||||
|
gdt64_code:
|
||||||
|
.quad 0x00AF9A000000FFFF
|
||||||
|
gdt64_descriptor:
|
||||||
|
.word gdt64_end - gdt64 - 1
|
||||||
|
.long gdt64
|
||||||
|
gdt64_end:
|
||||||
|
|
||||||
.section .text
|
.section .text
|
||||||
|
.code32
|
||||||
.global _start
|
.global _start
|
||||||
_start:
|
_start:
|
||||||
mov stack_top, esp
|
mov stack_top, esp
|
||||||
|
|
||||||
cmp eax, BOOTLOADER_MAGIC
|
cmp eax, 0x2BADB002
|
||||||
jne error
|
jne error
|
||||||
|
|
||||||
|
lgdt [gdt64_descriptor]
|
||||||
|
|
||||||
push ebx
|
push ebx
|
||||||
call kernel_main
|
call kernel_main
|
||||||
add esp, 4
|
add esp, 4
|
||||||
|
|||||||
109
src/idt_stub.asm
109
src/idt_stub.asm
@@ -1,109 +0,0 @@
|
|||||||
extern handle_isr
|
|
||||||
|
|
||||||
isr_common:
|
|
||||||
push rax
|
|
||||||
push rbx
|
|
||||||
push rcx
|
|
||||||
push rdx
|
|
||||||
push rsi
|
|
||||||
push rdi
|
|
||||||
push rbp
|
|
||||||
push r8
|
|
||||||
push r9
|
|
||||||
push r10
|
|
||||||
push r11
|
|
||||||
push r12
|
|
||||||
push r13
|
|
||||||
push r14
|
|
||||||
push r15
|
|
||||||
|
|
||||||
mov rdi, rsp
|
|
||||||
call handle_isr
|
|
||||||
|
|
||||||
pop r15
|
|
||||||
pop r14
|
|
||||||
pop r13
|
|
||||||
pop r12
|
|
||||||
pop r11
|
|
||||||
pop r10
|
|
||||||
pop r9
|
|
||||||
pop r8
|
|
||||||
pop rbp
|
|
||||||
pop rdi
|
|
||||||
pop rsi
|
|
||||||
pop rdx
|
|
||||||
pop rcx
|
|
||||||
pop rbx
|
|
||||||
pop rax
|
|
||||||
|
|
||||||
add rsp, 16
|
|
||||||
iretq
|
|
||||||
|
|
||||||
%macro ISR_NOERR 1
|
|
||||||
isr_stub_%1:
|
|
||||||
push qword 0
|
|
||||||
push qword %1
|
|
||||||
jmp isr_common
|
|
||||||
%endmacro
|
|
||||||
|
|
||||||
%macro ISR_ERR 1
|
|
||||||
isr_stub_%1:
|
|
||||||
push qword %1
|
|
||||||
jmp isr_common
|
|
||||||
%endmacro
|
|
||||||
|
|
||||||
; CPU exceptions 0-31
|
|
||||||
ISR_NOERR 0
|
|
||||||
ISR_NOERR 1
|
|
||||||
ISR_NOERR 2
|
|
||||||
ISR_NOERR 3
|
|
||||||
ISR_NOERR 4
|
|
||||||
ISR_NOERR 5
|
|
||||||
ISR_NOERR 6
|
|
||||||
ISR_NOERR 7
|
|
||||||
ISR_ERR 8
|
|
||||||
ISR_NOERR 9
|
|
||||||
ISR_ERR 10
|
|
||||||
ISR_ERR 11
|
|
||||||
ISR_ERR 12
|
|
||||||
ISR_ERR 13
|
|
||||||
ISR_ERR 14
|
|
||||||
ISR_NOERR 15
|
|
||||||
ISR_NOERR 16
|
|
||||||
ISR_ERR 17
|
|
||||||
ISR_NOERR 18
|
|
||||||
ISR_NOERR 19
|
|
||||||
ISR_NOERR 20
|
|
||||||
ISR_NOERR 21
|
|
||||||
ISR_NOERR 22
|
|
||||||
ISR_NOERR 23
|
|
||||||
ISR_NOERR 24
|
|
||||||
ISR_NOERR 25
|
|
||||||
ISR_NOERR 26
|
|
||||||
ISR_NOERR 27
|
|
||||||
ISR_NOERR 28
|
|
||||||
ISR_NOERR 29
|
|
||||||
ISR_ERR 30
|
|
||||||
ISR_NOERR 31
|
|
||||||
|
|
||||||
%macro GENERATE_ISRS 2
|
|
||||||
%assign i %1
|
|
||||||
%rep (%2 - %1 + 1)
|
|
||||||
ISR_NOERR i
|
|
||||||
%assign i i+1
|
|
||||||
%endrep
|
|
||||||
%endmacro
|
|
||||||
|
|
||||||
GENERATE_ISRS 32, 255
|
|
||||||
|
|
||||||
%macro GENERATE_ISR_TABLE 2
|
|
||||||
%assign i %1
|
|
||||||
%rep (%2 - %1 + 1)
|
|
||||||
dq isr_stub_%[i]
|
|
||||||
%assign i i+1
|
|
||||||
%endrep
|
|
||||||
%endmacro
|
|
||||||
|
|
||||||
global isr_stub_table
|
|
||||||
isr_stub_table:
|
|
||||||
GENERATE_ISR_TABLE 0, 255
|
|
||||||
Reference in New Issue
Block a user