Subject: Seperated i386-specific stuff out of .
To: None <current-users@sun-lamp.cs.Berkeley.EDU>
From: Jan-Oliver Neumann <jan@encap.Hanse.DE>
List: current-users
Date: 07/21/1994 01:00:59
Hello,

<sys/disklabel.h> contains '#ifdef i386' for some specific things to deal
with disklabels hidden in DOS partitions. I followed the example of the
amiga port and sorted things out to <machine/disklabel.h>. I left the
flag D_DOSPART in <sys/disklabel.h> to ensure that nobody uses that value
accidently. 

I also deleted one of the last references to 386BSD by renaming DOSPTYP_
386BSD to DOSPTYP_NETBSD. I do not supply diffs for all references to 
this, I only name affected files:
  * sbin/disklabel/disklabel.c
  * sbin/fdisk/fdisk.c
  * sys/arch/i386/boot/disk.c
  * sys/arch/i386/i386/disksubr.c
  * sys/arch/i386/include/pc/msdos.h  (does this thing live ?)

this is the diff for <sys/disklabel.h>:
*** /usr/NetBSD-current/usr/src/sys/sys/disklabel.h~	Thu Jul 21 00:21:17 1994
--- /usr/NetBSD-current/usr/src/sys/sys/disklabel.h	Thu Jul 21 00:46:23 1994
***************
*** 42,47 ****
--- 42,51 ----
  #include <machine/disklabel.h>
  #endif
  
+ #ifdef i386
+ #include <machine/disklabel.h>
+ #endif
+ 
  /*
   * Disk description table, see disktab(5)
   */
***************
*** 188,195 ****
  #define	DTYPE_FLOPPY		10		/* floppy */
  
  /* d_subtype values: */
- #define DSTYPE_INDOSPART	0x8		/* is inside dos partition */
- #define  DSTYPE_DOSPART(s)	 ((s) & 3)	 /* dos partition number */
  #define DSTYPE_GEOMETRY		0x10		/* drive params in label */
  
  #ifdef DKTYPENAMES
--- 192,197 ----
***************
*** 310,347 ****
  	struct partition *part;
  };
  
! #ifdef i386
! /* DOS partition table -- located in boot block */
! 
! #define	DOSBBSECTOR	0	/* DOS boot block relative sector number */
! #define	DOSPARTOFF	446
! #define NDOSPART	4
! 
! struct dos_partition {
! 	unsigned char	dp_flag;	/* bootstrap flags */
! 	unsigned char	dp_shd;		/* starting head */
! 	unsigned char	dp_ssect;	/* starting sector */
! 	unsigned char	dp_scyl;	/* starting cylinder */
! 	unsigned char	dp_typ;		/* partition type */
! #define		DOSPTYP_386BSD	0xa5		/* 386BSD partition type */
! 	unsigned char	dp_ehd;		/* end head */
! 	unsigned char	dp_esect;	/* end sector */
! 	unsigned char	dp_ecyl;	/* end cylinder */
! 	unsigned long	dp_start;	/* absolute starting sector number */
! 	unsigned long	dp_size;	/* partition size in sectors */
! } dos_partitions[NDOSPART];
! 
! #include <sys/dkbad.h>
! struct cpu_disklabel {
! 	struct dos_partition dosparts[NDOSPART];
! 	struct dkbad bad;
! };
! 
! #endif /* i386 */
  
! #if defined(hp300) || defined(mac68k) || defined(vax) || defined(pc532) || \
!     defined(sun3) || defined(sparc) || defined(da30) || defined(pmax) || \
!     defined(alpha)
  struct cpu_disklabel {
  	int	cd_dummy;		/* must have one element. */
  };
--- 312,323 ----
  	struct partition *part;
  };
  
! /*
!  * The i386- and Amiga-ports define their own cpu_disklabels in
!  * <machine/disklabel.h>. 
!  */
  
! #if !defined(i386) && !defined(amiga)   /* both define different ones */
  struct cpu_disklabel {
  	int	cd_dummy;		/* must have one element. */
  };
***************
*** 370,378 ****
  #define DIOCSBAD	_IOW('d', 110, struct dkbad)	/* set kernel dkbad */
  
  #ifdef KERNEL
- #ifdef i386
- int bounds_check_with_label __P((struct buf *, struct disklabel *, int));
- #endif
  void	 diskerr
  	    __P((struct buf *, char *, char *, int, int, struct disklabel *));
  void	 disksort __P((struct buf *, struct buf *));
--- 346,351 ----
------------------------------------------------------------------------------
This is the new /usr/src/sys/arch/i386/include/disklabel.h:
------------------------------------------------------------------------------
/*
 * Copyright (c) 1987, 1988 Regents of the University of California.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *	This product includes software developed by the University of
 *	California, Berkeley and its contributors.
 * 4. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 *	@(#)disklabel.h	7.19 (Berkeley) 5/7/91
 */

#ifndef _I386_DISKLABEL_H_
#define _I386_DISKLABEL_H_

/*
 * This file contains i386 specific additions to <sys/disklabel.h> to
 * let the i386-port hide disklabels inside DOS/BIOS-partitions.
 */

/* d_subtype values: */
#define DSTYPE_INDOSPART	0x8		/* is inside dos partition */
#define  DSTYPE_DOSPART(s)	 ((s) & 3)	 /* dos partition number */

#ifndef LOCORE

/* DOS partition table -- located in boot block */

#define	DOSBBSECTOR	0	/* DOS boot block relative sector number */
#define	DOSPARTOFF	446
#define NDOSPART	4

struct dos_partition {
	unsigned char	dp_flag;	/* bootstrap flags */
	unsigned char	dp_shd;		/* starting head */
	unsigned char	dp_ssect;	/* starting sector */
	unsigned char	dp_scyl;	/* starting cylinder */
	unsigned char	dp_typ;		/* partition type */
#define		DOSPTYP_NETBSD	0xa5		/* NETBSD partition type */
	unsigned char	dp_ehd;		/* end head */
	unsigned char	dp_esect;	/* end sector */
	unsigned char	dp_ecyl;	/* end cylinder */
	unsigned long	dp_start;	/* absolute starting sector number */
	unsigned long	dp_size;	/* partition size in sectors */
} dos_partitions[NDOSPART];

#include <sys/dkbad.h>
struct cpu_disklabel {
	struct dos_partition dosparts[NDOSPART];
	struct dkbad bad;
};

#ifdef KERNEL
int bounds_check_with_label __P((struct buf *, struct disklabel *, int));
#endif

#endif /* !LOCORE */

#endif /* !_I386_DISKLABEL_H_ */
----------------------------------------------------------------------------

I hope this changes are worthwile and ok; I can't compile a kernel at the
moment.

Jan

------------------------------------------------------------------------------