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