*:first-child {
margin-top: 0 !important;
}

body>*:last-child {
margin-bottom: 0 !important;
}

/* BLOCKS
=============================================================================*/

p, blockquote, ul, ol, dl, table, pre {
margin: 15px 0;
}

/* HEADERS
=============================================================================*/

h1, h2, h3, h4, h5, h6 {
margin: 20px 0 10px;
padding: 0;
font-weight: bold;
-webkit-font-smoothing: antialiased;
}

h1 tt, h1 code, h2 tt, h2 code, h3 tt, h3 code, h4 tt, h4 code, h5 tt, h5 code, h6 tt, h6 code {
font-size: inherit;
}

h1 {
font-size: 28px;
color: #000;
}

h2 {
font-size: 24px;
border-bottom: 1px solid #ccc;
color: #000;
}

h3 {
font-size: 18px;
}

h4 {
font-size: 16px;
}

h5 {
font-size: 14px;
}

h6 {
color: #777;
font-size: 14px;
}

body>h2:first-child, body>h1:first-child, body>h1:first-child+h2, body>h3:first-child, body>h4:first-child, body>h5:first-child, body>h6:first-child {
margin-top: 0;
padding-top: 0;
}

a:first-child h1, a:first-child h2, a:first-child h3, a:first-child h4, a:first-child h5, a:first-child h6 {
margin-top: 0;
padding-top: 0;
}

h1+p, h2+p, h3+p, h4+p, h5+p, h6+p {
margin-top: 10px;
}

/* LINKS
=============================================================================*/

a {
color: #4183C4;
text-decoration: none;
}

a:hover {
text-decoration: underline;
}

/* LISTS
=============================================================================*/

ul, ol {
padding-left: 30px;
}

ul li > :first-child,
ol li > :first-child,
ul li ul:first-of-type,
ol li ol:first-of-type,
ul li ol:first-of-type,
ol li ul:first-of-type {
margin-top: 0px;
}

ul ul, ul ol, ol ol, ol ul {
margin-bottom: 0;
}

dl {
padding: 0;
}

dl dt {
font-size: 14px;
font-weight: bold;
font-style: italic;
padding: 0;
margin: 15px 0 5px;
}

dl dt:first-child {
padding: 0;
}

dl dt>:first-child {
margin-top: 0px;
}

dl dt>:last-child {
margin-bottom: 0px;
}

dl dd {
margin: 0 0 15px;
padding: 0 15px;
}

dl dd>:first-child {
margin-top: 0px;
}

dl dd>:last-child {
margin-bottom: 0px;
}

/* CODE
=============================================================================*/

pre, code, tt {
font-size: 12px;
font-family: Consolas, "Liberation Mono", Courier, monospace;
}

code, tt {
margin: 0 0px;
padding: 0px 0px;
white-space: nowrap;
border: 1px solid #eaeaea;
background-color: #f8f8f8;
border-radius: 3px;
}

pre>code {
margin: 0;
padding: 0;
white-space: pre;
border: none;
background: transparent;
}

pre {
background-color: #f8f8f8;
border: 1px solid #ccc;
font-size: 13px;
line-height: 19px;
overflow: auto;
padding: 6px 10px;
border-radius: 3px;
}

pre code, pre tt {
background-color: transparent;
border: none;
}

/* QUOTES
=============================================================================*/

blockquote {
border-left: 4px solid #DDD;
padding: 0 15px;
color: #777;
}

blockquote>:first-child {
margin-top: 0px;
}

blockquote>:last-child {
margin-bottom: 0px;
}

/* HORIZONTAL RULES
=============================================================================*/

hr {
clear: both;
margin: 15px 0;
height: 0px;
overflow: hidden;
border: none;
background: transparent;
border-bottom: 4px solid #ddd;
padding: 0;
}

/* TABLES
=============================================================================*/

table th {
font-weight: bold;
}

table th, table td {
border: 1px solid #ccc;
padding: 6px 13px;
}

table tr {
border-top: 1px solid #ccc;
background-color: #fff;
}

table tr:nth-child(2n) {
background-color: #f8f8f8;
}

/* IMAGES
=============================================================================*/

img {
max-width: 100%
}
-->

核心配置文件

  • .config:该文件位于Linux内核源代码顶层目录,为隐藏文件。用于配置Linux内核中的模块。在.config文件中可以对Linux驱动进行三方面的配置:编译成驱动模块文件、编译进内核和从内核去除。可以手工修改,也可以使用make menuconifg命令用菜单方式进行配置。
  • Kconifg:该文件主要用于定义make menuconifg命令的显示的菜单,除此之外,Kconifg文件还可以导入位于其他目录的Kconifg文件。make命令通过Kconfig文件的递归引用,可以找到Linux内核中的所有Kconfig文件,从而建立一个完整的配置菜单。
  • Makefile:一般与Kconfig同时出现。每有一个Kconfig文件,就必须有一个Makefile文件。该文件用于指定如何编译Makefile文件所在目录的源代码。

例:由于word_count属于字符驱动,所以可以使用如下步骤加入Linux内核源代码树

第1步:将word_count.c文件放入Linux内核源代码

将word_count.c文件放入< Linux内核目录 >/driver/char目录中。

第2步,修改Kconfig文件

打开/root/kernel/goldfish/driver/char/Kconifg 文件,找到endmenu,在endmenu前面添加如下代码。

conifg WORD_COUNT
bool "word_count driver"
help
this is a word count driver. It can get a word count from /dev/wordcount

每一个具体的模块都会对应一个Shell变量来保存该模块的3个编译行为(生成.ko文件、编译进内核或从内核中去除)。conifg后面的字符串将作为Shell变量名的后半部分,前半部分是CONFIG_(所以是CONIFG_WORD_COUNT),该值会保存在.config中。

第3步,修改Makefile文件

打开/root/goldfish/drivers/char/Makefile文件。在任意位置插入如下内容

obj-$(CONFIG_WORD_COUNT)    += word_count.o

obj-后面使用了第2步产生的CONFIG_WORD_COUNT变量,而不是使用固定的值。make命令在编译Linux内核时会将该变量替换成相应的值.

第4步,设置.config文件

.config可以通过手工配置,也可以通过make menuconfig在菜单中进行配置。这里采用菜单配置的方法。进入内核顶层目录,执行make menuconfig显示配置菜单,并进入“Device” > “Character devices”子菜单,找到“wordcountdriver”菜单项,按空格将该菜单项前设置成星号(*)。然后退出并保存。

第5步,编译Linux内核

使用make命令进行编译。

编译之后的/dev/word_count可能没有读写权限。如果要改动/dev/一些设备的权限,可以把chmod 777写在init.rc文件中。但是要注意写的位置,不能太早执行,不能写在early-init段内,因为那时/dev/的设备节点还没有被创建。

将驱动编译进Linux内核的更多相关文章

  1. 【转】6.4.6 将驱动编译进Linux内核进行测试

    原文网址:http://www.apkbus.com/android-98520-1-1.html 前面几节都是将Linux驱动编译成模块,然后动态装载进行测试.动态装载驱动模块不会随着Android ...

  2. 将MPLS编译进linux内核中

    系统环境:linux kernel 2.6.35.(此环境是上一篇文章中将ubuntu内核替换后的环境) 编译过程如下: 1)首先需要下载patch文件:linux-kernel-v2.6.35-mp ...

  3. 编译安装linux内核步骤

    编译安装linux内核步骤: 一.获取内核源码 源码网址:www.kernel.org 二.解压内核源码 首先以root帐号登录,然后进入/usr/src子目录.如果用户在安装Linux时,安装了内核 ...

  4. linux内核系列(一)编译安装Linux内核 2.6.18

    1.配置环境 操作系统:CentOS 5.2 下载linux-2.6.18版本的内核,网址:http://www.kernel.org 说明:该编译文档适合2.6.18以上的Linux内核版本,只需所 ...

  5. 如何编译安装Linux内核

    操作系统环境 VMware workstation15 Pro ubuntu18.04 LTS 待编译内核5.3.10版本 内核下载地址 kernel.org 环境配置 在正式编译前需要安装部分软件. ...

  6. 编译aarch64 Linux内核并基于qemu运行

    核心流程 首先,本文主要讲述如何编译Linux内核并在qemu虚拟机上运行.这里针对的架构是aarch64. 本文的实验平台是Ubuntu 16.04. 为了达成目标,我们需要有qemu.buildr ...

  7. 编译x86_64 Linux内核并基于QEMU运行

    编译并运行内核镜像 安装包准备 $ sudo apt install git $ sudo apt install build-essential kernel-package fakeroot li ...

  8. 编译最新linux内核(version 4.4.2)

    环境:centos6.4 内核版本为2.6.32 目标:编译4.4.2内核,升级到 4.4.2 准备工作: 安装开发库和ncurses库 # yum groupinstall "Develo ...

  9. Linux课程实践二:编译模块实现内核数据操控

    一.内核模块原理 1. Linux内核增加功能 Linux内核整体结构很庞大,包含了很多的组件,现在有两种方法将需要的功能包含进内核当中: - 静态加载:将所有的功能都编译进Linux内核. - 动态 ...

随机推荐

  1. SQLSTATE[HY000]: General error: 1030 Got error 28 from storage engine

    今天上课程化平台考试,输入平台网址突然报这个错误 可以先df -h 发现/tmp文件使用满了 ,清理下不需要的临时文件即可

  2. VUE的一个数据绑定与页面刷新相关的bug

    1.场景: N层嵌套的循环查询业务场景,框架是vue.其中在最后一层查完之后,还需要查其中每一项的两个属性,类型都是列表.查完之后将其赋值给一个变量用于页面展示.代码如下: (1)异常代码: getS ...

  3. python已经感觉到放弃接近的day08

    居然能超过一个星期,我甚至都有点佩服我自己了,今天有两个新的知识点,一个简单一个难,先从简单的开始入手吧,进制,进制分为4种,2进制,8进制,10进制,16进制,一般最常用的就是10进制了,计算机用的 ...

  4. Linux新手随手笔记

    RPM通过将安装规则与源代码打包到一起,来降低软件的安装难度 yum 通过将大量的常用RPM软件存放在一起,解决软件包之间的依赖关系,进一步降低软件的安装难度 rhel 5\6 init rhel 7 ...

  5. Asp.net mvc 动作方法中 调用 另一个控制器的动作方法

    public ActionResult 动作方法(){ var otherController = DependencyResolver.Current.GetService<另一个控制器的类名 ...

  6. redis session 共享 测试案列

    下载 spring redis session demo 2.分别在不同的服务器上启动 3.nginx 安装 测试

  7. jsp假分页

    假分页:从数据库中取出所有的数据,然后分页在界面上显示.访问一次数据库,但由于选择的数据量比较大,所以第一次花费时间比较长,但之后每一页的显示都是直接.快速的,避免对数据库的多次访问. 真分页:确定要 ...

  8. Java8 list转map 坑

    Map<String , SonCargosForm> orderCargosMap = sonTemporaryForm.getOrderCargosList().stream() .c ...

  9. 搭建alpine仓库 提供apk包

    搭建alpine私有仓库从官方拉取alpine所有的包 wget -r -np -nH http://nl.alpinelinux.org/alpine/v3.5/main/x86_64/ wget ...

  10. pip模块

    pip模块 Usage: pip <command> [options] Commands: install Install packages. download Download pac ...