2 #ifndef __VENTOY_VDISK_H__
3 #define __VENTOY_VDISK_H__
5 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL
);
7 #define grub_uint64_t uint64_t
8 #define grub_uint32_t uint32_t
9 #define grub_uint16_t uint16_t
10 #define grub_uint8_t uint8_t
12 #define COMPILE_ASSERT(expr) extern char __compile_assert[(expr) ? 1 : -1]
14 #define VENTOY_GUID { 0x77772020, 0x2e77, 0x6576, { 0x6e, 0x74, 0x6f, 0x79, 0x2e, 0x6e, 0x65, 0x74 }}
16 typedef enum ventoy_chain_type
18 ventoy_chain_linux
= 0, /* 0: linux */
19 ventoy_chain_windows
, /* 1: windows */
20 ventoy_chain_wim
, /* 2: wim */
27 typedef struct ventoy_guid
32 grub_uint8_t data4
[8];
35 typedef struct ventoy_image_disk_region
37 grub_uint32_t image_sector_count
; /* image sectors contained in this region */
38 grub_uint32_t image_start_sector
; /* image sector start */
39 grub_uint64_t disk_start_sector
; /* disk sector start */
40 }ventoy_image_disk_region
;
42 typedef struct ventoy_image_location
46 /* image sector size, currently this value is always 2048 */
47 grub_uint32_t image_sector_size
;
49 /* disk sector size, normally the value is 512 */
50 grub_uint32_t disk_sector_size
;
52 grub_uint32_t region_count
;
56 * If the image file has more than one fragments in disk,
57 * there will be more than one region data here.
60 ventoy_image_disk_region regions
[1];
62 /* ventoy_image_disk_region regions[2~region_count-1] */
63 }ventoy_image_location
;
65 typedef struct ventoy_os_param
67 ventoy_guid guid
; // VENTOY_GUID
68 grub_uint8_t chksum
; // checksum
70 grub_uint8_t vtoy_disk_guid
[16];
71 grub_uint64_t vtoy_disk_size
; // disk size in bytes
72 grub_uint16_t vtoy_disk_part_id
; // begin with 1
73 grub_uint16_t vtoy_disk_part_type
; // 0:exfat 1:ntfs other: reserved
74 char vtoy_img_path
[384]; // It seems to be enough, utf-8 format
75 grub_uint64_t vtoy_img_size
; // image file size in bytes
78 * Ventoy will write a copy of ventoy_image_location data into runtime memory
79 * this is the physically address and length of that memory.
80 * Address 0 means no such data exist.
81 * Address will be aligned by 4KB.
84 grub_uint64_t vtoy_img_location_addr
;
85 grub_uint32_t vtoy_img_location_len
;
87 grub_uint64_t vtoy_reserved
[4]; // Internal use by ventoy
89 grub_uint8_t reserved
[31];
92 typedef struct ventoy_iso9660_override
94 uint32_t first_sector
;
95 uint32_t first_sector_be
;
98 }ventoy_iso9660_override
;
102 // compile assert to check that size of ventoy_os_param must be 512
103 COMPILE_ASSERT(sizeof(ventoy_os_param
) == 512);
113 typedef struct ventoy_chain_head
115 ventoy_os_param os_param
;
117 grub_uint32_t disk_drive
;
118 grub_uint32_t drive_map
;
119 grub_uint32_t disk_sector_size
;
121 grub_uint64_t real_img_size_in_bytes
;
122 grub_uint64_t virt_img_size_in_bytes
;
123 grub_uint32_t boot_catalog
;
124 grub_uint8_t boot_catalog_sector
[2048];
126 grub_uint32_t img_chunk_offset
;
127 grub_uint32_t img_chunk_num
;
129 grub_uint32_t override_chunk_offset
;
130 grub_uint32_t override_chunk_num
;
132 grub_uint32_t virt_chunk_offset
;
133 grub_uint32_t virt_chunk_num
;
137 typedef struct ventoy_img_chunk
139 grub_uint32_t img_start_sector
; //2KB
140 grub_uint32_t img_end_sector
;
142 grub_uint64_t disk_start_sector
; // in disk_sector_size
143 grub_uint64_t disk_end_sector
;
147 typedef struct ventoy_override_chunk
149 grub_uint64_t img_offset
;
150 grub_uint32_t override_size
;
151 grub_uint8_t override_data
[512];
152 }ventoy_override_chunk
;
154 typedef struct ventoy_virt_chunk
156 grub_uint32_t mem_sector_start
;
157 grub_uint32_t mem_sector_end
;
158 grub_uint32_t mem_sector_offset
;
159 grub_uint32_t remap_sector_start
;
160 grub_uint32_t remap_sector_end
;
161 grub_uint32_t org_sector_start
;
168 #define ventoy_debug_pause() \
170 printf("\nPress Ctrl+C to continue......");\
175 typedef struct ventoy_sector_flag
177 uint8_t flag
; // 0:init 1:mem 2:remap
181 #define VENTOY_BIOS_FAKE_DRIVE 0xFE
182 #define VENTOY_BOOT_FIXBIN_DRIVE 0xFD
185 extern char *g_cmdline_copy
;
186 extern void *g_initrd_addr
;
187 extern size_t g_initrd_len
;
188 extern uint32_t g_disk_sector_size
;
189 unsigned int ventoy_int13_hook (ventoy_chain_head
*chain
);
190 int ventoy_int13_boot ( unsigned int drive
, void *imginfo
, const char *cmdline
);
191 void * ventoy_get_runtime_addr(void);
192 int ventoy_boot_vdisk(void *data
);
195 uint32_t CalculateCrc32
202 struct smbios3_entry
{
204 uint8_t signature
[5];
227 } __attribute__ (( packed
));
230 typedef struct isolinux_boot_info
234 uint32_t PvdLocation
;
235 uint32_t BootFileLocation
;
236 uint32_t BootFileLen
;
237 uint32_t BootFileChecksum
;
238 uint8_t Reserved
[40];
244 #endif /* __VENTOY_VDISK_H__ */