1*5021bb44Schristos /* $NetBSD: disklabel.h,v 1.10 2013/05/16 19:06:45 christos Exp $ */ 24b7a1286Ssimonb 34b7a1286Ssimonb /* 44b7a1286Ssimonb * Copyright 2000, 2001 54b7a1286Ssimonb * Broadcom Corporation. All rights reserved. 64b7a1286Ssimonb * 74b7a1286Ssimonb * This software is furnished under license and may be used and copied only 84b7a1286Ssimonb * in accordance with the following terms and conditions. Subject to these 94b7a1286Ssimonb * conditions, you may download, copy, install, use, modify and distribute 104b7a1286Ssimonb * modified or unmodified copies of this software in source and/or binary 114b7a1286Ssimonb * form. No title or ownership is transferred hereby. 124b7a1286Ssimonb * 134b7a1286Ssimonb * 1) Any source code used, modified or distributed must reproduce and 144b7a1286Ssimonb * retain this copyright notice and list of conditions as they appear in 154b7a1286Ssimonb * the source file. 164b7a1286Ssimonb * 174b7a1286Ssimonb * 2) No right is granted to use any trade name, trademark, or logo of 188a6b8c3bScgd * Broadcom Corporation. The "Broadcom Corporation" name may not be 198a6b8c3bScgd * used to endorse or promote products derived from this software 208a6b8c3bScgd * without the prior written permission of Broadcom Corporation. 214b7a1286Ssimonb * 224b7a1286Ssimonb * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED 234b7a1286Ssimonb * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF 244b7a1286Ssimonb * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR 254b7a1286Ssimonb * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE 264b7a1286Ssimonb * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE 274b7a1286Ssimonb * LIABLE FOR DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 284b7a1286Ssimonb * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 294b7a1286Ssimonb * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 304b7a1286Ssimonb * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 314b7a1286Ssimonb * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 324b7a1286Ssimonb * OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 334b7a1286Ssimonb */ 344b7a1286Ssimonb 354b7a1286Ssimonb /* from: $NetBSD: disklabel.h,v 1.4 2000/05/05 03:27:22 soren Exp */ 364b7a1286Ssimonb 374b7a1286Ssimonb /* 384b7a1286Ssimonb * Copyright (c) 1994 Christopher G. Demetriou 394b7a1286Ssimonb * All rights reserved. 404b7a1286Ssimonb * 414b7a1286Ssimonb * Redistribution and use in source and binary forms, with or without 424b7a1286Ssimonb * modification, are permitted provided that the following conditions 434b7a1286Ssimonb * are met: 444b7a1286Ssimonb * 1. Redistributions of source code must retain the above copyright 454b7a1286Ssimonb * notice, this list of conditions and the following disclaimer. 464b7a1286Ssimonb * 2. Redistributions in binary form must reproduce the above copyright 474b7a1286Ssimonb * notice, this list of conditions and the following disclaimer in the 484b7a1286Ssimonb * documentation and/or other materials provided with the distribution. 494b7a1286Ssimonb * 3. All advertising materials mentioning features or use of this software 504b7a1286Ssimonb * must display the following acknowledgement: 514b7a1286Ssimonb * This product includes software developed by Christopher G. Demetriou. 524b7a1286Ssimonb * 4. The name of the author may not be used to endorse or promote products 534b7a1286Ssimonb * derived from this software without specific prior written permission 544b7a1286Ssimonb * 554b7a1286Ssimonb * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 564b7a1286Ssimonb * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 574b7a1286Ssimonb * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 584b7a1286Ssimonb * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 594b7a1286Ssimonb * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 604b7a1286Ssimonb * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 614b7a1286Ssimonb * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 624b7a1286Ssimonb * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 634b7a1286Ssimonb * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 644b7a1286Ssimonb * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 654b7a1286Ssimonb */ 664b7a1286Ssimonb 674b7a1286Ssimonb #ifndef _MACHINE_DISKLABEL_H_ 684b7a1286Ssimonb #define _MACHINE_DISKLABEL_H_ 694b7a1286Ssimonb 70a47e2eb7Sbouyer #define LABELUSESMBR 0 /* no MBR partitionning */ 714b7a1286Ssimonb #define LABELSECTOR 1 /* sector containing label */ 724b7a1286Ssimonb #define LABELOFFSET 0 /* offset of label in sector */ 734b7a1286Ssimonb #define MAXPARTITIONS 16 744b7a1286Ssimonb #define RAW_PART 3 754b7a1286Ssimonb 764b7a1286Ssimonb #ifdef __NetBSD__ 774b7a1286Ssimonb /* Pull in MBR partition definitions. */ 78a37289dbSdyoung #if HAVE_NBTOOL_CONFIG_H 79a37289dbSdyoung #include <nbinclude/sys/bootblock.h> 80a37289dbSdyoung #else 811c33b4e6Slukem #include <sys/bootblock.h> 82a37289dbSdyoung #endif /* HAVE_NBTOOL_CONFIG_H */ 834b7a1286Ssimonb 844b7a1286Ssimonb #ifndef __ASSEMBLER__ 85a37289dbSdyoung #if HAVE_NBTOOL_CONFIG_H 86a37289dbSdyoung #include <nbinclude/sys/dkbad.h> 87a37289dbSdyoung #else 884b7a1286Ssimonb #include <sys/dkbad.h> 89a37289dbSdyoung #endif /* HAVE_NBTOOL_CONFIG_H */ 904b7a1286Ssimonb struct cpu_disklabel { 912ec4fd84Schristos struct mbr_partition mbrparts[MBR_PART_COUNT]; 9209dbb89bSpooka #define __HAVE_DISKLABEL_DKBAD 934b7a1286Ssimonb struct dkbad bad; 944b7a1286Ssimonb }; 954b7a1286Ssimonb #endif 964b7a1286Ssimonb #endif 974b7a1286Ssimonb 984b7a1286Ssimonb /* 994b7a1286Ssimonb * CFE boot block, modeled loosely on Alpha. 1004b7a1286Ssimonb * 1014b7a1286Ssimonb * It consists of: 1024b7a1286Ssimonb * 1034b7a1286Ssimonb * BSD disk label 1044b7a1286Ssimonb * <blank space> 1054b7a1286Ssimonb * Boot block info (5 uint_64s) 1064b7a1286Ssimonb * 1074b7a1286Ssimonb * The boot block portion looks like: 1084b7a1286Ssimonb * 1094b7a1286Ssimonb * 1104b7a1286Ssimonb * +-------+-------+-------+-------+-------+-------+-------+-------+ 1114b7a1286Ssimonb * | BOOT_MAGIC_NUMBER | 1124b7a1286Ssimonb * +-------+-------+-------+-------+-------+-------+-------+-------+ 1134b7a1286Ssimonb * | Flags | Reserved | Vers | Header Checksum | 1144b7a1286Ssimonb * +-------+-------+-------+-------+-------+-------+-------+-------+ 1154b7a1286Ssimonb * | Secondary Loader Location (bytes) | 1164b7a1286Ssimonb * +-------+-------+-------+-------+-------+-------+-------+-------+ 1174b7a1286Ssimonb * | Loader Checksum | Size of loader (bytes) | 1184b7a1286Ssimonb * +-------+-------+-------+-------+-------+-------+-------+-------+ 1194b7a1286Ssimonb * | Reserved | Architecture Information | 1204b7a1286Ssimonb * +-------+-------+-------+-------+-------+-------+-------+-------+ 1214b7a1286Ssimonb * 1224b7a1286Ssimonb * Boot block fields should always be read as 64-bit numbers. 1234b7a1286Ssimonb * 1244b7a1286Ssimonb */ 1254b7a1286Ssimonb 1264b7a1286Ssimonb 1274b7a1286Ssimonb struct boot_block { 12895d060b0Ssimonb uint64_t cfe_bb_data[64]; /* data (disklabel, also as below) */ 1294b7a1286Ssimonb }; 13095d060b0Ssimonb #define cfe_bb_magic cfe_bb_data[59] /* magic number */ 13195d060b0Ssimonb #define cfe_bb_hdrinfo cfe_bb_data[60] /* header checksum, ver, flags */ 13295d060b0Ssimonb #define cfe_bb_secstart cfe_bb_data[61] /* secondary start (bytes) */ 13395d060b0Ssimonb #define cfe_bb_secsize cfe_bb_data[62] /* secondary size (bytes) */ 13495d060b0Ssimonb #define cfe_bb_archinfo cfe_bb_data[63] /* architecture info */ 1354b7a1286Ssimonb 1364b7a1286Ssimonb #define BOOT_BLOCK_OFFSET 0 /* offset of boot block. */ 1374b7a1286Ssimonb #define BOOT_BLOCK_BLOCKSIZE 512 /* block size for sec. size/start, 1384b7a1286Ssimonb * and for boot block itself 1394b7a1286Ssimonb */ 1404b7a1286Ssimonb #define BOOT_BLOCK_SIZE 40 /* 5 64-bit words */ 1414b7a1286Ssimonb 1424b7a1286Ssimonb #define BOOT_MAGIC_NUMBER 0x43465631424f4f54 1434b7a1286Ssimonb #define BOOT_HDR_CHECKSUM_MASK 0x00000000FFFFFFFF 1444b7a1286Ssimonb #define BOOT_HDR_VER_MASK 0x000000FF00000000 1454b7a1286Ssimonb #define BOOT_HDR_VER_SHIFT 32 1464b7a1286Ssimonb #define BOOT_HDR_FLAGS_MASK 0xFF00000000000000 1474b7a1286Ssimonb #define BOOT_SECSIZE_MASK 0x00000000FFFFFFFF 1484b7a1286Ssimonb #define BOOT_DATA_CHECKSUM_MASK 0xFFFFFFFF00000000 1494b7a1286Ssimonb #define BOOT_DATA_CHECKSUM_SHIFT 32 1504b7a1286Ssimonb #define BOOT_ARCHINFO_MASK 0x00000000FFFFFFFF 1514b7a1286Ssimonb 1524b7a1286Ssimonb #define BOOT_HDR_VERSION 1 1534b7a1286Ssimonb 1544b7a1286Ssimonb #define CHECKSUM_BOOT_BLOCK(bb,cksum) \ 1554b7a1286Ssimonb do { \ 1564b7a1286Ssimonb uint32_t *_ptr = (uint32_t *) (bb); \ 1574b7a1286Ssimonb uint32_t _cksum; \ 1584b7a1286Ssimonb int _i; \ 1594b7a1286Ssimonb \ 1604b7a1286Ssimonb _cksum = 0; \ 1614b7a1286Ssimonb for (_i = 0; \ 1624b7a1286Ssimonb _i < (BOOT_BLOCK_SIZE / sizeof (uint32_t)); \ 1634b7a1286Ssimonb _i++) \ 1644b7a1286Ssimonb _cksum += _ptr[_i]; \ 1654b7a1286Ssimonb *(cksum) = _cksum; \ 1664b7a1286Ssimonb } while (0) 1674b7a1286Ssimonb 1684b7a1286Ssimonb 1694b7a1286Ssimonb #define CHECKSUM_BOOT_DATA(data,len,cksum) \ 1704b7a1286Ssimonb do { \ 1714b7a1286Ssimonb uint32_t *_ptr = (uint32_t *) (data); \ 1724b7a1286Ssimonb uint32_t _cksum; \ 1734b7a1286Ssimonb int _i; \ 1744b7a1286Ssimonb \ 1754b7a1286Ssimonb _cksum = 0; \ 1764b7a1286Ssimonb for (_i = 0; \ 1774b7a1286Ssimonb _i < ((len) / sizeof (uint32_t)); \ 1784b7a1286Ssimonb _i++) \ 1794b7a1286Ssimonb _cksum += _ptr[_i]; \ 1804b7a1286Ssimonb *(cksum) = _cksum; \ 1814b7a1286Ssimonb } while (0) 1824b7a1286Ssimonb 1834b7a1286Ssimonb 1844b7a1286Ssimonb #endif /* _MACHINE_DISKLABEL_H_ */ 185