开发者社区> 技术小胖子> 正文

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

简介:
+关注继续查看

添加代码、Kconfig和Makefile

bhsong@bhsong-laptop:~/develop/svn/ldd6410/linux-2.6.31/drivers/char$ mkdir 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 ./
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)                                                                        
 
                                                                                                                   
 
                                                                                                                   
 
                                                       
obj-$(CONFIG_DRIVER_EXAMPLE)        += driver_examples/
添加drivers/char/driver_examples/Makefile文件:
obj-$(CONFIG_HELLO_WORLD)       += hello.o
obj
-$(CONFIG_GLOBALMEM)         += globalmem.o
obj
-$(CONFIG_GLOBALFIFO)        += globalfifo.o
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_EXAMPLE
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




本文转自 21cnbao 51CTO博客,原文链接:http://blog.51cto.com/21cnbao/266975,如需转载请自行联系原作者





版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

相关文章
arm嵌入式Linux系统移植实例过程及问题
arm嵌入式Linux系统移植实例过程及问题
29 0
阿里云国际版创建ESC实例Linux系统
本篇文章www.123clouds带你一起看一下创建阿里云ecs实例Linux系统教程
223 0
阿里云国际版Linux系统的ECS实例内部无法正常解析域名
本文www.123clouds.com介绍阿里云国际版Linux系统的ECS实例内部无法正常解析域名的解决办法。
151 0
阿里云国际版Linux实例中执行wget命令时提示“command not found”
本文www.123clouds.com介绍阿里云国际版Linux实例中执行wget命令时提示“command not found”时该如何解决。
79 0
阿里云国际版Linux实例通过端口转发来访问内网服务
本文www.123clouds.com介绍阿里云国际版Linux实例如何通过端口转发来访问内网服务。
70 0
阿里云国际版Linux系统的ECS实例中通过TestDisk工具进行数据恢复
本文www.123clouds.com介绍阿里云国际版Linux系统的ECS实例中如何使用TestDisk工具进行数据恢复
72 0
阿里云国际创建阿里云ecs实例Linux系统教程
今天123clouds继续教大家创建阿里云ecs实例Linux系统教程,如果需要注册阿里云国际的,可以通过123clouds.com注册,只需要一个邮箱就可以注册了。
38 0
linux系统的日志轮转介绍和yum的轮转实例
linux系统的日志轮转介绍和yum的轮转实例
56 0
Linux:文件及目录权限详解+实例
Linux:文件及目录权限详解+实例
28 0
Linux:时间日期指令(date)+查找指令(find,locate,grep)+压缩和解压指令(gzip,gunzip;zip,unzip;tar)(内含详细解释+操作实例)
Linux:时间日期指令(date)+查找指令(find,locate,grep)+压缩和解压指令(gzip,gunzip;zip,unzip;tar)(内含详细解释+操作实例)
26 0
文章
问答
文章排行榜
最热
最新
相关电子书
更多
Decian GNU/Linux安全合规之路
立即下载
从 Linux 系统内核层面来解决实际问题的实战经验
立即下载
冬季实战营第二期:Linux操作系统实战入门
立即下载