Linux Audio

Check our new training course

Loading...
v4.6
 
  1/*
  2 * Copyright (C) 2013-2015 Linaro Ltd
  3 * Authors: Roy Franz <roy.franz@linaro.org>
  4 *          Ard Biesheuvel <ard.biesheuvel@linaro.org>
  5 *
  6 * This program is free software; you can redistribute it and/or modify
  7 * it under the terms of the GNU General Public License version 2 as
  8 * published by the Free Software Foundation.
  9 */
 10
 
 
 
 11		.macro	__nop
 12#ifdef CONFIG_EFI_STUB
 13		@ This is almost but not quite a NOP, since it does clobber the
 14		@ condition flags. But it is the best we can do for EFI, since
 15		@ PE/COFF expects the magic string "MZ" at offset 0, while the
 16		@ ARM/Linux boot protocol expects an executable instruction
 17		@ there.
 18		.inst	'M' | ('Z' << 8) | (0x1310 << 16)   @ tstne r0, #0x4d000
 19#else
 20		mov	r0, r0
 
 21#endif
 22		.endm
 23
 24		.macro	__EFI_HEADER
 25#ifdef CONFIG_EFI_STUB
 26		b	__efi_start
 27
 28		.set	start_offset, __efi_start - start
 29		.org	start + 0x3c
 30		@
 31		@ The PE header can be anywhere in the file, but for
 32		@ simplicity we keep it together with the MSDOS header
 33		@ The offset to the PE/COFF header needs to be at offset
 34		@ 0x3C in the MSDOS header.
 35		@ The only 2 fields of the MSDOS header that are used are this
 36		@ PE/COFF offset, and the "MZ" bytes at offset 0x0.
 37		@
 38		.long	pe_header - start	@ Offset to the PE header.
 39
 40pe_header:
 41		.ascii	"PE\0\0"
 42
 43coff_header:
 44		.short	0x01c2			@ ARM or Thumb
 45		.short	2			@ nr_sections
 46		.long	0 			@ TimeDateStamp
 47		.long	0			@ PointerToSymbolTable
 48		.long	1			@ NumberOfSymbols
 49		.short	section_table - optional_header
 50						@ SizeOfOptionalHeader
 51		.short	0x306			@ Characteristics.
 52						@ IMAGE_FILE_32BIT_MACHINE |
 53						@ IMAGE_FILE_DEBUG_STRIPPED |
 54						@ IMAGE_FILE_EXECUTABLE_IMAGE |
 55						@ IMAGE_FILE_LINE_NUMS_STRIPPED
 56
 57optional_header:
 58		.short	0x10b			@ PE32 format
 59		.byte	0x02			@ MajorLinkerVersion
 60		.byte	0x14			@ MinorLinkerVersion
 61		.long	_end - __efi_start	@ SizeOfCode
 62		.long	0			@ SizeOfInitializedData
 63		.long	0			@ SizeOfUninitializedData
 64		.long	efi_stub_entry - start	@ AddressOfEntryPoint
 65		.long	start_offset		@ BaseOfCode
 66		.long	0			@ data
 67
 68extra_header_fields:
 69		.long	0			@ ImageBase
 70		.long	0x200			@ SectionAlignment
 71		.long	0x200			@ FileAlignment
 72		.short	0			@ MajorOperatingSystemVersion
 73		.short	0			@ MinorOperatingSystemVersion
 74		.short	0			@ MajorImageVersion
 75		.short	0			@ MinorImageVersion
 76		.short	0			@ MajorSubsystemVersion
 77		.short	0			@ MinorSubsystemVersion
 78		.long	0			@ Win32VersionValue
 79
 80		.long	_end - start		@ SizeOfImage
 81		.long	start_offset		@ SizeOfHeaders
 82		.long	0			@ CheckSum
 83		.short	0xa			@ Subsystem (EFI application)
 84		.short	0			@ DllCharacteristics
 85		.long	0			@ SizeOfStackReserve
 86		.long	0			@ SizeOfStackCommit
 87		.long	0			@ SizeOfHeapReserve
 88		.long	0			@ SizeOfHeapCommit
 89		.long	0			@ LoaderFlags
 90		.long	0x6			@ NumberOfRvaAndSizes
 91
 92		.quad	0			@ ExportTable
 93		.quad	0			@ ImportTable
 94		.quad	0			@ ResourceTable
 95		.quad	0			@ ExceptionTable
 96		.quad	0			@ CertificationTable
 97		.quad	0			@ BaseRelocationTable
 98
 99section_table:
100		@
101		@ The EFI application loader requires a relocation section
102		@ because EFI applications must be relocatable. This is a
103		@ dummy section as far as we are concerned.
104		@
105		.ascii	".reloc\0\0"
106		.long	0			@ VirtualSize
107		.long	0			@ VirtualAddress
108		.long	0			@ SizeOfRawData
109		.long	0			@ PointerToRawData
110		.long	0			@ PointerToRelocations
111		.long	0			@ PointerToLineNumbers
112		.short	0			@ NumberOfRelocations
113		.short	0			@ NumberOfLineNumbers
114		.long	0x42100040		@ Characteristics
115
116		.ascii	".text\0\0\0"
117		.long	_end - __efi_start	@ VirtualSize
118		.long	__efi_start		@ VirtualAddress
119		.long	_edata - __efi_start	@ SizeOfRawData
120		.long	__efi_start		@ PointerToRawData
121		.long	0			@ PointerToRelocations
122		.long	0			@ PointerToLineNumbers
123		.short	0			@ NumberOfRelocations
124		.short	0			@ NumberOfLineNumbers
125		.long	0xe0500020		@ Characteristics
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
127		.align	9
128__efi_start:
129#endif
130		.endm
v5.14.15
  1/* SPDX-License-Identifier: GPL-2.0-only */
  2/*
  3 * Copyright (C) 2013-2017 Linaro Ltd
  4 * Authors: Roy Franz <roy.franz@linaro.org>
  5 *          Ard Biesheuvel <ard.biesheuvel@linaro.org>
 
 
 
 
  6 */
  7
  8#include <linux/pe.h>
  9#include <linux/sizes.h>
 10
 11		.macro	__nop
 12#ifdef CONFIG_EFI_STUB
 13		@ This is almost but not quite a NOP, since it does clobber the
 14		@ condition flags. But it is the best we can do for EFI, since
 15		@ PE/COFF expects the magic string "MZ" at offset 0, while the
 16		@ ARM/Linux boot protocol expects an executable instruction
 17		@ there.
 18		.inst	MZ_MAGIC | (0x1310 << 16)	@ tstne r0, #0x4d000
 19#else
 20 AR_CLASS(	mov	r0, r0		)
 21  M_CLASS(	nop.w			)
 22#endif
 23		.endm
 24
 25		.macro	__EFI_HEADER
 26#ifdef CONFIG_EFI_STUB
 
 
 27		.set	start_offset, __efi_start - start
 28		.org	start + 0x3c
 29		@
 30		@ The PE header can be anywhere in the file, but for
 31		@ simplicity we keep it together with the MSDOS header
 32		@ The offset to the PE/COFF header needs to be at offset
 33		@ 0x3C in the MSDOS header.
 34		@ The only 2 fields of the MSDOS header that are used are this
 35		@ PE/COFF offset, and the "MZ" bytes at offset 0x0.
 36		@
 37		.long	pe_header - start		@ Offset to the PE header.
 38
 39pe_header:
 40		.long	PE_MAGIC
 41
 42coff_header:
 43		.short	IMAGE_FILE_MACHINE_THUMB	@ Machine
 44		.short	section_count			@ NumberOfSections
 45		.long	0 				@ TimeDateStamp
 46		.long	0				@ PointerToSymbolTable
 47		.long	0				@ NumberOfSymbols
 48		.short	section_table - optional_header	@ SizeOfOptionalHeader
 49		.short	IMAGE_FILE_32BIT_MACHINE | \
 50			IMAGE_FILE_DEBUG_STRIPPED | \
 51			IMAGE_FILE_EXECUTABLE_IMAGE | \
 52			IMAGE_FILE_LINE_NUMS_STRIPPED	@ Characteristics
 53
 54#define __pecoff_code_size (__pecoff_data_start - __efi_start)
 55
 56optional_header:
 57		.short	PE_OPT_MAGIC_PE32		@ PE32 format
 58		.byte	0x02				@ MajorLinkerVersion
 59		.byte	0x14				@ MinorLinkerVersion
 60		.long	__pecoff_code_size		@ SizeOfCode
 61		.long	__pecoff_data_size		@ SizeOfInitializedData
 62		.long	0				@ SizeOfUninitializedData
 63		.long	efi_pe_entry - start		@ AddressOfEntryPoint
 64		.long	start_offset			@ BaseOfCode
 65		.long	__pecoff_data_start - start	@ BaseOfData
 66
 67extra_header_fields:
 68		.long	0				@ ImageBase
 69		.long	SZ_4K				@ SectionAlignment
 70		.long	SZ_512				@ FileAlignment
 71		.short	0				@ MajorOsVersion
 72		.short	0				@ MinorOsVersion
 73		.short	LINUX_EFISTUB_MAJOR_VERSION	@ MajorImageVersion
 74		.short	LINUX_EFISTUB_MINOR_VERSION	@ MinorImageVersion
 75		.short	0				@ MajorSubsystemVersion
 76		.short	0				@ MinorSubsystemVersion
 77		.long	0				@ Win32VersionValue
 78
 79		.long	__pecoff_end - start		@ SizeOfImage
 80		.long	start_offset			@ SizeOfHeaders
 81		.long	0				@ CheckSum
 82		.short	IMAGE_SUBSYSTEM_EFI_APPLICATION	@ Subsystem
 83		.short	0				@ DllCharacteristics
 84		.long	0				@ SizeOfStackReserve
 85		.long	0				@ SizeOfStackCommit
 86		.long	0				@ SizeOfHeapReserve
 87		.long	0				@ SizeOfHeapCommit
 88		.long	0				@ LoaderFlags
 89		.long	(section_table - .) / 8		@ NumberOfRvaAndSizes
 90
 91		.quad	0				@ ExportTable
 92		.quad	0				@ ImportTable
 93		.quad	0				@ ResourceTable
 94		.quad	0				@ ExceptionTable
 95		.quad	0				@ CertificationTable
 96		.quad	0				@ BaseRelocationTable
 97
 98section_table:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 99		.ascii	".text\0\0\0"
100		.long	__pecoff_code_size		@ VirtualSize
101		.long	__efi_start			@ VirtualAddress
102		.long	__pecoff_code_size		@ SizeOfRawData
103		.long	__efi_start			@ PointerToRawData
104		.long	0				@ PointerToRelocations
105		.long	0				@ PointerToLineNumbers
106		.short	0				@ NumberOfRelocations
107		.short	0				@ NumberOfLineNumbers
108		.long	IMAGE_SCN_CNT_CODE | \
109			IMAGE_SCN_MEM_READ | \
110			IMAGE_SCN_MEM_EXECUTE		@ Characteristics
111
112		.ascii	".data\0\0\0"
113		.long	__pecoff_data_size		@ VirtualSize
114		.long	__pecoff_data_start - start	@ VirtualAddress
115		.long	__pecoff_data_rawsize		@ SizeOfRawData
116		.long	__pecoff_data_start - start	@ PointerToRawData
117		.long	0				@ PointerToRelocations
118		.long	0				@ PointerToLineNumbers
119		.short	0				@ NumberOfRelocations
120		.short	0				@ NumberOfLineNumbers
121		.long	IMAGE_SCN_CNT_INITIALIZED_DATA | \
122			IMAGE_SCN_MEM_READ | \
123			IMAGE_SCN_MEM_WRITE		@ Characteristics
124
125		.set	section_count, (. - section_table) / 40
126
127		.align	12
128__efi_start:
129#endif
130		.endm