xref: /freebsd/usr.sbin/makefs/cd9660/cd9660_eltorito.h (revision 56e53cb8ef000c3ef72337a4095987a932cdedef)
1 /*	$NetBSD: cd9660_eltorito.h,v 1.5 2009/07/04 14:31:38 ahoka Exp $	*/
2 
3 /*-
4  * SPDX-License-Identifier: BSD-2-Clause-NetBSD
5  *
6  * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
7  * Perez-Rathke and Ram Vedam.  All rights reserved.
8  *
9  * This code was written by Daniel Watt, Walter Deignan, Ryan Gabrys,
10  * Alan Perez-Rathke and Ram Vedam.
11  *
12  * Redistribution and use in source and binary forms, with or
13  * without modification, are permitted provided that the following
14  * conditions are met:
15  * 1. Redistributions of source code must retain the above copyright
16  *    notice, this list of conditions and the following disclaimer.
17  * 2. Redistributions in binary form must reproduce the above
18  *    copyright notice, this list of conditions and the following
19  *    disclaimer in the documentation and/or other materials provided
20  *    with the distribution.
21  *
22  * THIS SOFTWARE IS PROVIDED BY DANIEL WATT, WALTER DEIGNAN, RYAN
23  * GABRYS, ALAN PEREZ-RATHKE AND RAM VEDAM ``AS IS'' AND ANY EXPRESS OR
24  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26  * DISCLAIMED.  IN NO EVENT SHALL DANIEL WATT, WALTER DEIGNAN, RYAN
27  * GABRYS, ALAN PEREZ-RATHKE AND RAM VEDAM BE LIABLE FOR ANY DIRECT, INDIRECT,
28  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
30  * USE,DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
34  * OF SUCH DAMAGE.
35  *
36  * $FreeBSD$
37  */
38 
39 #ifndef _CD9660_ELTORITO_H_
40 #define _CD9660_ELTORITO_H_
41 
42 /* Boot defines */
43 #define	ET_ID		"EL TORITO SPECIFICATION"
44 #define	ET_SYS_X86	0
45 #define	ET_SYS_PPC	1
46 #define	ET_SYS_MAC	2
47 
48 #define ET_BOOT_ENTRY_SIZE 0x20
49 
50 #define	ET_BOOTABLE		0x88
51 #define	ET_NOT_BOOTABLE	0
52 
53 #define	ET_MEDIA_NOEM	0
54 #define	ET_MEDIA_12FDD			1
55 #define	ET_MEDIA_144FDD			2
56 #define	ET_MEDIA_288FDD			3
57 #define	ET_MEDIA_HDD			4
58 
59 #define ET_INDICATOR_HEADERMORE	0x90
60 #define ET_INDICATOR_HEADERLAST	0x91
61 #define ET_INDICATOR_EXTENSION	0x44
62 
63 /*** Boot Structures ***/
64 
65 typedef struct _boot_volume_descriptor {
66 	u_char boot_record_indicator	[ISODCL(0x00,0x00)];
67 	u_char identifier		[ISODCL(0x01,0x05)];
68 	u_char version			[ISODCL(0x06,0x06)];
69 	u_char boot_system_identifier	[ISODCL(0x07,0x26)];
70 	u_char unused1			[ISODCL(0x27,0x46)];
71 	u_char boot_catalog_pointer	[ISODCL(0x47,0x4A)];
72 	u_char unused2			[ISODCL(0x4B,0x7FF)];
73 } boot_volume_descriptor;
74 
75 typedef struct _boot_catalog_validation_entry {
76 	u_char header_id		[ISODCL(0x00,0x00)];
77 	u_char platform_id		[ISODCL(0x01,0x01)];
78 	u_char reserved1		[ISODCL(0x02,0x03)];
79 	u_char manufacturer		[ISODCL(0x04,0x1B)];
80 	u_char checksum			[ISODCL(0x1C,0x1D)];
81 	u_char key			[ISODCL(0x1E,0x1F)];
82 } boot_catalog_validation_entry;
83 
84 typedef struct _boot_catalog_initial_entry {
85 	u_char boot_indicator		[ISODCL(0x00,0x00)];
86 	u_char media_type		[ISODCL(0x01,0x01)];
87 	u_char load_segment		[ISODCL(0x02,0x03)];
88 	u_char system_type		[ISODCL(0x04,0x04)];
89 	u_char unused_1			[ISODCL(0x05,0x05)];
90 	u_char sector_count		[ISODCL(0x06,0x07)];
91 	u_char load_rba			[ISODCL(0x08,0x0B)];
92 	u_char unused_2			[ISODCL(0x0C,0x1F)];
93 } boot_catalog_initial_entry;
94 
95 #define ET_SECTION_HEADER_MORE		0x90
96 #define ET_SECTION_HEADER_LAST		0x91
97 
98 typedef struct _boot_catalog_section_header {
99 	u_char header_indicator		[ISODCL(0x00,0x00)];
100 	u_char platform_id		[ISODCL(0x01,0x01)];
101 	u_char num_section_entries	[ISODCL(0x02,0x03)];
102 	u_char id_string		[ISODCL(0x04,0x1F)];
103 } boot_catalog_section_header;
104 
105 typedef struct _boot_catalog_section_entry {
106 	u_char boot_indicator		[ISODCL(0x00,0x00)];
107 	u_char media_type		[ISODCL(0x01,0x01)];
108 	u_char load_segment		[ISODCL(0x02,0x03)];
109 	u_char system_type		[ISODCL(0x04,0x04)];
110 	u_char unused_1			[ISODCL(0x05,0x05)];
111 	u_char sector_count		[ISODCL(0x06,0x07)];
112 	u_char load_rba			[ISODCL(0x08,0x0B)];
113 	u_char selection_criteria	[ISODCL(0x0C,0x0C)];
114 	u_char vendor_criteria		[ISODCL(0x0D,0x1F)];
115 } boot_catalog_section_entry;
116 
117 typedef struct _boot_catalog_section_entry_extension {
118 	u_char extension_indicator	[ISODCL(0x00,0x00)];
119 	u_char flags			[ISODCL(0x01,0x01)];
120 	u_char vendor_criteria		[ISODCL(0x02,0x1F)];
121 } boot_catalog_section_entry_extension;
122 
123 #define ET_ENTRY_VE 1
124 #define ET_ENTRY_IE 2
125 #define ET_ENTRY_SH 3
126 #define ET_ENTRY_SE 4
127 #define ET_ENTRY_EX 5
128 
129 struct boot_catalog_entry {
130 	char entry_type;
131 	union {
132 		boot_catalog_validation_entry		VE;
133 		boot_catalog_initial_entry 		IE;
134 		boot_catalog_section_header		SH;
135 		boot_catalog_section_entry		SE;
136 		boot_catalog_section_entry_extension	EX;
137 	} entry_data;
138 
139 	LIST_ENTRY(boot_catalog_entry) ll_struct;
140 };
141 
142 /* Temporary structure */
143 struct cd9660_boot_image {
144 	char *filename;
145 	int size;
146 	int sector; 			/* copied to LoadRBA */
147 	int num_sectors;
148 	unsigned int loadSegment;
149 	u_char targetMode;
150 	u_char system;
151 	u_char bootable;
152 	/*
153 	 * If the boot image exists in the filesystem
154 	 * already, this is a pointer to that node. For the sake
155 	 * of simplicity in future versions, this pointer is only
156 	 * to the node in the primary volume. This SHOULD be done
157 	 * via a hashtable lookup.
158 	 */
159 	struct _cd9660node *boot_image_node;
160 	TAILQ_ENTRY(cd9660_boot_image) image_list;
161 	int serialno;
162 };
163 
164 
165 #endif /* _CD9660_ELTORITO_H_ */
166 
167