]>
Commit | Line | Data |
---|---|---|
715f6251 | 1 | /* |
2 | * This file is part of the SPL: Solaris Porting Layer. | |
3 | * | |
4 | * Copyright (c) 2008 Lawrence Livermore National Security, LLC. | |
5 | * Produced at Lawrence Livermore National Laboratory | |
6 | * Written by: | |
7 | * Brian Behlendorf <behlendorf1@llnl.gov>, | |
8 | * Herb Wartens <wartens2@llnl.gov>, | |
9 | * Jim Garlick <garlick@llnl.gov> | |
10 | * UCRL-CODE-235197 | |
11 | * | |
12 | * This is free software; you can redistribute it and/or modify it | |
13 | * under the terms of the GNU General Public License as published by | |
14 | * the Free Software Foundation; either version 2 of the License, or | |
15 | * (at your option) any later version. | |
16 | * | |
17 | * This is distributed in the hope that it will be useful, but WITHOUT | |
18 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
19 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
20 | * for more details. | |
21 | * | |
22 | * You should have received a copy of the GNU General Public License along | |
23 | * with this program; if not, write to the Free Software Foundation, Inc., | |
24 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
25 | */ | |
26 | ||
23f28c4f | 27 | #ifndef _SPL_SUNDDI_H |
28 | #define _SPL_SUNDDI_H | |
29 | ||
4e62fd41 | 30 | #include <sys/cred.h> |
31 | #include <sys/uio.h> | |
32 | #include <sys/sunldi.h> | |
33 | #include <sys/mutex.h> | |
34 | #include <linux/kdev_t.h> | |
35 | #include <linux/fs.h> | |
36 | #include <linux/cdev.h> | |
37 | #include <linux/list.h> | |
46c685d0 | 38 | #include <spl-device.h> |
4e62fd41 | 39 | |
40 | typedef int ddi_devid_t; | |
41 | ||
42 | typedef enum { | |
43 | DDI_INFO_DEVT2DEVINFO = 0, | |
44 | DDI_INFO_DEVT2INSTANCE = 1 | |
45 | } ddi_info_cmd_t; | |
46 | ||
47 | typedef enum { | |
48 | DDI_ATTACH = 0, | |
49 | DDI_RESUME = 1, | |
50 | DDI_PM_RESUME = 2 | |
51 | } ddi_attach_cmd_t; | |
52 | ||
53 | typedef enum { | |
54 | DDI_DETACH = 0, | |
55 | DDI_SUSPEND = 1, | |
56 | DDI_PM_SUSPEND = 2, | |
57 | DDI_HOTPLUG_DETACH = 3 | |
58 | } ddi_detach_cmd_t; | |
59 | ||
60 | typedef enum { | |
61 | DDI_RESET_FORCE = 0 | |
62 | } ddi_reset_cmd_t; | |
63 | ||
64 | typedef enum { | |
65 | PROP_LEN = 0, | |
66 | PROP_LEN_AND_VAL_BUF = 1, | |
67 | PROP_LEN_AND_VAL_ALLOC = 2, | |
68 | PROP_EXISTS = 3 | |
69 | } ddi_prop_op_t; | |
70 | ||
71 | typedef void *devmap_cookie_t; | |
72 | typedef struct as { | |
73 | uchar_t a_flags; | |
74 | } as_t; | |
75 | ||
76 | typedef struct pollhead { | |
77 | struct polldat *ph_list; | |
78 | } pollhead_t; | |
79 | ||
80 | typedef struct dev_info { | |
81 | kmutex_t di_lock; | |
82 | struct dev_ops *di_ops; | |
83 | struct cdev *di_cdev; | |
46c685d0 | 84 | spl_class *di_class; |
25557fd8 | 85 | spl_device *di_device; |
4e62fd41 | 86 | major_t di_major; |
87 | minor_t di_minor; | |
88 | dev_t di_dev; | |
89 | unsigned di_minors; | |
90 | struct list_head di_list; | |
91 | } dev_info_t; | |
92 | ||
93 | typedef struct cb_ops { | |
94 | int (*cb_open)(dev_t *devp, int flag, int otyp, cred_t *credp); | |
95 | int (*cb_close)(dev_t dev, int flag, int otyp, cred_t *credp); | |
96 | int (*cb_strategy)(void *bp); | |
97 | int (*cb_print)(dev_t dev, char *str); | |
98 | int (*cb_dump)(dev_t dev, caddr_t addr, daddr_t blkno, int nblk); | |
99 | int (*cb_read)(dev_t dev, struct uio *uiop, cred_t *credp); | |
100 | int (*cb_write)(dev_t dev, struct uio *uiop, cred_t *credp); | |
101 | int (*cb_ioctl)(dev_t dev, int cmd, intptr_t arg, int mode, | |
102 | cred_t *credp, int *rvalp); | |
103 | int (*cb_devmap)(dev_t dev, devmap_cookie_t dhp, offset_t off, | |
104 | size_t len, size_t *maplen, uint_t model); | |
105 | int (*cb_mmap)(dev_t dev, off_t off, int prot); | |
106 | int (*cb_segmap)(dev_t dev, off_t off, struct as *asp, | |
107 | caddr_t *addrp, off_t len, unsigned int prot, | |
108 | unsigned int maxprot, unsigned int flags, | |
109 | cred_t *credp); | |
110 | int (*cb_chpoll)(dev_t dev, short events, int anyyet, | |
111 | short *reventsp, struct pollhead **phpp); | |
112 | int (*cb_prop_op)(dev_t dev, dev_info_t *dip, | |
113 | ddi_prop_op_t prop_op, int mod_flags, | |
114 | char *name, caddr_t valuep, int *length); | |
115 | struct streamtab *cb_str; | |
116 | int cb_flag; | |
117 | int cb_rev; | |
118 | int (*cb_aread)(dev_t dev, struct aio_req *aio, cred_t *credp); | |
119 | int (*cb_awrite)(dev_t dev, struct aio_req *aio, cred_t *credp); | |
120 | } cb_ops_t; | |
121 | ||
122 | typedef struct dev_ops { | |
123 | int devo_rev; | |
124 | int devo_refcnt; | |
125 | ||
126 | int (*devo_getinfo)(dev_info_t *dip, | |
127 | ddi_info_cmd_t infocmd, void *arg, void **result); | |
128 | int (*devo_identify)(dev_info_t *dip); | |
129 | int (*devo_probe)(dev_info_t *dip); | |
130 | int (*devo_attach)(dev_info_t *dip, ddi_attach_cmd_t cmd); | |
131 | int (*devo_detach)(dev_info_t *dip, ddi_detach_cmd_t cmd); | |
132 | int (*devo_reset)(dev_info_t *dip, ddi_reset_cmd_t cmd); | |
133 | ||
134 | struct cb_ops *devo_cb_ops; | |
135 | struct bus_ops *devo_bus_ops; | |
136 | int (*devo_power)(dev_info_t *dip, int component, int level); | |
137 | } dev_ops_t; | |
138 | ||
139 | typedef struct mod_ops { | |
140 | int (*modm_install)(void); | |
141 | int (*modm_remove)(void); | |
142 | int (*modm_info)(void); | |
143 | } mod_ops_t; | |
144 | ||
145 | typedef struct modldrv { | |
146 | struct mod_ops *drv_modops; | |
147 | char *drv_linkinfo; | |
148 | struct dev_ops *drv_dev_ops; | |
149 | struct dev_info *drv_dev_info; | |
150 | } modldrv_t; | |
151 | ||
152 | #define MODREV_1 1 | |
153 | ||
154 | #define D_NEW 0x000 | |
155 | #define D_MP 0x020 | |
156 | #define D_64BIT 0x200 | |
157 | ||
158 | #define DEVO_REV 3 | |
159 | #define CB_REV 1 | |
160 | ||
161 | #define DDI_SUCCESS 0 | |
162 | #define DDI_FAILURE -1 | |
163 | ||
164 | #define DDI_PSEUDO "ddi_pseudo" | |
165 | ||
166 | #define nodev NULL | |
167 | #define nochpoll NULL | |
168 | #define nulldev NULL | |
169 | #define mod_driverops NULL | |
170 | #define ddi_prop_op NULL | |
171 | ||
b831734a | 172 | #define getminor(x) (x) |
173 | #define getmajor(x) (x) | |
174 | #define ddi_driver_major(di) getmajor(di->di_dev) | |
4e62fd41 | 175 | |
6ab69573 | 176 | #define DDI_DEV_T_NONE ((dev_t)-1) |
177 | #define DDI_DEV_T_ANY ((dev_t)-2) | |
178 | #define DDI_MAJOR_T_UNKNOWN ((major_t)0) | |
179 | ||
180 | #define DDI_PROP_DONTPASS 0x0001 | |
181 | #define DDI_PROP_CANSLEEP 0x0002 | |
182 | ||
183 | #define ddi_prop_lookup_string(x1,x2,x3,x4,x5) (*x5 = NULL) | |
184 | #define ddi_prop_free(x) (void)0 | |
185 | #define ddi_root_node() (void)0 | |
186 | ||
4e62fd41 | 187 | #define mod_install(x) 0 |
188 | #define mod_remove(x) 0 | |
189 | ||
190 | extern int __ddi_create_minor_node(dev_info_t *dip, char *name, int spec_type, | |
191 | minor_t minor_num, char *node_type, | |
192 | int flag, struct module *mod); | |
193 | extern void __ddi_remove_minor_node(dev_info_t *dip, char *name); | |
194 | extern int __mod_install(struct modlinkage *modlp); | |
195 | extern int __mod_remove(struct modlinkage *modlp); | |
196 | ||
197 | static __inline__ void ddi_report_dev(dev_info_t *d) { } | |
198 | static __inline__ void ddi_prop_remove_all(dev_info_t *dip) { } | |
199 | ||
4e62fd41 | 200 | static __inline__ int |
201 | ddi_create_minor_node(dev_info_t *di, char *name, int spec_type, | |
202 | minor_t minor_num, char *node_type, int flag) | |
203 | { | |
204 | return __ddi_create_minor_node(di, name, spec_type, minor_num, | |
205 | node_type, flag, THIS_MODULE); | |
206 | ||
207 | } | |
208 | ||
209 | #undef mod_install | |
210 | #undef mod_remove | |
211 | ||
212 | #define ddi_remove_minor_node __ddi_remove_minor_node | |
213 | #define mod_install __mod_install | |
214 | #define mod_remove __mod_remove | |
215 | ||
23f28c4f | 216 | #endif /* SPL_SUNDDI_H */ |