aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/boot/compressed/eboot.h
diff options
context:
space:
mode:
authorMatt Fleming <matt.fleming@intel.com>2011-12-12 16:27:52 -0500
committerH. Peter Anvin <hpa@linux.intel.com>2011-12-12 17:26:10 -0500
commit291f36325f9f252bd76ef5f603995f37e453fc60 (patch)
treed2730af48f276882ef3a33f96b8db21f19d593eb /arch/x86/boot/compressed/eboot.h
parent55839d515495e766605d7aaabd9c2758370a8d27 (diff)
x86, efi: EFI boot stub support
There is currently a large divide between kernel development and the development of EFI boot loaders. The idea behind this patch is to give the kernel developers full control over the EFI boot process. As H. Peter Anvin put it, "The 'kernel carries its own stub' approach been very successful in dealing with BIOS, and would make a lot of sense to me for EFI as well." This patch introduces an EFI boot stub that allows an x86 bzImage to be loaded and executed by EFI firmware. The bzImage appears to the firmware as an EFI application. Luckily there are enough free bits within the bzImage header so that it can masquerade as an EFI application, thereby coercing the EFI firmware into loading it and jumping to its entry point. The beauty of this masquerading approach is that both BIOS and EFI boot loaders can still load and run the same bzImage, thereby allowing a single kernel image to work in any boot environment. The EFI boot stub supports multiple initrds, but they must exist on the same partition as the bzImage. Command-line arguments for the kernel can be appended after the bzImage name when run from the EFI shell, e.g. Shell> bzImage console=ttyS0 root=/dev/sdb initrd=initrd.img v7: - Fix checkpatch warnings. v6: - Try to allocate initrd memory just below hdr->inird_addr_max. v5: - load_options_size is UTF-16, which needs dividing by 2 to convert to the corresponding ASCII size. v4: - Don't read more than image->load_options_size v3: - Fix following warnings when compiling CONFIG_EFI_STUB=n arch/x86/boot/tools/build.c: In function ‘main’: arch/x86/boot/tools/build.c:138:24: warning: unused variable ‘pe_header’ arch/x86/boot/tools/build.c:138:15: warning: unused variable ‘file_sz’ - As reported by Matthew Garrett, some Apple machines have GOPs that don't have hardware attached. We need to weed these out by searching for ones that handle the PCIIO protocol. - Don't allocate memory if no initrds are on cmdline - Don't trust image->load_options_size Maarten Lankhorst noted: - Don't strip first argument when booted from efibootmgr - Don't allocate too much memory for cmdline - Don't update cmdline_size, the kernel considers it read-only - Don't accept '\n' for initrd names v2: - File alignment was too large, was 8192 should be 512. Reported by Maarten Lankhorst on LKML. - Added UGA support for graphics - Use VIDEO_TYPE_EFI instead of hard-coded number. - Move linelength assignment until after we've assigned depth - Dynamically fill out AddressOfEntryPoint in tools/build.c - Don't use magic number for GDT/TSS stuff. Requested by Andi Kleen - The bzImage may need to be relocated as it may have been loaded at a high address address by the firmware. This was required to get my macbook booting because the firmware loaded it at 0x7cxxxxxx, which triggers this error in decompress_kernel(), if (heap > ((-__PAGE_OFFSET-(128<<20)-1) & 0x7fffffff)) error("Destination address too large"); Cc: Mike Waychison <mikew@google.com> Cc: Matthew Garrett <mjg@redhat.com> Tested-by: Henrik Rydberg <rydberg@euromail.se> Signed-off-by: Matt Fleming <matt.fleming@intel.com> Link: http://lkml.kernel.org/r/1321383097.2657.9.camel@mfleming-mobl1.ger.corp.intel.com Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Diffstat (limited to 'arch/x86/boot/compressed/eboot.h')
-rw-r--r--arch/x86/boot/compressed/eboot.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/arch/x86/boot/compressed/eboot.h b/arch/x86/boot/compressed/eboot.h
new file mode 100644
index 000000000000..f66d023e91ef
--- /dev/null
+++ b/arch/x86/boot/compressed/eboot.h
@@ -0,0 +1,60 @@
1#ifndef BOOT_COMPRESSED_EBOOT_H
2#define BOOT_COMPRESSED_EBOOT_H
3
4#define SEG_TYPE_DATA (0 << 3)
5#define SEG_TYPE_READ_WRITE (1 << 1)
6#define SEG_TYPE_CODE (1 << 3)
7#define SEG_TYPE_EXEC_READ (1 << 1)
8#define SEG_TYPE_TSS ((1 << 3) | (1 << 0))
9#define SEG_OP_SIZE_32BIT (1 << 0)
10#define SEG_GRANULARITY_4KB (1 << 0)
11
12#define DESC_TYPE_CODE_DATA (1 << 0)
13
14#define EFI_PAGE_SIZE (1UL << EFI_PAGE_SHIFT)
15
16#define PIXEL_RGB_RESERVED_8BIT_PER_COLOR 0
17#define PIXEL_BGR_RESERVED_8BIT_PER_COLOR 1
18#define PIXEL_BIT_MASK 2
19#define PIXEL_BLT_ONLY 3
20#define PIXEL_FORMAT_MAX 4
21
22struct efi_pixel_bitmask {
23 u32 red_mask;
24 u32 green_mask;
25 u32 blue_mask;
26 u32 reserved_mask;
27};
28
29struct efi_graphics_output_mode_info {
30 u32 version;
31 u32 horizontal_resolution;
32 u32 vertical_resolution;
33 int pixel_format;
34 struct efi_pixel_bitmask pixel_information;
35 u32 pixels_per_scan_line;
36} __packed;
37
38struct efi_graphics_output_protocol_mode {
39 u32 max_mode;
40 u32 mode;
41 unsigned long info;
42 unsigned long size_of_info;
43 u64 frame_buffer_base;
44 unsigned long frame_buffer_size;
45} __packed;
46
47struct efi_graphics_output_protocol {
48 void *query_mode;
49 unsigned long set_mode;
50 unsigned long blt;
51 struct efi_graphics_output_protocol_mode *mode;
52};
53
54struct efi_uga_draw_protocol {
55 void *get_mode;
56 void *set_mode;
57 void *blt;
58};
59
60#endif /* BOOT_COMPRESSED_EBOOT_H */