Harmonizing package dependencies.
[syslinux-debian/hramrach.git] / efi / wrapper.h
blob492c262b30fb2b258e7b0e4359e00f61f0dc749e
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[0x3c - 2];
32 __uint32_t pe_hdr;
33 __uint16_t pe_signature;
34 __uint16_t _pad2;
35 } __packed;
37 /* FIXME: when setting up coff_hdr, set up optional_hdr_sz
38 * based on PE32 or PE32+ format
41 * COFF header
43 struct coff_hdr {
44 __uint16_t arch;
45 __uint16_t nr_sections;
46 __uint32_t timedatestamp;
47 __uint32_t symtab;
48 __uint32_t nr_syms;
49 __uint16_t optional_hdr_sz;
50 __uint16_t characteristics;
51 } __packed;
53 struct optional_hdr {
54 __uint16_t format;
55 __uint8_t major_linker_version;
56 __uint8_t minor_linker_version;
57 __uint32_t code_sz;
58 __uint32_t initialized_data_sz;
59 __uint32_t uninitialized_data_sz;
60 __uint32_t entry_point;
61 __uint32_t base_code;
62 __uint32_t data;
63 } __packed;
65 /* For PE32+, the optional_header does NOT have
66 * data after base_code
68 struct optional_hdr_pe32p {
69 __uint16_t format;
70 __uint8_t major_linker_version;
71 __uint8_t minor_linker_version;
72 __uint32_t code_sz;
73 __uint32_t initialized_data_sz;
74 __uint32_t uninitialized_data_sz;
75 __uint32_t entry_point;
76 __uint32_t base_code;
77 } __packed;
79 * Extra header fields
81 struct extra_hdr {
82 __uint32_t image_base;
83 __uint32_t section_align;
84 __uint32_t file_align;
85 __uint16_t major_os_version;
86 __uint16_t minor_os_version;
87 __uint16_t major_image_version;
88 __uint16_t minor_image_version;
89 __uint16_t major_subsystem_version;
90 __uint16_t minor_subsystem_version;
91 __uint32_t win32_version;
92 __uint32_t image_sz;
93 __uint32_t headers_sz;
94 __uint32_t checksum;
95 __uint16_t subsystem;
96 __uint16_t dll_characteristics;
97 __uint32_t stack_reserve_sz;
98 __uint32_t stack_commit_sz;
99 __uint32_t heap_reserve_sz;
100 __uint32_t heap_commit_sz;
101 __uint32_t loader_flags;
102 __uint32_t rva_and_sizes_nr;
103 __uint64_t export_table;
104 __uint64_t import_table;
105 __uint64_t resource_table;
106 __uint64_t exception_table;
107 __uint64_t certification_table;
108 __uint64_t base_relocation_table;
109 } __packed;
111 /* Extra header for PE32+ format
112 * FIXME: There are additional fields in Microsoft PE COFF v8
115 struct extra_hdr_pe32p {
116 __uint64_t image_base;
117 __uint32_t section_align;
118 __uint32_t file_align;
119 __uint16_t major_os_version;
120 __uint16_t minor_os_version;
121 __uint16_t major_image_version;
122 __uint16_t minor_image_version;
123 __uint16_t major_subsystem_version;
124 __uint16_t minor_subsystem_version;
125 __uint32_t win32_version;
126 __uint32_t image_sz;
127 __uint32_t headers_sz;
128 __uint32_t checksum;
129 __uint16_t subsystem;
130 __uint16_t dll_characteristics;
131 __uint64_t stack_reserve_sz;
132 __uint64_t stack_commit_sz;
133 __uint64_t heap_reserve_sz;
134 __uint64_t heap_commit_sz;
135 __uint32_t loader_flags;
136 __uint32_t rva_and_sizes_nr;
137 __uint64_t export_table;
138 __uint64_t import_table;
139 __uint64_t resource_table;
140 __uint64_t exception_table;
141 __uint64_t certification_table;
142 __uint64_t base_relocation_table;
143 } __packed;
145 struct section {
146 __uint8_t name[8];
147 __uint32_t virtual_sz;
148 __uint32_t virtual_address;
149 __uint32_t raw_data_sz;
150 __uint32_t raw_data;
151 __uint32_t relocs;
152 __uint32_t line_numbers;
153 __uint16_t relocs_nr;
154 __uint16_t line_numbers_nr;
155 __uint32_t characteristics;
156 } __packed;
158 struct coff_reloc {
159 __uint32_t virtual_address;
160 __uint32_t symtab_index;
161 __uint16_t type;
164 #endif /* EFI_WRAPPER_H */