码迷,mamicode.com
首页 > 系统相关 > 详细

linux设备驱动程序

时间:2020-02-11 11:56:41      阅读:98      评论:0      收藏:0      [点我收藏+]

标签:size_t   程序加载   context   ase   spi   text   bool   struct   port   

LDD:linux device driver ,在操作系统作用下,应用程序必须要通过设备驱动程序操作设备

驱动程序:应用程序和设备之间必须通过驱动程序

应用程序 ——> write(ioctl)驱动程序——>(write)设备

应用程序 <——read(ioctl)驱动程序——>(read)设备

LDD程序结构:

LDD程序加载方式:

LDD程序测试:

文件操作结构体在/lib/modules/5.5.2-1-MANJARO/build/include/linux/fs.h中的定义为:

 1 struct file_operations {
 2     struct module *owner;
 3     loff_t (*llseek) (struct file *, loff_t, int);
 4     ssize_t (*read) (struct file *, char __user *, size_t, loff_t *);
 5     ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *);
 6     ssize_t (*read_iter) (struct kiocb *, struct iov_iter *);
 7     ssize_t (*write_iter) (struct kiocb *, struct iov_iter *);
 8     int (*iopoll)(struct kiocb *kiocb, bool spin);
 9     int (*iterate) (struct file *, struct dir_context *);
10     int (*iterate_shared) (struct file *, struct dir_context *);
11     __poll_t (*poll) (struct file *, struct poll_table_struct *);
12     long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
13     long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
14     int (*mmap) (struct file *, struct vm_area_struct *);
15     unsigned long mmap_supported_flags;
16     int (*open) (struct inode *, struct file *);
17     int (*flush) (struct file *, fl_owner_t id);
18     int (*release) (struct inode *, struct file *);
19     int (*fsync) (struct file *, loff_t, loff_t, int datasync);
20     int (*fasync) (int, struct file *, int);
21     int (*lock) (struct file *, int, struct file_lock *);
22     ssize_t (*sendpage) (struct file *, struct page *, int, size_t, loff_t *, int);
23     unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
24     int (*check_flags)(int);
25     int (*setfl)(struct file *, unsigned long);
26     int (*flock) (struct file *, int, struct file_lock *);
27     ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, loff_t *, size_t, unsigned int);
28     ssize_t (*splice_read)(struct file *, loff_t *, struct pipe_inode_info *, size_t, unsigned int);
29     int (*setlease)(struct file *, long, struct file_lock **, void **);
30     long (*fallocate)(struct file *file, int mode, loff_t offset,
31               loff_t len);
32     void (*show_fdinfo)(struct seq_file *m, struct file *f);
33 #ifndef CONFIG_MMU
34     unsigned (*mmap_capabilities)(struct file *);
35 #endif
36     ssize_t (*copy_file_range)(struct file *, loff_t, struct file *,
37             loff_t, size_t, unsigned int);
38     loff_t (*remap_file_range)(struct file *file_in, loff_t pos_in,
39                    struct file *file_out, loff_t pos_out,
40                    loff_t len, unsigned int remap_flags);
41     int (*fadvise)(struct file *, loff_t, loff_t, int);
42 } __randomize_layout;

 

linux设备驱动程序

标签:size_t   程序加载   context   ase   spi   text   bool   struct   port   

原文地址:https://www.cnblogs.com/guochaoxxl/p/12294203.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!