易截截图软件、单文件、免安装、纯绿色、仅160KB

linux驱动程序实例

本例是冯国进的 《嵌入式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 device structure        */
};
//函数申明 原来Linux驱动程序设计这么简单 只需要实现这么几个函数就可以了
ssize_t DEMO_read(struct file *filp, char __user *buf, size_t count,
                   loff_t *f_pos);
ssize_t DEMO_write(struct file *filp, const char __user *buf, size_t count,
                    loff_t *f_pos);
loff_t DEMO_llseek(struct file *filp, loff_t off, int whence);
int     DEMO_ioctl(struct inode *inode, struct file *filp,
                &nbs


相关文档:

Linux从源码安装subversion遇到问题及解决

Linux源码安装Subversion
先从subversion的官方网站下载源码,subversion.apache.org
解压开到subversion-xxx 然后configure
然后一般就是找不到某某库的错误,以下说明
1.找不到sqlite3
  从sqlite网站上下载sqlite3的源码,然后把sqlite3.c拷贝到 subversion-xxx/sqlite-amalgamation/sqlite3.c
2.找不到apr
......

The Linux USB Input Subsystem, Part I


The Linux USB input subsystem is a single, harmonized way to manage all input devices. This is a relatively new approach for Linux, with the system being partly incorporated in kernel version 2.4 and fully integrated in the 2.5 development series.
This article covers four basic areas: a descripti ......

linux 新增系统调用


此文于2010-02-26被推荐到CSDN首页
如何被推荐?
最近在研究 Linux
内核的时间子系统,为下一篇长文《服务器程序中的日期与时间》做准备,无意中注意到了 Linux
新增的几个系统调用的对编写服务器代码的影响,先大致记录在这里。这篇博客也可算作前一篇《多线
程服务器的常用编程模型》
的一个注脚。
< type="te ......

Linux use notes

-----------------------------
Based on Fedora 8 version:
-----------------------------
1. No common command like ifconfig in os?
Root cause is the standard search path not include /sbin and /usr/sbin. Try to include them in /etc/profile. As belows:
 #Kenny add /sbin and /usr/sbin here.
&n ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号