mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-25 18:33:24 +00:00
Switch to EFI boot and use official release for QEMU and GDB
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
aea8f38dc1
commit
cdc2b960dc
@ -4,6 +4,9 @@
|
||||
.section ".boot", "awx"
|
||||
.code32
|
||||
|
||||
// With the 32-bit entry types we should go through a common paging and machine
|
||||
// state setup routine. Thus we make a mark of protocol used in each entrypoint
|
||||
// on the stack.
|
||||
ENTRYTYPE_MULTIBOOT = 1
|
||||
ENTRYTYPE_MULTIBOOT2 = 2
|
||||
ENTRYTYPE_LINUX_32 = 3
|
||||
@ -122,6 +125,7 @@ PTE_GLOBAL = (1 << 8)
|
||||
// 0xffff8000_40000000 ~ 0xffff8000_7fffffff
|
||||
// 0xffff8000_80000000 ~ 0xffff8000_bfffffff
|
||||
// 0xffff8000_c0000000 ~ 0xffff8000_ffffffff
|
||||
// 0xffff8008_00000000 ~ 0xffff8008_3fffffff
|
||||
lea edi, [boot_pml4 + 0x100 * 8]
|
||||
lea eax, [boot_pdpt + (PTE_PRESENT | PTE_WRITE | PTE_GLOBAL)]
|
||||
mov dword ptr [edi], eax
|
||||
@ -158,6 +162,13 @@ PTE_GLOBAL = (1 << 8)
|
||||
mov dword ptr [edi], eax
|
||||
mov dword ptr [edi + 4], 0
|
||||
|
||||
// 1000 00000|000 100000|00 0000000|0 00000000 000
|
||||
// PDPT: 0xffff8008_00000000 ~ 0xffff8008_3fffffff
|
||||
lea edi, [boot_pdpt + 0x20 * 8]
|
||||
lea eax, [boot_pd_32g + (PTE_PRESENT | PTE_WRITE | PTE_GLOBAL)]
|
||||
mov dword ptr [edi], eax
|
||||
mov dword ptr [edi + 4], 0
|
||||
|
||||
// PDPT: 0xffffffff_80000000 ~ 0xffffffff_bfffffff
|
||||
lea edi, [boot_pdpt + 0x1fe * 8]
|
||||
lea eax, [boot_pd_0g_1g + (PTE_PRESENT | PTE_WRITE | PTE_GLOBAL)]
|
||||
@ -172,27 +183,25 @@ PTE_GLOBAL = (1 << 8)
|
||||
|
||||
// Page Directory: map to low 1 GiB * 4 space
|
||||
lea edi, [boot_pd]
|
||||
lea eax, [boot_pt + (PTE_PRESENT | PTE_WRITE | PTE_GLOBAL)]
|
||||
mov eax, (PTE_PRESENT | PTE_WRITE | PTE_GLOBAL | PTE_HUGE) // Map offset 0.
|
||||
mov ecx, 512 * 4 // (of entries in PD) * (number of PD)
|
||||
|
||||
write_pd_entry:
|
||||
mov dword ptr [edi], eax
|
||||
mov dword ptr [edi + 4], 0
|
||||
add eax, 0x1000 // 4kiB
|
||||
add eax, 0x200000 // +2MiB
|
||||
add edi, 8
|
||||
loop write_pd_entry
|
||||
|
||||
// Page Table: map to low 4 KiB * 1M space
|
||||
lea edi, [boot_pt]
|
||||
mov eax, 0x103 // Present, writable, global.
|
||||
mov ecx, 512 * 512 * 4 // (of entries in PT) * (number of PT)
|
||||
|
||||
write_pt_entry:
|
||||
// Page Directory: map to 1 GiB space offset 32GiB
|
||||
lea edi, [boot_pd_32g]
|
||||
mov eax, (PTE_PRESENT | PTE_WRITE | PTE_GLOBAL | PTE_HUGE) // Should +0x800000000 but this is 32-bit.
|
||||
mov ecx, 512 // (of entries in PD)
|
||||
write_pd_32g_entry:
|
||||
mov dword ptr [edi], eax
|
||||
mov dword ptr [edi + 4], 0
|
||||
add eax, 0x1000 // 4KiB
|
||||
mov dword ptr [edi + 4], 0x8 // Map offset 32GiB.
|
||||
add eax, 0x200000 // +2MiB
|
||||
add edi, 8
|
||||
loop write_pt_entry
|
||||
loop write_pd_32g_entry
|
||||
|
||||
jmp enable_long_mode
|
||||
|
||||
@ -258,8 +267,8 @@ boot_pd_2g_3g:
|
||||
.skip 4096
|
||||
boot_pd_3g_4g:
|
||||
.skip 4096
|
||||
boot_pt:
|
||||
.skip 4096 * 512 * 4
|
||||
boot_pd_32g:
|
||||
.skip 4096
|
||||
boot_page_table_end:
|
||||
|
||||
boot_stack_bottom:
|
||||
@ -299,11 +308,11 @@ long_mode:
|
||||
cmp rax, ENTRYTYPE_MULTIBOOT2
|
||||
je entry_type_multiboot2
|
||||
cmp rax, ENTRYTYPE_LINUX_32
|
||||
je entry_type_pvh_elf
|
||||
je entry_type_linux_32
|
||||
// Unreachable!
|
||||
jmp halt
|
||||
|
||||
entry_type_pvh_elf:
|
||||
entry_type_linux_32:
|
||||
pop rdi // boot_params ptr
|
||||
|
||||
// Clear the frame pointer to stop backtracing here.
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
// The section name is used by the build script to strip and make
|
||||
// the binary file.
|
||||
.section ".header", "awx"
|
||||
.section ".header", "ax"
|
||||
|
||||
// The Linux x86 Boot Protocol header.
|
||||
//
|
||||
@ -56,8 +56,8 @@ hardware_subarch_data: .quad 0
|
||||
payload_offset: .long 0xabababab # at 0x248/4, to be filled by the runner
|
||||
payload_length: .long 0xabababab # at 0x24c/4, to be filled by the runner
|
||||
setup_data: .quad 0
|
||||
pref_address: .quad 0
|
||||
init_size: .long 0
|
||||
pref_address: .quad 0x8000000 # 128MiB
|
||||
init_size: .long 0x4000000 # 64MiB
|
||||
handover_offset: .long 0
|
||||
kernel_info_offset: .long 0
|
||||
|
||||
|
@ -17,4 +17,4 @@
|
||||
"os": "none",
|
||||
"relocation-model": "static",
|
||||
"features": "+soft-float,-sse,-mmx"
|
||||
}
|
||||
}
|
||||
|
@ -80,7 +80,9 @@ fn init_acpi_arg(acpi: &'static Once<BootloaderAcpiArg>) {
|
||||
}
|
||||
|
||||
fn init_framebuffer_info(framebuffer_arg: &'static Once<BootloaderFramebufferArg>) {
|
||||
let fb_tag = MB2_INFO.get().unwrap().framebuffer_tag().unwrap().unwrap();
|
||||
let Some(Ok(fb_tag)) = MB2_INFO.get().unwrap().framebuffer_tag() else {
|
||||
return;
|
||||
};
|
||||
framebuffer_arg.call_once(|| BootloaderFramebufferArg {
|
||||
address: fb_tag.address() as usize,
|
||||
width: fb_tag.width() as usize,
|
||||
@ -122,19 +124,20 @@ fn init_memory_regions(memory_regions: &'static Once<Vec<MemoryRegion>>) {
|
||||
);
|
||||
regions.push(region);
|
||||
}
|
||||
// Add the framebuffer region since Grub does not specify it.
|
||||
let fb_tag = MB2_INFO.get().unwrap().framebuffer_tag().unwrap().unwrap();
|
||||
let fb = BootloaderFramebufferArg {
|
||||
address: fb_tag.address() as usize,
|
||||
width: fb_tag.width() as usize,
|
||||
height: fb_tag.height() as usize,
|
||||
bpp: fb_tag.bpp() as usize,
|
||||
};
|
||||
regions.push(MemoryRegion::new(
|
||||
fb.address,
|
||||
(fb.width * fb.height * fb.bpp + 7) / 8, // round up when divide with 8 (bits/Byte)
|
||||
MemoryRegionType::Framebuffer,
|
||||
));
|
||||
if let Some(Ok(fb_tag)) = MB2_INFO.get().unwrap().framebuffer_tag() {
|
||||
// Add the framebuffer region since Grub does not specify it.
|
||||
let fb = BootloaderFramebufferArg {
|
||||
address: fb_tag.address() as usize,
|
||||
width: fb_tag.width() as usize,
|
||||
height: fb_tag.height() as usize,
|
||||
bpp: fb_tag.bpp() as usize,
|
||||
};
|
||||
regions.push(MemoryRegion::new(
|
||||
fb.address,
|
||||
(fb.width * fb.height * fb.bpp + 7) / 8, // round up when divide with 8 (bits/Byte)
|
||||
MemoryRegionType::Framebuffer,
|
||||
));
|
||||
}
|
||||
// Add the kernel region since Grub does not specify it.
|
||||
// These are physical addresses provided by the linker script.
|
||||
extern "C" {
|
||||
|
@ -9,7 +9,6 @@
|
||||
#![feature(core_intrinsics)]
|
||||
#![feature(new_uninit)]
|
||||
#![feature(strict_provenance)]
|
||||
//#![feature(link_llvm_intrinsics)]
|
||||
#![feature(const_trait_impl)]
|
||||
#![feature(generators)]
|
||||
#![feature(iter_from_generator)]
|
||||
|
Reference in New Issue
Block a user