xref: /openbmc/linux/arch/loongarch/kernel/efi-header.S (revision ead384d956345681e1ddf97890d5e15ded015f07)
1*ead384d9SHuacai Chen/* SPDX-License-Identifier: GPL-2.0 */
2*ead384d9SHuacai Chen/*
3*ead384d9SHuacai Chen * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
4*ead384d9SHuacai Chen */
5*ead384d9SHuacai Chen
6*ead384d9SHuacai Chen#include <linux/pe.h>
7*ead384d9SHuacai Chen#include <linux/sizes.h>
8*ead384d9SHuacai Chen
9*ead384d9SHuacai Chen	.macro	__EFI_PE_HEADER
10*ead384d9SHuacai Chen	.long	PE_MAGIC
11*ead384d9SHuacai Chen.Lcoff_header:
12*ead384d9SHuacai Chen	.short	IMAGE_FILE_MACHINE_LOONGARCH64		/* Machine */
13*ead384d9SHuacai Chen	.short	.Lsection_count				/* NumberOfSections */
14*ead384d9SHuacai Chen	.long	0 					/* TimeDateStamp */
15*ead384d9SHuacai Chen	.long	0					/* PointerToSymbolTable */
16*ead384d9SHuacai Chen	.long	0					/* NumberOfSymbols */
17*ead384d9SHuacai Chen	.short	.Lsection_table - .Loptional_header	/* SizeOfOptionalHeader */
18*ead384d9SHuacai Chen	.short	IMAGE_FILE_DEBUG_STRIPPED | \
19*ead384d9SHuacai Chen		IMAGE_FILE_EXECUTABLE_IMAGE | \
20*ead384d9SHuacai Chen		IMAGE_FILE_LINE_NUMS_STRIPPED		/* Characteristics */
21*ead384d9SHuacai Chen
22*ead384d9SHuacai Chen.Loptional_header:
23*ead384d9SHuacai Chen	.short	PE_OPT_MAGIC_PE32PLUS			/* PE32+ format */
24*ead384d9SHuacai Chen	.byte	0x02					/* MajorLinkerVersion */
25*ead384d9SHuacai Chen	.byte	0x14					/* MinorLinkerVersion */
26*ead384d9SHuacai Chen	.long	__inittext_end - .Lefi_header_end	/* SizeOfCode */
27*ead384d9SHuacai Chen	.long	_end - __initdata_begin			/* SizeOfInitializedData */
28*ead384d9SHuacai Chen	.long	0					/* SizeOfUninitializedData */
29*ead384d9SHuacai Chen	.long	__efistub_efi_pe_entry - _head		/* AddressOfEntryPoint */
30*ead384d9SHuacai Chen	.long	.Lefi_header_end - _head		/* BaseOfCode */
31*ead384d9SHuacai Chen
32*ead384d9SHuacai Chen.Lextra_header_fields:
33*ead384d9SHuacai Chen	.quad	0					/* ImageBase */
34*ead384d9SHuacai Chen	.long	PECOFF_SEGMENT_ALIGN			/* SectionAlignment */
35*ead384d9SHuacai Chen	.long	PECOFF_FILE_ALIGN			/* FileAlignment */
36*ead384d9SHuacai Chen	.short	0					/* MajorOperatingSystemVersion */
37*ead384d9SHuacai Chen	.short	0					/* MinorOperatingSystemVersion */
38*ead384d9SHuacai Chen	.short	LINUX_EFISTUB_MAJOR_VERSION		/* MajorImageVersion */
39*ead384d9SHuacai Chen	.short	LINUX_EFISTUB_MINOR_VERSION		/* MinorImageVersion */
40*ead384d9SHuacai Chen	.short	0					/* MajorSubsystemVersion */
41*ead384d9SHuacai Chen	.short	0					/* MinorSubsystemVersion */
42*ead384d9SHuacai Chen	.long	0					/* Win32VersionValue */
43*ead384d9SHuacai Chen
44*ead384d9SHuacai Chen	.long	_end - _head				/* SizeOfImage */
45*ead384d9SHuacai Chen
46*ead384d9SHuacai Chen	/* Everything before the kernel image is considered part of the header */
47*ead384d9SHuacai Chen	.long	.Lefi_header_end - _head		/* SizeOfHeaders */
48*ead384d9SHuacai Chen	.long	0					/* CheckSum */
49*ead384d9SHuacai Chen	.short	IMAGE_SUBSYSTEM_EFI_APPLICATION		/* Subsystem */
50*ead384d9SHuacai Chen	.short	0					/* DllCharacteristics */
51*ead384d9SHuacai Chen	.quad	0					/* SizeOfStackReserve */
52*ead384d9SHuacai Chen	.quad	0					/* SizeOfStackCommit */
53*ead384d9SHuacai Chen	.quad	0					/* SizeOfHeapReserve */
54*ead384d9SHuacai Chen	.quad	0					/* SizeOfHeapCommit */
55*ead384d9SHuacai Chen	.long	0					/* LoaderFlags */
56*ead384d9SHuacai Chen	.long	(.Lsection_table - .) / 8		/* NumberOfRvaAndSizes */
57*ead384d9SHuacai Chen
58*ead384d9SHuacai Chen	.quad	0					/* ExportTable */
59*ead384d9SHuacai Chen	.quad	0					/* ImportTable */
60*ead384d9SHuacai Chen	.quad	0					/* ResourceTable */
61*ead384d9SHuacai Chen	.quad	0					/* ExceptionTable */
62*ead384d9SHuacai Chen	.quad	0					/* CertificationTable */
63*ead384d9SHuacai Chen	.quad	0					/* BaseRelocationTable */
64*ead384d9SHuacai Chen
65*ead384d9SHuacai Chen	/* Section table */
66*ead384d9SHuacai Chen.Lsection_table:
67*ead384d9SHuacai Chen	.ascii	".text\0\0\0"
68*ead384d9SHuacai Chen	.long	__inittext_end - .Lefi_header_end	/* VirtualSize */
69*ead384d9SHuacai Chen	.long	.Lefi_header_end - _head		/* VirtualAddress */
70*ead384d9SHuacai Chen	.long	__inittext_end - .Lefi_header_end	/* SizeOfRawData */
71*ead384d9SHuacai Chen	.long	.Lefi_header_end - _head		/* PointerToRawData */
72*ead384d9SHuacai Chen
73*ead384d9SHuacai Chen	.long	0					/* PointerToRelocations */
74*ead384d9SHuacai Chen	.long	0					/* PointerToLineNumbers */
75*ead384d9SHuacai Chen	.short	0					/* NumberOfRelocations */
76*ead384d9SHuacai Chen	.short	0					/* NumberOfLineNumbers */
77*ead384d9SHuacai Chen	.long	IMAGE_SCN_CNT_CODE | \
78*ead384d9SHuacai Chen		IMAGE_SCN_MEM_READ | \
79*ead384d9SHuacai Chen		IMAGE_SCN_MEM_EXECUTE			/* Characteristics */
80*ead384d9SHuacai Chen
81*ead384d9SHuacai Chen	.ascii	".data\0\0\0"
82*ead384d9SHuacai Chen	.long	_end - __initdata_begin			/* VirtualSize */
83*ead384d9SHuacai Chen	.long	__initdata_begin - _head		/* VirtualAddress */
84*ead384d9SHuacai Chen	.long	_edata - __initdata_begin		/* SizeOfRawData */
85*ead384d9SHuacai Chen	.long	__initdata_begin - _head		/* PointerToRawData */
86*ead384d9SHuacai Chen
87*ead384d9SHuacai Chen	.long	0					/* PointerToRelocations */
88*ead384d9SHuacai Chen	.long	0					/* PointerToLineNumbers */
89*ead384d9SHuacai Chen	.short	0					/* NumberOfRelocations */
90*ead384d9SHuacai Chen	.short	0					/* NumberOfLineNumbers */
91*ead384d9SHuacai Chen	.long	IMAGE_SCN_CNT_INITIALIZED_DATA | \
92*ead384d9SHuacai Chen		IMAGE_SCN_MEM_READ | \
93*ead384d9SHuacai Chen		IMAGE_SCN_MEM_WRITE			/* Characteristics */
94*ead384d9SHuacai Chen
95*ead384d9SHuacai Chen	.set	.Lsection_count, (. - .Lsection_table) / 40
96*ead384d9SHuacai Chen
97*ead384d9SHuacai Chen	.balign	0x10000					/* PECOFF_SEGMENT_ALIGN */
98*ead384d9SHuacai Chen.Lefi_header_end:
99*ead384d9SHuacai Chen	.endm
100