disklabel.h revision 1.13
11.13Sryo/*	$NetBSD: disklabel.h,v 1.13 2018/04/01 04:35:04 ryo Exp $	*/
21.1Sbjh21
31.1Sbjh21/*
41.1Sbjh21 * Copyright (c) 1994 Mark Brinicombe.
51.1Sbjh21 * Copyright (c) 1994 Brini.
61.1Sbjh21 * All rights reserved.
71.1Sbjh21 *
81.1Sbjh21 * This code is derived from software written for Brini by Mark Brinicombe
91.1Sbjh21 *
101.1Sbjh21 * Redistribution and use in source and binary forms, with or without
111.1Sbjh21 * modification, are permitted provided that the following conditions
121.1Sbjh21 * are met:
131.1Sbjh21 * 1. Redistributions of source code must retain the above copyright
141.1Sbjh21 *    notice, this list of conditions and the following disclaimer.
151.1Sbjh21 * 2. Redistributions in binary form must reproduce the above copyright
161.1Sbjh21 *    notice, this list of conditions and the following disclaimer in the
171.1Sbjh21 *    documentation and/or other materials provided with the distribution.
181.1Sbjh21 * 3. All advertising materials mentioning features or use of this software
191.1Sbjh21 *    must display the following acknowledgement:
201.1Sbjh21 *	This product includes software developed by Brini.
211.1Sbjh21 * 4. The name of the company nor the name of the author may be used to
221.1Sbjh21 *    endorse or promote products derived from this software without specific
231.1Sbjh21 *    prior written permission.
241.1Sbjh21 *
251.1Sbjh21 * THIS SOFTWARE IS PROVIDED BY BRINI ``AS IS'' AND ANY EXPRESS OR IMPLIED
261.1Sbjh21 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
271.1Sbjh21 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
281.1Sbjh21 * IN NO EVENT SHALL BRINI OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
291.1Sbjh21 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
301.1Sbjh21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
311.1Sbjh21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
321.1Sbjh21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
331.1Sbjh21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
341.1Sbjh21 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
351.1Sbjh21 * SUCH DAMAGE.
361.1Sbjh21 *
371.1Sbjh21 * RiscBSD kernel project
381.1Sbjh21 *
391.1Sbjh21 * disklabel.h
401.1Sbjh21 *
411.1Sbjh21 * machine specific disk label info
421.1Sbjh21 *
431.1Sbjh21 * Created      : 04/10/94
441.1Sbjh21 */
451.1Sbjh21
461.2Sthorpej#ifndef _ARM_DISKLABEL_H_
471.2Sthorpej#define _ARM_DISKLABEL_H_
481.1Sbjh21
491.10Sbouyer#ifndef LABELUSESMBR
501.12Smsaitoh#define LABELUSESMBR		1	/* use MBR partitionning */
511.10Sbouyer#endif
521.11Smatt#define LABELSECTOR		1	/* sector containing label */
531.11Smatt#define LABELOFFSET		0	/* offset of label in sector */
541.11Smatt#define MAXPARTITIONS		16	/* number of partitions */
551.11Smatt#define OLDMAXPARTITIONS	8	/* old number of partitions */
561.11Smatt#ifndef RAW_PART
571.11Smatt#define RAW_PART		2	/* raw partition: XX?c */
581.11Smatt#endif
591.11Smatt
601.13Sryo
611.13Sryo#ifdef __HAVE_OLD_DISKLABEL
621.11Smatt/*
631.11Smatt * We use the highest bit of the minor number for the partition number.
641.11Smatt * This maintains backward compatibility with device nodes created before
651.11Smatt * MAXPARTITIONS was increased.
661.11Smatt */
671.11Smatt#define	__ARM_MAXDISKS	((1 << 20) / MAXPARTITIONS)
681.11Smatt#define	DISKUNIT(dev)	((minor(dev) / OLDMAXPARTITIONS) % __ARM_MAXDISKS)
691.11Smatt#define	DISKPART(dev)	((minor(dev) % OLDMAXPARTITIONS) + \
701.11Smatt    ((minor(dev) / (__ARM_MAXDISKS * OLDMAXPARTITIONS)) * OLDMAXPARTITIONS))
711.11Smatt#define	DISKMINOR(unit, part) \
721.11Smatt    (((unit) * OLDMAXPARTITIONS) + ((part) % OLDMAXPARTITIONS) + \
731.11Smatt     ((part) / OLDMAXPARTITIONS) * (__ARM_MAXDISKS * OLDMAXPARTITIONS))
741.13Sryo#endif
751.1Sbjh21
761.6Sdyoung#if HAVE_NBTOOL_CONFIG_H
771.6Sdyoung#include <nbinclude/sys/dkbad.h>
781.6Sdyoung#include <nbinclude/sys/disklabel_acorn.h>
791.6Sdyoung#include <nbinclude/sys/bootblock.h>
801.6Sdyoung#else
811.1Sbjh21#include <sys/dkbad.h>
821.2Sthorpej#include <sys/disklabel_acorn.h>
831.4Slukem#include <sys/bootblock.h>
841.6Sdyoung#endif /* HAVE_NBTOOL_CONFIG_H */
851.1Sbjh21
861.1Sbjh21struct cpu_disklabel {
871.4Slukem	struct mbr_partition mbrparts[MBR_PART_COUNT];
881.9Spooka#define __HAVE_DISKLABEL_DKBAD
891.1Sbjh21	struct dkbad bad;
901.1Sbjh21};
911.1Sbjh21
921.1Sbjh21#ifdef _KERNEL
931.1Sbjh21struct buf;
941.1Sbjh21struct disklabel;
951.1Sbjh21
961.1Sbjh21/* for readdisklabel.  rv != 0 -> matches, msg == NULL -> success */
971.8Sdslint	mbr_label_read(dev_t, void (*)(struct buf *), struct disklabel *,
981.8Sdsl	    struct cpu_disklabel *, const char **, int *, int *);
991.1Sbjh21
1001.1Sbjh21/* for writedisklabel.  rv == 0 -> dosen't match, rv > 0 -> success */
1011.8Sdslint	mbr_label_locate(dev_t, void (*)(struct buf *),
1021.8Sdsl	    struct disklabel *, struct cpu_disklabel *, int *, int *);
1031.1Sbjh21#endif /* _KERNEL */
1041.1Sbjh21
1051.2Sthorpej#endif /* _ARM_DISKLABEL_H_ */
106