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