]> git.proxmox.com Git - mirror_spl-debian.git/blob - include/sys/sunddi.h
- Thinko fix to the SPL module interface
[mirror_spl-debian.git] / include / sys / sunddi.h
1 #ifndef _SPL_SUNDDI_H
2 #define _SPL_SUNDDI_H
3
4 #include <sys/cred.h>
5 #include <sys/uio.h>
6 #include <sys/sunldi.h>
7 #include <sys/mutex.h>
8 #include <linux/kdev_t.h>
9 #include <linux/fs.h>
10 #include <linux/cdev.h>
11 #include <linux/list.h>
12 #include <linux/device.h>
13
14 typedef int ddi_devid_t;
15
16 typedef enum {
17 DDI_INFO_DEVT2DEVINFO = 0,
18 DDI_INFO_DEVT2INSTANCE = 1
19 } ddi_info_cmd_t;
20
21 typedef enum {
22 DDI_ATTACH = 0,
23 DDI_RESUME = 1,
24 DDI_PM_RESUME = 2
25 } ddi_attach_cmd_t;
26
27 typedef enum {
28 DDI_DETACH = 0,
29 DDI_SUSPEND = 1,
30 DDI_PM_SUSPEND = 2,
31 DDI_HOTPLUG_DETACH = 3
32 } ddi_detach_cmd_t;
33
34 typedef enum {
35 DDI_RESET_FORCE = 0
36 } ddi_reset_cmd_t;
37
38 typedef enum {
39 PROP_LEN = 0,
40 PROP_LEN_AND_VAL_BUF = 1,
41 PROP_LEN_AND_VAL_ALLOC = 2,
42 PROP_EXISTS = 3
43 } ddi_prop_op_t;
44
45 typedef void *devmap_cookie_t;
46 typedef struct as {
47 uchar_t a_flags;
48 } as_t;
49
50 typedef struct pollhead {
51 struct polldat *ph_list;
52 } pollhead_t;
53
54 typedef struct dev_info {
55 kmutex_t di_lock;
56 struct dev_ops *di_ops;
57 struct cdev *di_cdev;
58 struct class *di_class;
59 major_t di_major;
60 minor_t di_minor;
61 dev_t di_dev;
62 unsigned di_minors;
63 struct list_head di_list;
64 } dev_info_t;
65
66 typedef struct cb_ops {
67 int (*cb_open)(dev_t *devp, int flag, int otyp, cred_t *credp);
68 int (*cb_close)(dev_t dev, int flag, int otyp, cred_t *credp);
69 int (*cb_strategy)(void *bp);
70 int (*cb_print)(dev_t dev, char *str);
71 int (*cb_dump)(dev_t dev, caddr_t addr, daddr_t blkno, int nblk);
72 int (*cb_read)(dev_t dev, struct uio *uiop, cred_t *credp);
73 int (*cb_write)(dev_t dev, struct uio *uiop, cred_t *credp);
74 int (*cb_ioctl)(dev_t dev, int cmd, intptr_t arg, int mode,
75 cred_t *credp, int *rvalp);
76 int (*cb_devmap)(dev_t dev, devmap_cookie_t dhp, offset_t off,
77 size_t len, size_t *maplen, uint_t model);
78 int (*cb_mmap)(dev_t dev, off_t off, int prot);
79 int (*cb_segmap)(dev_t dev, off_t off, struct as *asp,
80 caddr_t *addrp, off_t len, unsigned int prot,
81 unsigned int maxprot, unsigned int flags,
82 cred_t *credp);
83 int (*cb_chpoll)(dev_t dev, short events, int anyyet,
84 short *reventsp, struct pollhead **phpp);
85 int (*cb_prop_op)(dev_t dev, dev_info_t *dip,
86 ddi_prop_op_t prop_op, int mod_flags,
87 char *name, caddr_t valuep, int *length);
88 struct streamtab *cb_str;
89 int cb_flag;
90 int cb_rev;
91 int (*cb_aread)(dev_t dev, struct aio_req *aio, cred_t *credp);
92 int (*cb_awrite)(dev_t dev, struct aio_req *aio, cred_t *credp);
93 } cb_ops_t;
94
95 typedef struct dev_ops {
96 int devo_rev;
97 int devo_refcnt;
98
99 int (*devo_getinfo)(dev_info_t *dip,
100 ddi_info_cmd_t infocmd, void *arg, void **result);
101 int (*devo_identify)(dev_info_t *dip);
102 int (*devo_probe)(dev_info_t *dip);
103 int (*devo_attach)(dev_info_t *dip, ddi_attach_cmd_t cmd);
104 int (*devo_detach)(dev_info_t *dip, ddi_detach_cmd_t cmd);
105 int (*devo_reset)(dev_info_t *dip, ddi_reset_cmd_t cmd);
106
107 struct cb_ops *devo_cb_ops;
108 struct bus_ops *devo_bus_ops;
109 int (*devo_power)(dev_info_t *dip, int component, int level);
110 } dev_ops_t;
111
112 typedef struct mod_ops {
113 int (*modm_install)(void);
114 int (*modm_remove)(void);
115 int (*modm_info)(void);
116 } mod_ops_t;
117
118 typedef struct modldrv {
119 struct mod_ops *drv_modops;
120 char *drv_linkinfo;
121 struct dev_ops *drv_dev_ops;
122 struct dev_info *drv_dev_info;
123 } modldrv_t;
124
125 #define MODREV_1 1
126
127 #define D_NEW 0x000
128 #define D_MP 0x020
129 #define D_64BIT 0x200
130
131 #define DEVO_REV 3
132 #define CB_REV 1
133
134 #define DDI_SUCCESS 0
135 #define DDI_FAILURE -1
136
137 #define DDI_PSEUDO "ddi_pseudo"
138
139 #define nodev NULL
140 #define nochpoll NULL
141 #define nulldev NULL
142 #define mod_driverops NULL
143 #define ddi_prop_op NULL
144
145 #define getminor MINOR
146 #define getmajor MAJOR
147
148 #define mod_install(x) 0
149 #define mod_remove(x) 0
150
151 extern int __ddi_create_minor_node(dev_info_t *dip, char *name, int spec_type,
152 minor_t minor_num, char *node_type,
153 int flag, struct module *mod);
154 extern void __ddi_remove_minor_node(dev_info_t *dip, char *name);
155 extern int __mod_install(struct modlinkage *modlp);
156 extern int __mod_remove(struct modlinkage *modlp);
157
158 static __inline__ void ddi_report_dev(dev_info_t *d) { }
159 static __inline__ void ddi_prop_remove_all(dev_info_t *dip) { }
160
161 static __inline__ major_t
162 ddi_driver_major(dev_info_t *di)
163 {
164 return getmajor(di->di_dev);
165 }
166
167 static __inline__ int
168 ddi_create_minor_node(dev_info_t *di, char *name, int spec_type,
169 minor_t minor_num, char *node_type, int flag)
170 {
171 return __ddi_create_minor_node(di, name, spec_type, minor_num,
172 node_type, flag, THIS_MODULE);
173
174 }
175
176 #undef mod_install
177 #undef mod_remove
178
179 #define ddi_remove_minor_node __ddi_remove_minor_node
180 #define mod_install __mod_install
181 #define mod_remove __mod_remove
182
183 #endif /* SPL_SUNDDI_H */