Home | History | Annotate | Line # | Download | only in scsipi
      1 /*	$NetBSD: sdvar.h,v 1.42 2025/02/27 17:17:00 jakllsch Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 1998, 2004 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Charles M. Hannum.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  *
     19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  * POSSIBILITY OF SUCH DAMAGE.
     30  */
     31 
     32 /*
     33  * Originally written by Julian Elischer (julian (at) dialix.oz.au)
     34  * for TRW Financial Systems for use under the MACH(2.5) operating system.
     35  *
     36  * TRW Financial Systems, in accordance with their agreement with Carnegie
     37  * Mellon University, makes this software available to CMU to distribute
     38  * or use in any manner that they see fit as long as this message is kept with
     39  * the software. For this reason TFS also grants any other persons or
     40  * organisations permission to use or modify this software.
     41  *
     42  * TFS supplies this software to be publicly redistributed
     43  * on the understanding that TFS is not responsible for the correct
     44  * functioning of this software in any circumstances.
     45  *
     46  * Ported to run under 386BSD by Julian Elischer (julian (at) dialix.oz.au) Sept 1992
     47  */
     48 
     49 #ifndef _DEV_SCSIPI_SDVAR_H_
     50 #define _DEV_SCSIPI_SDVAR_H_
     51 
     52 #ifdef _KERNEL_OPT
     53 #include "opt_scsi.h"
     54 #endif
     55 
     56 #include <dev/dkvar.h>
     57 
     58 #ifndef	SDRETRIES
     59 #define	SDRETRIES	4
     60 #endif
     61 
     62 #ifndef	SD_IO_TIMEOUT
     63 #define	SD_IO_TIMEOUT	(60 * 1000)
     64 #endif
     65 
     66 struct disk_parms {
     67 	u_long	heads;			/* number of heads */
     68 	u_long	cyls;			/* number of cylinders */
     69 	u_long	sectors;		/* number of sectors/track */
     70 	u_long	blksize;		/* number of bytes/sector */
     71 	u_long	rot_rate;		/* rotational rate, in RPM */
     72 	u_int64_t disksize;		/* total number sectors */
     73 	u_int64_t disksize512;		/* total number sectors */
     74 	uint8_t	lbppbe;			/* logical blocks per physical block exponent */
     75 	uint16_t lalba;			/* lowest aligned logical block address */
     76 };
     77 
     78 struct sd_softc {
     79 	struct dk_softc sc_dksc;
     80 
     81 	int flags;
     82 #define	SDF_ANCIENT	0x10		/* disk is ancient; for minphys */
     83 #define	SDF_DIRTY	0x20		/* disk is dirty; needs cache flush */
     84 #define	SDF_FLUSHING	0x40		/* flushing, for sddone() */
     85 #define	SDF_LBPME	0x80		/* logical block provisioning management enabled */
     86 #define	SDF_LBPU	0x100		/* logical block provisioning unmap */
     87 
     88 	struct scsipi_periph *sc_periph;/* contains our targ, lun, etc. */
     89 
     90 	struct disk_parms params;
     91 
     92 	callout_t sc_callout;
     93 	u_int8_t type;
     94 	char name[16]; /* product name, for default disklabel */
     95 	char typename[16+1]; /* stored in disk info */
     96 };
     97 
     98 #define	SDGP_RESULT_OK		0	/* parameters obtained */
     99 #define	SDGP_RESULT_OFFLINE	1	/* no media, or otherwise losing */
    100 #define	SDGP_RESULT_UNFORMATTED	2	/* unformatted media (max params) */
    101 
    102 #endif /* _DEV_SCSIPI_SDVAR_H_ */
    103