1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright (c) 1999 by Sun Microsystems, Inc. 24*7c478bd9Sstevel@tonic-gate * All rights reserved. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #ifndef _PCFS_BPB_H 28*7c478bd9Sstevel@tonic-gate #define _PCFS_BPB_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 33*7c478bd9Sstevel@tonic-gate extern "C" { 34*7c478bd9Sstevel@tonic-gate #endif 35*7c478bd9Sstevel@tonic-gate 36*7c478bd9Sstevel@tonic-gate /* 37*7c478bd9Sstevel@tonic-gate * Common Bios Parameter Block definitions for the pcfs user-level utilities 38*7c478bd9Sstevel@tonic-gate * 39*7c478bd9Sstevel@tonic-gate * At press time these definitions are duplicated in mkfs_pcfs.h. They really 40*7c478bd9Sstevel@tonic-gate * need to be separated out of mkfs_pcfs.h and then it should reference this 41*7c478bd9Sstevel@tonic-gate * file. 42*7c478bd9Sstevel@tonic-gate */ 43*7c478bd9Sstevel@tonic-gate #define BPSEC 512 /* Assumed # of bytes per sector */ 44*7c478bd9Sstevel@tonic-gate 45*7c478bd9Sstevel@tonic-gate #define OPCODE1 0xE9 46*7c478bd9Sstevel@tonic-gate #define OPCODE2 0xEB 47*7c478bd9Sstevel@tonic-gate #define BOOTSECSIG 0xAA55 48*7c478bd9Sstevel@tonic-gate 49*7c478bd9Sstevel@tonic-gate /* 50*7c478bd9Sstevel@tonic-gate * Offset (in bytes) from address of boot sector to where we put 51*7c478bd9Sstevel@tonic-gate * the backup copy of that sector. (FAT32 only) 52*7c478bd9Sstevel@tonic-gate */ 53*7c478bd9Sstevel@tonic-gate #define BKUP_BOOTSECT_OFFSET 0xC00 54*7c478bd9Sstevel@tonic-gate 55*7c478bd9Sstevel@tonic-gate #define uppercase(c) ((c) >= 'a' && (c) <= 'z' ? (c) - 'a' + 'A' : (c)) 56*7c478bd9Sstevel@tonic-gate 57*7c478bd9Sstevel@tonic-gate #define FAT12_TYPE_STRING "FAT12 " 58*7c478bd9Sstevel@tonic-gate #define FAT16_TYPE_STRING "FAT16 " 59*7c478bd9Sstevel@tonic-gate #define FAT32_TYPE_STRING "FAT32 " 60*7c478bd9Sstevel@tonic-gate 61*7c478bd9Sstevel@tonic-gate #define FAT12_ENTSPERSECT 341 62*7c478bd9Sstevel@tonic-gate #define FAT16_ENTSPERSECT 256 63*7c478bd9Sstevel@tonic-gate #define FAT32_ENTSPERSECT 128 64*7c478bd9Sstevel@tonic-gate 65*7c478bd9Sstevel@tonic-gate #ifndef SUNIXOSBOOT 66*7c478bd9Sstevel@tonic-gate #define SUNIXOSBOOT 190 /* Solaris UNIX boot partition */ 67*7c478bd9Sstevel@tonic-gate #endif 68*7c478bd9Sstevel@tonic-gate 69*7c478bd9Sstevel@tonic-gate /* 70*7c478bd9Sstevel@tonic-gate * MS-DOS Disk layout: 71*7c478bd9Sstevel@tonic-gate * 72*7c478bd9Sstevel@tonic-gate * --------------------- 73*7c478bd9Sstevel@tonic-gate * | Boot sector | 74*7c478bd9Sstevel@tonic-gate * |-------------------| 75*7c478bd9Sstevel@tonic-gate * | Reserved area | 76*7c478bd9Sstevel@tonic-gate * |-------------------| 77*7c478bd9Sstevel@tonic-gate * | FAT #1 | 78*7c478bd9Sstevel@tonic-gate * |-------------------| 79*7c478bd9Sstevel@tonic-gate * | FAT #2 | 80*7c478bd9Sstevel@tonic-gate * |-------------------| 81*7c478bd9Sstevel@tonic-gate * | Root directory | 82*7c478bd9Sstevel@tonic-gate * |-------------------| 83*7c478bd9Sstevel@tonic-gate * | | 84*7c478bd9Sstevel@tonic-gate * | File area | 85*7c478bd9Sstevel@tonic-gate * |___________________| 86*7c478bd9Sstevel@tonic-gate */ 87*7c478bd9Sstevel@tonic-gate #ifdef i386 88*7c478bd9Sstevel@tonic-gate #pragma pack(1) 89*7c478bd9Sstevel@tonic-gate #endif 90*7c478bd9Sstevel@tonic-gate struct _orig_bios_param_blk { 91*7c478bd9Sstevel@tonic-gate uint16_t bytes_per_sector; 92*7c478bd9Sstevel@tonic-gate uchar_t sectors_per_cluster; 93*7c478bd9Sstevel@tonic-gate uint16_t resv_sectors; 94*7c478bd9Sstevel@tonic-gate uchar_t num_fats; 95*7c478bd9Sstevel@tonic-gate uint16_t num_root_entries; 96*7c478bd9Sstevel@tonic-gate /* 97*7c478bd9Sstevel@tonic-gate * The sectors_in_volume field will be zero on larger volumes (>32Mb) 98*7c478bd9Sstevel@tonic-gate * and newer file systems (>=MSDOS4.0). In these cases the 99*7c478bd9Sstevel@tonic-gate * sectors_in_logical_volume field should be used instead. 100*7c478bd9Sstevel@tonic-gate */ 101*7c478bd9Sstevel@tonic-gate uint16_t sectors_in_volume; 102*7c478bd9Sstevel@tonic-gate uchar_t media; 103*7c478bd9Sstevel@tonic-gate uint16_t sectors_per_fat; 104*7c478bd9Sstevel@tonic-gate uint16_t sectors_per_track; 105*7c478bd9Sstevel@tonic-gate uint16_t heads; 106*7c478bd9Sstevel@tonic-gate /* 107*7c478bd9Sstevel@tonic-gate * Number of sectors in the partition prior to the start of the logical disk 108*7c478bd9Sstevel@tonic-gate */ 109*7c478bd9Sstevel@tonic-gate uint32_t hidden_sectors; 110*7c478bd9Sstevel@tonic-gate uint32_t sectors_in_logical_volume; 111*7c478bd9Sstevel@tonic-gate }; 112*7c478bd9Sstevel@tonic-gate #ifdef i386 113*7c478bd9Sstevel@tonic-gate #pragma pack() 114*7c478bd9Sstevel@tonic-gate #endif 115*7c478bd9Sstevel@tonic-gate 116*7c478bd9Sstevel@tonic-gate #ifdef i386 117*7c478bd9Sstevel@tonic-gate #pragma pack(1) 118*7c478bd9Sstevel@tonic-gate #endif 119*7c478bd9Sstevel@tonic-gate struct _bpb32_extensions { 120*7c478bd9Sstevel@tonic-gate uint32_t big_sectors_per_fat; 121*7c478bd9Sstevel@tonic-gate uint16_t ext_flags; 122*7c478bd9Sstevel@tonic-gate uchar_t fs_vers_lo; 123*7c478bd9Sstevel@tonic-gate uchar_t fs_vers_hi; 124*7c478bd9Sstevel@tonic-gate uint32_t root_dir_clust; 125*7c478bd9Sstevel@tonic-gate uint16_t fsinfosec; 126*7c478bd9Sstevel@tonic-gate uint16_t backupboot; 127*7c478bd9Sstevel@tonic-gate uint16_t reserved[6]; 128*7c478bd9Sstevel@tonic-gate }; 129*7c478bd9Sstevel@tonic-gate #ifdef i386 130*7c478bd9Sstevel@tonic-gate #pragma pack() 131*7c478bd9Sstevel@tonic-gate #endif 132*7c478bd9Sstevel@tonic-gate 133*7c478bd9Sstevel@tonic-gate #ifdef i386 134*7c478bd9Sstevel@tonic-gate #pragma pack(1) 135*7c478bd9Sstevel@tonic-gate #endif 136*7c478bd9Sstevel@tonic-gate struct _bpb_extensions { 137*7c478bd9Sstevel@tonic-gate uchar_t phys_drive_num; 138*7c478bd9Sstevel@tonic-gate uchar_t reserved; 139*7c478bd9Sstevel@tonic-gate uchar_t ext_signature; 140*7c478bd9Sstevel@tonic-gate uint32_t volume_id; 141*7c478bd9Sstevel@tonic-gate uchar_t volume_label[11]; 142*7c478bd9Sstevel@tonic-gate uchar_t type[8]; 143*7c478bd9Sstevel@tonic-gate }; 144*7c478bd9Sstevel@tonic-gate #ifdef i386 145*7c478bd9Sstevel@tonic-gate #pragma pack() 146*7c478bd9Sstevel@tonic-gate #endif 147*7c478bd9Sstevel@tonic-gate 148*7c478bd9Sstevel@tonic-gate #ifdef i386 149*7c478bd9Sstevel@tonic-gate #pragma pack(1) 150*7c478bd9Sstevel@tonic-gate #endif 151*7c478bd9Sstevel@tonic-gate struct _sun_bpb_extensions { 152*7c478bd9Sstevel@tonic-gate uint16_t bs_offset_high; 153*7c478bd9Sstevel@tonic-gate uint16_t bs_offset_low; 154*7c478bd9Sstevel@tonic-gate }; 155*7c478bd9Sstevel@tonic-gate #ifdef i386 156*7c478bd9Sstevel@tonic-gate #pragma pack() 157*7c478bd9Sstevel@tonic-gate #endif 158*7c478bd9Sstevel@tonic-gate 159*7c478bd9Sstevel@tonic-gate /* 160*7c478bd9Sstevel@tonic-gate * bpb_t is a conglomeration of all the fields a bpb can have. Every 161*7c478bd9Sstevel@tonic-gate * bpb will have the orig_bios struct, but only FAT32's will have bpb32, 162*7c478bd9Sstevel@tonic-gate * and only Solaris boot diskettes will have the sunbpb structure. 163*7c478bd9Sstevel@tonic-gate */ 164*7c478bd9Sstevel@tonic-gate typedef struct _bios_param_blk { 165*7c478bd9Sstevel@tonic-gate struct _orig_bios_param_blk bpb; 166*7c478bd9Sstevel@tonic-gate struct _bpb32_extensions bpb32; 167*7c478bd9Sstevel@tonic-gate struct _bpb_extensions ebpb; 168*7c478bd9Sstevel@tonic-gate struct _sun_bpb_extensions sunbpb; 169*7c478bd9Sstevel@tonic-gate } bpb_t; 170*7c478bd9Sstevel@tonic-gate 171*7c478bd9Sstevel@tonic-gate #ifdef i386 172*7c478bd9Sstevel@tonic-gate #pragma pack(1) 173*7c478bd9Sstevel@tonic-gate struct _bpb_head { 174*7c478bd9Sstevel@tonic-gate uchar_t bs_jump_code[3]; 175*7c478bd9Sstevel@tonic-gate uchar_t bs_oem_name[8]; 176*7c478bd9Sstevel@tonic-gate struct _orig_bios_param_blk bs_bpb; 177*7c478bd9Sstevel@tonic-gate }; 178*7c478bd9Sstevel@tonic-gate #pragma pack() 179*7c478bd9Sstevel@tonic-gate 180*7c478bd9Sstevel@tonic-gate #pragma pack(1) 181*7c478bd9Sstevel@tonic-gate struct _boot_sector { 182*7c478bd9Sstevel@tonic-gate struct _bpb_head bs_front; 183*7c478bd9Sstevel@tonic-gate struct _bpb_extensions bs_ebpb; 184*7c478bd9Sstevel@tonic-gate struct _sun_bpb_extensions bs_sebpb; 185*7c478bd9Sstevel@tonic-gate uchar_t bs_bootstrap[444]; 186*7c478bd9Sstevel@tonic-gate uchar_t bs_signature[2]; 187*7c478bd9Sstevel@tonic-gate }; 188*7c478bd9Sstevel@tonic-gate #pragma pack() 189*7c478bd9Sstevel@tonic-gate 190*7c478bd9Sstevel@tonic-gate #pragma pack(1) 191*7c478bd9Sstevel@tonic-gate struct _boot_sector32 { 192*7c478bd9Sstevel@tonic-gate struct _bpb_head bs_front; 193*7c478bd9Sstevel@tonic-gate struct _bpb32_extensions bs_bpb32; 194*7c478bd9Sstevel@tonic-gate struct _bpb_extensions bs_ebpb; 195*7c478bd9Sstevel@tonic-gate uchar_t bs_bootstrap[420]; 196*7c478bd9Sstevel@tonic-gate uchar_t bs_signature[2]; 197*7c478bd9Sstevel@tonic-gate }; 198*7c478bd9Sstevel@tonic-gate #pragma pack() 199*7c478bd9Sstevel@tonic-gate #else 200*7c478bd9Sstevel@tonic-gate #define ORIG_BPB_START_INDEX 8 /* index into filler field */ 201*7c478bd9Sstevel@tonic-gate #define EXT_BPB_START_INDEX 33 /* index into filler field */ 202*7c478bd9Sstevel@tonic-gate #define BPB_32_START_INDEX 33 /* index into filler field */ 203*7c478bd9Sstevel@tonic-gate #define EXT_BPB_32_START_INDEX 61 /* index into filler field */ 204*7c478bd9Sstevel@tonic-gate struct _boot_sector { 205*7c478bd9Sstevel@tonic-gate uchar_t bs_jump_code[3]; 206*7c478bd9Sstevel@tonic-gate uchar_t bs_filler[59]; 207*7c478bd9Sstevel@tonic-gate uchar_t bs_sun_bpb[4]; 208*7c478bd9Sstevel@tonic-gate uchar_t bs_bootstrap[444]; 209*7c478bd9Sstevel@tonic-gate uchar_t bs_signature[2]; 210*7c478bd9Sstevel@tonic-gate }; 211*7c478bd9Sstevel@tonic-gate 212*7c478bd9Sstevel@tonic-gate struct _boot_sector32 { 213*7c478bd9Sstevel@tonic-gate uchar_t bs_jump_code[3]; 214*7c478bd9Sstevel@tonic-gate uchar_t bs_filler[87]; 215*7c478bd9Sstevel@tonic-gate uchar_t bs_bootstrap[420]; 216*7c478bd9Sstevel@tonic-gate uchar_t bs_signature[2]; 217*7c478bd9Sstevel@tonic-gate }; 218*7c478bd9Sstevel@tonic-gate #endif 219*7c478bd9Sstevel@tonic-gate 220*7c478bd9Sstevel@tonic-gate typedef union _ubso { 221*7c478bd9Sstevel@tonic-gate struct _boot_sector bs; 222*7c478bd9Sstevel@tonic-gate struct _boot_sector32 bs32; 223*7c478bd9Sstevel@tonic-gate struct mboot mb; 224*7c478bd9Sstevel@tonic-gate uchar_t buf[BPSEC]; 225*7c478bd9Sstevel@tonic-gate } boot_sector_t; 226*7c478bd9Sstevel@tonic-gate 227*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 228*7c478bd9Sstevel@tonic-gate } 229*7c478bd9Sstevel@tonic-gate #endif 230*7c478bd9Sstevel@tonic-gate 231*7c478bd9Sstevel@tonic-gate #endif /* _PCFS_BPB_H */ 232