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