易截截图软件、单文件、免安装、纯绿色、仅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只列出文件夹

ls -l|grep ^d    ----列出当前目录下的文件夹
ls -l|grep ^d|grep "tmp"  ----列出当前目录下明子含有"tmp"的文件夹
for dir in `ls -l ~/dxy/|grep ^d | awk '{print $9}'`  ---- awk '{print $9}' ,只print 文件夹的名字
do
echo "==== $dir"
cd ~/dxy;cd $dir/
t=`ls -l|grep ^d|grep " ......

linux下的so、o、lo、a、la文件有什么区别?

o: 编译的目标文件
a: 静态库,其实就是把若干o文件打了个包
so: 动态链接库(共享库)
lo: 使用libtool编译出的目标文件,其实就是在o文件中添加了一些信息
la: 使用libtool编译出的库文件,其实是个文本文件,记录同名动态库和静态库的相关信息
 
1 libtool的工作原理
libtool 是一个通用库支持脚本,将使用 ......

remote desktop, linux >windows

学校服务器的一个windows虚拟机开启了Desktop共享,这样可以在配置不高的终端使用高性能的机器,除了windows客户端访问外,在Ubuntu里可以通过自带的 rdesktop访问,该程序为命令行形式。参数较多,比较有用的是提供远程与本地交互的-r参数。
如:
rdesktop -r disk:floppy=/home/xiajing/t  192.168.111.111 ......

Linux环境下USB的原理、驱动和配置

什么是USB?
USB是英文Universal Serial Bus的缩写,意为通用串行总线。USB最初是为了替代许多不同的低速总线(包括并行、串行和键盘连接)而设计的,它以单一类型的总线连接各种不同的类型的设备。USB的发展已经超越了这些低速的连接方式,它现在可以支持几乎所有可以连接到PC上的设备。最新的USB规范修订了理论上高达480 ......

Linux中的内存分配和释放之__alloc_boot函数分析

 对于这个函数,其实是很多宏定义调用的函数,其中alloc_bootmem_low_pages(x)是其中一个调用它的宏,大家可以认为这些宏只是把这个__alloc_bootmem实质性的函数进行了封装。#define alloc_bootmem_low_pages(x)相当于__alloc_bootmem((x), PAGE_SIZE, 0),就是从0地址开始的低端内存分配按页大小对齐的内存。好了,为 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号