📄 scullv.h
字号:
/* * scullv.h -- definitions for the vmalloc char module * *********/#include <linux/ioctl.h>/* version dependencies have been confined to a separate file */#define VERSION_CODE(vers,rel,seq) ( ((vers)<<16) | ((rel)<<8) | (seq) )#include "sysdep.h"/* * Macros to help debugging */#undef PDEBUG /* undef it, just in case */#ifdef SCULLV_DEBUG# ifdef __KERNEL__ /* This one if debugging is on, and kernel space */# define PDEBUG(fmt, args...) printk( KERN_DEBUG "scullv: " fmt, ## args)# else /* This one for user space */# define PDEBUG(fmt, args...) fprintf(stderr, fmt, ## args)# endif#else# define PDEBUG(fmt, args...) /* not debugging: nothing */#endif#undef PDEBUGG#define PDEBUGG(fmt, args...) /* nothing: it's a placeholder */#define SCULLV_MAJOR 0 /* dynamic major by default */#define SCULLV_DEVS 4 /* scullv0 through scullv3 *//* * The bare device is a variable-length region of memory. * Use a linked list of indirect blocks. * * "ScullV_Dev->data" points to an array of pointers, each * pointer refers to a memory page. * * The array (quantum-set) is SCULLV_QSET long. */#define SCULLV_ORDER 4 /* 16 pages at a time */#define SCULLV_QSET 500typedef struct ScullV_Dev { void **data; struct ScullV_Dev *next; /* next listitem */ int vmas; /* active mappings */ int order; /* the current order */ int qset; /* the current array size */ size_t size; /* 32-bit will suffice */} ScullV_Dev;extern struct ScullV_Dev *scullv_devices;extern struct file_operations scullv_fops;/* * The different configurable parameters */extern int scullv_major; /* main.c */extern int scullv_devs;extern int scullv_order;extern int scullv_qset;/* * Prototypes for shared functions */int scullv_trim(ScullV_Dev *dev);read_write_t scullv_read (struct inode *inode, struct file *filp, char *buf, count_t count);read_write_t scullv_write (struct inode *inode, struct file *filp, const char *buf, count_t count);int scullv_lseek (struct inode *inode, struct file *filp, off_t off, int whence);int scullv_ioctl (struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg);#ifdef SCULLV_DEBUG# if LINUX_VERSION_CODE > VERSION_CODE(1,99,3) /* 1.99.4 exported the needed symbols */# define SCULLV_USE_PROC# endif#endif#ifndef min# define min(a,b) ((a)<(b) ? (a) : (b))#endif/* * Ioctl definitions *//* Use 'K' as magic number */#define SCULLV_IOC_MAGIC 'K'#define SCULLV_IOCRESET _IO(SCULLV_IOC_MAGIC, 0)/* * S means "Set" through a ptr, * T means "Tell" directly * G means "Get" (to a pointed var) * Q means "Query", response is on the return value * X means "eXchange": G and S atomically * H means "sHift": T and Q atomically */#define SCULLV_IOCSORDER _IOW(SCULLV_IOC_MAGIC, 1, scullv_order)#define SCULLV_IOCSQSET _IOW(SCULLV_IOC_MAGIC, 2, scullv_qset)#define SCULLV_IOCTORDER _IO(SCULLV_IOC_MAGIC, 3)#define SCULLV_IOCTQSET _IO(SCULLV_IOC_MAGIC, 4)#define SCULLV_IOCGORDER _IOR(SCULLV_IOC_MAGIC, 5, scullv_order)#define SCULLV_IOCGQSET _IOR(SCULLV_IOC_MAGIC, 6, scullv_qset)#define SCULLV_IOCQORDER _IO(SCULLV_IOC_MAGIC, 7)#define SCULLV_IOCQQSET _IO(SCULLV_IOC_MAGIC, 8)#define SCULLV_IOCXORDER _IOWR(SCULLV_IOC_MAGIC, 9, scullv_order)#define SCULLV_IOCXQSET _IOWR(SCULLV_IOC_MAGIC,10, scullv_qset)#define SCULLV_IOCHORDER _IO(SCULLV_IOC_MAGIC, 11)#define SCULLV_IOCHQSET _IO(SCULLV_IOC_MAGIC, 12)#define SCULLV_IOCHARDRESET _IO(SCULLV_IOC_MAGIC, 13) /* debugging tool */#define SCULLV_IOC_MAXNR 13
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -