Linux设备驱动程序学习之基础篇
Linux设备驱动程序学习笔记系列文章原作者是:Tekkaman Ninja,他博客地址:
http://blog.chinaunix.net/u1/34474/showart_404278.html
在此向Tekkaman Ninja表示感谢,写出这么好的文章,使我少走了很多弯路。
Linux设备驱动程序学习(0)-Hello, world!模块
文章来源:http://blog.chinaunix.net/u2/62910/showart_492083.html
一个学习Linux设备驱动程序都会碰到的第一个例程:
#include <linux/init.h>
#include <linux/module.h>
MODULE_LICENSE("Dual BSD/GPL");
static int hello_init(void)
{
printk(KERN_ALERT "Hello, Tekkaman Ninja !\n");
return 0;
}
static void hello_exit(void)
{
printk(KERN_ALERT "Goodbye, Tekkaman Ninja !\n Love Linux !Love ARM ! Love KeKe !\n");
}
module_init(hello_init);
module_exit(hello_exit);
我将其复制到我的工作目录,并编写了一个简单的Makefile文件:
KERNELDIR = /home/tekkaman/working/SBC2440/linux-2.6.22.2
# The current directory is passed to sub-makes as argument
PWD := $(shell pwd)
INSTALLDIR = /home/tekkaman/working/rootfs/lib/modules
CROSS_COMPILE =/home/tekkaman/working/crosstool-gcc410-k26222/gcc-4.1.0-glibc-2.3.2/arm-9tdmi-linux-gnu/bin/arm-9tdmi-linux-gnu-
CC = $(CROSS_COMPILE)gcc
obj-m := hello.o
modules:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
modules_install:
cp hello.ko $(INSTALLDIR)
clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions
.PHONY: modules modules_install clean
说实话,以上是我参考了《Linux设备驱动程序(第3版)》的Makefile源码修改得来的。我对Makefile不是很了解,是该好好学习学习了!
然后就是make modules 、 make modules_install 。
[root@Tekkaman-Ninja Helloworld]# make modules
make -C /home/tekkaman/working/SBC2440/linux-2.6.22.2 M=/home/tekkaman/working/Linuxdriver/Helloworld modules
make[1]: Entering directory `/home/tekkaman/working/SBC2440/linux-2.6.22.2
相关文档:
查看软件xxx安装内容
dpkg -L xxx
查找软件
apt-cache search 正则表达式
查找文件属于哪个包
dpkg -S filename apt-file search filename
查询软件xxx依赖哪些包
apt-cache depends xxx
查询 ......
首先Perl mkdir 的语法是:
1.mkdir('dir', 代表九位二进制数字的十进制值)
设置775,则该值为十进制的509,即二进制的111111101
此数值不能设置为111111111即十进制的511即777。
2.mkdir('dir', 0常见unix3位权限)
可以设置777。
然后在linux下时,由于umask的原因,只能设置为755。
因为创建文件时的权限是umask和 ......
Linux内存线性地址空间大小为4GB,分为2个部分:用户空间部分(通常是3G)和内核空间部分(通常是1G)。在此我们主要关注内核地址空间部分。
内核通过内核页全局目录来管理所有的物理内存,由于线性地址前3G空间为用户使用,内核页全局目录前768项(刚好3G)除0、1两项外全部为0,后256项(1G)用来管理所有的物 ......
<!--
@page { margin: 2cm }
P { margin-bottom: 0.21cm }
-->
4
月
10
日,科技部就“国家自主创新产品认定工作”发出通知,公开征求意见,其中的
指导思想有重大突破。具体情况如何?
2009
年
10
月
30
日,在我国政府 ......
安装后
运行snavigator
出现
Can't find a usable tk.tcl in the following directories:
/opt/sourcenav/share/tk8.3
/opt/sourcenav/share/tk8.3/tk.tcl: no event type or button # or keysym
no event type or button # or keysym
while executing
"bind Listbox <MouseWheel> {
%W yview scroll ......