1 1.4 snj /* $NetBSD: ahdilabel.h,v 1.4 2009/10/20 19:10:11 snj Exp $ */ 2 1.1 leo 3 1.1 leo /* 4 1.1 leo * Copyright (c) 1995 Leo Weppelman. 5 1.1 leo * All rights reserved. 6 1.1 leo * 7 1.1 leo * Redistribution and use in source and binary forms, with or without 8 1.1 leo * modification, are permitted provided that the following conditions 9 1.1 leo * are met: 10 1.1 leo * 1. Redistributions of source code must retain the above copyright 11 1.1 leo * notice, this list of conditions and the following disclaimer. 12 1.1 leo * 2. Redistributions in binary form must reproduce the above copyright 13 1.1 leo * notice, this list of conditions and the following disclaimer in the 14 1.1 leo * documentation and/or other materials provided with the distribution. 15 1.1 leo * 16 1.1 leo * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 1.1 leo * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 1.1 leo * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 1.1 leo * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 1.1 leo * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 1.1 leo * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 1.1 leo * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 1.1 leo * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 1.1 leo * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 1.1 leo * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 1.1 leo */ 27 1.1 leo 28 1.1 leo #ifndef _MACHINE_AHDILABEL_H_ 29 1.1 leo #define _MACHINE_AHDILABEL_H_ 30 1.1 leo 31 1.1 leo #define AHDI_BSIZE 512 /* AHDI blocksize */ 32 1.1 leo #define AHDI_BBLOCK 0 /* AHDI bootblock (root sector) */ 33 1.1 leo #define AHDI_MAXROOTS (MAXAUXROOTS) /* max. # of AHDI rootsectors */ 34 1.1 leo #define AHDI_MAXPARTS (AHDI_MAXROOTS+3) /* max. # of AHDI partitions */ 35 1.1 leo 36 1.1 leo /* 37 1.1 leo * Various `well known' AHDI partition identifiers. 38 1.1 leo */ 39 1.1 leo #define AHDI_MKPID(x,y,z) ( ((u_int32_t)(x) << 16) \ 40 1.1 leo | ((u_int32_t)(y) << 8) \ 41 1.1 leo | ((u_int32_t)(z)) \ 42 1.1 leo ) 43 1.1 leo #define AHDI_PID_XGM AHDI_MKPID('X','G','M') 44 1.1 leo #define AHDI_PID_GEM AHDI_MKPID('G','E','M') 45 1.1 leo #define AHDI_PID_BGM AHDI_MKPID('B','G','M') 46 1.1 leo #define AHDI_PID_RAW AHDI_MKPID('R','A','W') 47 1.1 leo #define AHDI_PID_SWP AHDI_MKPID('S','W','P') 48 1.1 leo #define AHDI_PID_NBD AHDI_MKPID('N','B','D') 49 1.1 leo #define AHDI_PID_NBR AHDI_MKPID('N','B','R') 50 1.1 leo #define AHDI_PID_NBS AHDI_MKPID('N','B','S') 51 1.1 leo #define AHDI_PID_NBU AHDI_MKPID('N','B','U') 52 1.1 leo 53 1.1 leo /* 54 1.1 leo * Format of AHDI boot block. 55 1.1 leo */ 56 1.1 leo #define AHDI_MAXRPD 4 /* max. # of partition descriptors */ 57 1.1 leo /* in an AHDI bootblock (aka root) */ 58 1.1 leo #define AHDI_MAXARPD 2 /* max. # of partition descriptors */ 59 1.3 wiz /* in an AHDI auxiliary root sector */ 60 1.1 leo struct ahdi_part { 61 1.1 leo u_int8_t ap_flg; /* bit 0 is in-use flag */ 62 1.1 leo u_int8_t ap_id[3]; /* id: GEM, BGM, XGM, UNX, MIX */ 63 1.1 leo u_int32_t ap_st; /* block where partition starts */ 64 1.1 leo u_int32_t ap_size; /* partition size in blocks */ 65 1.2 leo } __attribute__((__packed__)); 66 1.1 leo #define ap_end ap_size /* in the in-core copy, store end instead of size */ 67 1.1 leo 68 1.1 leo struct ahdi_root { 69 1.1 leo u_int8_t ar_fill[0x1c2];/* filler, can be boot code */ 70 1.1 leo u_int32_t ar_hdsize; /* size of entire volume in blocks */ 71 1.1 leo struct ahdi_part ar_parts[AHDI_MAXRPD]; /* root partition table */ 72 1.1 leo u_int32_t ar_bslst; /* start of bad-sector list */ 73 1.1 leo u_int32_t ar_bslsize; /* # of blocks in bad-sector list */ 74 1.1 leo u_int16_t ar_checksum; 75 1.2 leo } __attribute__((__packed__)); 76 1.1 leo 77 1.1 leo /* 78 1.1 leo * AHDI partition table. 79 1.1 leo */ 80 1.1 leo #ifdef _KERNEL 81 1.1 leo struct ahdi_ptbl { 82 1.1 leo struct cpu_disklabel *at_cdl; 83 1.1 leo u_int at_hdsize; /* size of volume in blocks */ 84 1.3 wiz u_int at_nroots; /* # of auxiliary root sectors */ 85 1.1 leo u_int at_nparts; /* # of AHDI partitions */ 86 1.1 leo struct ahdi_part at_parts[AHDI_MAXPARTS]; 87 1.1 leo }; 88 1.1 leo #define at_bblock at_cdl->cd_bblock 89 1.1 leo #define at_label at_cdl->cd_label 90 1.1 leo #define at_bslst at_cdl->cd_bslst 91 1.1 leo #define at_bslend at_cdl->cd_bslend 92 1.1 leo #define at_roots at_cdl->cd_roots 93 1.1 leo #endif /* _KERNEL */ 94 1.1 leo 95 1.1 leo #endif /* _MACHINE_AHDILABEL_H_ */ 96