1 #ifndef _LINUX_STRUCT_H_
2 #define	_LINUX_STRUCT_H_
3 
4 struct bus_type;
5 struct cdev;
6 struct class;
7 struct cpumask;
8 struct device;
9 struct device_driver;
10 struct device_node;
11 struct dmi_system_id;
12 struct fb_videomode;
13 struct file;
14 struct inode;
15 struct input_device_id;
16 struct kmem_cache;
17 struct kobj_uevent_env;
18 struct lock_class_key;
19 struct module;
20 struct mutex;
21 struct page;
22 struct pci_dev;
23 struct poll_table_page;
24 struct pt_regs;
25 struct seq_file;
26 struct snd_pcm_runtime;
27 struct spi_board_info;
28 struct spi_device;
29 struct spi_master;
30 struct tasklet_struct;
31 struct usb_driver;
32 struct usb_interface;
33 struct vm_area_struct;
34 struct vm_operations_struct;
35 struct vfsmount;
36 
37 #define	LINUX_VMA_MAX 128
38 
39 #define	SET_SYSTEM_SLEEP_PM_OPS(...)
40 #define	SET_RUNTIME_PM_OPS(...)
41 #define	SIMPLE_DEV_PM_OPS(name, ...) \
42 const struct dev_pm_ops __maybe_unused name = { }
43 
44 struct dev_pm_ops {
45 };
46 
47 struct notifier_block {
48 	int     (*notifier_call) (struct notifier_block *, unsigned long, void *);
49 	struct notifier_block *next;
50 	int	priority;
51 };
52 
53 enum dma_data_direction {
54 	DMA_DATA_DIRECTION_DUMMY
55 };
56 
57 struct dma_buf {
58 	size_t size;
59 };
60 
61 typedef struct pm_message {
62 	int	event;
63 } pm_message_t;
64 
65 typedef struct poll_table_struct {
66 }	poll_table;
67 
68 typedef struct {
69 	volatile unsigned int counter;
70 } atomic_t;
71 
72 typedef struct {
73 	volatile uint64_t counter;
74 } atomic64_t;
75 
76 struct module {
77 };
78 
79 struct kobject {
80 	struct kobject *parent;
81 };
82 
83 struct kobj_uevent_env {
84 	char	buf[512];
85 	int	buflen;
86 };
87 
88 struct kref {
89 	atomic_t refcount;
90 };
91 
92 typedef struct refcount_struct {
93 	atomic_t refs;
94 } refcount_t;
95 
96 struct attribute {
97 	const char *name;
98 	struct module *owner;
99 	mode_t	mode;
100 };
101 
102 struct kobj_attribute {
103 	struct attribute attr;
104 	ssize_t (*show)(struct kobject *, struct kobj_attribute *, char *);
105 	ssize_t (*store)(struct kobject *, struct kobj_attribute *, const char *, size_t);
106 };
107 
108 struct bin_attribute {
109 	struct attribute attr;
110 	size_t	size;
111 	void   *private;
112 	ssize_t (*read) (struct file *, struct kobject *, struct bin_attribute *,
113 	    	char  *, loff_t, size_t);
114 	ssize_t (*write) (struct file *, struct kobject *, struct bin_attribute *,
115 	    	char  *, loff_t, size_t);
116 	int     (*mmap) (struct file *, struct kobject *, struct bin_attribute *,
117 	    	struct	vm_area_struct *);
118 };
119 
120 struct attribute_group {
121 	const char *name;
122 	struct attribute **attrs;
123 	struct bin_attribute **bin_attrs;
124 	umode_t (*is_visible)(struct kobject *, struct attribute *, int);
125 };
126 
127 #define	__ATTRIBUTE_GROUPS(name)				\
128 static const struct attribute_group *name##_groups[] = {	\
129 	&name##_group,						\
130 	NULL,							\
131 }
132 
133 #define	ATTRIBUTE_GROUPS(name)					\
134 static const struct attribute_group name##_group = {		\
135 	.attrs = name##_attrs,					\
136 };								\
137 static const struct attribute_group *name##_groups[] = {	\
138 	&name##_group,						\
139 	NULL,							\
140 }
141 
142 struct class_attribute {
143 	struct attribute attr;
144 	ssize_t (*show) (struct class *, char *buf);
145 	ssize_t (*store) (struct class *, const char *buf, size_t count);
146 };
147 
148 struct device_attribute {
149 	struct attribute attr;
150 	ssize_t (*show) (struct device *, struct device_attribute *, char *);
151 	ssize_t (*store) (struct device *, struct device_attribute *, const char *, size_t);
152 };
153 
154 struct bus_attribute {
155 	struct attribute attr;
156 	ssize_t (*show) (struct bus_type *, char *);
157 	ssize_t (*store) (struct bus_type *, const char *, size_t);
158 };
159 
160 struct driver_attribute {
161 	struct attribute attr;
162 	ssize_t (*show) (struct device_driver *, char *);
163 	ssize_t (*store) (struct device_driver *, const char *, size_t);
164 };
165 
166 struct device_type {
167 	const char *name;
168 	const struct attribute_group **groups;
169 	int     (*uevent) (struct device *dev, struct kobj_uevent_env *env);
170 	char   *(*devnode) (struct device *dev, mode_t *mode);
171 	void    (*release) (struct device *dev);
172 
173 	const struct dev_pm_ops *pm;
174 };
175 
176 #define	__ATTR(_name,_mode,_show,_store) {		\
177         .attr = {.name = __stringify(_name),		\
178 	    .mode = _mode, .owner = THIS_MODULE },	\
179         .show   = _show,				\
180         .store  = _store,				\
181 }
182 
183 #define	__ATTR_RO(_n) {					\
184 	.attr = { .name = __stringify(_n),		\
185 	    .mode = 0444, .owner = THIS_MODULE },	\
186 	.show = _n##_show,				\
187 }
188 
189 #define	__ATTR_WO(_n) {					\
190 	.attr = { .name = __stringify(_n),		\
191 	    .mode = 0222, .owner = THIS_MODULE },	\
192 	.store = _n##_store,				\
193 }
194 
195 #define	__ATTR_RW(_n)				\
196 	__ATTR(_n, 0666, _n##_show, _n##_store)
197 
198 #define	__ATTR_NULL { }
199 
200 #define	__BIN_ATTR(_name, _mode, _read, _write, _size)		\
201 {								\
202 	.attr = { .name = __stringify(_name), .mode = _mode },	\
203 	.read	= (_read),					\
204 	.write	= (_write),					\
205 	.size	= (_size),					\
206 }
207 
208 #define	DEVICE_ATTR(_name,_mode,_show,_store)	\
209 struct device_attribute				\
210 	dev_attr_##_name =			\
211         __ATTR(_name,_mode,_show,_store)
212 
213 #define	DEVICE_ATTR_RO(_name)				\
214 struct device_attribute					\
215 	dev_attr_##_name = __ATTR_RO(_name)
216 
217 #define	DEVICE_ATTR_RW(_name)				\
218 struct device_attribute					\
219 	dev_attr_##_name = __ATTR_RW(_name)
220 
221 extern struct device_attribute dev_attr_protocols;
222 
223 #define	DRIVER_ATTR(_name,_mode,_show,_store)	\
224 struct driver_attribute				\
225 	driver_attr_##_name =			\
226         __ATTR(_name,_mode,_show,_store)
227 
228 #define	DRIVER_ATTR_RO(_name)				\
229 struct driver_attribute					\
230 	driver_attr_##_name = __ATTR_RO(_name)
231 
232 #define	DRIVER_ATTR_WO(_name)				\
233 struct driver_attribute					\
234 	driver_attr_##_name = __ATTR_WO(_name)
235 
236 #define	DRIVER_ATTR_RW(_name)				\
237 struct driver_attribute					\
238 	driver_attr_##_name = __ATTR_RW(_name)
239 
240 #define	BIN_ATTR(_name, _mode, _read, _write, _size)	\
241 struct bin_attribute bin_attr_##_name =			\
242     __BIN_ATTR(_name, _mode, _read, _write, _size)
243 
244 struct class {
245 	const char *name;
246 	const char *nodename;
247 	const struct device_attribute *dev_attrs;
248 	const struct attribute_group **dev_groups;
249 	int     (*dev_uevent) (struct device *, struct kobj_uevent_env *);
250 	void    (*class_release) (struct class *);
251 	void    (*dev_release) (struct device *);
252 	char   *(*devnode) (struct device *, mode_t *);
253 
254 	struct kref refcount;
255 };
256 
257 struct device_driver {
258 	const char *name;
259 	struct module *owner;
260 	const struct dev_pm_ops *pm;
261 	struct bus_type *bus;
262 	const char *mod_name;
263 	void *of_match_table;
264 	uint8_t suppress_bind_attrs;
265 
266 	TAILQ_ENTRY(device_driver) entry;
267 };
268 
269 typedef void device_release_t (struct device *);
270 
271 typedef void (*dr_release_t)(struct device *dev, void *res);
272 typedef int (*dr_match_t)(struct device *dev, void *res, void *match_data);
273 
274 struct bus_type {
275 	const char *name;
276 	const char *dev_name;
277 	struct device *dev_root;
278 	struct bus_attribute *bus_attrs;
279 	struct device_attribute *dev_attrs;
280 	struct driver_attribute *drv_attrs;
281 	const struct attribute_group **bus_groups;
282 	const struct attribute_group **dev_groups;
283 	const struct attribute_group **drv_groups;
284 
285 	int     (*match) (struct device *dev, struct device_driver *drv);
286 	int     (*uevent) (struct device *dev, struct kobj_uevent_env *env);
287 	int     (*probe) (struct device *dev);
288 	int     (*remove) (struct device *dev);
289 	void    (*shutdown) (struct device *dev);
290 
291 	int     (*suspend) (struct device *dev, pm_message_t state);
292 	int     (*resume) (struct device *dev);
293 
294 	const struct dev_pm_ops *pm;
295 
296 	TAILQ_ENTRY(bus_type) entry;
297 };
298 
299 struct device {
300 	int	minor;
301 	int	busnum;
302 	struct kobject kobj;
303 	struct kref refcount;
304 	device_release_t *release;
305 	struct device_driver *driver;
306 	struct device *parent;
307 	const struct device_type *type;
308 	void   *platform_data;
309 	void   *driver_data;
310 	void   *of_node;
311 	void   *fwnode;
312 	const struct file_operations *fops;
313 	const struct attribute_group **groups;
314 	struct bus_type *bus;
315 	struct cdev *cdev;
316 	struct class *class;
317 	void *sysdev;
318 	struct device_driver driver_static;
319 	dev_t	devt;
320 	char	name[64];
321 	char	bus_name[32];
322 	char	bus_id[32];
323 };
324 
325 struct pci_dev {
326 	struct device dev;
327 };
328 
329 struct platform_device {
330 	struct device dev;
331 };
332 
333 struct platform_driver {
334 	int (*probe)(struct platform_device *);
335 	int (*remove)(struct platform_device *);
336 	struct device_driver driver;
337 	const struct platform_device_id *id_table;
338 };
339 
340 typedef unsigned long pgprot_t;
341 typedef unsigned long fl_owner_t;
342 
343 struct vm_fault {
344 	void   *virtual_address;
345 	struct page *page;
346 };
347 
348 struct vm_area_struct {
349 	unsigned long vm_start;
350 	unsigned long vm_end;
351 	unsigned long vm_pgoff;
352 	void   *vm_private_data;
353 	const struct vm_operations_struct *vm_ops;
354 	uint32_t vm_flags;
355 	pgprot_t vm_page_prot;
356 	void   *vm_buffer_address;
357 };
358 
359 struct vm_operations_struct {
360 	void    (*open) (struct vm_area_struct *vma);
361 	void    (*close) (struct vm_area_struct *vma);
362 	int     (*fault) (struct vm_area_struct *vma, struct vm_fault *vmf);
363 };
364 
365 typedef struct spinlock {
366 } spinlock_t;
367 
368 typedef struct rw_semaphore {
369 } rw_semaphore_t;
370 
371 typedef struct rwlock {
372 } rwlock_t;
373 
374 typedef struct raw_spinlock {
375 } raw_spinlock_t;
376 
377 struct file_operations {
378 	struct module *owner;
379 	loff_t  (*llseek) (struct file *, loff_t, int);
380 	ssize_t (*read) (struct file *, char __user *, size_t, loff_t *);
381 	ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *);
382 	unsigned int (*poll) (struct file *, poll_table *);
383 	int     (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
384 	long    (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
385 	long    (*compat_ioctl) (struct file *, unsigned int, unsigned long);
386 	int     (*mmap) (struct file *, struct vm_area_struct *);
387 	int     (*open) (struct inode *, struct file *);
388 	int     (*flush) (struct file *, fl_owner_t);
389 	int     (*fasync) (int, struct file *, int);
390 	int     (*release) (struct inode *, struct file *);
391 	int     (*check_flags) (int);
392 	int     (*dir_notify) (struct file *filp, unsigned long arg);
393 	unsigned long (*get_unmapped_area) (struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
394 };
395 
396 struct fasync_struct {
397 };
398 
399 struct dentry {
400 	struct inode *d_inode;
401 };
402 
403 struct file {
404 	void   *private_data;
405 	const struct file_operations *f_op;
406 	struct {
407 		struct dentry *dentry;
408 	}	f_path;
409 	int	f_flags;
410 };
411 
412 #define	file_inode(_f) (_f)->f_dentry->d_inode
413 #define	f_dentry f_path.dentry
414 #define	iminor(i) ((i)->d_inode & 0xFFFFUL)
415 
416 typedef struct inode {
417 	dev_t	d_inode;
418 	void   *i_private;
419 	char	i_rdev[0];		/* dummy, must be non-zero */
420 	struct cdev *i_cdev;		/* pointer to cdev */
421 } inode_t;
422 
423 #define	F_V4B_SUBDEV_MAX 	8
424 #define	F_V4B_SUBSUBDEV_MAX 	4
425 
426 enum {
427 	F_V4B_VIDEO,
428 	F_V4B_DVB_AUDIO,
429 	F_V4B_DVB_CA,
430 	F_V4B_DVB_DEMUX,
431 	F_V4B_DVB_DVR,
432 	F_V4B_DVB_FRONTEND,
433 	F_V4B_DVB_OSD,
434 	F_V4B_DVB_SEC,
435 	F_V4B_DVB_VIDEO,
436 	F_V4B_LIRC,
437 	F_V4B_EVDEV,
438 	F_V4B_JOYDEV,
439 	F_V4B_ROCCAT,
440 	F_V4B_MAX,
441 };
442 
443 struct cdev_handle {
444 	struct dentry fixed_dentry;
445 	struct inode fixed_inode;
446 	struct file fixed_file;
447 	struct vm_area_struct fixed_vma[LINUX_VMA_MAX];
448 };
449 
450 struct cdev {
451 	const struct file_operations *ops;
452 	struct module *owner;
453 	dev_t	mm_start;
454 	dev_t	mm_end;
455 	struct kobject kobj;
456 	uint8_t	is_alloced;
457 };
458 
459 struct poll_wqueues {
460 	poll_table pt;
461 	struct poll_table_page *table;
462 	int	error;
463 };
464 
465 struct usb_class_driver {
466 	char   *name;
467 	char   *(*devnode) (struct device *dev, mode_t *mode);
468 	const struct file_operations *fops;
469 	int	minor_base;
470 };
471 
472 struct scatterlist {
473         unsigned int    offset;
474         unsigned int    length;
475         dma_addr_t      dma_address;
476         unsigned int    dma_length;
477 };
478 
479 struct sg_table {
480         struct scatterlist *sgl;        /* the list */
481         unsigned int nents;             /* number of mapped entries */
482         unsigned int orig_nents;        /* original size of list */
483         struct scatterlist dummy[1];
484 };
485 
486 struct va_format {
487 	const char *fmt;
488 	va_list *va;
489 };
490 
491 struct old_timespec32 {
492 	int32_t tv_sec;
493 	int32_t tv_nsec;
494 };
495 
496 struct old_timeval32 {
497 	int32_t tv_sec;
498 	int32_t tv_usec;
499 };
500 
501 #endif					/* _LINUX_STRUCT_H_ */
502