Boot application processors into spin loops

Co-authored-by: Chuandong Li <lichuand@pku.edu.cn>
This commit is contained in:
Zhang Junyang
2024-07-06 04:43:33 +00:00
committed by Tate, Hongliang Tian
parent 870d542f60
commit 393c9019c0
21 changed files with 828 additions and 123 deletions

View File

@ -2,27 +2,93 @@ ENTRY(__multiboot_boot)
OUTPUT_ARCH(i386:x86-64)
OUTPUT_FORMAT(elf64-x86-64)
# The physical address where the kernel will start to be loaded.
KERNEL_LMA = 0x8000000;
LINUX_32_ENTRY = 0x8001000;
# The physical address of the boot section for the bootstrap processor.
BSP_BOOT_LMA = 0x8001000;
# The application processors need to start with low physical addresses.
# We link the symbols to low address plus virtual offset, and load the segment
# to higher physical memory. The BSP will copy the segment to low physical
# addresses before bringing up the APs.
AP_EXEC_MA = 0x8000;
# The virtual memory offset of the kernel mapping.
KERNEL_VMA = 0xffffffff80000000;
SECTIONS
{
# --------------------------------------------------------------------------- #
# The multiboot headers are placed at the beginning of the ELF file. #
# --------------------------------------------------------------------------- #
. = KERNEL_LMA + KERNEL_VMA;
__kernel_start = .;
.multiboot_header : AT(ADDR(.multiboot_header) - KERNEL_VMA) { KEEP(*(.multiboot_header)) }
.multiboot2_header : AT(ADDR(.multiboot2_header) - KERNEL_VMA) { KEEP(*(.multiboot2_header)) }
.multiboot_header : AT(ADDR(.multiboot_header) - KERNEL_VMA) {
KEEP(*(.multiboot_header))
}
.multiboot2_header : AT(ADDR(.multiboot2_header) - KERNEL_VMA) {
KEEP(*(.multiboot2_header))
}
. = LINUX_32_ENTRY + KERNEL_VMA;
# --------------------------------------------------------------------------- #
# These are 2 boot sections that need specific physical addresses. But they #
# should use virtual symbols. #
# --------------------------------------------------------------------------- #
. = BSP_BOOT_LMA + KERNEL_VMA;
.boot : AT(ADDR(.boot) - KERNEL_VMA) { KEEP(*(.boot)) }
.bsp_boot : AT(BSP_BOOT_LMA) {
KEEP(*(.bsp_boot .bsp_boot.*))
}
. = AP_EXEC_MA + KERNEL_VMA;
PROVIDE(__ap_boot_start = BSP_BOOT_LMA + SIZEOF(.bsp_boot) + KERNEL_VMA);
.ap_boot : AT(BSP_BOOT_LMA + SIZEOF(.bsp_boot)) {
KEEP(*(.ap_boot .ap_boot.*))
}
PROVIDE(__ap_boot_end = __ap_boot_start + SIZEOF(.ap_boot));
. = BSP_BOOT_LMA + KERNEL_VMA + SIZEOF(.bsp_boot) + SIZEOF(.ap_boot);
. = ALIGN(4096);
# --------------------------------------------------------------------------- #
# Here are the rest of the virtual memory sections which can be relocated. #
# --------------------------------------------------------------------------- #
.text : AT(ADDR(.text) - KERNEL_VMA) {
*(.text .text.*)
PROVIDE(__etext = .);
}
# The section to store exception table (ExTable).
# This table is used for recovering from specific exception handling faults
# occurring at known points in the code.
# Ref: /aster-frame/src/arch/x86/ex_table.rs
.ex_table : AT(ADDR(.ex_table) - KERNEL_VMA) {
__ex_table = .;
KEEP(*(SORT(.ex_table)))
__ex_table_end = .;
}
# The list of unit test function symbols that should be executed while
# doing `cargo osdk test`.
.ktest_array : AT(ADDR(.ktest_array) - KERNEL_VMA) {
__ktest_array = .;
KEEP(*(SORT(.ktest_array)))
__ktest_array_end = .;
}
# A list of initialization function symbols. They will be called on OSTD
# initialization.
.init_array : AT(ADDR(.init_array) - KERNEL_VMA) {
__sinit_array = .;
KEEP(*(SORT(.init_array .init_array.*)))
__einit_array = .;
}
.rodata : AT(ADDR(.rodata) - KERNEL_VMA) { *(.rodata .rodata.*) }
.eh_frame_hdr : AT(ADDR(.eh_frame_hdr) - KERNEL_VMA) {
@ -39,12 +105,6 @@ SECTIONS
.data.rel.ro : AT(ADDR(.data.rel.ro) - KERNEL_VMA) { *(.data.rel.ro .data.rel.ro.*) }
.dynamic : AT(ADDR(.dynamic) - KERNEL_VMA) { *(.dynamic) }
.init_array : AT(ADDR(.init_array) - KERNEL_VMA) {
__sinit_array = .;
KEEP(*(SORT(.init_array .init_array.*)))
__einit_array = .;
}
.got : AT(ADDR(.got) - KERNEL_VMA) { *(.got .got.*) }
.got.plt : AT(ADDR(.got.plt) - KERNEL_VMA) { *(.got.plt .got.plt.*) }
@ -56,6 +116,7 @@ SECTIONS
# The CPU local data storage. It is readable and writable for the bootstrap
# processor, while it would be copied to other dynamically allocated memory
# areas for the application processors.
. = ALIGN(4096);
.cpu_local : AT(ADDR(.cpu_local) - KERNEL_VMA) {
__cpu_local_start = .;
@ -78,22 +139,6 @@ SECTIONS
__bss_end = .;
}
# The section to store exception table (ExTable).
# This table is used for recovering from specific exception handling faults
# occurring at known points in the code.
# Ref: /aster-frame/src/arch/x86/ex_table.rs
.ex_table : AT(ADDR(.ex_table) - KERNEL_VMA) {
__ex_table = .;
KEEP(*(SORT(.ex_table)))
__ex_table_end = .;
}
.ktest_array : AT(ADDR(.ktest_array) - KERNEL_VMA) {
__ktest_array = .;
KEEP(*(SORT(.ktest_array)))
__ktest_array_end = .;
}
.tdata : AT(ADDR(.tdata) - KERNEL_VMA) { *(.tdata .tdata.*) }
.tbss : AT(ADDR(.tbss) - KERNEL_VMA) { *(.tbss .tbss.*) }