arch/arm/boot/compressed/efi-header.S

Source file repositories/reference/linux-study-clean/arch/arm/boot/compressed/efi-header.S

File Facts

System
Linux kernel
Corpus path
arch/arm/boot/compressed/efi-header.S
Extension
.S
Size
4236 bytes
Lines
137
Domain
Architecture Layer
Bucket
arch/arm
Inferred role
Architecture Layer: arch/arm
Status
atlas-only

Why This File Exists

CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.

Dependency Surface

Detected Declarations

Annotated Snippet

#include <linux/pe.h>
#include <linux/sizes.h>

		.macro	__nop
 AR_CLASS(	mov	r0, r0		)
  M_CLASS(	nop.w			)
		.endm

		.macro __initial_nops
#ifdef CONFIG_EFI_STUB
		@ This is a two-instruction NOP, which happens to bear the
		@ PE/COFF signature "MZ" in the first two bytes, so the kernel
		@ is accepted as an EFI binary. Booting via the UEFI stub
		@ will not execute those instructions, but the ARM/Linux
		@ boot protocol does, so we need some NOPs here.
		.inst	IMAGE_DOS_SIGNATURE | (0xe225 << 16) @ eor r5, r5, 0x4d000
		eor	r5, r5, 0x4d000			@ undo previous insn
#else
		__nop
		__nop
#endif
		.endm

		.macro	__EFI_HEADER
#ifdef CONFIG_EFI_STUB
		.set	start_offset, __efi_start - start
		.org	start + 0x3c
		@
		@ The PE header can be anywhere in the file, but for
		@ simplicity we keep it together with the MSDOS header
		@ The offset to the PE/COFF header needs to be at offset
		@ 0x3C in the MSDOS header.
		@ The only 2 fields of the MSDOS header that are used are this
		@ PE/COFF offset, and the "MZ" bytes at offset 0x0.
		@
		.long	pe_header - start		@ Offset to the PE header.

pe_header:
		.long	IMAGE_NT_SIGNATURE

coff_header:
		.short	IMAGE_FILE_MACHINE_THUMB	@ Machine
		.short	section_count			@ NumberOfSections
		.long	0 				@ TimeDateStamp
		.long	0				@ PointerToSymbolTable
		.long	0				@ NumberOfSymbols
		.short	section_table - optional_header	@ SizeOfOptionalHeader
		.short	IMAGE_FILE_32BIT_MACHINE | \
			IMAGE_FILE_DEBUG_STRIPPED | \
			IMAGE_FILE_EXECUTABLE_IMAGE | \
			IMAGE_FILE_LINE_NUMS_STRIPPED	@ Characteristics

#define __pecoff_code_size (__pecoff_data_start - __efi_start)

optional_header:
		.short	IMAGE_NT_OPTIONAL_HDR32_MAGIC	@ PE32 format
		.byte	0x02				@ MajorLinkerVersion
		.byte	0x14				@ MinorLinkerVersion
		.long	__pecoff_code_size		@ SizeOfCode
		.long	__pecoff_data_size		@ SizeOfInitializedData
		.long	0				@ SizeOfUninitializedData
		.long	efi_pe_entry - start		@ AddressOfEntryPoint
		.long	start_offset			@ BaseOfCode
		.long	__pecoff_data_start - start	@ BaseOfData

extra_header_fields:
		.long	0				@ ImageBase
		.long	SZ_4K				@ SectionAlignment
		.long	SZ_512				@ FileAlignment
		.short	0				@ MajorOsVersion

Annotation

Implementation Notes