Driver file: qudong. c. make generates qudong. ko file, burned to the ARM Board <linux/module. h> <linux/kernel. h> <linux/poll. h> <linux/errno. h> DEV_NAME "rwtest" major = MAX_BUF_LEN = drv_buf [WRI_LENGTH = ssize_t dx_write (file * file, _ user * buffer, size_t count, loff_t * (count> MAX_BUF_LEN) count = ssize_t dx_read (file * filp, _ user * buffer, size_t count, loff_t * I =, j = (count> = (I = strlen (drv_buf ); i>; I -- = drv_buf [I-++ printk (dx_open (inode * inode, file * dx_release (inode * inode, file * file_operations file_opt = _ init qudong_init (= register_chrdev (, DEV_NAME, & (ret <= _ exit qudong_exit ();View Code
Makefile file:
-M: ==$ (shell uname-=-C/lib/modules/$ (UNAME)/build SUBDIRS =-f *-f. *-View Code
Or Makefile in ARM:
-M: =/usr/src/linux2.-C $ (KDIR) M = $ (PWD) modules ARCH = arm CROSS_COMPILE = arm-linux -- f *. ko *. o *. mod. o *. mod. c *. symvers modul *View Code
The test procedure is as follows:
<Stdlib. h> <fcntl. h> <unistd. h> <sys/ioctl. h> <. h> fd = ret = bufw [] = {bufr [] = {= open (fd <= (ret <= read (fd, bufr, (ret <View Code