]> glassweightruler.freedombox.rocks Git - Ventoy.git/blob - IPXE/ipxe_mod_code/ipxe-3fe683e/src/include/ventoy.h
Fix the boot issue for Fedora/CentOS when file name contains special character (e...
[Ventoy.git] / IPXE / ipxe_mod_code / ipxe-3fe683e / src / include / ventoy.h
1
2 #ifndef __VENTOY_VDISK_H__
3 #define __VENTOY_VDISK_H__
4
5 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
6
7 //#define VTOY_DEBUG 1
8
9 #define grub_uint64_t uint64_t
10 #define grub_uint32_t uint32_t
11 #define grub_uint16_t uint16_t
12 #define grub_uint8_t uint8_t
13
14 #define COMPILE_ASSERT(expr) extern char __compile_assert[(expr) ? 1 : -1]
15
16 #define VENTOY_GUID { 0x77772020, 0x2e77, 0x6576, { 0x6e, 0x74, 0x6f, 0x79, 0x2e, 0x6e, 0x65, 0x74 }}
17
18 typedef enum ventoy_chain_type
19 {
20 ventoy_chain_linux = 0, /* 0: linux */
21 ventoy_chain_windows, /* 1: windows */
22 ventoy_chain_wim, /* 2: wim */
23
24 ventoy_chain_max
25 }ventoy_chain_type;
26
27 #pragma pack(1)
28
29 typedef struct ventoy_guid
30 {
31 grub_uint32_t data1;
32 grub_uint16_t data2;
33 grub_uint16_t data3;
34 grub_uint8_t data4[8];
35 }ventoy_guid;
36
37 typedef struct ventoy_image_disk_region
38 {
39 grub_uint32_t image_sector_count; /* image sectors contained in this region */
40 grub_uint32_t image_start_sector; /* image sector start */
41 grub_uint64_t disk_start_sector; /* disk sector start */
42 }ventoy_image_disk_region;
43
44 typedef struct ventoy_image_location
45 {
46 ventoy_guid guid;
47
48 /* image sector size, 2048/512 */
49 grub_uint32_t image_sector_size;
50
51 /* disk sector size, normally the value is 512 */
52 grub_uint32_t disk_sector_size;
53
54 grub_uint32_t region_count;
55
56 /*
57 * disk region data
58 * If the image file has more than one fragments in disk,
59 * there will be more than one region data here.
60 *
61 */
62 ventoy_image_disk_region regions[1];
63
64 /* ventoy_image_disk_region regions[2~region_count-1] */
65 }ventoy_image_location;
66
67 typedef struct ventoy_os_param
68 {
69 ventoy_guid guid; // VENTOY_GUID
70 grub_uint8_t chksum; // checksum
71
72 grub_uint8_t vtoy_disk_guid[16];
73 grub_uint64_t vtoy_disk_size; // disk size in bytes
74 grub_uint16_t vtoy_disk_part_id; // begin with 1
75 grub_uint16_t vtoy_disk_part_type; // 0:exfat 1:ntfs other: reserved
76 char vtoy_img_path[384]; // It seems to be enough, utf-8 format
77 grub_uint64_t vtoy_img_size; // image file size in bytes
78
79 /*
80 * Ventoy will write a copy of ventoy_image_location data into runtime memory
81 * this is the physically address and length of that memory.
82 * Address 0 means no such data exist.
83 * Address will be aligned by 4KB.
84 *
85 */
86 grub_uint64_t vtoy_img_location_addr;
87 grub_uint32_t vtoy_img_location_len;
88
89 grub_uint8_t vtoy_reserved[32]; // Internal use by ventoy
90
91 grub_uint8_t vtoy_disk_signature[4];
92
93 grub_uint8_t reserved[27];
94 }ventoy_os_param;
95
96 typedef struct ventoy_iso9660_override
97 {
98 uint32_t first_sector;
99 uint32_t first_sector_be;
100 uint32_t size;
101 uint32_t size_be;
102 }ventoy_iso9660_override;
103
104 #pragma pack()
105
106 // compile assert to check that size of ventoy_os_param must be 512
107 COMPILE_ASSERT(sizeof(ventoy_os_param) == 512);
108
109
110
111
112
113
114
115 #pragma pack(4)
116
117 typedef struct ventoy_chain_head
118 {
119 ventoy_os_param os_param;
120
121 grub_uint32_t disk_drive;
122 grub_uint32_t drive_map;
123 grub_uint32_t disk_sector_size;
124
125 grub_uint64_t real_img_size_in_bytes;
126 grub_uint64_t virt_img_size_in_bytes;
127 grub_uint32_t boot_catalog;
128 grub_uint8_t boot_catalog_sector[2048];
129
130 grub_uint32_t img_chunk_offset;
131 grub_uint32_t img_chunk_num;
132
133 grub_uint32_t override_chunk_offset;
134 grub_uint32_t override_chunk_num;
135
136 grub_uint32_t virt_chunk_offset;
137 grub_uint32_t virt_chunk_num;
138 }ventoy_chain_head;
139
140
141 typedef struct ventoy_img_chunk
142 {
143 grub_uint32_t img_start_sector; //2KB
144 grub_uint32_t img_end_sector;
145
146 grub_uint64_t disk_start_sector; // in disk_sector_size
147 grub_uint64_t disk_end_sector;
148 }ventoy_img_chunk;
149
150
151 typedef struct ventoy_override_chunk
152 {
153 grub_uint64_t img_offset;
154 grub_uint32_t override_size;
155 grub_uint8_t override_data[512];
156 }ventoy_override_chunk;
157
158 typedef struct ventoy_virt_chunk
159 {
160 grub_uint32_t mem_sector_start;
161 grub_uint32_t mem_sector_end;
162 grub_uint32_t mem_sector_offset;
163 grub_uint32_t remap_sector_start;
164 grub_uint32_t remap_sector_end;
165 grub_uint32_t org_sector_start;
166 }ventoy_virt_chunk;
167
168
169 #pragma pack()
170
171
172 #define ventoy_debug_pause() \
173 {\
174 printf("\nPress Ctrl+C to continue......");\
175 sleep(3600);\
176 printf("\n");\
177 }
178
179 typedef struct ventoy_sector_flag
180 {
181 uint8_t flag; // 0:init 1:mem 2:remap
182 uint64_t remap_lba;
183 }ventoy_sector_flag;
184
185 #define VENTOY_BIOS_FAKE_DRIVE 0xFE
186 #define VENTOY_BOOT_FIXBIN_DRIVE 0xFD
187
188 extern int g_debug;
189 extern int g_hddmode;
190 extern int g_bios_disk80;
191 extern char *g_cmdline_copy;
192 extern void *g_initrd_addr;
193 extern size_t g_initrd_len;
194 extern uint32_t g_disk_sector_size;
195 unsigned int ventoy_int13_hook (ventoy_chain_head *chain);
196 int ventoy_int13_boot ( unsigned int drive, void *imginfo, const char *cmdline);
197 void * ventoy_get_runtime_addr(void);
198 int ventoy_boot_vdisk(void *data);
199
200
201 uint32_t CalculateCrc32
202 (
203 const void *Buffer,
204 uint32_t Length,
205 uint32_t InitValue
206 );
207
208 struct smbios3_entry {
209
210 uint8_t signature[5];
211
212 /** Checksum */
213 uint8_t checksum;
214
215 /** Length */
216 uint8_t len;
217
218 /** Major version */
219 uint8_t major;
220
221 /** Minor version */
222 uint8_t minor;
223
224 uint8_t docrev;
225
226 uint8_t revision;
227
228 uint8_t reserved;
229
230 uint32_t maxsize;
231
232 uint64_t address;
233 } __attribute__ (( packed ));
234
235
236 typedef struct isolinux_boot_info
237 {
238 uint32_t isolinux0;
239 uint32_t isolinux1;
240 uint32_t PvdLocation;
241 uint32_t BootFileLocation;
242 uint32_t BootFileLen;
243 uint32_t BootFileChecksum;
244 uint8_t Reserved[40];
245 }isolinux_boot_info;
246
247 //#undef DBGLVL
248 //#define DBGLVL 7
249
250 #endif /* __VENTOY_VDISK_H__ */
251