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