Fork Me on GitHub

源码开放学ARM

LASO - Learn ARM with Source Open

首页         目录索引         资料下载         代码下载         联系作者        
下载PDF打印版本

参考速查

头文件和函数

#include <linux/kernel.h>	// printk()
#include <linux/module.h>	// module_init()
#include <asm/io.h>			// ioremap()
#include <linux/fs.h>		// register_chrdev()
#include <linux/cdev.h>		// cdev()
#include <linux/interrupt.h>		// request_irq()/free_irq()
#include <linux/wait.h>		// wait_event/wake_up()

fs/char_dev.c		cdev_init() 

#include <asm/uaccess.h>		// copy_to_user()

关联操作汇总

open	close
read	write

init	exit

module_init()
module_exit()

led_init()
led_exit()

printf()	- user
printk()	- kernel

mmap()		- user
ioremap()	- kernel

register_chrdev()
unregister_chrdev()

open()
release()

request_irq()
free_irq()

// wait queue
wait_queue_head_t wq;
init_waitqueue_head(&wq);
wait_event()/wait_event_interruptible()
wake_up()/wake_up_interruptible()

驱动的几种模型

		user space			kernel space
-------------------------------------------------------------
"hello"		printf				printk
		<stdio.h>			<linux/kernel.h>

-------------------------------------------------------------
ledon/off	1.				1.
		open("/dev/leds");		cdev
		ioctl(fd, No, on);		f_ops

		2.				2.
		open("/dev/mem");		ioremap(addr, size);
		mmap(GPXDAT, fd);		<asm/io.h>
blog comments powered by Disqus