Your Ad Here
首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 操作系统 > Linux > Device Driver Functions Reference
【标  题】:Device Driver Functions Reference
【关键字】:Device,Driver,Functions,Reference
【来  源】:http://www.cublog.cn/u/16358/showart.php?id=175151

Device Driver Functions Reference

Your Ad Here
Device Driver Functions Reference
 
#include<linux/fs.h>
 The "file system" header is the header required for writing device drivers.All the important functions are declared in here.
 
int register_chrdev(unsigned int major,const char *name,struct file_operations *fops);
 Register a character device driver.If the major number is not 0, it is used unchanged;if the number is 0, then a dynamic number is assigned for this device.
 
int unregister_chrdev(unsigned int major,const char *name);
 Unregisters the driver at unload time.Both major and the name string must contain the same values that were used to register the driver.
 
kdev_t inode->i_rdev;
 The device "number" for the current device is accessible from the inode struct.
 
int MAJOR(kdev_t dev);
int MINOR(kdev_t dev);
 These macros extract the major and minor numbers from a device item.
 
kdev_t MKDEV(int major,int minor);
 This macro builds a kdev_t data item from the major and minor numbers.
 
SET_MUDULE_OWNER(struct file_operations *fops)
 This macro sets the owner field in the given file_operations structure.
 
#include<asm/semaphore.h>
 Defines functions and types for the ues of semaphores.
 
void sema_init(struct semaphore *sem,int val);
 Initializes a semaphore to a known value.Mutual exclusion semaphores are usually initialized to a value of 1.
 
int down_interruptible(struct semaphore *sem);
void up(struct semaphore *sem);
 Obtains a semaphore (sleeping,if necessary) and releases it, respectively.
 
#include<asm/segment.h>
#include<asm/uaccess.h>
 segment.h defines functions related to cross-space copying in all kernels up to and including 2.0.The name was changed to uaccess.h in the 2.1 development series.
 
unsigned long _ _copy_from_user (void *to,const void *from, unsigned long count);
unsigned long _ _copy_to_user(void *to,const void *from,unsigned long count);
 Copy data between user space and kernel space.
 
void memcpy_fromfs(void *to,const void *from,unsigned long count);
void memcpy_tofs(void *to,const void *from,unsigned long count);
 These functions were used to copy an array of bytes from user space to kernel space and vice versa in version 2.0 of the kernel.
 
#include<linux/devfs_fs_kernel.h>
devfs_handle_t devfs_mk_dir(devfs_handle_t dir, const char *name,void *info);
devfs_handle_t devfs_register(devfs_handle_t dir, const char *name,unsigned int flags, unsigned int major, unsigned int minor, umode_t mode, void *ops, void *info);
void devfs_unregister(devfs_handle_t de);
 These are the basic functions for registering devices with the device filesystem(devfs);
 
 
[转]Linux日志管理详解:【上一篇】
[转]Linux下修改系统时间:【下一篇】
【相关文章】
  • Linux Device Driver Reference
  • Linux Device Drivers: Building and Running Modules
  • Linux Device Drivers: An Intro to Device Drivers
  • Linux Device Drivers: Char Drivers
  • Linux Device Drivers: Debugging Techniques
  • Linux Device Drivers: Enhanced Char Driver Op
  • Linux Device Drivers: Flow of Time
  • Linux Device Drivers: Getting Hold of Memory
  • Linux Device Drivers: Hardware Management
  • Linux Device Drivers: Interrupt Handling
  • 【随机文章】
  • MIME之Base64编解码 选择自 bhw98 的 Blog
  • 开发自己的SQL2005报表查看SharePoint WebPart(一)
  • 章立民老师力作出版1个半月5000册售罄重印,微软亚洲研究院专家高度评价!
  • freebsd安装JAVA的最简单方法
  • Delphi中的线程类 三
  • 为茶进化
  • C++字符串完全指引之一 —— Win32 字符编码
  • FreeHand 创建空心封套(1)
  • netscreen恢复默认方法
  • 【翻译】Managed DirectX(第八章)
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 bbb软讯网络 All Rigths Reserved.