使用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,如需转载请自行联系原作者





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值