添加代码、Kconfig和Makefile

在linux-2.6.31/drivers/char目录下建立子目录:
bhsong@bhsong-laptop:~/develop/svn/ldd6410/linux-2.6.31/drivers/char$ mkdir driver_examples
将三个驱动hello.c、globalmem.c、globalfifo.c拷入driver_examples目录:
cd driver_examples/cp ../../../../training/kernel/drivers/hello/hello.c ./cp ../../../../training/kernel/drivers/globalmem/globalmem.c ./cp ../../../../training/kernel/drivers/globalmem/globalfifo.c ./
修改drivers/char下面的Kconfig和Makefile导入driver_examples目录:
  • 在drivers/char/Kconfig中添加:
source "drivers/char/driver_examples/Kconfig"

添加drivers/char/driver_examples/Kconfig文件:

## driver examples configuration#

menuconfig DRIVER_EXAMPLE    tristate "driver examples in 'Explain Linux Device Drivers in detail'"    ---help---      say Yes to build-in hello world, globalmem, globalfifo, say M to get       those kernel modules

if DRIVER_EXAMPLE

config HELLO_WORLD    tristate "Hello World"    ---help---      To compile this driver as a module, choose M here; the module will be      called hello.mem

config GLOBALMEM    tristate "globalmem"    ---help---      To  compile this driver as a module, choose M here; the module will be      called globalmem.

config GLOBALFIFO    tristate "globalfifo"    ---help---      To  compile this driver as a module, choose M here; the module will be      called globalfifo.

endif # DRIVER_EXAMPLE
这将形成如下菜单:
 driver examples in 'Explain Linux Device Drivers in detail' ─────────────────────────────┐  │  Arrow keys navigate the menu.  <Enter> selects submenus --->.  Highlighted letters are hotkeys.  Pressing <Y>        │    │  includes, <N> excludes, <M> modularizes features.  Press <Esc><Esc> to exit, <?> for Help, </> for Search.  Legend:  │    │  [*] built-in  [ ] excluded  <M> module  < > module capable                                                           │    │                                                                                                                       │    │ ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │    │ │                      --- driver examples in 'Explain Linux Device Drivers in detail'                              │ │    │ │                      < >   Hello World (NEW)                                                                      │ │    │ │                      < >   globalmem (NEW)                                                                        │ │    │ │                      < >   globalfifo (NEW)                                                                       │ │    │ │                                                                                                                   │ │    │ │                                                                                                                   │ │    │ │                                                        
  • 在drivers/char/Makefile中添加:
obj-$(CONFIG_DRIVER_EXAMPLE)        += driver_examples/

添加drivers/char/driver_examples/Makefile文件:

obj-$(CONFIG_HELLO_WORLD)       += hello.oobj-$(CONFIG_GLOBALMEM)         += globalmem.oobj-$(CONFIG_GLOBALFIFO)        += globalfifo.o
相关的Kconfig和Makefile patch如下:
Index: drivers/char/Kconfig===================================================================--- drivers/char/Kconfig        (revision 87)+++ drivers/char/Kconfig        (working copy)Index: drivers/char/driver_examples/Makefile===================================================================--- drivers/char/driver_examples/Makefile       (revision 0)+++ drivers/char/driver_examples/Makefile       (revision 0)@@ -0,0 +1,3 @@+obj-$(CONFIG_HELLO_WORLD)              += hello.o+obj-$(CONFIG_GLOBALMEM)                += globalmem.o+obj-$(CONFIG_GLOBALFIFO)               += globalfifo.o@@ -1110,5 +1110,7 @@

 source "drivers/s390/char/Kconfig"

+source "drivers/char/driver_examples/Kconfig"+ endmenu

Index: drivers/char/Makefile===================================================================--- drivers/char/Makefile       (revision 87)+++ drivers/char/Makefile       (working copy)@@ -111,6 +111,8 @@ obj-$(CONFIG_JS_RTC)           += js-rtc.o js-rtc-y = rtc.o

+obj-$(CONFIG_DRIVER_EXAMPLE)           += driver_examples/+ # Files generated that shall be removed upon make clean clean-files := consolemap_deftbl.c defkeymap.c

Index: drivers/char/driver_examples/Kconfig===================================================================--- drivers/char/driver_examples/Kconfig        (revision 0)+++ drivers/char/driver_examples/Kconfig        (revision 0)@@ -0,0 +1,31 @@+#+# driver examples configuration+#++menuconfig DRIVER_EXAMPLE+       tristate "driver examples in 'Explain Linux Device Drivers in detail'"+       ---help---+         say Yes to build-in hello world, globalmem, globalfifo, say M to get+         those kernel modules++if DRIVER_EXAMPLE++config HELLO_WORLD+       tristate "Hello World"+       ---help---+         To compile this driver as a module, choose M here; the module will be+         called hello.++config GLOBALMEM+       tristate "globalmem"+       ---help---+         To  compile this driver as a module, choose M here; the module will be+         called globalmem.++config GLOBALFIFO+       tristate "globalfifo"+       ---help---+         To  compile this driver as a module, choose M here; the module will be+         called globalfifo.++endif # DRIVER_EXAMPLE+Index: drivers/char/Kconfig===================================================================--- drivers/char/Kconfig        (revision 87)+++ drivers/char/Kconfig        (working copy)@@ -1110,5 +1110,7 @@

 source "drivers/s390/char/Kconfig"

+source "drivers/char/driver_examples/Kconfig"+ endmenu

Index: drivers/char/Makefile===================================================================--- drivers/char/Makefile       (revision 87)+++ drivers/char/Makefile       (working copy)@@ -111,6 +111,8 @@ obj-$(CONFIG_JS_RTC)           += js-rtc.o js-rtc-y = rtc.o

+obj-$(CONFIG_DRIVER_EXAMPLE)           += driver_examples/+ # Files generated that shall be removed upon make clean clean-files := consolemap_deftbl.c defkeymap.c

Index: drivers/char/driver_examples/Kconfig===================================================================--- drivers/char/driver_examples/Kconfig        (revision 0)+++ drivers/char/driver_examples/Kconfig        (revision 0)@@ -0,0 +1,31 @@+#+# driver examples configuration+#++menuconfig DRIVER_EXAMPLE+       tristate "driver examples in 'Explain Linux Device Drivers in detail'"+       ---help---+         say Yes to build-in hello world, globalmem, globalfifo, say M to get+         those kernel modules++if DRIVER_EXAMPLE++config HELLO_WORLD+       tristate "Hello World"+       ---help---+         To compile this driver as a module, choose M here; the module will be+         called hello.++config GLOBALMEM+       tristate "globalmem"+       ---help---+         To  compile this driver as a module, choose M here; the module will be+         called globalmem.++config GLOBALFIFO+       tristate "globalfifo"+       ---help---+         To  compile this driver as a module, choose M here; the module will be+         called globalfifo.++endif # DRIVER_EXAMPLEIndex: drivers/char/driver_examples/Makefile===================================================================--- drivers/char/driver_examples/Makefile       (revision 0)+++ drivers/char/driver_examples/Makefile       (revision 0)@@ -0,0 +1,3 @@+obj-$(CONFIG_HELLO_WORLD)              += hello.o+obj-$(CONFIG_GLOBALMEM)                += globalmem.o+obj-$(CONFIG_GLOBALFIFO)               += globalfifo.o

使用skyeye运行《Linux设备驱动开发详解》的实例(一)相关推荐

  1. linux 设备驱动 ppt,linux设备驱动开发详解讲座ppt

    PPT内容 这是linux设备驱动开发详解讲座ppt下载,主要介绍了设备驱动简介:建立和运行模块:字符驱动:调试技术:并发和竞争:分配内存:硬件通讯:中断处理:块设备驱动,欢迎点击下载. 嵌入式Lin ...

  2. 《Linux设备驱动开发详解(第2版)》隆重出版

    Linux设备驱动开发详解(第2版)(前一版狂销3万册,畅销书最新升级) [新品] 点击看大图     基本信息 * 作者: 宋宝华       * 出版社:人民邮电出版社     * ISBN:97 ...

  3. linux设备驱动总结,《Linux设备驱动开发详解(第3版)》海量更新总结

    本博实时更新<Linux设备驱动开发详解(第3版)>的最新进展. 2015.2.26 几乎完成初稿. [F]是修正或升级:[N]是新增知识点:[D]是删除的内容 第1章 <Linux ...

  4. 《Linux设备驱动开发详解(第3版)》(即《Linux设备驱动开发详解:基于最新的Linux 4.0内核》)进展同步更新

    本博实时更新<Linux设备驱动开发详解(第3版)>的最新进展. 目前已经完成稿件. 2015年8月9日,china-pub开始上线预售: http://product.china-pub ...

  5. 《Linux设备驱动开发详解 A》一一2.3 接口与总线

    本节书摘来华章计算机出版社<Linux设备驱动开发详解 A>一书中的第2章,第2.3节,作者:宋宝华 更多章节内容可以访问云栖社区"华章计算机"公众号查看.1 2.3 ...

  6. linux设备驱动开发详解源码,linux设备驱动开发详解光盘源码.rar

    压缩包 : linux设备驱动开发详解光盘源码.rar 列表 19/busybox源代码/busybox-1.2.1.tar.bz2 19/MTD工具/mtd-utils-1.0.0.tar.gz 1 ...

  7. 《Linux设备驱动开发详解》学习笔记一

    Linux设备驱动开发详解学习笔记<一> 书名:<Linux设备驱动开发详解>第二版 主机环境:Linux version 2.6.25-14.fc9.i686@Fedora ...

  8. 《Linux 设备驱动开发详解(第2版)》——1.4 Linux设备驱动

    本节书摘来自异步社区<Linux 设备驱动开发详解(第2版)>一书中的第1章,第1.1节,作者:宋宝华著,更多章节内容可以访问云栖社区"异步社区"公众号查看 1.4 L ...

  9. Linux设备驱动开发详解 第3版 (即 Linux设备驱动开发详解 基于最新的Linux 4 0内核 )前言

    Linux从未停歇脚步.Linus Torvalds,世界上最伟大的程序员之一,Linux内核的创始人,Git的缔造者,仍然在没日没夜的合并补丁,升级内核.做技术,从来没有终南捷径,拼的就是坐冷板凳的 ...

  10. 《linux设备驱动开发详解》笔记——15 linux i2c驱动

    <linux设备驱动开发详解>笔记--15 linux i2c驱动 15.1 总体结构 如下图,i2c驱动分为如下几个重要模块 核心层core,完成i2c总线.设备.驱动模型,对用户提供s ...

最新文章

  1. 用了这么久 IDEA,你竟然不知道有个功能叫自动补全!
  2. Python 开源项目大集合,跨 15 个领域,181 个项目
  3. 面试题编程题06-python 输入一个字符串,反转输出
  4. 第一次使用HP-UX时用到的命令
  5. 年薪50万美金的工程师到底牛在哪里?
  6. 【Python1】双系统安装,深度学习环境搭建,目标检测(Tensorflow_API_SSD)
  7. CSS基础(part7)--字体样式属性
  8. 一步步编写操作系统 5 配置bochs
  9. Python中列表的del,remove和pop函数之间的区别
  10. VIIRS SDR数据预处理(二)
  11. 支持bt,种子,torrent的离线下载网页版工具!
  12. 演示面阵激光雷达的工作原理
  13. 根据url 在ensembl 网站爬取外显子等数据
  14. 2017最新qq第三方登陆教程
  15. 室内定位算法_【好设计论文】基于行人航迹推算的室内定位算法研究
  16. 【JS】json导出到excel,自定义文件名和后缀名
  17. 豆芽的生长过程观察日记
  18. 万能遥控器小制作(二)
  19. 21款超赞的手写英文字体,总有一款适合你
  20. 熄灯一小时就是环保?能用体温发电的薄膜了解一下?

热门文章

  1. [JS基础] 之类型判断
  2. 点号“·”的显示 替代 ul li 的功能
  3. antd权限管理_Ant Design Pro开发后台管理系统(权限)-阿里云开发者社区
  4. c++函数不允许递归_面试算法题:不会递归函数被面试官刷了下来!
  5. linux设备驱动 注册 命令6,Linux设备驱动程序学习----6.模块的参数
  6. 分布式事务框架-TX-LCN
  7. Spring Boot整合Swagger3
  8. Logback MDC
  9. cocos2d 嵌入网页_在 cocos2d-x 中嵌入浏览器
  10. java回收内存_JAVA之内存回收