⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 linux-mdep.h

📁 7号信令功能代码,为开源代码
💻 H
📖 第 1 页 / 共 2 页
字号:
extern int lis_fdetach(const char *);/* *  syscall interfaces */extern asmlinkage int lis_sys_fattach(int, const char *);extern asmlinkage int lis_sys_fdetach(const char *);/* *  ioctl interfaces */extern int lis_ioc_fattach(struct file *, char *);extern int lis_ioc_fdetach(char *);/* * Kernel loadable module support */#ifdef CONFIG_KERNELD#define LIS_LOADABLE_SUPPORT 1#endif/* lis_loadable_load - load a loadable module. * * Routine is always present but returns error if the kernel is not * built for dynamic loading of modules from within the kernel. */int lis_loadable_load(const char *name);/* * Process kill */extern int	lis_kill_proc(int pid, int sig, int priv) ;extern int	lis_kill_pg (int pgrp, int sig, int priv) ;/* Use Linux system macros for MAJOR and MINOR */#if defined(KERNEL_2_5)#define	STR_MAJOR		MAJOR		/* for dev_t */#define	STR_MINOR		MINOR		/* for dev_t */#define	STR_KMAJOR		major		/* for kdev struct */#define	STR_KMINOR		minor		/* for kdev struct */#else			/* not KERNEL_2_5 */#define	STR_MAJOR		MAJOR		/* for dev_t */#define	STR_MINOR		MINOR		/* for dev_t */#define	STR_KMAJOR		MAJOR		/* for kdev struct */#define	STR_KMINOR		MINOR		/* for kdev struct */#endif			/* KERNEL_2_5 *//* * Kernel threads * * This function can be used to start a kernel thread.  Any driver can use * this function. * * 'fcn' is the function that serves as the entry point for the thread. * * 'arg' is the argument passed to that function. * * 'name' is the name to give to the function.  Keep it under 16 bytes. * * lis_thread_start returns the pid of the new process, or < 0 if an error * occurred. * * Before the 'fcn' is entered, the newly created thread will have shed all * user space files and mapped memory.  All signals are still enabled.  Note * that when the kernel goes down for reboot all processes are first sent a * SIGTERM.  Once those have been processed, all processes are then sent a * SIGKILL.  It is the implementor's choice which of these it pays attention to * in order to exit prior to a reboot.  The LiS queue runner ignores SIGTERM so * that it can be in place to help close streams files.  It then exits on * SIGKILL.  Other processes may behave differently. * * The 'fcn' is entered with the "big kernel lock" NOT held, just as it would * be for calling the "kernel_thread" function directly.  On 2.2 kernels, the * 'fcn' should get this lock so that it can utilize kernel services safely. * * The user's function returns a value when it exits and that value is returned * to the kernel.  It is not clear that anything actually pays any attention to * this returned value.  It particular, it is not visible to the thread that * started the new thread. */pid_t   lis_thread_start(int (*fcn)(void *), void *arg, const char *name) ;int	lis_thread_stop(pid_t pid) ;#else				/* __KERNEL__ *//* * For user programs, provide a substitute for the lis_atomic_t that * is the same size, and hopefully numerical layout, as the kernel's * type.  This allows uer programs to view data structures that have * lis_atomic_t data in them. */typedef	volatile long		lis_atomic_t ;#define	lis_atomic_set(atomic_addr,valu) (*(atomic_addr) = (valu))#define	lis_atomic_read(atomic_addr) 	 (*(atomic_addr))#define	lis_atomic_add(atomic_addr,amt)  (*(atomic_addr) += (amt))#define	lis_atomic_sub(atomic_addr,amt)  (*(atomic_addr) -= (amt))#define	lis_atomic_inc(atomic_addr) 	 ((*(atomic_addr))++)#define	lis_atomic_dec(atomic_addr) 	 ((*(atomic_addr))--)#define	lis_atomic_dec_and_test(atomic_addr) ((*(atomic_addr))--)#endif				/* __KERNEL__ *//*************************************************************************                            major/minor                                ***************************************************************************									** Macros to extract the major and minor device numbers from a dev_t	** variable.								**									*************************************************************************//* * Major and minor macros come from linux ./include/linux/kdev_t.h * * If sysmacros.h has been included it defines major and minor in * the old way.  We want the new way so we undefine them and redefine * them to use the kdev_t style. */#if defined(KERNEL_2_5)/* * Use major and minor from kdev_t.h. * * dev_t is an integer.  kdev_t is a structure.  Someday the kernel will * have 20 bit minor device numbers in kdev structures.  For now the * dev_t is still 8:8.  LiS uses dev_t almost everywhere.  The Linux * inode structure i_rdev is a kdev_t. * * This topic will probably have to be revisited later. * * The mk_dev function returns a kdev_t value. */#define makedevice(majornum,minornum)	mk_kdev(majornum,minornum)#define DEV_SAME(d1,d2)	((d1) == (d2))#define DEV_TO_INT(dev) ((int)(dev))#define KDEV_TO_INT(kdev)	kdev_val(kdev)#define INT_TO_KDEV(dev)	val_to_kdev((unsigned int)(dev))#else			/* not KERNEL_2_5 */#ifdef major#undef major#endif#ifdef minor#undef minor#endif#ifdef makedevice#undef makedevice#endif#ifndef _SYS_SYSMACROS_H#define _SYS_SYSMACROS_H		/* pretend sysmacros.h included */#endif#define	major(dev_t_var)	MAJOR(dev_t_var)#define	minor(dev_t_var)	MINOR(dev_t_var)#define makedevice(majornum,minornum)	MKDEV(majornum,minornum)#define DEV_SAME(d1,d2)	((d1) == (d2))#define DEV_TO_INT(dev) ((int)(dev))#define KDEV_TO_INT(kdev)	((int)(kdev))#define INT_TO_KDEV(dev)	((dev_t)(dev))#endif			/* KERNEL_2_5 */typedef unsigned long	major_t ;	/* mimics SVR4 */typedef unsigned long	minor_t ;	/* mimics SVR4 */#define	LIS_FIFO  FIFO__CMAJOR_0#define LIS_CLONE CLONE__CMAJOR_0#ifdef __KERNEL__#ifndef VOID#define VOID	void#endif#define UID(fp)	  current->uid#define GID(fp)	  current->gid#define EUID(fp)  current->euid#define EGID(fp)  current->egid#define PGRP(fp)  current->pgrp#define PID(fp)	  current->pid#define OPENFILES()     current->files->count#define SESSION()       current->session#define DBLK_ALLOC(n,f,l,g)	lis_malloc(n,GFP_ATOMIC | (g),1,f,l)#define ALLOC(n)		lis_malloc(n,GFP_ATOMIC,0,__FILE__,__LINE__)#define ZALLOC(n)		lis_zmalloc(n,GFP_ATOMIC,__FILE__,__LINE__)#define ALLOCF(n,f)		lis_malloc(n,GFP_ATOMIC,0, f __FILE__,__LINE__)#define ALLOCF_CACHE(n,f)	lis_malloc(n,GFP_ATOMIC,1, f __FILE__,__LINE__)#define MALLOC(n)		lis_malloc(n,GFP_ATOMIC,0,__FILE__,__LINE__)#define LISALLOC(n,f,l)		lis_malloc(n,GFP_ATOMIC,0,f,l)#define FREE(p)			lis_free(p,__FILE__,__LINE__)#define MEMCPY(dest, src, len)	memcpy(dest, src, len)#define PANIC(msg)		panic(msg)#if (defined(LINUX) && defined(USE_LINUX_KMEM_CACHE))#define	LIS_QBAND_FREE(p)	kmem_cache_free(lis_qband_cachep, (p));#define	LIS_QUEUE_FREE(p)	kmem_cache_free(lis_queue_cachep, (p));#define	LIS_QUEUE_ALLOC(nb,s)	kmem_cache_alloc(lis_queue_cachep,GFP_ATOMIC);#define LIS_QBAND_ALLOC(nb,s)	kmem_cache_alloc(lis_qband_cachep,GFP_ATOMIC);#else#define	LIS_QBAND_FREE		FREE#define	LIS_QUEUE_FREE		FREE#define	LIS_QUEUE_ALLOC(nb,s)	ALLOCF_CACHE(nb,s)#define LIS_QBAND_ALLOC(nb,s)	ALLOCF(nb,s)#endif/* * These are used only internally */#define	KALLOC(n,cls,cache)	lis__kmalloc(n,cls,cache)	/* lismem.c */#define	KFREE(p)		lis__kfree(p)			/* lismem.c */extern struct stdata	*lis_fd2str(int fd) ;	/* file descr -> stream */extern void *lis__kmalloc(int nbytes, int class, int use_cache) ;extern void *lis__kfree(void *ptr) ;#endif				/* __KERNEL__ *//*  -------------------------------------------------------------------  *//* This should be entry points from the kernel into LiS * kernel should be fixed to call them when appropriate. *//* some kernel memory has been free'd  * tell STREAMS */#ifdef __KERNEL__extern voidlis_memfree( void );/* Get avail kernel memory size */#define lis_kmemavail()	((unsigned long)-1) /* lots of mem avail :) */#endif				/* __KERNEL__ *//*  -------------------------------------------------------------------  *//* This will copyin usr string pointed by ustr and return the result  in * *kstr. It will stop at  '\0' or max bytes copyed in. * caller should call free_page(*kstr) on success. * Will return 0 or errno */#ifdef __KERNEL__extern int lis_copyin_str(struct file *fp, const char *ustr, char **kstr, int max);int     lis_copyin(struct file *fp, void *kbuf, const void *ubuf, int len);int     lis_copyout(struct file *fp, const void *kbuf, void *ubuf, int len);int	lis_check_umem(struct file *fp, int rd_wr_fcn,	                   const void *usr_addr, int lgth) ;#endif				/* __KERNEL__ *//*  -------------------------------------------------------------------  *//* * The routine 'lis_runqueues' just requests that the queues be run * at a later time.  A daemon process runs the queus with the help * of a special driver.  This driver has the routine lis_setqsched * in it.  See drivers/str/runq.c. */#ifdef __KERNEL__extern void	lis_setqsched(int can_call) ;extern lis_atomic_t	lis_in_syscall ;extern lis_atomic_t	lis_runq_req_cnt ;#define	lis_runqueues()		do {					      \    				     if (lis_atomic_read(&lis_runq_req_cnt))  \					lis_setqsched(1);		      \				   } while(0)#endif				/* __KERNEL__ *//*  -------------------------------------------------------------------  *//* * Macros for locking and unlocking a queue structure. */#define lis_lockqf(qp,f,l) do { 					\				 lis_spin_lock_fcn(&(qp)->q_lock,f,l);	\			      } while(0)#define lis_lockq(qp)	lis_lockqf(qp,__FILE__,__LINE__)#define lis_unlockqf(qp,f,l) do { 					     \				     lis_spin_unlock_fcn(&(qp)->q_lock,f,l); \			        } while(0)#define lis_unlockq(qp)	lis_unlockqf(qp,__FILE__,__LINE__)/*  -------------------------------------------------------------------  *//* * The routine 'lis_select' handles select calls from the Linux kernel. * The structure 'lis_select_t' is embedded in the stdata structure * and contains the wait queue head. */#ifdef __KERNEL__#ifdef KERNEL_2_0typedef struct lis_select_struct{    struct wait_queue	*sel_wait ;} lis_select_t ;extern int	lis_select(struct inode *inode, struct file *file,			   int sel_type, select_table *wait) ;extern void	lis_select_wakeup(struct stdata *hd) ;#elif defined(KERNEL_2_1)extern unsigned	lis_poll_2_1(struct file *fp, poll_table * wait);#else#error "Either KERNEL_2_0 or KERNEL_2_1 needs to be defined"#endif/* * bzero and bcopy */#define	bzero(addr,nbytes)	memset(addr, 0, nbytes)#define	bcopy(src,dst,n)	memcpy(dst,src,n)/*  -------------------------------------------------------------------  *//* * These routines protect us from being unloaded while we have files open */extern void    lis_inc_mod_cnt_fcn(const char *file, int line) ;extern void    lis_dec_mod_cnt_fcn(const char *file, int line) ;#define lis_inc_mod_cnt()	lis_inc_mod_cnt_fcn(__LIS_FILE__,__LINE__)#define lis_dec_mod_cnt()	lis_dec_mod_cnt_fcn(__LIS_FILE__,__LINE__)#endif				/* __KERNEL__ *//*  -------------------------------------------------------------------  *//* * These are externs for functions defined in the liskmod.c module. * * If the kernel is of an advanced enough version then these are * unnecessary since they will be inlines in a .h file or at least * there will be a standard extern for them in a kernel .h. * * When these externs are enabled the the liskmod module must be * loaded prior to streams.o in order for these symbols to be * resolved. */#ifdef __KERNEL__# if (   LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)	\      && LINUX_VERSION_CODE <  KERNEL_VERSION(2,2,18))	\  ||							\     (   LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)	\      && LINUX_VERSION_CODE <  KERNEL_VERSION(2,4,1))extern void	put_unused_fd(unsigned int fd) ;# endif/* * The following version testing is only approximately correct. * I know that 2.2.5 does not have "igrab" and that 2.2.14 * does. */# if (   LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)	\      && LINUX_VERSION_CODE <  KERNEL_VERSION(2,2,14))	\extern struct inode *igrab(struct inode *inode) ;# endif/* * For convenience, define FATTACH_VIA_MOUNT if appropriate */#if defined(KERNEL_2_4_7)#define FATTACH_VIA_MOUNT 1#endif#endif				/* __KERNEL__ */#ifdef __KERNEL__#if defined(USE_LINUX_KMEM_CACHE)#if defined(CONFIG_DEV)#define allochdr(a,b) lis_kmem_cache_allochdr()#else#define allochdr() lis_kmem_cache_allochdr()#endif#define lis_terminate_msg() kmem_cache_destroy(lis_msgb_cachep);#define freehdr(a) lis_msgb_cache_freehdr((a))extern kmem_cache_t *lis_msgb_cachep;extern kmem_cache_t *lis_queue_cachep;extern kmem_cache_t *lis_qband_cachep;extern struct mdbblock *lis_kmem_cache_allochdr(void);extern void lis_msgb_cache_freehdr(void *);extern void lis_init_queues(void);extern void lis_terminate_queues(void);#endif#if defined(USE_LINUX_KMEM_TIMER)#define lis_terminate_dki() kmem_cache_destroy(lis_timer_cachep)extern kmem_cache_t *lis_timer_cachep;#endif#endif				/* __KERNEL__ */#endif /*!__LIS_M_DEP_H*//*----------------------------------------------------------------------# Local Variables:      ***# change-log-default-name: "~/src/prj/streams/src/NOTES" ***# End: ***  ----------------------------------------------------------------------*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -