Linux kernel & device driver programming

Cross-Referenced Linux and Device Driver Code

[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ]
Version: [ 2.6.11.8 ] [ 2.6.25 ] [ 2.6.25.8 ] [ 2.6.31.13 ] Architecture: [ i386 ]
  1 /* -*- C -*-
  2  * sculld.h -- definitions for the sculld 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 #include <linux/device.h>
 19 #include "../include/lddbus.h"
 20 
 21 /*
 22  * Macros to help debugging
 23  */
 24 
 25 #undef PDEBUG             /* undef it, just in case */
 26 #ifdef SCULLD_DEBUG
 27 #  ifdef __KERNEL__
 28      /* This one if debugging is on, and kernel space */
 29 #    define PDEBUG(fmt, args...) printk( KERN_DEBUG "sculld: " fmt, ## args)
 30 #  else
 31      /* This one for user space */
 32 #    define PDEBUG(fmt, args...) fprintf(stderr, fmt, ## args)
 33 #  endif
 34 #else
 35 #  define PDEBUG(fmt, args...) /* not debugging: nothing */
 36 #endif
 37 
 38 #undef PDEBUGG
 39 #define PDEBUGG(fmt, args...) /* nothing: it's a placeholder */
 40 
 41 #define SCULLD_MAJOR 0   /* dynamic major by default */
 42 
 43 #define SCULLD_DEVS 4    /* sculld0 through sculld3 */
 44 
 45 /*
 46  * The bare device is a variable-length region of memory.
 47  * Use a linked list of indirect blocks.
 48  *
 49  * "sculld_dev->data" points to an array of pointers, each
 50  * pointer refers to a memory page.
 51  *
 52  * The array (quantum-set) is SCULLD_QSET long.
 53  */
 54 #define SCULLD_ORDER    0 /* one page at a time */
 55 #define SCULLD_QSET     500
 56 
 57 struct sculld_dev {
 58         void **data;
 59         struct sculld_dev *next;  /* next listitem */
 60         int vmas;                 /* active mappings */
 61         int order;                /* the current allocation order */
 62         int qset;                 /* the current array size */
 63         size_t size;              /* 32-bit will suffice */
 64         struct semaphore sem;     /* Mutual exclusion */
 65         struct cdev cdev;
 66         char devname[20];
 67         struct ldd_device ldev;
 68 };
 69 
 70 extern struct sculld_dev *sculld_devices;
 71 
 72 extern struct file_operations sculld_fops;
 73 
 74 /*
 75  * The different configurable parameters
 76  */
 77 extern int sculld_major;     /* main.c */
 78 extern int sculld_devs;
 79 extern int sculld_order;
 80 extern int sculld_qset;
 81 
 82 /*
 83  * Prototypes for shared functions
 84  */
 85 int sculld_trim(struct sculld_dev *dev);
 86 struct sculld_dev *sculld_follow(struct sculld_dev *dev, int n);
 87 
 88 
 89 #ifdef SCULLD_DEBUG
 90 #  define SCULLD_USE_PROC
 91 #endif
 92 
 93 /*
 94  * Ioctl definitions
 95  */
 96 
 97 /* Use 'K' as magic number */
 98 #define SCULLD_IOC_MAGIC  'K'
 99 
100 #define SCULLD_IOCRESET    _IO(SCULLD_IOC_MAGIC, 0)
101 
102 /*
103  * S means "Set" through a ptr,
104  * T means "Tell" directly
105  * G means "Get" (to a pointed var)
106  * Q means "Query", response is on the return value
107  * X means "eXchange": G and S atomically
108  * H means "sHift": T and Q atomically
109  */
110 #define SCULLD_IOCSORDER   _IOW(SCULLD_IOC_MAGIC,  1, int)
111 #define SCULLD_IOCTORDER   _IO(SCULLD_IOC_MAGIC,   2)
112 #define SCULLD_IOCGORDER   _IOR(SCULLD_IOC_MAGIC,  3, int)
113 #define SCULLD_IOCQORDER   _IO(SCULLD_IOC_MAGIC,   4)
114 #define SCULLD_IOCXORDER   _IOWR(SCULLD_IOC_MAGIC, 5, int)
115 #define SCULLD_IOCHORDER   _IO(SCULLD_IOC_MAGIC,   6)
116 #define SCULLD_IOCSQSET    _IOW(SCULLD_IOC_MAGIC,  7, int)
117 #define SCULLD_IOCTQSET    _IO(SCULLD_IOC_MAGIC,   8)
118 #define SCULLD_IOCGQSET    _IOR(SCULLD_IOC_MAGIC,  9, int)
119 #define SCULLD_IOCQQSET    _IO(SCULLD_IOC_MAGIC,  10)
120 #define SCULLD_IOCXQSET    _IOWR(SCULLD_IOC_MAGIC,11, int)
121 #define SCULLD_IOCHQSET    _IO(SCULLD_IOC_MAGIC,  12)
122 
123 #define SCULLD_IOC_MAXNR 12
124 
125 
126 
127 
  This page was automatically generated by the LXR engine.