diff options
Diffstat (limited to 'arch/x86/boot/header.S')
-rw-r--r-- | arch/x86/boot/header.S | 158 |
1 files changed, 158 insertions, 0 deletions
diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S index bdb4d458ec8c..f1bbeeb09148 100644 --- a/arch/x86/boot/header.S +++ b/arch/x86/boot/header.S | |||
@@ -45,6 +45,11 @@ SYSSEG = 0x1000 /* historical load address >> 4 */ | |||
45 | 45 | ||
46 | .global bootsect_start | 46 | .global bootsect_start |
47 | bootsect_start: | 47 | bootsect_start: |
48 | #ifdef CONFIG_EFI_STUB | ||
49 | # "MZ", MS-DOS header | ||
50 | .byte 0x4d | ||
51 | .byte 0x5a | ||
52 | #endif | ||
48 | 53 | ||
49 | # Normalize the start address | 54 | # Normalize the start address |
50 | ljmp $BOOTSEG, $start2 | 55 | ljmp $BOOTSEG, $start2 |
@@ -79,6 +84,14 @@ bs_die: | |||
79 | # invoke the BIOS reset code... | 84 | # invoke the BIOS reset code... |
80 | ljmp $0xf000,$0xfff0 | 85 | ljmp $0xf000,$0xfff0 |
81 | 86 | ||
87 | #ifdef CONFIG_EFI_STUB | ||
88 | .org 0x3c | ||
89 | # | ||
90 | # Offset to the PE header. | ||
91 | # | ||
92 | .long pe_header | ||
93 | #endif /* CONFIG_EFI_STUB */ | ||
94 | |||
82 | .section ".bsdata", "a" | 95 | .section ".bsdata", "a" |
83 | bugger_off_msg: | 96 | bugger_off_msg: |
84 | .ascii "Direct booting from floppy is no longer supported.\r\n" | 97 | .ascii "Direct booting from floppy is no longer supported.\r\n" |
@@ -87,6 +100,141 @@ bugger_off_msg: | |||
87 | .ascii "Remove disk and press any key to reboot . . .\r\n" | 100 | .ascii "Remove disk and press any key to reboot . . .\r\n" |
88 | .byte 0 | 101 | .byte 0 |
89 | 102 | ||
103 | #ifdef CONFIG_EFI_STUB | ||
104 | pe_header: | ||
105 | .ascii "PE" | ||
106 | .word 0 | ||
107 | |||
108 | coff_header: | ||
109 | #ifdef CONFIG_X86_32 | ||
110 | .word 0x14c # i386 | ||
111 | #else | ||
112 | .word 0x8664 # x86-64 | ||
113 | #endif | ||
114 | .word 2 # nr_sections | ||
115 | .long 0 # TimeDateStamp | ||
116 | .long 0 # PointerToSymbolTable | ||
117 | .long 1 # NumberOfSymbols | ||
118 | .word section_table - optional_header # SizeOfOptionalHeader | ||
119 | #ifdef CONFIG_X86_32 | ||
120 | .word 0x306 # Characteristics. | ||
121 | # IMAGE_FILE_32BIT_MACHINE | | ||
122 | # IMAGE_FILE_DEBUG_STRIPPED | | ||
123 | # IMAGE_FILE_EXECUTABLE_IMAGE | | ||
124 | # IMAGE_FILE_LINE_NUMS_STRIPPED | ||
125 | #else | ||
126 | .word 0x206 # Characteristics | ||
127 | # IMAGE_FILE_DEBUG_STRIPPED | | ||
128 | # IMAGE_FILE_EXECUTABLE_IMAGE | | ||
129 | # IMAGE_FILE_LINE_NUMS_STRIPPED | ||
130 | #endif | ||
131 | |||
132 | optional_header: | ||
133 | #ifdef CONFIG_X86_32 | ||
134 | .word 0x10b # PE32 format | ||
135 | #else | ||
136 | .word 0x20b # PE32+ format | ||
137 | #endif | ||
138 | .byte 0x02 # MajorLinkerVersion | ||
139 | .byte 0x14 # MinorLinkerVersion | ||
140 | |||
141 | # Filled in by build.c | ||
142 | .long 0 # SizeOfCode | ||
143 | |||
144 | .long 0 # SizeOfInitializedData | ||
145 | .long 0 # SizeOfUninitializedData | ||
146 | |||
147 | # Filled in by build.c | ||
148 | .long 0x0000 # AddressOfEntryPoint | ||
149 | |||
150 | .long 0x0000 # BaseOfCode | ||
151 | #ifdef CONFIG_X86_32 | ||
152 | .long 0 # data | ||
153 | #endif | ||
154 | |||
155 | extra_header_fields: | ||
156 | #ifdef CONFIG_X86_32 | ||
157 | .long 0 # ImageBase | ||
158 | #else | ||
159 | .quad 0 # ImageBase | ||
160 | #endif | ||
161 | .long 0x1000 # SectionAlignment | ||
162 | .long 0x200 # FileAlignment | ||
163 | .word 0 # MajorOperatingSystemVersion | ||
164 | .word 0 # MinorOperatingSystemVersion | ||
165 | .word 0 # MajorImageVersion | ||
166 | .word 0 # MinorImageVersion | ||
167 | .word 0 # MajorSubsystemVersion | ||
168 | .word 0 # MinorSubsystemVersion | ||
169 | .long 0 # Win32VersionValue | ||
170 | |||
171 | # | ||
172 | # The size of the bzImage is written in tools/build.c | ||
173 | # | ||
174 | .long 0 # SizeOfImage | ||
175 | |||
176 | .long 0x200 # SizeOfHeaders | ||
177 | .long 0 # CheckSum | ||
178 | .word 0xa # Subsystem (EFI application) | ||
179 | .word 0 # DllCharacteristics | ||
180 | #ifdef CONFIG_X86_32 | ||
181 | .long 0 # SizeOfStackReserve | ||
182 | .long 0 # SizeOfStackCommit | ||
183 | .long 0 # SizeOfHeapReserve | ||
184 | .long 0 # SizeOfHeapCommit | ||
185 | #else | ||
186 | .quad 0 # SizeOfStackReserve | ||
187 | .quad 0 # SizeOfStackCommit | ||
188 | .quad 0 # SizeOfHeapReserve | ||
189 | .quad 0 # SizeOfHeapCommit | ||
190 | #endif | ||
191 | .long 0 # LoaderFlags | ||
192 | .long 0x1 # NumberOfRvaAndSizes | ||
193 | |||
194 | .quad 0 # ExportTable | ||
195 | .quad 0 # ImportTable | ||
196 | .quad 0 # ResourceTable | ||
197 | .quad 0 # ExceptionTable | ||
198 | .quad 0 # CertificationTable | ||
199 | .quad 0 # BaseRelocationTable | ||
200 | |||
201 | # Section table | ||
202 | section_table: | ||
203 | .ascii ".text" | ||
204 | .byte 0 | ||
205 | .byte 0 | ||
206 | .byte 0 | ||
207 | .long 0 | ||
208 | .long 0x0 # startup_{32,64} | ||
209 | .long 0 # Size of initialized data | ||
210 | # on disk | ||
211 | .long 0x0 # startup_{32,64} | ||
212 | .long 0 # PointerToRelocations | ||
213 | .long 0 # PointerToLineNumbers | ||
214 | .word 0 # NumberOfRelocations | ||
215 | .word 0 # NumberOfLineNumbers | ||
216 | .long 0x60500020 # Characteristics (section flags) | ||
217 | |||
218 | # | ||
219 | # The EFI application loader requires a relocation section | ||
220 | # because EFI applications are relocatable and not having | ||
221 | # this section seems to confuse it. But since we don't need | ||
222 | # the loader to fixup any relocs for us just fill it with a | ||
223 | # single dummy reloc. | ||
224 | # | ||
225 | .ascii ".reloc" | ||
226 | .byte 0 | ||
227 | .byte 0 | ||
228 | .long reloc_end - reloc_start | ||
229 | .long reloc_start | ||
230 | .long reloc_end - reloc_start # SizeOfRawData | ||
231 | .long reloc_start # PointerToRawData | ||
232 | .long 0 # PointerToRelocations | ||
233 | .long 0 # PointerToLineNumbers | ||
234 | .word 0 # NumberOfRelocations | ||
235 | .word 0 # NumberOfLineNumbers | ||
236 | .long 0x42100040 # Characteristics (section flags) | ||
237 | #endif /* CONFIG_EFI_STUB */ | ||
90 | 238 | ||
91 | # Kernel attributes; used by setup. This is part 1 of the | 239 | # Kernel attributes; used by setup. This is part 1 of the |
92 | # header, from the old boot sector. | 240 | # header, from the old boot sector. |
@@ -318,3 +466,13 @@ die: | |||
318 | setup_corrupt: | 466 | setup_corrupt: |
319 | .byte 7 | 467 | .byte 7 |
320 | .string "No setup signature found...\n" | 468 | .string "No setup signature found...\n" |
469 | |||
470 | .data | ||
471 | dummy: .long 0 | ||
472 | |||
473 | .section .reloc | ||
474 | reloc_start: | ||
475 | .long dummy - reloc_start | ||
476 | .long 10 | ||
477 | .word 0 | ||
478 | reloc_end: | ||