1/*
2 * Copyright (c) 2020 EPAM Systems
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#include <zephyr/linker/sections.h>
8#include <zephyr/arch/cpu.h>
9#include "mmu.h"
10
11#if CONFIG_MMU_PAGE_SIZE == 4096 || defined(CONFIG_ARM_MPU)
12#define HEADER_PGSIZE	1
13#elif CONFIG_MMU_PAGE_SIZE == 16384
14#define HEADER_PGSIZE	2
15#elif CONFIG_MMU_PAGE_SIZE == 65536
16#define HEADER_PGSIZE	3
17#else
18#define HEADER_PGSIZE 0
19#warning "Can't determine page size for header flags"
20#endif
21
22#define HEADER_FLAGS	(HEADER_PGSIZE << 1)
23
24_ASM_FILE_PROLOGUE
25
26SECTION_SUBSEC_FUNC(image_header,_image_header_section,_image_header)
27	b	__start				// branch to kernel start
28	.long	0				// reserved
29	.quad	0				// Image load offset from start
30						// of RAM, little-endian
31
32	.quad	_flash_used			// Effective size of kernel
33						// image, little-endian
34
35	.quad	HEADER_FLAGS			// Informative flags,
36						// little-endian
37
38	.quad	0				// reserved
39	.quad	0				// reserved
40	.quad	0				// reserved
41	.ascii	"ARM\x64"			// Magic number
42	.long	0				// reserved
43