]> glassweightruler.freedombox.rocks Git - Ventoy.git/blob - GRUB2/grub-2.04/include/grub/ventoy.h
1. add Italian languare, translated by AverageUser2
[Ventoy.git] / GRUB2 / grub-2.04 / include / grub / ventoy.h
1 /******************************************************************************
2 * ventoy.h
3 *
4 * Copyright (c) 2020, longpanda <admin@ventoy.net>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 3 of the
9 * License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21 #ifndef __VENTOY_H__
22 #define __VENTOY_H__
23
24 #define COMPILE_ASSERT(expr) extern char __compile_assert[(expr) ? 1 : -1]
25
26 #define VENTOY_COMPATIBLE_STR "VENTOY COMPATIBLE"
27 #define VENTOY_COMPATIBLE_STR_LEN 17
28
29 #define VENTOY_GUID { 0x77772020, 0x2e77, 0x6576, { 0x6e, 0x74, 0x6f, 0x79, 0x2e, 0x6e, 0x65, 0x74 }}
30
31 #pragma pack(1)
32
33 typedef struct ventoy_guid
34 {
35 grub_uint32_t data1;
36 grub_uint16_t data2;
37 grub_uint16_t data3;
38 grub_uint8_t data4[8];
39 }ventoy_guid;
40
41
42 typedef struct ventoy_image_disk_region
43 {
44 grub_uint32_t image_sector_count; /* image sectors contained in this region (in 2048) */
45 grub_uint32_t image_start_sector; /* image sector start (in 2048) */
46 grub_uint64_t disk_start_sector; /* disk sector start (in 512) */
47 }ventoy_image_disk_region;
48
49 typedef struct ventoy_image_location
50 {
51 ventoy_guid guid;
52
53 /* image sector size, currently this value is always 2048 */
54 grub_uint32_t image_sector_size;
55
56 /* disk sector size, normally the value is 512 */
57 grub_uint32_t disk_sector_size;
58
59 grub_uint32_t region_count;
60
61 /*
62 * disk region data (region_count)
63 * If the image file has more than one fragments in disk,
64 * there will be more than one region data here.
65 *
66 */
67 ventoy_image_disk_region regions[1];
68
69 /* ventoy_image_disk_region regions[2~region_count-1] */
70 }ventoy_image_location;
71
72
73 typedef struct ventoy_os_param
74 {
75 ventoy_guid guid; // VENTOY_GUID
76 grub_uint8_t chksum; // checksum
77
78 grub_uint8_t vtoy_disk_guid[16];
79 grub_uint64_t vtoy_disk_size; // disk size in bytes
80 grub_uint16_t vtoy_disk_part_id; // begin with 1
81 grub_uint16_t vtoy_disk_part_type; // 0:exfat 1:ntfs other: reserved
82 char vtoy_img_path[384]; // It seems to be enough, utf-8 format
83 grub_uint64_t vtoy_img_size; // image file size in bytes
84
85 /*
86 * Ventoy will write a copy of ventoy_image_location data into runtime memory
87 * this is the physically address and length of that memory.
88 * Address 0 means no such data exist.
89 * Address will be aligned by 4KB.
90 *
91 */
92 grub_uint64_t vtoy_img_location_addr;
93 grub_uint32_t vtoy_img_location_len;
94
95 /*
96 * These 32 bytes are reserved by ventoy.
97 *
98 * vtoy_reserved[0]: vtoy_break_level
99 * vtoy_reserved[1]: vtoy_debug_level
100 *
101 */
102 grub_uint8_t vtoy_reserved[32]; // Internal use by ventoy
103
104 grub_uint8_t reserved[31];
105 }ventoy_os_param;
106
107
108 typedef struct ventoy_windows_data
109 {
110 char auto_install_script[384];
111 grub_uint8_t reserved[128];
112 }ventoy_windows_data;
113
114
115
116 #pragma pack()
117
118 // compile assert check : sizeof(ventoy_os_param) must be 512
119 COMPILE_ASSERT(sizeof(ventoy_os_param) == 512);
120
121
122
123
124
125
126
127 #pragma pack(4)
128
129 typedef struct ventoy_chain_head
130 {
131 ventoy_os_param os_param;
132
133 grub_uint32_t disk_drive;
134 grub_uint32_t drive_map;
135 grub_uint32_t disk_sector_size;
136
137 grub_uint64_t real_img_size_in_bytes;
138 grub_uint64_t virt_img_size_in_bytes;
139 grub_uint32_t boot_catalog;
140 grub_uint8_t boot_catalog_sector[2048];
141
142 grub_uint32_t img_chunk_offset;
143 grub_uint32_t img_chunk_num;
144
145 grub_uint32_t override_chunk_offset;
146 grub_uint32_t override_chunk_num;
147
148 grub_uint32_t virt_chunk_offset;
149 grub_uint32_t virt_chunk_num;
150 }ventoy_chain_head;
151
152 typedef struct ventoy_img_chunk
153 {
154 grub_uint32_t img_start_sector; // sector size: 2KB
155 grub_uint32_t img_end_sector; // included
156
157 grub_uint64_t disk_start_sector; // in disk_sector_size
158 grub_uint64_t disk_end_sector; // included
159 }ventoy_img_chunk;
160
161
162 typedef struct ventoy_override_chunk
163 {
164 grub_uint64_t img_offset;
165 grub_uint32_t override_size;
166 grub_uint8_t override_data[512];
167 }ventoy_override_chunk;
168
169 typedef struct ventoy_virt_chunk
170 {
171 grub_uint32_t mem_sector_start;
172 grub_uint32_t mem_sector_end;
173 grub_uint32_t mem_sector_offset;
174 grub_uint32_t remap_sector_start;
175 grub_uint32_t remap_sector_end;
176 grub_uint32_t org_sector_start;
177 }ventoy_virt_chunk;
178
179 #define DEFAULT_CHUNK_NUM 1024
180 typedef struct ventoy_img_chunk_list
181 {
182 grub_uint32_t max_chunk;
183 grub_uint32_t cur_chunk;
184 ventoy_img_chunk *chunk;
185 }ventoy_img_chunk_list;
186
187
188 #pragma pack()
189
190 #define ventoy_filt_register grub_file_filter_register
191
192 typedef const char * (*grub_env_get_pf)(const char *name);
193
194 #pragma pack(1)
195
196 #define GRUB_FILE_REPLACE_MAGIC 0x1258BEEF
197
198 typedef struct ventoy_grub_param_file_replace
199 {
200 grub_uint32_t magic;
201 char old_file_name[4][256];
202 grub_uint32_t old_name_cnt;
203 grub_uint32_t new_file_virtual_id;
204 }ventoy_grub_param_file_replace;
205
206 typedef struct ventoy_grub_param
207 {
208 grub_env_get_pf grub_env_get;
209
210 ventoy_grub_param_file_replace file_replace;
211 }ventoy_grub_param;
212
213 #pragma pack()
214
215
216
217 int grub_fat_get_file_chunk(grub_uint64_t part_start, grub_file_t file, ventoy_img_chunk_list *chunk_list);
218 grub_uint64_t grub_iso9660_get_last_read_pos(grub_file_t file);
219 grub_uint64_t grub_iso9660_get_last_file_dirent_pos(grub_file_t file);
220 grub_uint64_t grub_udf_get_file_offset(grub_file_t file);
221 grub_uint64_t grub_udf_get_last_pd_size_offset(void);
222 grub_uint64_t grub_udf_get_last_file_attr_offset
223 (
224 grub_file_t file,
225 grub_uint32_t *startBlock,
226 grub_uint64_t *fe_entry_size_offset
227 );
228 int ventoy_is_efi_os(void);
229
230 #endif /* __VENTOY_H__ */
231