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





相关文章
|
9天前
|
Linux Python
linux上根据运行程序的进程号,查看程序所在的绝对路径。linux查看进程启动的时间
linux上根据运行程序的进程号,查看程序所在的绝对路径。linux查看进程启动的时间
23 2
|
6天前
|
存储 Linux 开发工具
如何进行Linux内核开发【ChatGPT】
如何进行Linux内核开发【ChatGPT】
|
12天前
|
Java Linux API
Linux设备驱动开发详解2
Linux设备驱动开发详解
20 6
|
12天前
|
消息中间件 算法 Unix
Linux设备驱动开发详解1
Linux设备驱动开发详解
20 5
|
7天前
|
Linux
用QEMU模拟运行uboot从SD卡启动Linux
用QEMU模拟运行uboot从SD卡启动Linux
|
14天前
|
存储 Linux 网络安全
【Azure 应用服务】App Service For Linux 如何在 Web 应用实例上住抓取网络日志
【Azure 应用服务】App Service For Linux 如何在 Web 应用实例上住抓取网络日志
|
15天前
|
Linux Perl
在Linux中,系统目前有许多正在运行的任务,在不重启机器的条件下,有什么方法可以把所有正在运行的进程移除呢?
在Linux中,系统目前有许多正在运行的任务,在不重启机器的条件下,有什么方法可以把所有正在运行的进程移除呢?
|
15天前
|
监控 Linux
在Linux中,有⼀个脚本运行时间可能超过2天,如何做才能使其不间断的运行,而且还可以随时观察脚本运行时的输出信息?
在Linux中,有⼀个脚本运行时间可能超过2天,如何做才能使其不间断的运行,而且还可以随时观察脚本运行时的输出信息?
|
15天前
|
关系型数据库 MySQL Linux
在Linux中,如何检查某项服务是否在运行?
在Linux中,如何检查某项服务是否在运行?
|
15天前
|
Linux Perl
在Linux中,如何停止正在运行的进程?
在Linux中,如何停止正在运行的进程?
下一篇
DDNS