linux内核驱动DIY (踏踏实实学内核之2)
上文中提到了kconfig文件修改,
在里面加入了
config EmbedSky_HELLO
tristate "TQ2440/SKY2440 Hello Driver"
depends on ARCH_S3C2440
help
EmbedSky TQ2440/SKY2440 Hello.
这几行代码,表示要编译EmbedSky_HELLO这个驱动进去,我们还要作的工作是
修改同母录下的makefile文件
在makefile里加入了这一行,
obj-$(CONFIG_EmbedSky_HELLO) += EmbedSky_hello.o
然后在内核编译选项里选定,后直接编译内核,或是使用命令#make SUBDIR=drivers/char/ modules,然后编译出驱动模块。
我们来看看驱动模块
*************************************
NAME:EmbedSky_hello.c
COPYRIGHT:www.embedsky.net
*************************************/
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/fs.h>
#include <linux/init.h>
#include <linux/miscdevice.h>
#include <linux/delay.h>
#include <asm/irq.h>
#include <asm/arch/regs-gpio.h>
#include <asm/hardware.h>
MODULE_LICENSE("GPL");
static int __init EmbedSky_hello_init(void) //insmod驱动的时候,系统会自动调用的函数。
{
printk("<1>\n Hello,EmbedSky!\n");
printk("<1>\nThis is first driver program.\n\n");
return 0;
}
static void __exit EmbedSky_hello_exit(void)
{
printk("<1>\n Exit!\n");
printk("<1>\nGoodbye EmbedSky!\n\n");
}
module_init(EmbedSky_hello_init);
module_exit(EmbedSky_hello_exit);
很简短的一段代码,但是似乎只能在内核里打印出几行字,没有跟硬件交互。
GPIO的驱动明天再看。
相关文档:
第3章 Linux基本配置
安装完操作系统后,常常需要做一些基本配置,以满足自己的需求。随着Linux桌面的日趋成熟和人性化,这种所谓的“基本配置”已经越来越少了。本章选择了入门用户最常问到的一些问题,以便读者能够尽快上手。 ......
1. 首先用 db2 list database directory 命令看在系统数据库目录(System Database Directory)中有没有该数据库,如果有,应该在确定该数据库是没有用的数据库之后用 db2 drop database 数据库名将其删除。
2. 如果没有,再用 db2 list database directory on location 看在本地数据库目录(Loc ......
1 程序流程图。
2 sample例子
HI_S32 TDE_DrawGraphicSample()
{
HI_U32 u32Size;
HI_S32 s32Fd;
HI_U32 u32Times;
HI_U8* pu8Screen;
HI_U32 u32PhyAddr;
HI_S32 s32Ret = -1;
  ......