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





相关文章
|
22天前
|
存储 网络协议 Ubuntu
【Linux开发实战指南】基于UDP协议的即时聊天室:快速构建登陆、聊天与退出功能
UDP 是一种无连接的、不可靠的传输层协议,位于IP协议之上。它提供了最基本的数据传输服务,不保证数据包的顺序、可靠到达或无重复。与TCP(传输控制协议)相比,UDP具有较低的传输延迟,因为省去了建立连接和确认接收等过程,适用于对实时性要求较高、但能容忍一定数据丢失的场景,如在线视频、语音通话、DNS查询等。 链表 链表是一种动态数据结构,用于存储一系列元素(节点),每个节点包含数据字段和指向下一个节点的引用(指针)。链表分为单向链表、双向链表和循环链表等类型。与数组相比,链表在插入和删除操作上更为高效,因为它不需要移动元素,只需修改节点间的指针即可。但访问链表中的元素不如数组直接,通常需要从
|
14天前
|
Web App开发 缓存 Linux
FFmpeg开发笔记(三十六)Linux环境安装SRS实现视频直播推流
《FFmpeg开发实战》书中第10章提及轻量级流媒体服务器MediaMTX,适合测试RTSP/RTMP协议,但不适合生产环境。推荐使用SRS或ZLMediaKit,其中SRS是国产开源实时视频服务器,支持多种流媒体协议。本文简述在华为欧拉系统上编译安装SRS和FFmpeg的步骤,包括安装依赖、下载源码、配置、编译以及启动SRS服务。此外,还展示了如何通过FFmpeg进行RTMP推流,并使用VLC播放器测试拉流。更多FFmpeg开发内容可参考相关书籍。
31 2
FFmpeg开发笔记(三十六)Linux环境安装SRS实现视频直播推流
|
21天前
|
Linux
FFmpeg开发笔记(三十四)Linux环境给FFmpeg集成libsrt和librist
《FFmpeg开发实战》书中介绍了直播的RTSP和RTMP协议,以及新协议SRT和RIST。SRT是安全可靠传输协议,RIST是可靠的互联网流传输协议,两者于2017年发布。腾讯视频云采用SRT改善推流卡顿。以下是Linux环境下为FFmpeg集成libsrt和librist的步骤:下载安装源码,配置、编译和安装。要启用这些库,需重新配置FFmpeg,添加相关选项,然后编译和安装。成功后,通过`ffmpeg -version`检查版本信息以确认启用SRT和RIST支持。详细过程可参考书中相应章节。
34 1
FFmpeg开发笔记(三十四)Linux环境给FFmpeg集成libsrt和librist
|
7天前
|
弹性计算 运维 自然语言处理
阿里云OS Copilot测评:重塑Linux运维与开发体验的智能革命
阿里云OS Copilot巧妙地将大语言模型的自然语言处理能力与操作系统团队的深厚经验相结合,支持自然语言问答、辅助命令执行等功能,为Linux用户带来了前所未有的智能运维与开发体验。
|
14天前
|
存储 安全 Linux
|
22天前
|
SQL 自然语言处理 网络协议
【Linux开发实战指南】基于TCP、进程数据结构与SQL数据库:构建在线云词典系统(含注册、登录、查询、历史记录管理功能及源码分享)
TCP(Transmission Control Protocol)连接是互联网上最常用的一种面向连接、可靠的、基于字节流的传输层通信协议。建立TCP连接需要经过著名的“三次握手”过程: 1. SYN(同步序列编号):客户端发送一个SYN包给服务器,并进入SYN_SEND状态,等待服务器确认。 2. SYN-ACK:服务器收到SYN包后,回应一个SYN-ACK(SYN+ACKnowledgment)包,告诉客户端其接收到了请求,并同意建立连接,此时服务器进入SYN_RECV状态。 3. ACK(确认字符):客户端收到服务器的SYN-ACK包后,发送一个ACK包给服务器,确认收到了服务器的确
147 1
|
22天前
|
运维 监控 大数据
部署-Linux01,后端开发,运维开发,大数据开发,测试开发,后端软件,大数据系统,运维监控,测试程序,网页服务都要在Linux中进行部署
部署-Linux01,后端开发,运维开发,大数据开发,测试开发,后端软件,大数据系统,运维监控,测试程序,网页服务都要在Linux中进行部署
|
22天前
|
Linux 调度
Linux |使用“at”命令在指定时间运行任务
Linux |使用“at”命令在指定时间运行任务
16 0
|
24天前
|
监控 算法 Linux
Linux下工具tc详细讲解及限制IP和端口实例
TC (Traffic Control) 是Linux内核中提供的一个用于控制和管理网络流量的强大工具,它允许用户实现QoS(Quality of Service)策略,包括带宽限制、优先级控制、延迟保证等。TC基于内核的队列 discipline (qdisc) 和流量类别(class) 体系结构,允许对进入或离开网络接口的数据流进行复杂的整形和过滤。
|
26天前
|
NoSQL Linux 开发工具
【linux】在linux操作系统下快速熟悉开发环境并上手开发工具——体验不一样的开发之旅
【linux】在linux操作系统下快速熟悉开发环境并上手开发工具——体验不一样的开发之旅