1 /* $OpenBSD: biovar.h,v 1.7 2005/07/18 15:10:57 dlg Exp $ */ 2 3 /* 4 * Copyright (c) 2002 Niklas Hallqvist. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27 /* 28 * Devices getting ioctls through this interface should use ioctl class 'B' 29 * and command numbers starting from 32, lower ones are reserved for generic 30 * ioctls. All ioctl data must be structures which start with a void * 31 * cookie. 32 */ 33 34 #include <sys/types.h> 35 36 struct bio_common { 37 void *cookie; 38 }; 39 40 #define BIOCLOCATE _IOWR('B', 0, struct bio_locate) 41 struct bio_locate { 42 void *cookie; 43 char *name; 44 }; 45 46 #ifdef _KERNEL 47 int bio_register(struct device *, int (*)(struct device *, u_long, 48 caddr_t)); 49 #endif 50 51 /* RAID section */ 52 53 #define BIOC_MAX_CDB 16 54 #define BIOC_MAX_SENSE 32 55 #define BIOC_MAX_PHYSDISK 128 /* based on FC arrays */ 56 #define BIOC_MAX_VIRTDISK 128 /* based on FC arrays */ 57 58 /* ioctl tunnel defines */ 59 /* SHALL be implemented */ 60 #define BIOCPING _IOWR('B', 32, bioc_ping) 61 typedef struct _bioc_ping { 62 void *cookie; 63 int x; 64 } bioc_ping; 65 66 /* SHALL be implemented */ 67 #define BIOCCAPABILITIES _IOWR('B', 33, bioc_capabilities) 68 typedef struct _bioc_capabilities { 69 void *cookie; 70 u_int64_t ioctls; /* bit field, 1 ioctl supported */ 71 #define BIOC_PING 0x01 72 #define BIOC_ALARM 0x02 73 #define BIOC_PREP_REMOVAL 0x04 74 #define BIOC_REBUILD 0x08 75 #define BIOC_STATUS 0x10 76 #define BIOC_SCSICMD 0x20 77 #define BIOC_STARTSTOP 0x40 78 #define BIOC_BLINK 0x80 79 u_int32_t raid_types; /* bit field, 1 supported raid type */ 80 #define BIOC_RAID0 0x01 81 #define BIOC_RAID1 0x02 82 #define BIOC_RAID3 0x04 83 #define BIOC_RAID5 0x08 84 #define BIOC_RAID10 0x10 85 #define BIOC_RAID01 0x20 86 #define BIOC_RAID50 0x40 87 } bioc_capabilities; 88 89 /* OPTIONAL */ 90 #define BIOCALARM _IOWR('B', 34, bioc_alarm) 91 typedef struct _bioc_alarm { 92 void *cookie; 93 u_int32_t opcode; 94 #define BIOCSALARM_DISABLE 0x00 95 #define BIOCSALARM_ENABLE 0x01 96 #define BIOCSALARM_SILENCE 0x02 97 #define BIOCGALARM_STATE 0x03 98 #define BIOCSALARM_TEST 0x04 99 u_int8_t state; /* only used with GET function */ 100 } bioc_alarm; 101 102 /* OPTIONAL */ 103 #define BIOCSCSICMD _IOWR('B', 35, bioc_scsicmd) 104 typedef struct _bioc_scsicmd { 105 void *cookie; 106 107 /* in (kernel centric) */ 108 u_int8_t channel; 109 u_int8_t target; 110 u_int8_t cdb[BIOC_MAX_CDB]; 111 u_int8_t cdblen; 112 u_int8_t direction; /* 0 = out, 1 = in, this is userland centric */ 113 #define BIOC_DIROUT 0x00 114 #define BIOC_DIRIN 0x01 115 #define BIOC_DIRNONE 0x02 116 117 /* out (kernel centric) */ 118 u_int8_t status; 119 u_int8_t sensebuf[BIOC_MAX_SENSE]; 120 u_int8_t senselen; 121 122 /* in & out (kernel centric) */ 123 void *data; 124 u_int32_t datalen; /* going in it governs the maximum buffer size 125 going out it contains actual bytes transfered */ 126 } bioc_scsicmd; 127 128 /* OPTIONAL */ 129 #define BIOCSTARTSTOP _IOWR('B', 36, bioc_startstop) 130 typedef struct _bioc_startstop { 131 void *cookie; 132 u_int8_t opcode; 133 #define BIOCSUNIT_START 0x00 134 #define BIOCSUNIT_STOP 0x01 135 u_int8_t channel; 136 u_int8_t target; 137 } bioc_startstop; 138 139 /* SHALL be implemented */ 140 #define BIOCSTATUS _IOWR('B', 37, bioc_status) 141 typedef struct _bioc_status { 142 void *cookie; 143 u_int8_t opcode; 144 #define BIOCGSTAT_CHANGE 0x00 /* any changes since last call? */ 145 #define BIOCGSTAT_ALL 0x01 /* get all status */ 146 #define BIOCGSTAT_PHYSDISK 0x02 /* get physical disk status only */ 147 #define BIOCGSTAT_VIRTDISK 0x03 /* get virtual disk status only */ 148 #define BIOCGSTAT_BATTERY 0x04 /* get battery status only */ 149 #define BIOCGSTAT_ENCLOSURE 0x05 /* get enclosure status only */ 150 #define BIOCGSTAT_TEMPERATURE 0x06 /* get temperature status only */ 151 u_int8_t status; /* global status flag */ 152 #define BIOC_STATOK 0x00 /* status is OK */ 153 #define BIOC_STATDEGRAD 0x01 /* status is degraded */ 154 #define BIOC_STATCRIT 0x02 /* status is critical */ 155 #define BIOC_STATBAT 0x04 /* something wrong with battery */ 156 #define BIOC_STATENC 0x08 /* something wrong with enclosure */ 157 #define BIOC_STATTEMP 0x10 /* something is over/under heating */ 158 /* return fields used per request define in opcode */ 159 u_int8_t channels; /* max channels */ 160 u_int8_t buswidth; /* max physical drives per channel */ 161 /* filled in when called with BIOCGSTAT_PHYSDISK set */ 162 u_int8_t pdcount; /* physical disk counter */ 163 u_int8_t physdisk[BIOC_MAX_PHYSDISK]; 164 #define BIOC_PDUNUSED 0x00 /* disk not present */ 165 #define BIOC_PDONLINE 0x01 /* disk present */ 166 #define BIOC_PDOFFLINE 0x02 /* disk present but offline */ 167 #define BIOC_PDINUSE 0x04 /* critical operation in progress */ 168 /* filled in when called with BIOCGSTAT_VIRTDISK set */ 169 u_int8_t vdcount; /* virtual disk counter */ 170 u_int8_t virtdisk[BIOC_MAX_VIRTDISK]; 171 #define BIOC_VDUNUSED 0x00 /* disk not present */ 172 #define BIOC_VDONLINE 0x01 /* disk present */ 173 #define BIOC_VDOFFLINE 0x02 /* disk present but offline */ 174 #define BIOC_VDINUSE 0x04 /* critical operation in progress */ 175 /* filled in when called with BIOCGSTAT_BATTERY set */ 176 u_int8_t batstat; /* battery status */ 177 #define BIOC_BATNOTPRES 0x00 /* battery not present */ 178 #define BIOC_BATMISSING 0x01 /* battery removed */ 179 #define BIOC_BATVOLTERR 0x02 /* battery low/high power */ 180 #define BIOC_BATTEMP 0x04 /* battery over/under temp*/ 181 /* NOTYET: encloure status & temperature status */ 182 } bioc_status; 183 184 /* OPTIONAL */ 185 /* depending on the controller it is handled either in userland or in kernel */ 186 #define BIOCBLINK _IOWR('B', 38, bioc_blink) 187 typedef struct _bioc_blink { 188 void *cookie; 189 u_int8_t opcode; 190 #define BIOCSBLINK_BLINK 0x00 191 #define BIOCSBLINK_UNBLINK 0x01 192 #define BIOCSBLINK_ALERT 0x02 193 u_int8_t channel; 194 u_int8_t target; 195 } bioc_blink; 196 197