Merge tag 'for-linus-4.12b-rc5-tag' of git://git.kernel.org/pub/scm/linux/kernel...
[sfrench/cifs-2.6.git] / arch / arm / boot / compressed / efi-header.S
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                 W(mov)  r0, r0
21 #endif
22                 .endm
23
24                 .macro  __EFI_HEADER
25 #ifdef CONFIG_EFI_STUB
26                 .set    start_offset, __efi_start - start
27                 .org    start + 0x3c
28                 @
29                 @ The PE header can be anywhere in the file, but for
30                 @ simplicity we keep it together with the MSDOS header
31                 @ The offset to the PE/COFF header needs to be at offset
32                 @ 0x3C in the MSDOS header.
33                 @ The only 2 fields of the MSDOS header that are used are this
34                 @ PE/COFF offset, and the "MZ" bytes at offset 0x0.
35                 @
36                 .long   pe_header - start       @ Offset to the PE header.
37
38 pe_header:
39                 .ascii  "PE\0\0"
40
41 coff_header:
42                 .short  0x01c2                  @ ARM or Thumb
43                 .short  2                       @ nr_sections
44                 .long   0                       @ TimeDateStamp
45                 .long   0                       @ PointerToSymbolTable
46                 .long   1                       @ NumberOfSymbols
47                 .short  section_table - optional_header
48                                                 @ SizeOfOptionalHeader
49                 .short  0x306                   @ Characteristics.
50                                                 @ IMAGE_FILE_32BIT_MACHINE |
51                                                 @ IMAGE_FILE_DEBUG_STRIPPED |
52                                                 @ IMAGE_FILE_EXECUTABLE_IMAGE |
53                                                 @ IMAGE_FILE_LINE_NUMS_STRIPPED
54
55 optional_header:
56                 .short  0x10b                   @ PE32 format
57                 .byte   0x02                    @ MajorLinkerVersion
58                 .byte   0x14                    @ MinorLinkerVersion
59                 .long   _end - __efi_start      @ SizeOfCode
60                 .long   0                       @ SizeOfInitializedData
61                 .long   0                       @ SizeOfUninitializedData
62                 .long   efi_stub_entry - start  @ AddressOfEntryPoint
63                 .long   start_offset            @ BaseOfCode
64                 .long   0                       @ data
65
66 extra_header_fields:
67                 .long   0                       @ ImageBase
68                 .long   0x200                   @ SectionAlignment
69                 .long   0x200                   @ FileAlignment
70                 .short  0                       @ MajorOperatingSystemVersion
71                 .short  0                       @ MinorOperatingSystemVersion
72                 .short  0                       @ MajorImageVersion
73                 .short  0                       @ MinorImageVersion
74                 .short  0                       @ MajorSubsystemVersion
75                 .short  0                       @ MinorSubsystemVersion
76                 .long   0                       @ Win32VersionValue
77
78                 .long   _end - start            @ SizeOfImage
79                 .long   start_offset            @ SizeOfHeaders
80                 .long   0                       @ CheckSum
81                 .short  0xa                     @ Subsystem (EFI application)
82                 .short  0                       @ DllCharacteristics
83                 .long   0                       @ SizeOfStackReserve
84                 .long   0                       @ SizeOfStackCommit
85                 .long   0                       @ SizeOfHeapReserve
86                 .long   0                       @ SizeOfHeapCommit
87                 .long   0                       @ LoaderFlags
88                 .long   0x6                     @ NumberOfRvaAndSizes
89
90                 .quad   0                       @ ExportTable
91                 .quad   0                       @ ImportTable
92                 .quad   0                       @ ResourceTable
93                 .quad   0                       @ ExceptionTable
94                 .quad   0                       @ CertificationTable
95                 .quad   0                       @ BaseRelocationTable
96
97 section_table:
98                 @
99                 @ The EFI application loader requires a relocation section
100                 @ because EFI applications must be relocatable. This is a
101                 @ dummy section as far as we are concerned.
102                 @
103                 .ascii  ".reloc\0\0"
104                 .long   0                       @ VirtualSize
105                 .long   0                       @ VirtualAddress
106                 .long   0                       @ SizeOfRawData
107                 .long   0                       @ PointerToRawData
108                 .long   0                       @ PointerToRelocations
109                 .long   0                       @ PointerToLineNumbers
110                 .short  0                       @ NumberOfRelocations
111                 .short  0                       @ NumberOfLineNumbers
112                 .long   0x42100040              @ Characteristics
113
114                 .ascii  ".text\0\0\0"
115                 .long   _end - __efi_start      @ VirtualSize
116                 .long   __efi_start             @ VirtualAddress
117                 .long   _edata - __efi_start    @ SizeOfRawData
118                 .long   __efi_start             @ PointerToRawData
119                 .long   0                       @ PointerToRelocations
120                 .long   0                       @ PointerToLineNumbers
121                 .short  0                       @ NumberOfRelocations
122                 .short  0                       @ NumberOfLineNumbers
123                 .long   0xe0500020              @ Characteristics
124
125                 .align  9
126 __efi_start:
127 #endif
128                 .endm