Correcting debconf field name for extlinux installation (Closes: #746785).
[syslinux-debian/hramrach.git] / efi / wrapper.h
blob4f769914c84ba5f1543407163ad5878a8fa77f91
1 #ifndef EFI_WRAPPER_H
2 #define EFI_WRAPPER_H
4 #define MSDOS_SIGNATURE 0x5a4d
5 #define PE_SIGNATURE 0x4550
6 #define PE32_FORMAT 0x10b
7 #define PE32P_FORMAT 0x20b /* PE32+ */
9 #define IMAGE_FILE_MACHINE_I386 0x14c
10 #define IMAGE_FILE_MACHINE_X86_64 0x8664
11 #define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002
12 #define IMAGE_FILE_LINE_NUMBERS_STRIPPED 0x0004
13 #define IMAGE_FILE_32BIT_MACHINE 0x0100
14 #define IMAGE_FILE_DEBUG_STRIPPED 0x0200
16 #define IMAGE_SUBSYSTEM_EFI_APPLICATION 0x0a
18 #define IMAGE_SCN_CNT_CODE 0x00000020
19 #define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040
20 #define IMAGE_SCN_ALIGN_1BYTES 0x00100000
21 #define IMAGE_SCN_ALIGN_16BYTES 0x00500000
22 #define IMAGE_SCN_MEM_DISCARDABLE 0x02000000
23 #define IMAGE_SCN_MEM_EXECUTE 0x20000000
24 #define IMAGE_SCN_MEM_READ 0x40000000
26 #define __packed __attribute__((packed))
27 #define OFFSETOF(t,m) ((size_t)&((t *)0)->m)
29 struct header {
30 __uint16_t msdos_signature;
31 __uint8_t _pad1[0x16];
32 __uint16_t relocs_ptr;
33 __uint8_t __pad2[0x3c - 0x1a];
34 __uint32_t pe_hdr;
35 __uint16_t pe_signature;
36 __uint16_t _pad2;
37 } __packed;
39 /* FIXME: when setting up coff_hdr, set up optional_hdr_sz
40 * based on PE32 or PE32+ format
43 * COFF header
45 struct coff_hdr {
46 __uint16_t arch;
47 __uint16_t nr_sections;
48 __uint32_t timedatestamp;
49 __uint32_t symtab;
50 __uint32_t nr_syms;
51 __uint16_t optional_hdr_sz;
52 __uint16_t characteristics;
53 } __packed;
55 struct optional_hdr {
56 __uint16_t format;
57 __uint8_t major_linker_version;
58 __uint8_t minor_linker_version;
59 __uint32_t code_sz;
60 __uint32_t initialized_data_sz;
61 __uint32_t uninitialized_data_sz;
62 __uint32_t entry_point;
63 __uint32_t base_code;
64 __uint32_t data;
65 } __packed;
67 /* For PE32+, the optional_header does NOT have
68 * data after base_code
70 struct optional_hdr_pe32p {
71 __uint16_t format;
72 __uint8_t major_linker_version;
73 __uint8_t minor_linker_version;
74 __uint32_t code_sz;
75 __uint32_t initialized_data_sz;
76 __uint32_t uninitialized_data_sz;
77 __uint32_t entry_point;
78 __uint32_t base_code;
79 } __packed;
81 * Extra header fields
83 struct extra_hdr {
84 __uint32_t image_base;
85 __uint32_t section_align;
86 __uint32_t file_align;
87 __uint16_t major_os_version;
88 __uint16_t minor_os_version;
89 __uint16_t major_image_version;
90 __uint16_t minor_image_version;
91 __uint16_t major_subsystem_version;
92 __uint16_t minor_subsystem_version;
93 __uint32_t win32_version;
94 __uint32_t image_sz;
95 __uint32_t headers_sz;
96 __uint32_t checksum;
97 __uint16_t subsystem;
98 __uint16_t dll_characteristics;
99 __uint32_t stack_reserve_sz;
100 __uint32_t stack_commit_sz;
101 __uint32_t heap_reserve_sz;
102 __uint32_t heap_commit_sz;
103 __uint32_t loader_flags;
104 __uint32_t rva_and_sizes_nr;
105 __uint64_t export_table;
106 __uint64_t import_table;
107 __uint64_t resource_table;
108 __uint64_t exception_table;
109 __uint64_t certification_table;
110 __uint64_t base_relocation_table;
111 } __packed;
113 /* Extra header for PE32+ format
114 * FIXME: There are additional fields in Microsoft PE COFF v8
117 struct extra_hdr_pe32p {
118 __uint64_t image_base;
119 __uint32_t section_align;
120 __uint32_t file_align;
121 __uint16_t major_os_version;
122 __uint16_t minor_os_version;
123 __uint16_t major_image_version;
124 __uint16_t minor_image_version;
125 __uint16_t major_subsystem_version;
126 __uint16_t minor_subsystem_version;
127 __uint32_t win32_version;
128 __uint32_t image_sz;
129 __uint32_t headers_sz;
130 __uint32_t checksum;
131 __uint16_t subsystem;
132 __uint16_t dll_characteristics;
133 __uint64_t stack_reserve_sz;
134 __uint64_t stack_commit_sz;
135 __uint64_t heap_reserve_sz;
136 __uint64_t heap_commit_sz;
137 __uint32_t loader_flags;
138 __uint32_t rva_and_sizes_nr;
139 __uint64_t export_table;
140 __uint64_t import_table;
141 __uint64_t resource_table;
142 __uint64_t exception_table;
143 __uint64_t certification_table;
144 __uint64_t base_relocation_table;
145 } __packed;
147 struct section {
148 __uint8_t name[8];
149 __uint32_t virtual_sz;
150 __uint32_t virtual_address;
151 __uint32_t raw_data_sz;
152 __uint32_t raw_data;
153 __uint32_t relocs;
154 __uint32_t line_numbers;
155 __uint16_t relocs_nr;
156 __uint16_t line_numbers_nr;
157 __uint32_t characteristics;
158 } __packed;
160 struct coff_reloc {
161 __uint32_t virtual_address;
162 __uint32_t symtab_index;
163 __uint16_t type;
166 #endif /* EFI_WRAPPER_H */