]> glassweightruler.freedombox.rocks Git - Ventoy.git/blob - VtoyTool/BabyISO/biso_eltorito.h
Add German language (#57)
[Ventoy.git] / VtoyTool / BabyISO / biso_eltorito.h
1 /******************************************************************************
2 * bios_eltorito.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
22 /*
23 * EL TORITO扩展规范相关定义
24 * 注意点:
25 * [1] EL TORITO扩展规范里定义的数据都是小字节序的
26 */
27
28 #ifndef __BISO_ELTORITO_H__
29 #define __BISO_ELTORITO_H__
30
31 /*
32 * EL TORITO规范里对于Boot Record里面BootCatlog指向的扩展区域做了
33 * 结构定义,分成一条条的表项,每一条表项固定32个字节长,1个扇区
34 * 可以保存64条表项。BootCatlog可以占用多个扇区。
35 * 表项必须按照如下顺序保存:
36 * ID Entry
37 * 0 Validation Entry
38 * 1 Initial Entry
39 * 2 Section Header
40 * 3 Section Entry
41 * 4 Section Extension Entry 1
42 * 5 Section Extension Entry 2
43 * 6 Section Extension Entry 3
44 * ....
45 * N Section Header
46 * N+1 Section Entry
47 * N+2 Section Extension Entry 1
48 * N+3 Section Extension Entry 2
49 * N+4 Section Extension Entry 3
50 * ....
51 */
52
53 #define BISO_ELTORITO_ENTRY_LEN 32
54
55 #pragma pack(1)
56
57 /* 检验表项, 必须是第一条 */
58 typedef struct tagBISO_TORITO_VALIDATION_ENTRY
59 {
60 UCHAR ucHeaderID; /* Must be 01 */
61
62 /*
63 * PlatID: CPU平台架构
64 * 0x00: x86
65 * 0x01: PowerPC
66 * 0x02: Mac
67 * 0xEF: EFI System Partition
68 */
69 UCHAR ucPlatID;
70
71 UINT16 usResv;
72
73 /* ID,一般用来保存CD-ROM的制造商信息 */
74 CHAR szID[24];
75
76 /*
77 * 校验补充字段, 注意[1]
78 * 这个字段用来保证整个Validation Entry的数据
79 * 按照WORD(双字节)累加起来为0(截取之后)
80 */
81 UINT16 usCheckSum;
82
83 /* 魔数字,检验使用,值必须为0x55和0xAA */
84 UCHAR ucData55;
85 UCHAR ucDataAA;
86 }BISO_TORITO_VALIDATION_ENTRY_S;
87
88 /* 默认初始化表项(BIOS里面的 INT 13) */
89 typedef struct tagBISO_TORITO_INITIAL_ENTRY
90 {
91 /* BOOTID: 0x88:Bootable, 00:Not Bootable */
92 UCHAR ucBootId;
93
94 /*
95 * ucBootMedia:
96 * Bit0 - Bit3的值:
97 * 0: No Emulation
98 * 1: 1.2 meg diskette
99 * 2: 1.44 meg diskette
100 * 3: 2.88 meg diskette
101 * 4: Hard Disk(drive 80)
102 * 5-F:保留
103 * Bit4 - Bit7:保留
104 */
105 UCHAR ucBootMedia;
106
107 /* 启动段,只对x86构架有效,为0默认使用7C0, 注意[1] */
108 UINT16 usLoadSegment;
109
110 /* 是Boot Image里面Partition Table的第5个字节(System Type) */
111 UCHAR ucSystemType;
112
113 UCHAR ucResv;
114
115 /* 启动时每次往内存读多长, 注意[1] */
116 UINT16 usSectorCount;
117
118 /* 启动文件所在的起始逻辑块编号,例如isolinux.bin文件的位置, 注意[1] */
119 UINT32 uiLoadRBA;
120
121 UCHAR aucResv[20];
122 }BISO_TORITO_INITIAL_ENTRY_S;
123
124 /*
125 * Section Header, 补充一系列可启动的Entry(比如UEFI启动)
126 * 如果默认的Initial/Default Entry不满足BIOS需求
127 * BIOS可以继续往下找,根据Section Header里面的ID
128 * 以及Section Entry里面的Criteria信息决定是否从
129 * 该条Entry启动
130 *
131 */
132 typedef struct tagBISO_TORITO_SECHDR_ENTRY
133 {
134 /* ucFlag: 0x90:表示后面还有Header, 0x91:表示最后一个Header */
135 UCHAR ucFlag;
136
137 /*
138 * PlatID: CPU平台架构
139 * 0x00: x86
140 * 0x01: PowerPC
141 * 0x02: Mac
142 * 0xEF: EFI System Partition
143 */
144 UCHAR ucPlatID;
145
146 /* 跟在这个头的后面有多少个Section Entry */
147 UINT16 usSecEntryNum;
148
149 /* ID信息 */
150 CHAR szId[28];
151 }BISO_TORITO_SECHDR_ENTRY_S;
152
153 /* Section Entry */
154 typedef struct tagBISO_TORITO_SECTION_ENTRY
155 {
156 /* BOOTID: 88:Bootable, 00:Not Bootable */
157 UCHAR ucBootId;
158
159 /*
160 * ucBootMedia:
161 * Bit0 - Bit3的值:
162 * 0: No Emulation
163 * 1: 1.2 meg diskette
164 * 2: 1.44 meg diskette
165 * 3: 2.88 meg diskette
166 * 4: Hard Disk(drive 80)
167 * 5-F:保留
168 * Bit4:保留
169 * Bit5:Continuation Entry Follows
170 * Bit6:Image contains an ATAPI driver
171 * Bit7:Image contains SCSI driver
172 */
173 UCHAR ucFlag;
174
175 /* 启动段,只对x86构架有效,为0默认使用7C0, 注意[1] */
176 UINT16 usLoadSegment;
177
178 /* 是Boot Image里面Partition Table的第5个字节(System Type) */
179 UCHAR ucSystemType;
180
181 UCHAR ucResv;
182
183 /* 启动时每次往内存读多长, 注意[1] */
184 UINT16 usSectorCount;
185
186 /* 启动文件所在的起始逻辑块编号,例如isolinux.bin文件的位置, 注意[1] */
187 UINT32 uiLoadRBA;
188
189 /*
190 * 它的值描述了后面的aucCriteria的格式
191 * 0: 没有
192 * 1: Language and Version Information (IBM)
193 * 2-FF - Reserved
194 */
195 UCHAR ucCriteriaType;
196
197 /* Criteria信息,如果这19个字节不够用,可以使用Section Extension Entry里的 */
198 UCHAR aucCriteria[19];
199 }BISO_TORITO_SECTION_ENTRY_S;
200
201 /* 扩展Section Entry */
202 typedef struct tagBISO_TORITO_SECEXT_ENTRY
203 {
204 /* ucExtId: 必须为44 */
205 UCHAR ucExtId;
206
207 /*
208 * ucFlag: 只有Bit5有用
209 * Bit5: 1表示后面还有Extension Record 0表示最后一个
210 */
211 UCHAR ucFlag;
212
213 /* Criteria信息 */
214 UCHAR aucCriteria[39];
215 }BISO_TORITO_SECEXT_ENTRY_S;
216
217 #pragma pack()
218
219 /*
220 * 当前缓冲区指针位置向前1条Entry
221 * 如果已经超过了2048字节,则继续从文件中读
222 */
223 #define BISO_ELTORITO_ENTRY_STEP(pstSection, pstFile, aucBuf, stMBuf) \
224 {\
225 UINT _uiReadLen;\
226 pstSection++;\
227 if ((UCHAR *)pstSection >= aucBuf + BISO_SECTOR_SIZE)\
228 {\
229 (VOID)BISO_MBUF_Append(&stMBuf, BISO_SECTOR_SIZE, aucBuf);\
230 _uiReadLen = (UINT)BISO_PLAT_ReadFile(pstFile, 1, BISO_SECTOR_SIZE, aucBuf);\
231 if (_uiReadLen != BISO_SECTOR_SIZE)\
232 {\
233 BISO_DIAG("Read Len %u, sector len %u.", _uiReadLen, BISO_SECTOR_SIZE);\
234 BISO_MBUF_Free(&stMBuf);\
235 return BISO_ERR_READ_FILE;\
236 }\
237 pstSection = (BISO_TORITO_SECTION_ENTRY_S *)aucBuf;\
238 }\
239 }
240
241 ULONG BISO_ELTORITO_ReadBootInfo(IN BISO_FILE_S *pstFile, OUT BISO_PARSER_S *pstParser);
242 VOID BISO_ELTORITO_Dump(IN CONST BISO_PARSER_S *pstParser);
243 UINT BISO_ELTORITO_GetBootEntryNum(IN CONST BISO_PARSER_S *pstParser);
244
245 #endif /* __BISO_ELTORITO_H__ */
246