1 /*
2 * Mach Operating System
3 * Copyright (c) 1991,1990,1989 Carnegie Mellon University
4 * All Rights Reserved.
5 *
6 * Permission to use, copy, modify and distribute this software and its
7 * documentation is hereby granted, provided that both the copyright
8 * notice and this permission notice appear in all copies of the
9 * software, derivative works or modified versions, and any portions
10 * thereof, and that both notices appear in supporting documentation.
11 *
12 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
13 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
15 *
16 * Carnegie Mellon requests users of this software to return to
17 *
18 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
19 * School of Computer Science
20 * Carnegie Mellon University
21 * Pittsburgh PA 15213-3890
22 *
23 * any improvements or extensions that they make and grant Carnegie Mellon
24 * the rights to redistribute these changes.
25 */
26 /*
27 * HISTORY
28 * $Log: device_types.h,v $
29 * Revision 2.11 93/08/10 15:10:33 mrt
30 * Added io_buf_vec_t for scatter/gather IO.
31 * Looks like a struct iovec from BSD.
32 * [93/04/14 cmaeda]
33 *
34 * Revision 2.10 93/01/14 17:26:50 danner
35 * Added dev_flavor_t.
36 * [92/11/30 af]
37 *
38 * Revision 2.9 92/02/23 22:42:53 elf
39 * Added mandatory DEV_GET_SIZE getstatus operation.
40 * Must be implemented by all devices.
41 * [92/02/22 19:59:27 af]
42 *
43 * Revision 2.8 91/07/31 17:33:54 dbg
44 * Fix dev_name_t to match definition in
45 * device/device_types.defs.
46 * [91/07/30 16:47:13 dbg]
47 *
48 * Revision 2.7 91/05/14 15:43:20 mrt
49 * Correcting copyright
50 *
51 * Revision 2.6 91/05/13 06:02:18 af
52 * Added D_READ_ONLY.
53 * [91/05/12 15:47:28 af]
54 *
55 * Revision 2.5 91/02/05 17:09:13 mrt
56 * Changed to new Mach copyright
57 * [91/01/31 17:28:40 mrt]
58 *
59 * Revision 2.4 90/06/02 14:47:52 rpd
60 * Converted to new IPC.
61 * [90/03/26 21:53:55 rpd]
62 *
63 * Revision 2.3 89/09/08 11:23:58 dbg
64 * Add device_t, and separate in-kernel and out-of-kernel
65 * definitions.
66 * [89/08/01 dbg]
67 *
68 * Revision 2.2 89/08/05 16:06:33 rwd
69 * Added code for inband writing
70 * [89/08/04 rwd]
71 *
72 * 3-Mar-89 David Golub (dbg) at Carnegie-Mellon University
73 * Created.
74 *
75 */
76 /*
77 * Author: David B. Golub, Carnegie Mellon University
78 * Date: 3/89
79 */
80
81 #ifndef DEVICE_TYPES_H
82 #define DEVICE_TYPES_H
83
84 /*
85 * Types for device interface.
86 */
87 #include <mach/std_types.h>
88
89 #ifdef KERNEL
90 /*
91 * Get kernel-only type definitions.
92 */
93 #include <device/device_types_kernel.h>
94
95 #else KERNEL
96 /*
97 * Device handle.
98 */
99 typedef mach_port_t device_t;
100
101 #endif KERNEL
102
103 /*
104 * Device name string
105 */
106 typedef char dev_name_t[128]; /* must match device_types.defs */
107
108 /*
109 * Mode for open/read/write
110 */
111 typedef unsigned int dev_mode_t;
112 #define D_READ 0x1 /* read */
113 #define D_WRITE 0x2 /* write */
114 #define D_NODELAY 0x4 /* no delay on open */
115 #define D_NOWAIT 0x8 /* do not wait if data not available */
116
117 /*
118 * IO buffer - out-of-line array of characters.
119 */
120 typedef char * io_buf_ptr_t;
121
122 /*
123 * IO buffer - in-line array of characters.
124 */
125 #define IO_INBAND_MAX (128) /* must match device_types.defs */
126 typedef char io_buf_ptr_inband_t[IO_INBAND_MAX];
127
128 /*
129 * IO buffer vector - for scatter/gather IO.
130 */
131 typedef struct {
132 vm_offset_t data;
133 vm_size_t count;
134 } io_buf_vec_t;
135
136 /*
137 * Record number for random-access devices
138 */
139 typedef unsigned int recnum_t;
140
141 /*
142 * Flavors of set/get statuses
143 */
144 typedef unsigned int dev_flavor_t;
145
146 /*
147 * Generic array for get/set status
148 */
149 typedef int *dev_status_t; /* Variable-length array of integers */
150 #define DEV_STATUS_MAX (1024) /* Maximum array size */
151
152 typedef int dev_status_data_t[DEV_STATUS_MAX];
153
154 /*
155 * Mandatory get/set status operations
156 */
157
158 /* size a device: op code and indexes for returned values */
159 #define DEV_GET_SIZE 0
160 # define DEV_GET_SIZE_DEVICE_SIZE 0 /* 0 if unknown */
161 # define DEV_GET_SIZE_RECORD_SIZE 1 /* 1 if sequential */
162 #define DEV_GET_SIZE_COUNT 2
163
164 /*
165 * Device error codes
166 */
167 typedef int io_return_t;
168
169 #define D_IO_QUEUED (-1) /* IO queued - do not return result */
170 #define D_SUCCESS 0
171
172 #define D_IO_ERROR 2500 /* hardware IO error */
173 #define D_WOULD_BLOCK 2501 /* would block, but D_NOWAIT set */
174 #define D_NO_SUCH_DEVICE 2502 /* no such device */
175 #define D_ALREADY_OPEN 2503 /* exclusive-use device already open */
176 #define D_DEVICE_DOWN 2504 /* device has been shut down */
177 #define D_INVALID_OPERATION 2505 /* bad operation for device */
178 #define D_INVALID_RECNUM 2506 /* invalid record (block) number */
179 #define D_INVALID_SIZE 2507 /* invalid IO size */
180 #define D_NO_MEMORY 2508 /* memory allocation failure */
181 #define D_READ_ONLY 2509 /* device cannot be written to */
182
183 #endif DEVICE_TYPES_H
Cache object: 1760d8441b29a49636b5b440f90704db
|