Home | History | Annotate | Line # | Download | only in include
disklabel.h revision 1.2.2.1
      1  1.2.2.1   skrll /* $NetBSD: disklabel.h,v 1.2.2.1 2004/08/03 10:39:56 skrll Exp $ */
      2      1.1  simonb 
      3      1.1  simonb /*
      4      1.1  simonb  * Copyright 2000, 2001
      5      1.1  simonb  * Broadcom Corporation. All rights reserved.
      6      1.1  simonb  *
      7      1.1  simonb  * This software is furnished under license and may be used and copied only
      8      1.1  simonb  * in accordance with the following terms and conditions.  Subject to these
      9      1.1  simonb  * conditions, you may download, copy, install, use, modify and distribute
     10      1.1  simonb  * modified or unmodified copies of this software in source and/or binary
     11      1.1  simonb  * form. No title or ownership is transferred hereby.
     12      1.1  simonb  *
     13      1.1  simonb  * 1) Any source code used, modified or distributed must reproduce and
     14      1.1  simonb  *    retain this copyright notice and list of conditions as they appear in
     15      1.1  simonb  *    the source file.
     16      1.1  simonb  *
     17      1.1  simonb  * 2) No right is granted to use any trade name, trademark, or logo of
     18      1.2     cgd  *    Broadcom Corporation.  The "Broadcom Corporation" name may not be
     19      1.2     cgd  *    used to endorse or promote products derived from this software
     20      1.2     cgd  *    without the prior written permission of Broadcom Corporation.
     21      1.1  simonb  *
     22      1.1  simonb  * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED
     23      1.1  simonb  *    WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF
     24      1.1  simonb  *    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
     25      1.1  simonb  *    NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE
     26      1.1  simonb  *    FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE
     27      1.1  simonb  *    LIABLE FOR DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     28      1.1  simonb  *    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     29      1.1  simonb  *    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
     30      1.1  simonb  *    BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     31      1.1  simonb  *    WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
     32      1.1  simonb  *    OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     33      1.1  simonb  */
     34      1.1  simonb 
     35      1.1  simonb /* from: $NetBSD: disklabel.h,v 1.4 2000/05/05 03:27:22 soren Exp */
     36      1.1  simonb 
     37      1.1  simonb /*
     38      1.1  simonb  * Copyright (c) 1994 Christopher G. Demetriou
     39      1.1  simonb  * All rights reserved.
     40      1.1  simonb  *
     41      1.1  simonb  * Redistribution and use in source and binary forms, with or without
     42      1.1  simonb  * modification, are permitted provided that the following conditions
     43      1.1  simonb  * are met:
     44      1.1  simonb  * 1. Redistributions of source code must retain the above copyright
     45      1.1  simonb  *    notice, this list of conditions and the following disclaimer.
     46      1.1  simonb  * 2. Redistributions in binary form must reproduce the above copyright
     47      1.1  simonb  *    notice, this list of conditions and the following disclaimer in the
     48      1.1  simonb  *    documentation and/or other materials provided with the distribution.
     49      1.1  simonb  * 3. All advertising materials mentioning features or use of this software
     50      1.1  simonb  *    must display the following acknowledgement:
     51      1.1  simonb  *      This product includes software developed by Christopher G. Demetriou.
     52      1.1  simonb  * 4. The name of the author may not be used to endorse or promote products
     53      1.1  simonb  *    derived from this software without specific prior written permission
     54      1.1  simonb  *
     55      1.1  simonb  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     56      1.1  simonb  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     57      1.1  simonb  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     58      1.1  simonb  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     59      1.1  simonb  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     60      1.1  simonb  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     61      1.1  simonb  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     62      1.1  simonb  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     63      1.1  simonb  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     64      1.1  simonb  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     65      1.1  simonb  */
     66      1.1  simonb 
     67      1.1  simonb #ifndef _MACHINE_DISKLABEL_H_
     68      1.1  simonb #define	_MACHINE_DISKLABEL_H_
     69      1.1  simonb 
     70      1.1  simonb #define	LABELSECTOR	1		/* sector containing label */
     71      1.1  simonb #define	LABELOFFSET	0		/* offset of label in sector */
     72      1.1  simonb #define	MAXPARTITIONS	16
     73      1.1  simonb #define	RAW_PART	3
     74      1.1  simonb 
     75      1.1  simonb #ifdef __NetBSD__
     76      1.1  simonb /* Pull in MBR partition definitions. */
     77  1.2.2.1   skrll #include <sys/bootblock.h>
     78      1.1  simonb 
     79      1.1  simonb #ifndef __ASSEMBLER__
     80      1.1  simonb #include <sys/dkbad.h>
     81      1.1  simonb struct cpu_disklabel {
     82  1.2.2.1   skrll 	struct mbr_partition dosparts[MBR_PART_COUNT];
     83      1.1  simonb 	struct dkbad bad;
     84      1.1  simonb };
     85      1.1  simonb #endif
     86      1.1  simonb #endif
     87      1.1  simonb 
     88      1.1  simonb /*
     89      1.1  simonb  * CFE boot block, modeled loosely on Alpha.
     90      1.1  simonb  *
     91      1.1  simonb  * It consists of:
     92      1.1  simonb  *
     93      1.1  simonb  * 		BSD disk label
     94      1.1  simonb  *		<blank space>
     95      1.1  simonb  *		Boot block info (5 uint_64s)
     96      1.1  simonb  *
     97      1.1  simonb  * The boot block portion looks like:
     98      1.1  simonb  *
     99      1.1  simonb  *
    100      1.1  simonb  *	+-------+-------+-------+-------+-------+-------+-------+-------+
    101      1.1  simonb  *	|                        BOOT_MAGIC_NUMBER                      |
    102      1.1  simonb  *	+-------+-------+-------+-------+-------+-------+-------+-------+
    103      1.1  simonb  *	| Flags |   Reserved    | Vers  |      Header Checksum          |
    104      1.1  simonb  *	+-------+-------+-------+-------+-------+-------+-------+-------+
    105      1.1  simonb  *	|             Secondary Loader Location (bytes)                 |
    106      1.1  simonb  *	+-------+-------+-------+-------+-------+-------+-------+-------+
    107      1.1  simonb  *	|     Loader Checksum           |     Size of loader (bytes)    |
    108      1.1  simonb  *	+-------+-------+-------+-------+-------+-------+-------+-------+
    109      1.1  simonb  *	|          Reserved             |    Architecture Information   |
    110      1.1  simonb  *	+-------+-------+-------+-------+-------+-------+-------+-------+
    111      1.1  simonb  *
    112      1.1  simonb  * Boot block fields should always be read as 64-bit numbers.
    113      1.1  simonb  *
    114      1.1  simonb  */
    115      1.1  simonb 
    116      1.1  simonb 
    117      1.1  simonb struct boot_block {
    118  1.2.2.1   skrll 	uint64_t cfe_bb_data[64];	/* data (disklabel, also as below) */
    119      1.1  simonb };
    120  1.2.2.1   skrll #define	cfe_bb_magic	cfe_bb_data[59]	/* magic number */
    121  1.2.2.1   skrll #define	cfe_bb_hdrinfo	cfe_bb_data[60]	/* header checksum, ver, flags */
    122  1.2.2.1   skrll #define	cfe_bb_secstart	cfe_bb_data[61]	/* secondary start (bytes) */
    123  1.2.2.1   skrll #define	cfe_bb_secsize	cfe_bb_data[62]	/* secondary size (bytes) */
    124  1.2.2.1   skrll #define	cfe_bb_archinfo	cfe_bb_data[63]	/* architecture info */
    125      1.1  simonb 
    126      1.1  simonb #define	BOOT_BLOCK_OFFSET	0	/* offset of boot block. */
    127      1.1  simonb #define	BOOT_BLOCK_BLOCKSIZE	512	/* block size for sec. size/start,
    128      1.1  simonb 					 * and for boot block itself
    129      1.1  simonb 					 */
    130      1.1  simonb #define	BOOT_BLOCK_SIZE		40	/* 5 64-bit words */
    131      1.1  simonb 
    132      1.1  simonb #define	BOOT_MAGIC_NUMBER	0x43465631424f4f54
    133      1.1  simonb #define	BOOT_HDR_CHECKSUM_MASK	0x00000000FFFFFFFF
    134      1.1  simonb #define	BOOT_HDR_VER_MASK	0x000000FF00000000
    135      1.1  simonb #define	BOOT_HDR_VER_SHIFT	32
    136      1.1  simonb #define	BOOT_HDR_FLAGS_MASK	0xFF00000000000000
    137      1.1  simonb #define	BOOT_SECSIZE_MASK	0x00000000FFFFFFFF
    138      1.1  simonb #define	BOOT_DATA_CHECKSUM_MASK 0xFFFFFFFF00000000
    139      1.1  simonb #define	BOOT_DATA_CHECKSUM_SHIFT 32
    140      1.1  simonb #define	BOOT_ARCHINFO_MASK	0x00000000FFFFFFFF
    141      1.1  simonb 
    142      1.1  simonb #define	BOOT_HDR_VERSION	1
    143      1.1  simonb 
    144      1.1  simonb #define	CHECKSUM_BOOT_BLOCK(bb,cksum)					\
    145      1.1  simonb 	do {								\
    146      1.1  simonb 		uint32_t *_ptr = (uint32_t *) (bb);			\
    147      1.1  simonb 		uint32_t _cksum;					\
    148      1.1  simonb 		int _i;							\
    149      1.1  simonb 									\
    150      1.1  simonb 		_cksum = 0;						\
    151      1.1  simonb 		for (_i = 0;						\
    152      1.1  simonb 		    _i < (BOOT_BLOCK_SIZE / sizeof (uint32_t));		\
    153      1.1  simonb 		    _i++)						\
    154      1.1  simonb 			_cksum += _ptr[_i];				\
    155      1.1  simonb 		*(cksum) = _cksum;					\
    156      1.1  simonb 	} while (0)
    157      1.1  simonb 
    158      1.1  simonb 
    159      1.1  simonb #define	CHECKSUM_BOOT_DATA(data,len,cksum)				\
    160      1.1  simonb 	do {								\
    161      1.1  simonb 		uint32_t *_ptr = (uint32_t *) (data);			\
    162      1.1  simonb 		uint32_t _cksum;					\
    163      1.1  simonb 		int _i;							\
    164      1.1  simonb 									\
    165      1.1  simonb 		_cksum = 0;						\
    166      1.1  simonb 		for (_i = 0;						\
    167      1.1  simonb 		    _i < ((len) / sizeof (uint32_t));			\
    168      1.1  simonb 		    _i++)						\
    169      1.1  simonb 			_cksum += _ptr[_i];				\
    170      1.1  simonb 		*(cksum) = _cksum;					\
    171      1.1  simonb 	} while (0)
    172      1.1  simonb 
    173      1.1  simonb 
    174      1.1  simonb #endif /* _MACHINE_DISKLABEL_H_ */
    175