Home | History | Annotate | Line # | Download | only in lib
biosdisk_ll.h revision 1.15.96.1
      1  1.15.96.1  pgoyette /*	$NetBSD: biosdisk_ll.h,v 1.15.96.1 2018/03/15 09:12:03 pgoyette Exp $	 */
      2        1.1     perry 
      3        1.1     perry /*
      4        1.1     perry  * Copyright (c) 1996
      5        1.1     perry  * 	Matthias Drochner.  All rights reserved.
      6        1.1     perry  * Copyright (c) 1996
      7        1.1     perry  * 	Perry E. Metzger.  All rights reserved.
      8        1.1     perry  *
      9        1.1     perry  * Redistribution and use in source and binary forms, with or without
     10        1.1     perry  * modification, are permitted provided that the following conditions
     11        1.1     perry  * are met:
     12        1.1     perry  * 1. Redistributions of source code must retain the above copyright
     13        1.1     perry  *    notice, this list of conditions and the following disclaimer.
     14        1.1     perry  * 2. Redistributions in binary form must reproduce the above copyright
     15        1.1     perry  *    notice, this list of conditions and the following disclaimer in the
     16        1.1     perry  *    documentation and/or other materials provided with the distribution.
     17        1.1     perry  * 3. All advertising materials mentioning features or use of this software
     18        1.1     perry  *    must display the following acknowledgements:
     19        1.1     perry  *	This product includes software developed for the NetBSD Project
     20        1.1     perry  *	by Matthias Drochner.
     21        1.1     perry  *	This product includes software developed for the NetBSD Project
     22        1.1     perry  *	by Perry E. Metzger.
     23        1.1     perry  * 4. The names of the authors may not be used to endorse or promote products
     24        1.1     perry  *    derived from this software without specific prior written permission.
     25        1.1     perry  *
     26        1.1     perry  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     27        1.1     perry  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     28        1.1     perry  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     29        1.1     perry  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     30        1.1     perry  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     31        1.1     perry  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     32        1.1     perry  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     33        1.1     perry  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     34        1.1     perry  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     35        1.1     perry  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     36        1.1     perry  */
     37        1.1     perry 
     38        1.2   thorpej /*
     39        1.2   thorpej  * shared by bootsector startup (bootsectmain) and biosdisk.c needs lowlevel
     40        1.2   thorpej  * parts from bios_disk.S
     41        1.1     perry  */
     42        1.1     perry 
     43        1.4      fvdl /*
     44        1.4      fvdl  * Beware that bios_disk.S relies on the offsets of the structure
     45        1.4      fvdl  * members.
     46        1.4      fvdl  */
     47        1.1     perry struct biosdisk_ll {
     48        1.2   thorpej 	int             dev;		/* BIOS device number */
     49       1.11  junyoung 	int		type;		/* device type; see below */
     50        1.4      fvdl 	int             sec, head, cyl;	/* geometry */
     51        1.3        ws 	int		flags;		/* see below */
     52        1.6      fvdl 	int		chs_sectors;	/* # of sectors addressable by CHS */
     53       1.11  junyoung 	int		secsize;	/* bytes per sector */
     54        1.1     perry };
     55       1.13  junyoung #define	BIOSDISK_INT13EXT	1	/* BIOS supports int13 extension */
     56        1.1     perry 
     57       1.11  junyoung #define BIOSDISK_TYPE_FD	0
     58       1.11  junyoung #define BIOSDISK_TYPE_HD	1
     59       1.11  junyoung #define BIOSDISK_TYPE_CD	2
     60       1.11  junyoung 
     61        1.4      fvdl /*
     62        1.8       dsl  * Version 1.x drive parameters from int13 extensions
     63        1.8       dsl  * - should be supported by every BIOS that supports the extensions.
     64        1.8       dsl  * Version 3.x parameters allow the drives to be matched properly
     65        1.8       dsl  * - but are much less likely to be supported.
     66        1.4      fvdl  */
     67        1.4      fvdl 
     68       1.13  junyoung struct biosdisk_extinfo {
     69        1.9  junyoung 	uint16_t	size;		/* size of buffer, set on call */
     70        1.9  junyoung 	uint16_t	flags;		/* flags, see below */
     71        1.9  junyoung 	uint32_t	cyl;		/* # of physical cylinders */
     72        1.9  junyoung 	uint32_t	head;		/* # of physical heads */
     73        1.9  junyoung 	uint32_t	sec;		/* # of physical sectors per track */
     74        1.9  junyoung 	uint64_t	totsec;		/* total number of sectors */
     75        1.9  junyoung 	uint16_t	sbytes;		/* # of bytes per sector */
     76       1.13  junyoung #if defined(BIOSDISK_EXTINFO_V2) || defined(BIOSDISK_EXTINFO_V3)
     77        1.8       dsl 	/* v2.0 extensions */
     78        1.9  junyoung 	uint32_t	edd_cfg;	/* EDD configuration parameters */
     79       1.13  junyoung #if defined(BIOSDISK_EXTINFO_V3)
     80        1.8       dsl 	/* v3.0 extensions */
     81        1.9  junyoung 	uint16_t	devpath_sig;	/* 0xbedd if path info present */
     82       1.13  junyoung #define EXTINFO_DEVPATH_SIGNATURE	0xbedd
     83       1.10  junyoung 	uint8_t		devpath_len;	/* length from devpath_sig */
     84       1.10  junyoung 	uint8_t		fill21[3];
     85        1.8       dsl 	char		host_bus[4];	/* Probably "ISA" or "PCI" */
     86        1.8       dsl 	char		iface_type[8];	/* "ATA", "ATAPI", "SCSI" etc */
     87        1.8       dsl 	union {
     88        1.9  junyoung 		uint8_t		ip_8[8];
     89        1.9  junyoung 		uint16_t	ip_16[4];
     90        1.9  junyoung 		uint32_t	ip_32[2];
     91        1.9  junyoung 		uint64_t	ip_64[1];
     92        1.8       dsl 	} interface_path;
     93        1.8       dsl #define	ip_isa_iobase	ip_16[0];	/* iobase for ISA bus */
     94        1.8       dsl #define	ip_pci_bus	ip_8[0];	/* PCI bus number */
     95        1.8       dsl #define	ip_pci_device	ip_8[1];	/* PCI device number */
     96        1.8       dsl #define	ip_pci_function	ip_8[2];	/* PCI function number */
     97        1.8       dsl 	union {
     98        1.9  junyoung 		uint8_t		dp_8[8];
     99        1.9  junyoung 		uint16_t	dp_16[4];
    100        1.9  junyoung 		uint32_t	dp_32[2];
    101        1.9  junyoung 		uint64_t	dp_64[1];
    102        1.8       dsl 	} device_path;
    103        1.8       dsl #define	dp_ata_slave	dp_8[0];
    104        1.8       dsl #define	dp_atapi_slave	dp_8[0];
    105        1.8       dsl #define	dp_atapi_lun	dp_8[1];
    106        1.8       dsl #define	dp_scsi_lun	dp_8[0];
    107        1.8       dsl #define	dp_firewire_guid dp_64[0];
    108        1.8       dsl #define	dp_fibrechnl_wwn dp_64[0];
    109        1.9  junyoung 	uint8_t		fill40[1];
    110        1.9  junyoung 	uint8_t		checksum;	/* byte sum from dev_path_sig is 0 */
    111       1.13  junyoung #endif /* BIOSDISK_EXTINFO_V3 */
    112       1.13  junyoung #endif /* BIOSDISK_EXTINFO_V2 */
    113       1.15     perry } __packed;
    114        1.5      fvdl 
    115       1.13  junyoung #define EXTINFO_DMA_TRANS	0x0001	/* transparent DMA boundary errors */
    116       1.13  junyoung #define EXTINFO_GEOM_VALID	0x0002	/* geometry in c/h/s in struct valid */
    117       1.13  junyoung #define EXTINFO_REMOVABLE	0x0004	/* removable device */
    118       1.13  junyoung #define EXTINFO_WRITEVERF	0x0008	/* supports write with verify */
    119       1.13  junyoung #define EXTINFO_CHANGELINE	0x0010	/* changeline support */
    120       1.13  junyoung #define EXTINFO_LOCKABLE	0x0020	/* device is lockable */
    121       1.13  junyoung #define EXTINFO_MAXGEOM		0x0040	/* geometry set to max; no media */
    122        1.4      fvdl 
    123  1.15.96.1  pgoyette #ifndef BIOSDISK_DEFAULT_SECSIZE
    124       1.12  junyoung #define BIOSDISK_DEFAULT_SECSIZE	512
    125  1.15.96.1  pgoyette #endif
    126       1.12  junyoung 
    127       1.13  junyoung int set_geometry(struct biosdisk_ll *, struct biosdisk_extinfo *);
    128        1.9  junyoung int readsects(struct biosdisk_ll *, daddr_t, int, char *, int);
    129