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