添加驱动程序到内核Linux 2.6内核的配置系统由以下3个部分组成:
在Linux内核中增加程序需要完成以下3项工作。
添加BEEP驱动程序到内核:
方法一:在linux-2.6.32.2/drivers/char/下直接添加beep_drv.c源程序
添加BEEP设备的内核配置选项,打开drivers/char/Kconfig文件,添加如下红色条目内容:
config BEEP_MINI2440
tristate “BEEP Driver Support for Mini2440 BEEP Test"
depends on MACH _MINI2440
default y if MACH_MINI2440
help
This option enables support for BEEP connected to GPIO lines on Mini2440 boards
configMINI2440_ADC
bool "ADC driver for FriendlyARMMini2440 development boards" depends on MACH_MINI2440
default y if MACH_MINI2440
help
this is ADC driver for Friendly ARM Mini2440 development boards
Notes: the touch-screen-driver required this option
根据该驱动的配置定义,把对应的驱动目标文件加入内核中,打开linux-2.6.32.2/drivers/char/Makefile文件,添加如下红色部分内容:
obj-$(CONFIG_LEDS _ MINI2440) += mini2440_leds.o
obj-$(CONFIG_MINI2440_ADC) += mini2440_adc.o
obj-$(CONFIG_BEEP_MINI2440) += beep_drv.o
在内核linux-2.6.32.2/drivers/char目录下,新建BEEP驱动文件beep_drv.c
方法二:在linux-2.6.32.2/drivers/char/下添加beep驱动目录
实例:在内核源代码drivers/char/目录下新增BEEP驱动BEEP driver的树形目录:
步骤:1、在drivers/char/路径下新建beep目录
2、在beep目录下添加beep_drv.c文件
3、在beep目录下创建Kconfig和Makefile
4、修改新增目录父目录的Kconfig和Makefile,以便新增的Kconfig和Makefile能够被引用
步骤:1、在drivers/char路径下新建beep目录
2、添加beep_drv.c驱动源文件
3、为新增目录创建Kconfig和Makefile
config BEEP_MINI2440
tristate“BEEP Driver Support for Mini2440 BEEP Test"
depends on MACH_MINI2440
default y if MACH_MINI2440
help
This option enables support for BEEP connected to GPIO lines on Mini2440 boards.
4、为新增目录创建Makefile
obj-$(CONFIG_BEEP_MINI2440) += beep_drv.o
修改新增目录的父目录的Kconfig和Makefile在drivers/char/Kconfig中加入:source “drivers/char/beep/Kconfig”
source “drivers/char/beep/Kconfig”
在drivers/char/Makefile中加入:obj-$(CONFIG_BEEP_MINI2440) += beep/
obj-$(CONFIG_LEDS_MINI2440) += mini2440_leds.o
obj-$(CONFIG_MINI2440_ADC) += mini2440_adc.o
obj-$(CONFIG_BEEP_MINI2440) += beep/
原文链接不详,侵删