xref: /freebsd/usr.sbin/makefs/cd9660/cd9660_eltorito.h (revision 1719886f6d08408b834d270c59ffcfd821c8f63a)
1 /*	$NetBSD: cd9660_eltorito.h,v 1.6 2017/01/24 11:22:43 nonaka Exp $	*/
2 
3 /*-
4  * SPDX-License-Identifier: BSD-2-Clause
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 
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 #define	ET_SYS_EFI	0xef	/* Platform ID at section header entry */
46 
47 #define ET_BOOT_ENTRY_SIZE 0x20
48 
49 #define	ET_BOOTABLE		0x88
50 #define	ET_NOT_BOOTABLE	0
51 
52 #define	ET_MEDIA_NOEM	0
53 #define	ET_MEDIA_12FDD			1
54 #define	ET_MEDIA_144FDD			2
55 #define	ET_MEDIA_288FDD			3
56 #define	ET_MEDIA_HDD			4
57 
58 #define ET_INDICATOR_HEADERMORE	0x90
59 #define ET_INDICATOR_HEADERLAST	0x91
60 #define ET_INDICATOR_EXTENSION	0x44
61 
62 /*** Boot Structures ***/
63 
64 typedef struct _boot_volume_descriptor {
65 	u_char boot_record_indicator	[ISODCL(0x00,0x00)];
66 	u_char identifier		[ISODCL(0x01,0x05)];
67 	u_char version			[ISODCL(0x06,0x06)];
68 	u_char boot_system_identifier	[ISODCL(0x07,0x26)];
69 	u_char unused1			[ISODCL(0x27,0x46)];
70 	u_char boot_catalog_pointer	[ISODCL(0x47,0x4A)];
71 	u_char unused2			[ISODCL(0x4B,0x7FF)];
72 } boot_volume_descriptor;
73 
74 typedef struct _boot_catalog_validation_entry {
75 	u_char header_id		[ISODCL(0x00,0x00)];
76 	u_char platform_id		[ISODCL(0x01,0x01)];
77 	u_char reserved1		[ISODCL(0x02,0x03)];
78 	u_char manufacturer		[ISODCL(0x04,0x1B)];
79 	u_char checksum			[ISODCL(0x1C,0x1D)];
80 	u_char key			[ISODCL(0x1E,0x1F)];
81 } boot_catalog_validation_entry;
82 
83 typedef struct _boot_catalog_initial_entry {
84 	u_char boot_indicator		[ISODCL(0x00,0x00)];
85 	u_char media_type		[ISODCL(0x01,0x01)];
86 	u_char load_segment		[ISODCL(0x02,0x03)];
87 	u_char system_type		[ISODCL(0x04,0x04)];
88 	u_char unused_1			[ISODCL(0x05,0x05)];
89 	u_char sector_count		[ISODCL(0x06,0x07)];
90 	u_char load_rba			[ISODCL(0x08,0x0B)];
91 	u_char unused_2			[ISODCL(0x0C,0x1F)];
92 } boot_catalog_initial_entry;
93 
94 #define ET_SECTION_HEADER_MORE		0x90
95 #define ET_SECTION_HEADER_LAST		0x91
96 
97 typedef struct _boot_catalog_section_header {
98 	u_char header_indicator		[ISODCL(0x00,0x00)];
99 	u_char platform_id		[ISODCL(0x01,0x01)];
100 	u_char num_section_entries	[ISODCL(0x02,0x03)];
101 	u_char id_string		[ISODCL(0x04,0x1F)];
102 } boot_catalog_section_header;
103 
104 typedef struct _boot_catalog_section_entry {
105 	u_char boot_indicator		[ISODCL(0x00,0x00)];
106 	u_char media_type		[ISODCL(0x01,0x01)];
107 	u_char load_segment		[ISODCL(0x02,0x03)];
108 	u_char system_type		[ISODCL(0x04,0x04)];
109 	u_char unused_1			[ISODCL(0x05,0x05)];
110 	u_char sector_count		[ISODCL(0x06,0x07)];
111 	u_char load_rba			[ISODCL(0x08,0x0B)];
112 	u_char selection_criteria	[ISODCL(0x0C,0x0C)];
113 	u_char vendor_criteria		[ISODCL(0x0D,0x1F)];
114 } boot_catalog_section_entry;
115 
116 typedef struct _boot_catalog_section_entry_extension {
117 	u_char extension_indicator	[ISODCL(0x00,0x00)];
118 	u_char flags			[ISODCL(0x01,0x01)];
119 	u_char vendor_criteria		[ISODCL(0x02,0x1F)];
120 } boot_catalog_section_entry_extension;
121 
122 #define ET_ENTRY_VE 1
123 #define ET_ENTRY_IE 2
124 #define ET_ENTRY_SH 3
125 #define ET_ENTRY_SE 4
126 #define ET_ENTRY_EX 5
127 
128 struct boot_catalog_entry {
129 	char entry_type;
130 	union {
131 		boot_catalog_validation_entry		VE;
132 		boot_catalog_initial_entry		IE;
133 		boot_catalog_section_header		SH;
134 		boot_catalog_section_entry		SE;
135 		boot_catalog_section_entry_extension	EX;
136 	} entry_data;
137 
138 	LIST_ENTRY(boot_catalog_entry) ll_struct;
139 };
140 
141 /* Temporary structure */
142 struct cd9660_boot_image {
143 	char *filename;
144 	int size;
145 	int sector;			/* copied to LoadRBA */
146 	int num_sectors;
147 	unsigned int loadSegment;
148 	u_char targetMode;
149 	u_char system;
150 	u_char bootable;
151 	u_char platform_id;		/* for section header entry */
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