xref: /freebsd/usr.sbin/makefs/cd9660/cd9660_eltorito.h (revision b3e7694832e81d7a904a10f525f8797b753bf0d3)
1756e49c3SBenno Rice /*	$NetBSD: cd9660_eltorito.h,v 1.6 2017/01/24 11:22:43 nonaka Exp $	*/
201a0f853SOlivier Houchard 
31de7b4b8SPedro F. Giffuni /*-
4*b61a5730SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
51de7b4b8SPedro F. Giffuni  *
601a0f853SOlivier Houchard  * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
701a0f853SOlivier Houchard  * Perez-Rathke and Ram Vedam.  All rights reserved.
801a0f853SOlivier Houchard  *
901a0f853SOlivier Houchard  * This code was written by Daniel Watt, Walter Deignan, Ryan Gabrys,
1001a0f853SOlivier Houchard  * Alan Perez-Rathke and Ram Vedam.
1101a0f853SOlivier Houchard  *
1201a0f853SOlivier Houchard  * Redistribution and use in source and binary forms, with or
1301a0f853SOlivier Houchard  * without modification, are permitted provided that the following
1401a0f853SOlivier Houchard  * conditions are met:
1501a0f853SOlivier Houchard  * 1. Redistributions of source code must retain the above copyright
1601a0f853SOlivier Houchard  *    notice, this list of conditions and the following disclaimer.
1701a0f853SOlivier Houchard  * 2. Redistributions in binary form must reproduce the above
1801a0f853SOlivier Houchard  *    copyright notice, this list of conditions and the following
1901a0f853SOlivier Houchard  *    disclaimer in the documentation and/or other materials provided
2001a0f853SOlivier Houchard  *    with the distribution.
2101a0f853SOlivier Houchard  *
2201a0f853SOlivier Houchard  * THIS SOFTWARE IS PROVIDED BY DANIEL WATT, WALTER DEIGNAN, RYAN
2301a0f853SOlivier Houchard  * GABRYS, ALAN PEREZ-RATHKE AND RAM VEDAM ``AS IS'' AND ANY EXPRESS OR
2401a0f853SOlivier Houchard  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
2501a0f853SOlivier Houchard  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
2601a0f853SOlivier Houchard  * DISCLAIMED.  IN NO EVENT SHALL DANIEL WATT, WALTER DEIGNAN, RYAN
2701a0f853SOlivier Houchard  * GABRYS, ALAN PEREZ-RATHKE AND RAM VEDAM BE LIABLE FOR ANY DIRECT, INDIRECT,
2801a0f853SOlivier Houchard  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2901a0f853SOlivier Houchard  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
3001a0f853SOlivier Houchard  * USE,DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
3101a0f853SOlivier Houchard  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
3201a0f853SOlivier Houchard  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3301a0f853SOlivier Houchard  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
3401a0f853SOlivier Houchard  * OF SUCH DAMAGE.
3501a0f853SOlivier Houchard  */
3601a0f853SOlivier Houchard 
3701a0f853SOlivier Houchard #ifndef _CD9660_ELTORITO_H_
3801a0f853SOlivier Houchard #define _CD9660_ELTORITO_H_
3901a0f853SOlivier Houchard 
4001a0f853SOlivier Houchard /* Boot defines */
4101a0f853SOlivier Houchard #define	ET_ID		"EL TORITO SPECIFICATION"
4201a0f853SOlivier Houchard #define	ET_SYS_X86	0
4301a0f853SOlivier Houchard #define	ET_SYS_PPC	1
4401a0f853SOlivier Houchard #define	ET_SYS_MAC	2
45756e49c3SBenno Rice #define	ET_SYS_EFI	0xef	/* Platform ID at section header entry */
4601a0f853SOlivier Houchard 
4701a0f853SOlivier Houchard #define ET_BOOT_ENTRY_SIZE 0x20
4801a0f853SOlivier Houchard 
4901a0f853SOlivier Houchard #define	ET_BOOTABLE		0x88
5001a0f853SOlivier Houchard #define	ET_NOT_BOOTABLE	0
5101a0f853SOlivier Houchard 
5201a0f853SOlivier Houchard #define	ET_MEDIA_NOEM	0
5301a0f853SOlivier Houchard #define	ET_MEDIA_12FDD			1
5401a0f853SOlivier Houchard #define	ET_MEDIA_144FDD			2
5501a0f853SOlivier Houchard #define	ET_MEDIA_288FDD			3
5601a0f853SOlivier Houchard #define	ET_MEDIA_HDD			4
5701a0f853SOlivier Houchard 
5801a0f853SOlivier Houchard #define ET_INDICATOR_HEADERMORE	0x90
5901a0f853SOlivier Houchard #define ET_INDICATOR_HEADERLAST	0x91
6001a0f853SOlivier Houchard #define ET_INDICATOR_EXTENSION	0x44
6101a0f853SOlivier Houchard 
6201a0f853SOlivier Houchard /*** Boot Structures ***/
6301a0f853SOlivier Houchard 
6401a0f853SOlivier Houchard typedef struct _boot_volume_descriptor {
6501a0f853SOlivier Houchard 	u_char boot_record_indicator	[ISODCL(0x00,0x00)];
6601a0f853SOlivier Houchard 	u_char identifier		[ISODCL(0x01,0x05)];
6701a0f853SOlivier Houchard 	u_char version			[ISODCL(0x06,0x06)];
6801a0f853SOlivier Houchard 	u_char boot_system_identifier	[ISODCL(0x07,0x26)];
6901a0f853SOlivier Houchard 	u_char unused1			[ISODCL(0x27,0x46)];
7001a0f853SOlivier Houchard 	u_char boot_catalog_pointer	[ISODCL(0x47,0x4A)];
7101a0f853SOlivier Houchard 	u_char unused2			[ISODCL(0x4B,0x7FF)];
7201a0f853SOlivier Houchard } boot_volume_descriptor;
7301a0f853SOlivier Houchard 
7401a0f853SOlivier Houchard typedef struct _boot_catalog_validation_entry {
7501a0f853SOlivier Houchard 	u_char header_id		[ISODCL(0x00,0x00)];
7601a0f853SOlivier Houchard 	u_char platform_id		[ISODCL(0x01,0x01)];
7701a0f853SOlivier Houchard 	u_char reserved1		[ISODCL(0x02,0x03)];
7801a0f853SOlivier Houchard 	u_char manufacturer		[ISODCL(0x04,0x1B)];
7901a0f853SOlivier Houchard 	u_char checksum			[ISODCL(0x1C,0x1D)];
8001a0f853SOlivier Houchard 	u_char key			[ISODCL(0x1E,0x1F)];
8101a0f853SOlivier Houchard } boot_catalog_validation_entry;
8201a0f853SOlivier Houchard 
8301a0f853SOlivier Houchard typedef struct _boot_catalog_initial_entry {
8401a0f853SOlivier Houchard 	u_char boot_indicator		[ISODCL(0x00,0x00)];
8501a0f853SOlivier Houchard 	u_char media_type		[ISODCL(0x01,0x01)];
8601a0f853SOlivier Houchard 	u_char load_segment		[ISODCL(0x02,0x03)];
8701a0f853SOlivier Houchard 	u_char system_type		[ISODCL(0x04,0x04)];
8801a0f853SOlivier Houchard 	u_char unused_1			[ISODCL(0x05,0x05)];
8901a0f853SOlivier Houchard 	u_char sector_count		[ISODCL(0x06,0x07)];
9001a0f853SOlivier Houchard 	u_char load_rba			[ISODCL(0x08,0x0B)];
9101a0f853SOlivier Houchard 	u_char unused_2			[ISODCL(0x0C,0x1F)];
9201a0f853SOlivier Houchard } boot_catalog_initial_entry;
9301a0f853SOlivier Houchard 
9401a0f853SOlivier Houchard #define ET_SECTION_HEADER_MORE		0x90
9501a0f853SOlivier Houchard #define ET_SECTION_HEADER_LAST		0x91
9601a0f853SOlivier Houchard 
9701a0f853SOlivier Houchard typedef struct _boot_catalog_section_header {
9801a0f853SOlivier Houchard 	u_char header_indicator		[ISODCL(0x00,0x00)];
9901a0f853SOlivier Houchard 	u_char platform_id		[ISODCL(0x01,0x01)];
10001a0f853SOlivier Houchard 	u_char num_section_entries	[ISODCL(0x02,0x03)];
10101a0f853SOlivier Houchard 	u_char id_string		[ISODCL(0x04,0x1F)];
10201a0f853SOlivier Houchard } boot_catalog_section_header;
10301a0f853SOlivier Houchard 
10401a0f853SOlivier Houchard typedef struct _boot_catalog_section_entry {
10501a0f853SOlivier Houchard 	u_char boot_indicator		[ISODCL(0x00,0x00)];
10601a0f853SOlivier Houchard 	u_char media_type		[ISODCL(0x01,0x01)];
10701a0f853SOlivier Houchard 	u_char load_segment		[ISODCL(0x02,0x03)];
10801a0f853SOlivier Houchard 	u_char system_type		[ISODCL(0x04,0x04)];
10901a0f853SOlivier Houchard 	u_char unused_1			[ISODCL(0x05,0x05)];
11001a0f853SOlivier Houchard 	u_char sector_count		[ISODCL(0x06,0x07)];
11101a0f853SOlivier Houchard 	u_char load_rba			[ISODCL(0x08,0x0B)];
11201a0f853SOlivier Houchard 	u_char selection_criteria	[ISODCL(0x0C,0x0C)];
11301a0f853SOlivier Houchard 	u_char vendor_criteria		[ISODCL(0x0D,0x1F)];
11401a0f853SOlivier Houchard } boot_catalog_section_entry;
11501a0f853SOlivier Houchard 
11601a0f853SOlivier Houchard typedef struct _boot_catalog_section_entry_extension {
11701a0f853SOlivier Houchard 	u_char extension_indicator	[ISODCL(0x00,0x00)];
11801a0f853SOlivier Houchard 	u_char flags			[ISODCL(0x01,0x01)];
11901a0f853SOlivier Houchard 	u_char vendor_criteria		[ISODCL(0x02,0x1F)];
12001a0f853SOlivier Houchard } boot_catalog_section_entry_extension;
12101a0f853SOlivier Houchard 
12201a0f853SOlivier Houchard #define ET_ENTRY_VE 1
12301a0f853SOlivier Houchard #define ET_ENTRY_IE 2
12401a0f853SOlivier Houchard #define ET_ENTRY_SH 3
12501a0f853SOlivier Houchard #define ET_ENTRY_SE 4
12601a0f853SOlivier Houchard #define ET_ENTRY_EX 5
12701a0f853SOlivier Houchard 
12801a0f853SOlivier Houchard struct boot_catalog_entry {
12901a0f853SOlivier Houchard 	char entry_type;
13001a0f853SOlivier Houchard 	union {
13101a0f853SOlivier Houchard 		boot_catalog_validation_entry		VE;
13201a0f853SOlivier Houchard 		boot_catalog_initial_entry		IE;
13301a0f853SOlivier Houchard 		boot_catalog_section_header		SH;
13401a0f853SOlivier Houchard 		boot_catalog_section_entry		SE;
13501a0f853SOlivier Houchard 		boot_catalog_section_entry_extension	EX;
13601a0f853SOlivier Houchard 	} entry_data;
13701a0f853SOlivier Houchard 
13801a0f853SOlivier Houchard 	LIST_ENTRY(boot_catalog_entry) ll_struct;
13901a0f853SOlivier Houchard };
14001a0f853SOlivier Houchard 
14101a0f853SOlivier Houchard /* Temporary structure */
14201a0f853SOlivier Houchard struct cd9660_boot_image {
14301a0f853SOlivier Houchard 	char *filename;
14401a0f853SOlivier Houchard 	int size;
14501a0f853SOlivier Houchard 	int sector;			/* copied to LoadRBA */
14601a0f853SOlivier Houchard 	int num_sectors;
14701a0f853SOlivier Houchard 	unsigned int loadSegment;
14801a0f853SOlivier Houchard 	u_char targetMode;
14901a0f853SOlivier Houchard 	u_char system;
15001a0f853SOlivier Houchard 	u_char bootable;
151756e49c3SBenno Rice 	u_char platform_id;		/* for section header entry */
15201a0f853SOlivier Houchard 	/*
15301a0f853SOlivier Houchard 	 * If the boot image exists in the filesystem
15401a0f853SOlivier Houchard 	 * already, this is a pointer to that node. For the sake
15501a0f853SOlivier Houchard 	 * of simplicity in future versions, this pointer is only
15601a0f853SOlivier Houchard 	 * to the node in the primary volume. This SHOULD be done
15701a0f853SOlivier Houchard 	 * via a hashtable lookup.
15801a0f853SOlivier Houchard 	 */
15901a0f853SOlivier Houchard 	struct _cd9660node *boot_image_node;
16001a0f853SOlivier Houchard 	TAILQ_ENTRY(cd9660_boot_image) image_list;
16101a0f853SOlivier Houchard 	int serialno;
16201a0f853SOlivier Houchard };
16301a0f853SOlivier Houchard 
16401a0f853SOlivier Houchard 
16501a0f853SOlivier Houchard #endif /* _CD9660_ELTORITO_H_ */
16601a0f853SOlivier Houchard 
167