]> git.karo-electronics.de Git - karo-tx-linux.git/blob - arch/arm64/kernel/efi-header.S
arm64: efi: move EFI header and related data to a separate .S file
[karo-tx-linux.git] / arch / arm64 / kernel / efi-header.S
1 /*
2  * Copyright (C) 2013 - 2017 Linaro, Ltd.
3  * Copyright (C) 2013, 2014 Red Hat, Inc.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation.
8  */
9
10         .macro  __EFI_PE_HEADER
11         .ascii  "PE"
12         .short  0
13 coff_header:
14         .short  0xaa64                                  // AArch64
15         .short  2                                       // nr_sections
16         .long   0                                       // TimeDateStamp
17         .long   0                                       // PointerToSymbolTable
18         .long   1                                       // NumberOfSymbols
19         .short  section_table - optional_header         // SizeOfOptionalHeader
20         .short  0x206                                   // Characteristics.
21                                                         // IMAGE_FILE_DEBUG_STRIPPED |
22                                                         // IMAGE_FILE_EXECUTABLE_IMAGE |
23                                                         // IMAGE_FILE_LINE_NUMS_STRIPPED
24 optional_header:
25         .short  0x20b                                   // PE32+ format
26         .byte   0x02                                    // MajorLinkerVersion
27         .byte   0x14                                    // MinorLinkerVersion
28         .long   _end - efi_header_end                   // SizeOfCode
29         .long   0                                       // SizeOfInitializedData
30         .long   0                                       // SizeOfUninitializedData
31         .long   __efistub_entry - _head                 // AddressOfEntryPoint
32         .long   efi_header_end - _head                  // BaseOfCode
33
34 extra_header_fields:
35         .quad   0                                       // ImageBase
36         .long   0x1000                                  // SectionAlignment
37         .long   PECOFF_FILE_ALIGNMENT                   // FileAlignment
38         .short  0                                       // MajorOperatingSystemVersion
39         .short  0                                       // MinorOperatingSystemVersion
40         .short  0                                       // MajorImageVersion
41         .short  0                                       // MinorImageVersion
42         .short  0                                       // MajorSubsystemVersion
43         .short  0                                       // MinorSubsystemVersion
44         .long   0                                       // Win32VersionValue
45
46         .long   _end - _head                            // SizeOfImage
47
48         // Everything before the kernel image is considered part of the header
49         .long   efi_header_end - _head                  // SizeOfHeaders
50         .long   0                                       // CheckSum
51         .short  0xa                                     // Subsystem (EFI application)
52         .short  0                                       // DllCharacteristics
53         .quad   0                                       // SizeOfStackReserve
54         .quad   0                                       // SizeOfStackCommit
55         .quad   0                                       // SizeOfHeapReserve
56         .quad   0                                       // SizeOfHeapCommit
57         .long   0                                       // LoaderFlags
58         .long   (section_table - .) / 8                 // NumberOfRvaAndSizes
59
60         .quad   0                                       // ExportTable
61         .quad   0                                       // ImportTable
62         .quad   0                                       // ResourceTable
63         .quad   0                                       // ExceptionTable
64         .quad   0                                       // CertificationTable
65         .quad   0                                       // BaseRelocationTable
66
67 #ifdef CONFIG_DEBUG_EFI
68         .long   efi_debug_table - _head                 // DebugTable
69         .long   efi_debug_table_size
70 #endif
71
72         // Section table
73 section_table:
74
75         /*
76          * The EFI application loader requires a relocation section
77          * because EFI applications must be relocatable.  This is a
78          * dummy section as far as we are concerned.
79          */
80         .ascii  ".reloc"
81         .byte   0
82         .byte   0                                       // end of 0 padding of section name
83         .long   0
84         .long   0
85         .long   0                                       // SizeOfRawData
86         .long   0                                       // PointerToRawData
87         .long   0                                       // PointerToRelocations
88         .long   0                                       // PointerToLineNumbers
89         .short  0                                       // NumberOfRelocations
90         .short  0                                       // NumberOfLineNumbers
91         .long   0x42100040                              // Characteristics (section flags)
92
93
94         .ascii  ".text"
95         .byte   0
96         .byte   0
97         .byte   0                                       // end of 0 padding of section name
98         .long   _end - efi_header_end                   // VirtualSize
99         .long   efi_header_end - _head                  // VirtualAddress
100         .long   _edata - efi_header_end                 // SizeOfRawData
101         .long   efi_header_end - _head                  // PointerToRawData
102
103         .long   0                                       // PointerToRelocations
104         .long   0                                       // PointerToLineNumbers
105         .short  0                                       // NumberOfRelocations
106         .short  0                                       // NumberOfLineNumbers
107         .long   0xe0500020                              // Characteristics
108
109 #ifdef CONFIG_DEBUG_EFI
110         /*
111          * The debug table is referenced via its Relative Virtual Address (RVA),
112          * which is only defined for those parts of the image that are covered
113          * by a section declaration. Since this header is not covered by any
114          * section, the debug table must be emitted elsewhere. So stick it in
115          * the .init.rodata section instead.
116          *
117          * Note that the EFI debug entry itself may legally have a zero RVA,
118          * which means we can simply put it right after the section headers.
119          */
120         __INITRODATA
121
122         .align  2
123 efi_debug_table:
124         // EFI_IMAGE_DEBUG_DIRECTORY_ENTRY
125         .long   0                                       // Characteristics
126         .long   0                                       // TimeDateStamp
127         .short  0                                       // MajorVersion
128         .short  0                                       // MinorVersion
129         .long   2                                       // Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW
130         .long   efi_debug_entry_size                    // SizeOfData
131         .long   0                                       // RVA
132         .long   efi_debug_entry - _head                 // FileOffset
133
134         .set    efi_debug_table_size, . - efi_debug_table
135         .previous
136
137 efi_debug_entry:
138         // EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY
139         .ascii  "NB10"                                  // Signature
140         .long   0                                       // Unknown
141         .long   0                                       // Unknown2
142         .long   0                                       // Unknown3
143
144         .asciz  VMLINUX_PATH
145
146         .set    efi_debug_entry_size, . - efi_debug_entry
147 #endif
148
149         /*
150          * EFI will load .text onwards at the 4k section alignment
151          * described in the PE/COFF header. To ensure that instruction
152          * sequences using an adrp and a :lo12: immediate will function
153          * correctly at this alignment, we must ensure that .text is
154          * placed at a 4k boundary in the Image to begin with.
155          */
156         .align 12
157 efi_header_end:
158         .endm