From fb3268e5a04f062a6cfcccbec0f1de529842f10a Mon Sep 17 00:00:00 2001 From: Hidenori Matsubayashi Date: Sat, 6 May 2023 10:06:13 +0900 Subject: [PATCH] linker: restructure linker script directory --- CMakeLists.txt | 4 ++-- .../qemu/cortex-a72/linker.ld | 21 ++++++++++++------- .../raspberry-pi4 => scripts/rpi4}/linker.ld | 21 ++++++++++++------- 3 files changed, 29 insertions(+), 17 deletions(-) rename src/arch/arm64/{boot => scripts}/qemu/cortex-a72/linker.ld (77%) rename src/arch/arm64/{boot/raspberry-pi4 => scripts/rpi4}/linker.ld (80%) diff --git a/CMakeLists.txt b/CMakeLists.txt index f1642b1..30d3b83 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -123,9 +123,9 @@ target_include_directories(${TARGET} PRIVATE "src") # Linker script # ========================================================================== if (${BOARD} STREQUAL "raspi4") - set(LINKER_SCRIPT "src/arch/arm64/boot/raspberry-pi4/linker.ld") + set(LINKER_SCRIPT "src/arch/arm64/scripts/rpi4/linker.ld") else() - set(LINKER_SCRIPT "src/arch/arm64/boot/qemu/cortex-a72/linker.ld") + set(LINKER_SCRIPT "src/arch/arm64/scripts/qemu/cortex-a72/linker.ld") endif() set_target_properties(${TARGET} PROPERTIES LINK_DEPENDS ${CMAKE_SOURCE_DIR}/${LINKER_SCRIPT}) target_link_options(${TARGET} PRIVATE "-T${CMAKE_SOURCE_DIR}/${LINKER_SCRIPT}") diff --git a/src/arch/arm64/boot/qemu/cortex-a72/linker.ld b/src/arch/arm64/scripts/qemu/cortex-a72/linker.ld similarity index 77% rename from src/arch/arm64/boot/qemu/cortex-a72/linker.ld rename to src/arch/arm64/scripts/qemu/cortex-a72/linker.ld index 4562846..a069bfa 100644 --- a/src/arch/arm64/boot/qemu/cortex-a72/linker.ld +++ b/src/arch/arm64/scripts/qemu/cortex-a72/linker.ld @@ -1,5 +1,5 @@ /** - * Linker Script for QEMU coretex-a72/virt/4GB + * Linker Script for QEMU coretex-a72/virt/1GB **/ OUTPUT_ARCH(aarch64) @@ -7,13 +7,17 @@ ENTRY(_start) MEMORY { - /* 0x40280000 => uboot load address*/ - /* 1GB memory */ + /* + * U-BOOT loadd address: 0x40280000 + * Physical memory size: 1GB + */ RAM (xrw) : ORIGIN = 0x40280000, LENGTH = 1 * 1024 * 1024 * 1024 } SECTIONS { __start = .; + + /* text region for Hypervisor */ .text : { __text_start = .; KEEP(*(.text.start)) @@ -23,6 +27,7 @@ SECTIONS { } > RAM __text_size = __text_end - __text_start; + /* rodata region for Hypervisor */ .rodata : { __rodata_start = .; *(.rodata*) @@ -31,6 +36,7 @@ SECTIONS { } > RAM __rodata_size = __rodata_end - __rodata_start; + /* data region for Hypervisor */ .data : { __data_start = . ; *(.data*) @@ -39,6 +45,7 @@ SECTIONS { } > RAM __data_size = __data_end - __data_start; + /* bss region for Hypervisor */ .bss : { __bss_start = . ; *(.bss*) @@ -47,36 +54,36 @@ SECTIONS { } > RAM __bss_size = __bss_end - __bss_start; + /* 64MB heap region for Hypervisor */ .heap : { __heap_start = .; - /* 64MiB heap */ . = . + 1024 * 1024 * 64; . = ALIGN(0x1000); __heap_end = .; } > RAM __heap_size = __heap_end - __heap_start; + /* 1MB uncached region for Hypervisor */ .uncached_space : { __uncached_space_start = .; - /* 1MB uncached regin */ . = . + 1024 * 1024 * 1; . = ALIGN(0x1000); __uncached_space_end = .; } > RAM __uncached_space_size = __uncached_space_end - __uncached_space_start; + /* 512MB user memory region for guests */ .user_space : { __user_space_start = .; - /* 512MiB user space */ . = . + 1024 * 1024 * 512; . = ALIGN(0x1000); __user_space_end = .; } __user_space_size = __user_space_end - __user_space_start; + /* 64MB stack region for Hypervisor */ .stack : { __stack_start = .; - /* 64MiB space */ . = ALIGN(0x1000); __stack_end = __stack_start + (1024 * 1024) * 64; } > RAM diff --git a/src/arch/arm64/boot/raspberry-pi4/linker.ld b/src/arch/arm64/scripts/rpi4/linker.ld similarity index 80% rename from src/arch/arm64/boot/raspberry-pi4/linker.ld rename to src/arch/arm64/scripts/rpi4/linker.ld index f838565..55be016 100644 --- a/src/arch/arm64/boot/raspberry-pi4/linker.ld +++ b/src/arch/arm64/scripts/rpi4/linker.ld @@ -7,16 +7,18 @@ ENTRY(_start) MEMORY { - /** - * - Raspberry Pi 4 has 4GiB RAM - * - "0x00080000" is the Kernel load address for aarch64 - **/ + /* + * PRI boot loader loadds kernel.bin to 0x40280000 + * Physical memory size: 4GB + */ RESERVED (r) : ORIGIN = 0x00000000, LENGTH = 32K RAM (xrw) : ORIGIN = 0x00080000, LENGTH = (0x100000000 - 0x00080000) } SECTIONS { __start = .; + + /* text region for Hypervisor */ .text : { __text_start = .; KEEP(*(.text.start)) @@ -26,6 +28,7 @@ SECTIONS { } > RAM __text_size = __text_end - __text_start; + /* rodata region for Hypervisor */ .rodata : { __rodata_start = .; *(.rodata*) @@ -34,6 +37,7 @@ SECTIONS { } > RAM __rodata_size = __rodata_end - __rodata_start; + /* data region for Hypervisor */ .data : { __data_start = . ; *(.data*) @@ -42,6 +46,7 @@ SECTIONS { } > RAM __data_size = __data_end - __data_start; + /* bss region for Hypervisor */ .bss : { __bss_start = . ; *(.bss*) @@ -50,36 +55,36 @@ SECTIONS { } > RAM __bss_size = __bss_end - __bss_start; + /* 64MB heap region for Hypervisor */ .heap : { __heap_start = .; - /* 64MiB heap */ . = . + 1024 * 1024 * 64; . = ALIGN(0x1000); __heap_end = .; } > RAM __heap_size = __heap_end - __heap_start; + /* 1MB uncached region for Hypervisor */ .uncached_space : { __uncached_space_start = .; - /* 1MB uncached regin */ . = . + 1024 * 1024 * 1; . = ALIGN(0x1000); __uncached_space_end = .; } > RAM __uncached_space_size = __uncached_space_end - __uncached_space_start; + /* 2GB user memory region for guests */ .user_space : { __user_space_start = .; - /* 2GiB user space */ . = . + 1024 * 1024 * 1024 * 2; . = ALIGN(0x1000); __user_space_end = .; } > RAM __user_space_size = __user_space_end - __user_space_start; + /* 64MB stack region for Hypervisor */ .stack : { __stack_start = .; - /* 64MiB space */ . = ALIGN(0x1000); __stack_end = __stack_start + (1024 * 1024) * 64; } > RAM