162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci
362306a36Sopenharmony_ci#ifndef __ASM_IMAGE_H
462306a36Sopenharmony_ci#define __ASM_IMAGE_H
562306a36Sopenharmony_ci
662306a36Sopenharmony_ci#define ARM64_IMAGE_MAGIC	"ARM\x64"
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci#define ARM64_IMAGE_FLAG_BE_SHIFT		0
962306a36Sopenharmony_ci#define ARM64_IMAGE_FLAG_PAGE_SIZE_SHIFT	(ARM64_IMAGE_FLAG_BE_SHIFT + 1)
1062306a36Sopenharmony_ci#define ARM64_IMAGE_FLAG_PHYS_BASE_SHIFT \
1162306a36Sopenharmony_ci					(ARM64_IMAGE_FLAG_PAGE_SIZE_SHIFT + 2)
1262306a36Sopenharmony_ci#define ARM64_IMAGE_FLAG_BE_MASK		0x1
1362306a36Sopenharmony_ci#define ARM64_IMAGE_FLAG_PAGE_SIZE_MASK		0x3
1462306a36Sopenharmony_ci#define ARM64_IMAGE_FLAG_PHYS_BASE_MASK		0x1
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ci#define ARM64_IMAGE_FLAG_LE			0
1762306a36Sopenharmony_ci#define ARM64_IMAGE_FLAG_BE			1
1862306a36Sopenharmony_ci#define ARM64_IMAGE_FLAG_PAGE_SIZE_4K		1
1962306a36Sopenharmony_ci#define ARM64_IMAGE_FLAG_PAGE_SIZE_16K		2
2062306a36Sopenharmony_ci#define ARM64_IMAGE_FLAG_PAGE_SIZE_64K		3
2162306a36Sopenharmony_ci#define ARM64_IMAGE_FLAG_PHYS_BASE		1
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ci#ifndef __ASSEMBLY__
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ci#define arm64_image_flag_field(flags, field) \
2662306a36Sopenharmony_ci				(((flags) >> field##_SHIFT) & field##_MASK)
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ci/*
2962306a36Sopenharmony_ci * struct arm64_image_header - arm64 kernel image header
3062306a36Sopenharmony_ci * See Documentation/arch/arm64/booting.rst for details
3162306a36Sopenharmony_ci *
3262306a36Sopenharmony_ci * @code0:		Executable code, or
3362306a36Sopenharmony_ci *   @mz_header		  alternatively used for part of MZ header
3462306a36Sopenharmony_ci * @code1:		Executable code
3562306a36Sopenharmony_ci * @text_offset:	Image load offset
3662306a36Sopenharmony_ci * @image_size:		Effective Image size
3762306a36Sopenharmony_ci * @flags:		kernel flags
3862306a36Sopenharmony_ci * @reserved:		reserved
3962306a36Sopenharmony_ci * @magic:		Magic number
4062306a36Sopenharmony_ci * @reserved5:		reserved, or
4162306a36Sopenharmony_ci *   @pe_header:	  alternatively used for PE COFF offset
4262306a36Sopenharmony_ci */
4362306a36Sopenharmony_ci
4462306a36Sopenharmony_cistruct arm64_image_header {
4562306a36Sopenharmony_ci	__le32 code0;
4662306a36Sopenharmony_ci	__le32 code1;
4762306a36Sopenharmony_ci	__le64 text_offset;
4862306a36Sopenharmony_ci	__le64 image_size;
4962306a36Sopenharmony_ci	__le64 flags;
5062306a36Sopenharmony_ci	__le64 res2;
5162306a36Sopenharmony_ci	__le64 res3;
5262306a36Sopenharmony_ci	__le64 res4;
5362306a36Sopenharmony_ci	__le32 magic;
5462306a36Sopenharmony_ci	__le32 res5;
5562306a36Sopenharmony_ci};
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_ci#endif /* __ASSEMBLY__ */
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ci#endif /* __ASM_IMAGE_H */
60