84 lines
1.6 KiB
ArmAsm
84 lines
1.6 KiB
ArmAsm
/* Original Open Agila Multiboot v1 entry. QEMU x86-64/BIOS target only. */
|
|
.section .multiboot,"a"
|
|
.balign 4
|
|
.long 0x1badb002
|
|
.long 0x00000003
|
|
.long -(0x1badb002 + 0x00000003)
|
|
.section .text.boot,"ax"
|
|
.code32
|
|
.global _start
|
|
.type _start,@function
|
|
_start:
|
|
cli
|
|
cld
|
|
mov %eax, boot_magic
|
|
mov $stack_top, %esp
|
|
/* GRUB enters 32-bit protected mode. Map the first GiB with 2 MiB pages.
|
|
These writable executable boot mappings are NOT process isolation. */
|
|
mov $pdpt, %eax
|
|
or $3, %eax
|
|
mov %eax, pml4
|
|
mov $page_directory, %eax
|
|
or $3, %eax
|
|
mov %eax, pdpt
|
|
xor %ecx, %ecx
|
|
1:
|
|
mov %ecx, %eax
|
|
shl $21, %eax
|
|
or $0x83, %eax
|
|
mov %eax, page_directory(,%ecx,8)
|
|
inc %ecx
|
|
cmp $512, %ecx
|
|
jne 1b
|
|
mov %cr4, %eax
|
|
or $0x20, %eax
|
|
mov %eax, %cr4
|
|
mov $pml4, %eax
|
|
mov %eax, %cr3
|
|
mov $0xc0000080, %ecx
|
|
rdmsr
|
|
or $0x100, %eax
|
|
wrmsr
|
|
lgdt gdt_pointer
|
|
mov %cr0, %eax
|
|
or $0x80000000, %eax
|
|
mov %eax, %cr0
|
|
ljmp $0x08, $long_mode
|
|
.code64
|
|
long_mode:
|
|
mov $0x10, %ax
|
|
mov %ax, %ds
|
|
mov %ax, %es
|
|
mov %ax, %ss
|
|
xor %eax, %eax
|
|
mov %ax, %fs
|
|
mov %ax, %gs
|
|
mov $stack_top, %rsp
|
|
xor %rbp, %rbp
|
|
mov boot_magic(%rip), %edi
|
|
call agila_boot_main
|
|
2: cli
|
|
hlt
|
|
jmp 2b
|
|
.section .rodata,"a"
|
|
.balign 8
|
|
gdt:
|
|
.quad 0
|
|
.quad 0x00af9a000000ffff
|
|
.quad 0x00cf92000000ffff
|
|
gdt_end:
|
|
gdt_pointer:
|
|
.word gdt_end-gdt-1
|
|
.long gdt
|
|
.section .bss,"aw",@nobits
|
|
.balign 4
|
|
boot_magic: .skip 4
|
|
.balign 4096
|
|
pml4: .skip 4096
|
|
pdpt: .skip 4096
|
|
page_directory: .skip 4096
|
|
.balign 16
|
|
stack_bottom: .skip 65536
|
|
stack_top:
|
|
.section .note.GNU-stack,"",@progbits
|