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