linux 设备驱动之IOCTRL
...
long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
...
};
2bits(读写区)_IOC_DIRBITS | 14bits(数据大小区)_IOC_SIZEBITS | 8bits(Magic)_IOC_TYPEBITS | 8bits(命令序号)_IOC_NRBITS |
ioctl(device_fd, REMOTE_IOC_SET_REPEAT_KEY_MAPPING, &val);
{
void __user *argp = (void __user *)args;
ret = copy_from_user(&val, argp, sizeof(unsigned long));
remote->key_repeat_map[remote->map_num][val >> 16] = val & 0xffff;
break;
#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),(_IOC_TYPECHECK(size)))
#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size)))
#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size)))
#define _IOR_BAD(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size))
#define _IOW_BAD(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size))
#define _IOWR_BAD(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size))
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。