aarch64: add ability to generate image header
Image header is compatible with Linux aarch64 boot protocol, so zephyr can be booted with U-boot or Xen loader. Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
This commit is contained in:
parent
7191b64c6f
commit
cd86ec2655
4 changed files with 55 additions and 0 deletions
|
@ -31,5 +31,6 @@ zephyr_library_sources_ifdef(CONFIG_GEN_SW_ISR_TABLE isr_wrapper.S)
|
|||
zephyr_library_sources_ifdef(CONFIG_IRQ_OFFLOAD irq_offload.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_THREAD_LOCAL_STORAGE ../common/tls.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_ARM_PSCI smccc-call.S)
|
||||
zephyr_library_sources_ifdef(CONFIG_AARCH64_IMAGE_HEADER header.S)
|
||||
|
||||
add_subdirectory_ifdef(CONFIG_ARM_MMU mmu)
|
||||
|
|
|
@ -56,6 +56,12 @@ config CMSIS_V2_THREAD_DYNAMIC_STACK_SIZE
|
|||
config IPM_CONSOLE_STACK_SIZE
|
||||
default 2048
|
||||
|
||||
config AARCH64_IMAGE_HEADER
|
||||
bool "Add image header"
|
||||
help
|
||||
This option enables standard ARM64 boot image header used by Linux
|
||||
and understood by loaders such as u-boot on Xen xl tool.
|
||||
|
||||
if CPU_CORTEX_A
|
||||
|
||||
config ARMV8_A_NS
|
||||
|
|
42
arch/arm/core/aarch64/header.S
Normal file
42
arch/arm/core/aarch64/header.S
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright (c) 2020 EPAM Systems
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <linker/sections.h>
|
||||
#include <arch/cpu.h>
|
||||
#include "mmu/arm_mmu.h"
|
||||
|
||||
#if CONFIG_MMU_PAGE_SIZE == 4096
|
||||
#define HEADER_PGSIZE 1
|
||||
#elif CONFIG_MMU_PAGE_SIZE == 16384
|
||||
#define HEADER_PGSIZE 2
|
||||
#elif CONFIG_MMU_PAGE_SIZE == 65536
|
||||
#define HEADER_PGSIZE 3
|
||||
#else
|
||||
#define HEADER_PGSIZE 0
|
||||
#warning "Can't determine page size for header flags"
|
||||
#endif
|
||||
|
||||
#define HEADER_FLAGS (HEADER_PGSIZE << 1)
|
||||
|
||||
_ASM_FILE_PROLOGUE
|
||||
|
||||
SECTION_SUBSEC_FUNC(image_header,_image_header_section,_image_header)
|
||||
b __start // branch to kernel start
|
||||
.long 0 // reserved
|
||||
.quad 0 // Image load offset from start
|
||||
// of RAM, little-endian
|
||||
|
||||
.quad _flash_used // Effective size of kernel
|
||||
// image, little-endian
|
||||
|
||||
.quad HEADER_FLAGS // Informative flags,
|
||||
// little-endian
|
||||
|
||||
.quad 0 // reserved
|
||||
.quad 0 // reserved
|
||||
.quad 0 // reserved
|
||||
.ascii "ARM\x64" // Magic number
|
||||
.long 0 // reserved
|
|
@ -107,6 +107,12 @@ SECTIONS
|
|||
#ifndef CONFIG_XIP
|
||||
z_mapped_start = .;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_AARCH64_IMAGE_HEADER
|
||||
KEEP(*(.image_header))
|
||||
KEEP(*(".image_header.*"))
|
||||
#endif
|
||||
|
||||
_vector_start = .;
|
||||
KEEP(*(.exc_vector_table))
|
||||
KEEP(*(".exc_vector_table.*"))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue