linux 0.11 内核学习 char_dev.c
/*
* linux/fs/char_dev.c
*
* (C) 1991 Linus Torvalds
*/
#include <errno.h>
#include <sys/types.h> // 定义了基本的系统数据类型
#include <linux/sched.h>
#include <linux/kernel.h> // 含有一些内核常用函数的原形定义
#include <asm/segment.h>
#include <asm/io.h>
/* 中断读 */
extern int tty_read(unsigned minor,char * buf,int count);
/* 中断写 */
extern int tty_write(unsigned minor,char * buf,int count);
/* 定义字符设备读写函数指针类型 */
typedef (*crw_ptr)(int rw,unsigned minor,char * buf,int count,off_t * pos);
/* 串口终端读写操作函数。参数 : rw读写命令,minor中断子设备号,buf缓冲区 */
/* count读写的字节数,pos读写操作当前指针,返回实际读写的字节数 */
static int rw_ttyx(int rw,unsigned minor,char * buf,int count,off_t * pos)
{
return ((rw==READ)?tty_read(minor,buf,count):
tty_write(minor,buf,count));
}
/* 终端读写操作函数,只是增加了对进程是否有控制终端的检测 */
static int rw_tty(int rw,unsigned minor,char * buf,int count, off_t * pos)
{
// 若进程没有对应的控制终端,则返回出错号
if (current->tty<0)
return -EPERM;
return rw_ttyx(rw,current->tty,buf,count,pos);
}
/* 内存数据读写函数,还没实现 */
static int rw_ram(int rw,char * buf, int count, off_t *pos)
{
return -EIO;
}
/* 内存数据读写操作函数。未实现 */
static int rw_mem(int rw,char * buf, int count, off_t * pos)
{
return -EIO;
}
/* 内核数据区读写函数。未实现 */
static int rw_kmem(int rw,char * buf, int count, off_t * pos)
{
return -EIO;
}
/* 端口读写操作函数,参数 : rw读写命令,buf缓冲区,count读写字节数,pos */
/* 端口地址,返回的是实际读写的字节数 */
static int rw_port(int rw,char * buf, int count, off_t * pos)
{
int i=*pos; // 端口地址
// 对于所要求读写的字节数,并且端口地址小于64k
while (count-->0 && i<65536)
{
// 若是读命令,则从端口i 中读取一字节内容并放到用户缓冲区中
if (rw==READ)
put_fs_byte(inb(i),buf++);
相关文档:
Linux各发行版本 优缺点 简介
来源: ChinaUnix博客 日期: 2008.01.21 13:43 (共有25条评论) 我要评论
Linux最早由Linus Benedict Torvalds在1991年开始编写。在这之前,Richard
Stallman创建了Free Software
Foundation(FSF)组织以及GNU项目,并不断的编写创建GNU程序(此类程序的许可方式均为 ......
Linux上构筑iPhone OS3.1.2开发环境搭建
教程地址: http://www.yifeiyang.net/iphone-development-introduction-3-linux-development-environment-on-the-build-iphone-os3-1-2/
#第一步没有什么问题
$ ./toolchain.sh headers
#第二步也顺利通过
$ ./toolchain.sh firmware
#第三步也挺顺利
$ ./toolchain ......
转载自:http://www.91linux.com/html/article/go/20090205/15634.html
bin = BINaries (binary)
/dev = devices
/etc = ETCetera
etcetera附加的人, 附加物, 以及其它, 等等
/lib = LIBrary
/proc = PROCesses
/sbin
= Superuser BINaries
/tmp = TeMPorary
/usr = Unix Shared
Resources
/var = ......
<!--
@page { margin: 2cm }
P { margin-bottom: 0.21cm }
-->
在现实生活中被人们称为大师级的人物确实很少见。
Brian
Proffitt
先生就是一位全球知名、受人尊敬的
Linux
大师。此言有何根据?近日,他向我们推荐了什么?
......
Linux内核配置办法:
1. make config
这种办法会遍历所有配置项,要求用户逐个选择Y/N/M
2. make menuconfig
这个办法是基于ncurse库编制的图形界面工具。常用
3. make xconfig
用于基于X11的图形工具
4. make gconfig
用于基于gtk+图形工具
5. make defconfig
创建一个默认的配置,生成当前的.config
6. make x ......