*: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. 关于nginx unit服务非正常关闭后,无法重新启动问题的处理

    昨天在前领导技术大牛吕哥的帮忙下,python服务管理从nginx+supervisor+uwsgi+python3改为了轻便结构nginx + unit + python3,部署和配置起来顿时轻松起 ...

  2. ThreadLocal源码解读

    1. 背景 ThreadLocal源码解读,网上面早已经泛滥了,大多比较浅,甚至有的连基本原理都说的很有问题,包括百度搜索出来的第一篇高访问量博文,说ThreadLocal内部有个map,键为线程对象 ...

  3. JS中各种宽度距离小结

    js中获取各种宽度和距离,常常让我们混淆,各种浏览器的不兼容让我们很头疼,现在就在说说js中有哪些宽度和距离. 1.名词解释 screen:屏幕.这一类取到的是关于屏幕的宽度和距离,与浏览器无关,应该 ...

  4. 论学好Linux系统的超级重要性

    不知道各位在日常的工作生活中有没有接触过“rm -rf /*”这个命令,因为这个命令搞出来的事情可还不少呢!前段时间就在一个群里看到了有个小伙子,老板让他去维护一下服务器,这小伙也不太懂,就问群里的大 ...

  5. Python两个栈实现一个队列

    牛客网原题: 用两个栈来实现一个队列,完成队列的Push和Pop操作. 队列中的元素为int类型.   实现这个算法的方式有很多种,这里就写一种比较简单易懂的:虽然可能算法和效率上不太出色,当大多数人 ...

  6. 【MySQL 读书笔记】当我们在执行更新语句的时候我们在做什么

    该篇其实重点涉及两个日志的使用和处理. 一个是 server 层的 binlog 一个是服务器层的 redolog. 首先还是根据主线来介绍当我们在执行更新语句的时候我们在做什么 Redo Log M ...

  7. 泛型与object

    一.泛型通俗的理解就是限制list集合里面的数据类型 比如List<int>,就限制LIST里面必须是int,这样放入其他就有报错(保证了安全),然后从 list里取元素,就不需要强制转化 ...

  8. delphi中响应鼠标进入或离开控件的方法

    Delphi没有MouseEnter与MouseLeave的事件,网上说可以响应CM_MOUSEENTER和CM_MOUSELEAVE消息来实现.这两个消息是VCL自己定义的消息,看了Delphi的C ...

  9. 拒绝回调,拥抱async await

    之前使用jquery中ajax,请求的结果需要写在回调函数里面,后面接触到了axios/fetch,使用了es6中Promise进行封装,这种链式结构调用,看起来比之前直观,可是还是没有解决回调的问题 ...

  10. HDU 2586 How far way?

    传送门 继续水板子题... #include <bits/stdc++.h> using namespace std; inline int read() { , f = ; char c ...