build: replace hosted target with static linux and add kernel target
Co-authored-by: aider (openrouter/moonshotai/kimi-k2.6) <aider@aider.chat>
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
# Multiboot2 header and x86_64 long-mode bootstrap
|
||||
|
||||
.section .multiboot2, "a"
|
||||
.align 8
|
||||
multiboot_header:
|
||||
.long 0xe85250d6
|
||||
.long 0
|
||||
.long multiboot_header_end - multiboot_header
|
||||
.long -(0xe85250d6 + 0 + (multiboot_header_end - multiboot_header))
|
||||
|
||||
.align 8
|
||||
.word 0
|
||||
.word 0
|
||||
.long 8
|
||||
multiboot_header_end:
|
||||
|
||||
.section .bss, "aw", @nobits
|
||||
.align 4096
|
||||
pml4:
|
||||
.space 4096
|
||||
pdpt:
|
||||
.space 4096
|
||||
pd:
|
||||
.space 4096
|
||||
|
||||
.align 16
|
||||
stack_bottom:
|
||||
.space 16384
|
||||
stack_top:
|
||||
|
||||
.section .text
|
||||
.code32
|
||||
.global _start
|
||||
.type _start, @function
|
||||
_start:
|
||||
movl $stack_top, %esp
|
||||
|
||||
movl $pdpt, %eax
|
||||
orl $0x03, %eax
|
||||
movl %eax, pml4
|
||||
|
||||
movl $pd, %eax
|
||||
orl $0x03, %eax
|
||||
movl %eax, pdpt
|
||||
|
||||
movl $0x00000083, %eax
|
||||
movl $pd, %edi
|
||||
movl $512, %ecx
|
||||
1:
|
||||
movl %eax, (%edi)
|
||||
addl $0x200000, %eax
|
||||
addl $8, %edi
|
||||
loop 1b
|
||||
|
||||
movl $pml4, %eax
|
||||
movl %eax, %cr3
|
||||
|
||||
movl %cr4, %eax
|
||||
orl $0x20, %eax
|
||||
movl %eax, %cr4
|
||||
|
||||
movl $0xC0000080, %ecx
|
||||
rdmsr
|
||||
orl $0x100, %eax
|
||||
wrmsr
|
||||
|
||||
movl %cr0, %eax
|
||||
orl $0x80000000, %eax
|
||||
movl %eax, %cr0
|
||||
|
||||
lgdt gdt64_pointer
|
||||
ljmp $0x08, $long_mode_start
|
||||
|
||||
.code64
|
||||
long_mode_start:
|
||||
movabsq $stack_top, %rax
|
||||
movq %rax, %rsp
|
||||
|
||||
movabsq $__bss_start, %rdi
|
||||
movabsq $__bss_end, %rcx
|
||||
subq %rdi, %rcx
|
||||
xorq %rax, %rax
|
||||
rep stosb
|
||||
|
||||
call kernel_main
|
||||
cli
|
||||
1:
|
||||
hlt
|
||||
jmp 1b
|
||||
|
||||
.section .rodata
|
||||
.align 8
|
||||
gdt64:
|
||||
.quad 0x0000000000000000
|
||||
.quad 0x00209A0000000000
|
||||
gdt64_pointer:
|
||||
.word gdt64_pointer - gdt64 - 1
|
||||
.quad gdt64
|
||||
Reference in New Issue
Block a user