linux基本驱动和linux字符设备驱动
先粘贴一个linux最简单的驱动,其实对于一个从2.4玩上来的人来说,驱动不复杂,比较不习惯的是那个makefile
驱动本身:
hello.c:
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
MODULE_LICENSE("Dual BSD/GPL");
static int hello_init(vodi){
printk(KERN_ALERT "hello world\n");
return 0;
}
static void hello_exit(vodi){
printk(KERN_ALERT"bye bye\n");
}
module_init(hello_init);
module_exit(hello_exit);
Makefile:
obj-m := hello.o
KERNELDIR :=/lib/modules/$(shell uname -r)/build
all:
make -C $(KERNELDIR) M=$(shell pwd) modules
clean:
rm -rf *.o *.ko
然后附过来一个驱动,暂时没有验证,是字符型的,如果验证好用,我再更新这篇日志
本例是冯国进的 《嵌入式Linux 驱动程序设计从入门到精通》的第一个例子
感觉真是好书 强烈推荐
注释是deep_pro加的 转载请注明!我的特点是文不加点!
这个驱动是在内存中分配一个256字节的空间,供用户态应用程序读写。
先是头文件 demo.h
#ifndef _DEMO_H_
#define _DEMO_H_
#include <linux/ioctl.h> /* needed for the _IOW etc stuff used later */
/********************************************************
* Macros to help debugging
********************************************************/
#undef PDEBUG /* undef it, just in case */
#ifdef DEMO_DEBUG
#ifdef __KERNEL__
# define PDEBUG(fmt, args...) printk( KERN_DEBUG "DEMO: " fmt, ## args)
#else//usr space
# define PDEBUG(fmt, args...) fprintf(stderr, fmt, ## args)
#endif
#else
# define PDEBUG(fmt, args...) /* not debugging: nothing */
#endif
#undef PDEBUGG
#define PDEBUGG(fmt, args...) /* nothing: it's a placeholder */
//设备号
#define DEMO_MAJOR 224
#define DEMO_MINOR 0
#define COMMAND1 1
#define COMMAND2 2
//自己定义的设备结构
struct DEMO_dev
{
struct cdev cdev; /* Char de
相关文档:
Service Discovery Protocol(SDP)提供一种能力,让应用程序有方法发现哪种服务可用以及这种服务的特性。
服务发现协议(SDP或Bluetooth SDP)在蓝牙协议栈中对蓝牙环境中的应用程序有特殊的含意,发现哪个服务是可用的和确定这些可用服务的特征。SDP定义了bluetooth client发现可用bluetooth server服务和它们的特征的方法。 ......
http://www.openchess.org/noitatsko/programming/ (2001-05-24 16:47:48)
信号处理
--------------------------------------------------------------------------------
信号处理概说
送出信号
接收信号
信号的处理
任务控制
----------------------------------- ......
参考资料一、linux调整系统时区/时间的方法(tzselect命令)
1) 找到相应的时区文件 /usr/share/zoneinfo/Asia/Shanghai
用这个文件替换当前的/etc/localtime文件。
2) 修改/etc/sysconfig/clock文件,修改为:
ZONE="Asia/Shanghai"
[color=red]UTC=true[/color]
ARC=false ......
screen.width*0.7)
{this.resized=true; this.width=screen.width*0.7; this.alt='Click here
to open new window\nCTRL Mouse wheel to zoom in/out';}"
onmouseover="if(this.width>screen.width*0.7) {this.resized=true;
this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='C ......
工作中发现,在linux中搭建WEBLOGIC应用服务器的环境下,有时可能同时发布多个war包,而且每一个war包的文件数目很多,或者客户同时访问量比较大,此时WEBLOGIC就会报错,报错信息中包含“Too many open files”,例如:
java.io.FileNotFoundException: /home/weblogic/bea/user_projects/domains/lhyth/server ......