1 /* 2 * Copyright 1991-1998 by Open Software Foundation, Inc. 3 * All Rights Reserved 4 * 5 * Permission to use, copy, modify, and distribute this software and 6 * its documentation for any purpose and without fee is hereby granted, 7 * provided that the above copyright notice appears in all copies and 8 * that both the copyright notice and this permission notice appear in 9 * supporting documentation. 10 * 11 * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 12 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 13 * FOR A PARTICULAR PURPOSE. 14 * 15 * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR 16 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 17 * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, 18 * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION 19 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 20 */ 21 /* 22 * MkLinux 23 */ 24 /* CMU_HIST */ 25 /* 26 * Revision 2.8.3.1 92/03/28 10:04:36 jeffreyh 27 * 04-Mar-92 emcmanus at gr.osf.org 28 * New D_OUT_OF_BAND return possible from device_read. 29 * [92/03/10 07:56:07 bernadat] 30 * Changes from TRUNK 31 * [92/03/10 14:10:45 jeffreyh] 32 * 33 * Revision 2.9 92/02/23 22:42:53 elf 34 * Added mandatory DEV_GET_SIZE getstatus operation. 35 * Must be implemented by all devices. 36 * [92/02/22 19:59:27 af] 37 * 38 * Revision 2.8 91/07/31 17:33:54 dbg 39 * Fix dev_name_t to match definition in 40 * device/device_types.defs. 41 * [91/07/30 16:47:13 dbg] 42 * 43 * Revision 2.7 91/05/14 15:43:20 mrt 44 * Correcting copyright 45 * 46 * Revision 2.6 91/05/13 06:02:18 af 47 * Added D_READ_ONLY. 48 * [91/05/12 15:47:28 af] 49 * 50 * Revision 2.5 91/02/05 17:09:13 mrt 51 * Changed to new Mach copyright 52 * [91/01/31 17:28:40 mrt] 53 * 54 * Revision 2.4 90/06/02 14:47:52 rpd 55 * Converted to new IPC. 56 * [90/03/26 21:53:55 rpd] 57 * 58 * Revision 2.3 89/09/08 11:23:58 dbg 59 * Add device_t, and separate in-kernel and out-of-kernel 60 * definitions. 61 * [89/08/01 dbg] 62 * 63 * Revision 2.2 89/08/05 16:06:33 rwd 64 * Added code for inband writing 65 * [89/08/04 rwd] 66 * 67 * 3-Mar-89 David Golub (dbg) at Carnegie-Mellon University 68 * Created. 69 * 70 */ 71 /* CMU_ENDHIST */ 72 /* 73 * Mach Operating System 74 * Copyright (c) 1991,1990,1989 Carnegie Mellon University 75 * All Rights Reserved. 76 * 77 * Permission to use, copy, modify and distribute this software and its 78 * documentation is hereby granted, provided that both the copyright 79 * notice and this permission notice appear in all copies of the 80 * software, derivative works or modified versions, and any portions 81 * thereof, and that both notices appear in supporting documentation. 82 * 83 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 84 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR 85 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 86 * 87 * Carnegie Mellon requests users of this software to return to 88 * 89 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 90 * School of Computer Science 91 * Carnegie Mellon University 92 * Pittsburgh PA 15213-3890 93 * 94 * any improvements or extensions that they make and grant Carnegie Mellon 95 * the rights to redistribute these changes. 96 */ 97 /* 98 */ 99 /* 100 * Author: David B. Golub, Carnegie Mellon University 101 * Date: 3/89 102 */ 103 104 #ifndef DEVICE_TYPES_H 105 #define DEVICE_TYPES_H 106 107 /* 108 * Types for device interface. 109 */ 110 #include <sys/mach/std_types.h> 111 112 /* 113 * I/O completion queues 114 */ 115 116 /* 117 * Device name string 118 */ 119 typedef char dev_name_t[128]; /* must match device_types.defs */ 120 121 /* 122 * Mode for open/read/write 123 */ 124 typedef uint32_t dev_mode_t; 125 #define D_READ 0x1 /* read */ 126 #define D_WRITE 0x2 /* write */ 127 #define D_NODELAY 0x4 /* no delay on open */ 128 #define D_NOWAIT 0x8 /* do not wait if data not available */ 129 #define D_CLONE 0x10 /* clone device on open */ 130 131 /* 132 * IO buffer - out-of-line array of characters. 133 */ 134 typedef char * io_buf_ptr_t; 135 136 /* 137 * IO buffer - in-line array of characters. 138 */ 139 #define IO_INBAND_MAX (128) /* must match device_types.defs */ 140 typedef char io_buf_ptr_inband_t[IO_INBAND_MAX]; 141 142 /* 143 * Buffer length data counts. 144 */ 145 typedef integer_t io_buf_len_t; 146 147 /* 148 * Record number for random-access devices 149 */ 150 typedef uint32_t recnum_t; 151 152 /* 153 * Flavors of set/get statuses 154 */ 155 typedef uint32_t dev_flavor_t; 156 157 /* 158 * Generic array for get/set status 159 */ 160 typedef int *dev_status_t; /* Variable-length array of integers */ 161 #define DEV_STATUS_MAX (1024) /* Maximum array size */ 162 163 typedef int dev_status_data_t[DEV_STATUS_MAX]; 164 165 /* 166 * Mandatory get/set status operations 167 */ 168 169 /* size a device: op code and indexes for returned values */ 170 #define DEV_GET_SIZE 0 171 # define DEV_GET_SIZE_DEVICE_SIZE 0 /* 0 if unknown */ 172 # define DEV_GET_SIZE_RECORD_SIZE 1 /* 1 if sequential */ 173 #define DEV_GET_SIZE_COUNT 2 174 175 /* 176 * Device error codes 177 */ 178 typedef int io_return_t; 179 180 #define D_IO_QUEUED (-1) /* IO queued - do not return result */ 181 #define D_SUCCESS 0 182 183 #define D_IO_ERROR 2500 /* hardware IO error */ 184 #define D_WOULD_BLOCK 2501 /* would block, but D_NOWAIT set */ 185 #define D_NO_SUCH_DEVICE 2502 /* no such device */ 186 #define D_ALREADY_OPEN 2503 /* exclusive-use device already open */ 187 #define D_DEVICE_DOWN 2504 /* device has been shut down */ 188 #define D_INVALID_OPERATION 2505 /* bad operation for device */ 189 #define D_INVALID_RECNUM 2506 /* invalid record (block) number */ 190 #define D_INVALID_SIZE 2507 /* invalid IO size */ 191 #define D_NO_MEMORY 2508 /* memory allocation failure */ 192 #define D_READ_ONLY 2509 /* device cannot be written to */ 193 #define D_OUT_OF_BAND 2510 /* out-of-band condition on device */ 194 #define D_NOT_CLONED 2511 /* device cannot be cloned */ 195 196 /* 197 * Values for r_type field 198 */ 199 #define IO_DONE_READ 1 200 #define IO_DONE_WRITE 2 201 #define IO_DONE_OVERWRITE 3 202 203 typedef struct io_done_result { 204 struct control_info { 205 int qd_type; /* type of I/O operation */ 206 mach_port_t qd_reqid; /* request id */ 207 kern_return_t qd_code; /* return code */ 208 io_buf_ptr_t qd_data; /* buffer pointer */ 209 int qd_count; /* number of bytes */ 210 } qd_control; 211 io_buf_ptr_inband_t qd_inline; /* inline data */ 212 } io_done_result_t; 213 214 #define qd_type qd_control.qd_type 215 #define qd_reqid qd_control.qd_reqid 216 #define qd_code qd_control.qd_code 217 #define qd_data qd_control.qd_data 218 #define qd_count qd_control.qd_count 219 220 #if 0 221 #ifdef MACH_KERNEL 222 /* 223 * Get kernel-only type definitions. 224 */ 225 #include <device/device_types_kernel.h> 226 227 #else /* MACH_KERNEL */ 228 /* 229 * Device handle. 230 */ 231 typedef mach_port_t device_t; 232 233 #endif /* MACH_KERNEL */ 234 #endif 235 236 #endif /* DEVICE_TYPES_H */ 237 238