-
Notifications
You must be signed in to change notification settings - Fork 43
linux 驱动开发小结
cheyiliu edited this page Sep 22, 2014
·
2 revisions
驱动在注册设备时,关联file_ops结构体(有wirte, read, seek, release, ioctl)
当用户程序调用write/read/ioctl时,内核会最终调用file_ops结构里的函数(write read ioctl均是系统调用 http://www.ibm.com/developerworks/cn/linux/kernel/syscall/part1/appendix.html)
使用内核提供的专用函数,完成数据在应用程序空间和驱动程序空间的交换
unsigned long copy_to_user(void __user *to,
const void *from, unsigned long n);
unsigned long copy_from_user(void *to, const
void __user *from, unsigned long n);
put_user(local,user);
get_user(local,user);
int register_chrdev_region(dev_t from, unsigned count, const char *name); void unregister_chrdev_region(dev_t from, unsigned count);
cdev_add cdev_del
Just build something.