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 
35 #ifndef _CD9660_ELTORITO_H_
36 #define _CD9660_ELTORITO_H_
37 
38 /* Boot defines */
39 #define	ET_ID		"EL TORITO SPECIFICATION"
40 #define	ET_SYS_X86	0
41 #define	ET_SYS_PPC	1
42 #define	ET_SYS_MAC	2
43 
44 #define ET_BOOT_ENTRY_SIZE 0x20
45 
46 #define	ET_BOOTABLE		0x88
47 #define	ET_NOT_BOOTABLE	0
48 
49 #define	ET_MEDIA_NOEM	0
50 #define	ET_MEDIA_12FDD			1
51 #define	ET_MEDIA_144FDD			2
52 #define	ET_MEDIA_288FDD			3
53 #define	ET_MEDIA_HDD			4
54 
55 #define ET_INDICATOR_HEADERMORE	0x90
56 #define ET_INDICATOR_HEADERLAST	0x91
57 #define ET_INDICATOR_EXTENSION	0x44
58 
59 /*** Boot Structures ***/
60 
61 typedef struct _boot_volume_descriptor {
62 	u_char boot_record_indicator	[ISODCL(0x00,0x00)];
63 	u_char identifier		[ISODCL(0x01,0x05)];
64 	u_char version			[ISODCL(0x06,0x06)];
65 	u_char boot_system_identifier	[ISODCL(0x07,0x26)];
66 	u_char unused1			[ISODCL(0x27,0x46)];
67 	u_char boot_catalog_pointer	[ISODCL(0x47,0x4A)];
68 	u_char unused2			[ISODCL(0x4B,0x7FF)];
69 } boot_volume_descriptor;
70 
71 typedef struct _boot_catalog_validation_entry {
72 	u_char header_id		[ISODCL(0x00,0x00)];
73 	u_char platform_id		[ISODCL(0x01,0x01)];
74 	u_char reserved1		[ISODCL(0x02,0x03)];
75 	u_char manufacturer		[ISODCL(0x04,0x1B)];
76 	u_char checksum			[ISODCL(0x1C,0x1D)];
77 	u_char key			[ISODCL(0x1E,0x1F)];
78 } boot_catalog_validation_entry;
79 
80 typedef struct _boot_catalog_initial_entry {
81 	u_char boot_indicator		[ISODCL(0x00,0x00)];
82 	u_char media_type		[ISODCL(0x01,0x01)];
83 	u_char load_segment		[ISODCL(0x02,0x03)];
84 	u_char system_type		[ISODCL(0x04,0x04)];
85 	u_char unused_1			[ISODCL(0x05,0x05)];
86 	u_char sector_count		[ISODCL(0x06,0x07)];
87 	u_char load_rba			[ISODCL(0x08,0x0B)];
88 	u_char unused_2			[ISODCL(0x0C,0x1F)];
89 } boot_catalog_initial_entry;
90 
91 #define ET_SECTION_HEADER_MORE		0x90
92 #define ET_SECTION_HEADER_LAST		0x91
93 
94 typedef struct _boot_catalog_section_header {
95 	u_char header_indicator		[ISODCL(0x00,0x00)];
96 	u_char platform_id		[ISODCL(0x01,0x01)];
97 	u_char num_section_entries	[ISODCL(0x02,0x03)];
98 	u_char id_string		[ISODCL(0x04,0x1F)];
99 } boot_catalog_section_header;
100 
101 typedef struct _boot_catalog_section_entry {
102 	u_char boot_indicator		[ISODCL(0x00,0x00)];
103 	u_char media_type		[ISODCL(0x01,0x01)];
104 	u_char load_segment		[ISODCL(0x02,0x03)];
105 	u_char system_type		[ISODCL(0x04,0x04)];
106 	u_char unused_1			[ISODCL(0x05,0x05)];
107 	u_char sector_count		[ISODCL(0x06,0x07)];
108 	u_char load_rba			[ISODCL(0x08,0x0B)];
109 	u_char selection_criteria	[ISODCL(0x0C,0x0C)];
110 	u_char vendor_criteria		[ISODCL(0x0D,0x1F)];
111 } boot_catalog_section_entry;
112 
113 typedef struct _boot_catalog_section_entry_extension {
114 	u_char extension_indicator	[ISODCL(0x00,0x00)];
115 	u_char flags			[ISODCL(0x01,0x01)];
116 	u_char vendor_criteria		[ISODCL(0x02,0x1F)];
117 } boot_catalog_section_entry_extension;
118 
119 #define ET_ENTRY_VE 1
120 #define ET_ENTRY_IE 2
121 #define ET_ENTRY_SH 3
122 #define ET_ENTRY_SE 4
123 #define ET_ENTRY_EX 5
124 
125 struct boot_catalog_entry {
126 	char entry_type;
127 	union {
128 		boot_catalog_validation_entry		VE;
129 		boot_catalog_initial_entry 		IE;
130 		boot_catalog_section_header		SH;
131 		boot_catalog_section_entry		SE;
132 		boot_catalog_section_entry_extension	EX;
133 	} entry_data;
134 
135 	LIST_ENTRY(boot_catalog_entry) ll_struct;
136 };
137 
138 /* Temporary structure */
139 struct cd9660_boot_image {
140 	char *filename;
141 	int size;
142 	int sector; 			/* copied to LoadRBA */
143 	int num_sectors;
144 	unsigned int loadSegment;
145 	u_char targetMode;
146 	u_char system;
147 	u_char bootable;
148 	/*
149 	 * If the boot image exists in the filesystem
150 	 * already, this is a pointer to that node. For the sake
151 	 * of simplicity in future versions, this pointer is only
152 	 * to the node in the primary volume. This SHOULD be done
153 	 * via a hashtable lookup.
154 	 */
155 	struct _cd9660node *boot_image_node;
156 	TAILQ_ENTRY(cd9660_boot_image) image_list;
157 	int serialno;
158 };
159 
160 
161 #endif /* _CD9660_ELTORITO_H_ */
162 
163