Hi, Youling,
On Tue, Aug 26, 2025 at 9:18 AM Youling Tang <youling.tang@linux.dev> wrote:
>
> From: Youling Tang <tangyouling@kylinos.cn>
>
> Define a dedicated image header structure for LoongArch architecture to
> standardize kernel loading in bootloaders (primarily for kexec_file).
>
> This header includes critical metadata such as PE signature, entry points,
> image size and load address offset, etc.
>
> Signed-off-by: Youling Tang <tangyouling@kylinos.cn>
> ---
> arch/loongarch/include/asm/image.h | 40 ++++++++++++++++++++++++++++++
> 1 file changed, 40 insertions(+)
> create mode 100644 arch/loongarch/include/asm/image.h
>
> diff --git a/arch/loongarch/include/asm/image.h b/arch/loongarch/include/asm/image.h
> new file mode 100644
> index 000000000000..1f090736e71d
> --- /dev/null
> +++ b/arch/loongarch/include/asm/image.h
> @@ -0,0 +1,40 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +/*
> + * LoongArch binary image header.
> + *
> + * Author: Youling Tang <tangyouling@kylinos.cn>
> + * Copyright (C) 2025 KylinSoft Corporation.
> + *
> + * Most code is derived from LoongArch port of kexec-tools
> + */
> +
> +#ifndef __ASM_IMAGE_H
> +#define __ASM_IMAGE_H
> +#ifndef __ASSEMBLY__
__ASSEMBLY__ is replaced by __ASSEMBLER__ now.
> +
> +/**
> + * struct loongarch_image_header
> + *
> + * @pe_sig: Optional PE format 'MZ' signature.
> + * @reserved_1: Reserved.
> + * @kernel_entry: Kernel image entry pointer.
> + * @image_size: An estimated size of the memory image size in LSB byte order.
> + * @text_offset: The image load offset in LSB byte order.
> + * @reserved_2: Reserved.
> + * @reserved_3: Reserved.
> + * @pe_header: Optional offset to a PE format header.
> + **/
> +
> +struct loongarch_image_header {
> + uint8_t pe_sig[2];
Use dos_sig is better.
> + uint16_t reserved_1[3];
Use padding_1[3] is better.
> + uint64_t kernel_entry;
> + uint64_t image_size;
Use kernel_asize to keep consistency with head.S.
> + uint64_t text_offset;
> + uint64_t reserved_2[3];
> + uint32_t reserved_3;
Just use uint32_t reserved_2[7] here?
Huacai
> + uint32_t pe_header;
> +};
> +
> +#endif /* __ASSEMBLY__ */
> +#endif /* __ASM_IMAGE_H */
> --
> 2.43.0
>