1 /* -*- C -*-
2 * scullp.h -- definitions for the scullp char module
3 *
4 * Copyright (C) 2001 Alessandro Rubini and Jonathan Corbet
5 * Copyright (C) 2001 O'Reilly & Associates
6 *
7 * The source code in this file can be freely used, adapted,
8 * and redistributed in source or binary form, so long as an
9 * acknowledgment appears in derived source files. The citation
10 * should list that the code comes from the book "Linux Device
11 * Drivers" by Alessandro Rubini and Jonathan Corbet, published
12 * by O'Reilly & Associates. No warranty is attached;
13 * we cannot take responsibility for errors or fitness for use.
14 */
15
16 #include <linux/ioctl.h>
17 #include <linux/cdev.h>
18
19 /*
20 * Macros to help debugging
21 */
22
23 #undef PDEBUG /* undef it, just in case */
24 #ifdef SCULLP_DEBUG
25 # ifdef __KERNEL__
26 /* This one if debugging is on, and kernel space */
27 # define PDEBUG(fmt, args...) printk( KERN_DEBUG "scullp: " fmt, ## args)
28 # else
29 /* This one for user space */
30 # define PDEBUG(fmt, args...) fprintf(stderr, fmt, ## args)
31 # endif
32 #else
33 # define PDEBUG(fmt, args...) /* not debugging: nothing */
34 #endif
35
36 #undef PDEBUGG
37 #define PDEBUGG(fmt, args...) /* nothing: it's a placeholder */
38
39 #define SCULLP_MAJOR 0 /* dynamic major by default */
40
41 #define SCULLP_DEVS 4 /* scullp0 through scullp3 */
42
43 /*
44 * The bare device is a variable-length region of memory.
45 * Use a linked list of indirect blocks.
46 *
47 * "scullp_dev->data" points to an array of pointers, each
48 * pointer refers to a memory page.
49 *
50 * The array (quantum-set) is SCULLP_QSET long.
51 */
52 #define SCULLP_ORDER 0 /* one page at a time */
53 #define SCULLP_QSET 500
54
55 struct scullp_dev {
56 void **data;
57 struct scullp_dev *next; /* next listitem */
58 int vmas; /* active mappings */
59 int order; /* the current allocation order */
60 int qset; /* the current array size */
61 size_t size; /* 32-bit will suffice */
62 struct semaphore sem; /* Mutual exclusion */
63 struct cdev cdev;
64 };
65
66 extern struct scullp_dev *scullp_devices;
67
68 extern struct file_operations scullp_fops;
69
70 /*
71 * The different configurable parameters
72 */
73 extern int scullp_major; /* main.c */
74 extern int scullp_devs;
75 extern int scullp_order;
76 extern int scullp_qset;
77
78 /*
79 * Prototypes for shared functions
80 */
81 int scullp_trim(struct scullp_dev *dev);
82 struct scullp_dev *scullp_follow(struct scullp_dev *dev, int n);
83
84
85 #ifdef SCULLP_DEBUG
86 # define SCULLP_USE_PROC
87 #endif
88
89 /*
90 * Ioctl definitions
91 */
92
93 /* Use 'K' as magic number */
94 #define SCULLP_IOC_MAGIC 'K'
95
96 #define SCULLP_IOCRESET _IO(SCULLP_IOC_MAGIC, 0)
97
98 /*
99 * S means "Set" through a ptr,
100 * T means "Tell" directly
101 * G means "Get" (to a pointed var)
102 * Q means "Query", response is on the return value
103 * X means "eXchange": G and S atomically
104 * H means "sHift": T and Q atomically
105 */
106 #define SCULLP_IOCSORDER _IOW(SCULLP_IOC_MAGIC, 1, int)
107 #define SCULLP_IOCTORDER _IO(SCULLP_IOC_MAGIC, 2)
108 #define SCULLP_IOCGORDER _IOR(SCULLP_IOC_MAGIC, 3, int)
109 #define SCULLP_IOCQORDER _IO(SCULLP_IOC_MAGIC, 4)
110 #define SCULLP_IOCXORDER _IOWR(SCULLP_IOC_MAGIC, 5, int)
111 #define SCULLP_IOCHORDER _IO(SCULLP_IOC_MAGIC, 6)
112 #define SCULLP_IOCSQSET _IOW(SCULLP_IOC_MAGIC, 7, int)
113 #define SCULLP_IOCTQSET _IO(SCULLP_IOC_MAGIC, 8)
114 #define SCULLP_IOCGQSET _IOR(SCULLP_IOC_MAGIC, 9, int)
115 #define SCULLP_IOCQQSET _IO(SCULLP_IOC_MAGIC, 10)
116 #define SCULLP_IOCXQSET _IOWR(SCULLP_IOC_MAGIC,11, int)
117 #define SCULLP_IOCHQSET _IO(SCULLP_IOC_MAGIC, 12)
118
119 #define SCULLP_IOC_MAXNR 12
120
121
122
123
|
This page was automatically generated by the
LXR engine.
|