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





相关文章
|
3天前
|
Linux 编译器 Android开发
FFmpeg开发笔记(九)Linux交叉编译Android的x265库
在Linux环境下,本文指导如何交叉编译x265的so库以适应Android。首先,需安装cmake和下载android-ndk-r21e。接着,下载x265源码,修改crosscompile.cmake的编译器设置。配置x265源码,使用指定的NDK路径,并在配置界面修改相关选项。随后,修改编译规则,编译并安装x265,调整pc描述文件并更新PKG_CONFIG_PATH。最后,修改FFmpeg配置脚本启用x265支持,编译安装FFmpeg,将生成的so文件导入Android工程,调整gradle配置以确保顺利运行。
24 1
FFmpeg开发笔记(九)Linux交叉编译Android的x265库
|
15天前
|
监控 Unix Linux
Linux操作系统调优相关工具(四)查看Network运行状态 和系统整体运行状态
Linux操作系统调优相关工具(四)查看Network运行状态 和系统整体运行状态
29 0
|
29天前
|
Linux 编译器 程序员
【Linux 调试秘籍】深入探索 C++:运行时获取堆栈信息和源代码行数的终极指南
【Linux 调试秘籍】深入探索 C++:运行时获取堆栈信息和源代码行数的终极指南
68 0
|
15天前
|
Linux
Linux操作系统调优相关工具(三)查看IO运行状态相关工具 查看哪个磁盘或分区最繁忙?
Linux操作系统调优相关工具(三)查看IO运行状态相关工具 查看哪个磁盘或分区最繁忙?
21 0
|
2天前
|
Linux 开发工具 C语言
Linux 安装 gcc 编译运行 C程序
Linux 安装 gcc 编译运行 C程序
15 0
|
2天前
|
Linux 数据安全/隐私保护
Linux常用命令实例带注释
Linux常用命令实例带注释
27 0
|
19天前
|
Linux API C语言
FFmpeg开发笔记(一)搭建Linux系统的开发环境
本文指导初学者如何在Linux上搭建FFmpeg开发环境。首先,由于FFmpeg依赖第三方库,可以免去编译源码的复杂过程,直接安装预编译的FFmpeg动态库。推荐网站<https://github.com/BtbN/FFmpeg-Builds/releases>提供适用于不同系统的FFmpeg包。但在安装前,需确保系统有不低于2.22版本的glibc库。详细步骤包括下载glibc-2.23源码,配置、编译和安装。接着,下载Linux版FFmpeg安装包,解压至/usr/local/ffmpeg,并设置环境变量。最后编写和编译简单的C或C++测试程序验证FFmpeg环境是否正确配置。
37 8
FFmpeg开发笔记(一)搭建Linux系统的开发环境
|
22天前
|
Ubuntu Unix Linux
【Linux/Ubuntu】Linux/Ubuntu运行python脚本
【Linux/Ubuntu】Linux/Ubuntu运行python脚本
|
22天前
|
Linux
Linux驱动运行灯 Heartbeat
Linux驱动运行灯 Heartbeat
10 0
|
23天前
|
Java Linux
Linux运行jar并选择配置文件
Linux运行jar并选择配置文件
8 1