随笔分类 -  嵌入式之Linux内核学习

摘要:/** ioctl.c 文件实现了输入/输出控制系统调用ioctl(),该函数* 主要是调用函数tty_ioctl()对终端的IO进行控制*//** linux/fs/ioctl.c** (C) 1991 Linus Torvalds*/#include <string.h>#include <errno.h>#include <sys/stat.h>#include <linux/sched.h>extern int tty_ioctl(int dev, int cmd, int 阅读全文
posted @ 2010-02-16 09:17 qiang.xu 阅读(1004) 评论(0) 推荐(0) 编辑
摘要:/** linux/fs/inode.c** (C) 1991 Linus Torvalds*/#include <string.h>#include <sys/stat.h> // 文件状态头文件#include <linux/sched.h>#include <linux/kernel.h>#include <linux/mm.h>#include <asm/system.h>struct m_inode inode_tab 阅读全文
posted @ 2010-02-16 09:15 qiang.xu 阅读(2816) 评论(1) 推荐(0) 编辑
摘要:/** linux/fs/fcntl.c** (C) 1991 Linus Torvalds*/#include <string.h>#include <errno.h>#include <linux/sched.h>#include <linux/kernel.h>#include <asm/segment.h>#include <fcntl.h>#include <sys/stat.h>exter 阅读全文
posted @ 2010-02-16 09:13 qiang.xu 阅读(527) 评论(0) 推荐(0) 编辑
摘要:/** 该文件的两个函数是为了向open和write函数提供接口,实现内核数据* 和用户数据的交互*//** linux/fs/block_dev.c** (C) 1991 Linus Torvalds*/#include <errno.h>#include <linux/sched.h>#include <linux/kernel.h>#include <asm/segment.h>#include <asm/system.h>/** | block 阅读全文
posted @ 2010-02-16 09:12 qiang.xu 阅读(692) 评论(0) 推荐(0) 编辑
摘要:/** linux/fs/bitmap.c** (C) 1991 Linus Torvalds*//* bitmap.c contains the code that handles the inode and block bitmaps */#include <string.h>#include <linux/sched.h>#include <linux/kernel.h> // 一些内核常用函数的原形定义/* 将指定地址(addr)处的一块内存清零 */#define clear_block(addr) 阅读全文
posted @ 2010-02-16 09:10 qiang.xu 阅读(1848) 评论(0) 推荐(0) 编辑
摘要:## 这段代码被连接到system模块的最前面,这也是它为什么称之为head.s的原因。# 从这里开始内核完全运行在保护模式下。head.s采用的是at&t格式的# 汇编。注意的是代码中的赋值方向是从左到右。## 这段程序实际上是出于内存的绝对地址0开始处。首先是加载各个数据段寄存器。# 重新设置全局描述符表gdt --> 检测a20地址线是否真的开启,没有开启,loop# 掉了 --> 检测pc是否含有数学协处理器 --> 设置管理内存分页的处理机制 --># 将页目录放置在内存地址0开始处。所以这段程序将被覆盖掉。 - 阅读全文
posted @ 2010-02-16 09:07 qiang.xu 阅读(1528) 评论(0) 推荐(0) 编辑
摘要:1. “按位与”运算符(&) 参加运算的两个数据,按二进位进行“与”运算。原则是全1为1,有0为0,即:0&0=0; 0&1=0; 1&0=0; 1&1=1; 如下例: a=5&3; //a=(0b 0101) & (0b 0011) =0b 0001 =1 那么如果参加运算的两个数为负数,又该如何算呢?会以其补码形式表示的二进制数来进行与运算。 a=-5&-3; //a=(0b 阅读全文
posted @ 2010-02-12 23:53 qiang.xu 阅读(316) 评论(0) 推荐(0) 编辑
摘要:/** 该文件主要是实现do_execve函数,主要是实现对于二进制文件的加载执行* 和shell脚本文件的加载执行*//** linux/fs/exec.c** (C) 1991 Linus Torvalds*//** #!-checking implemented by tytso.*//** Demand-loading implemented 01.12.91 - no need to read anything but* the header into memory. The inode of the executable is put into* "current-&am 阅读全文
posted @ 2010-02-09 22:53 qiang.xu 阅读(1542) 评论(0) 推荐(0) 编辑
摘要:/** linux/fs/file_dev.c** (C) 1991 Linus Torvalds*/#include <errno.h>#include <fcntl.h>#include <linux/sched.h>#include <linux/kernel.h>#include <asm/segment.h>#define MIN(a,b) (((a)<(b))?(a):(b))#define MAX(a,b) (((a)& 阅读全文
posted @ 2010-02-08 11:16 qiang.xu 阅读(613) 评论(0) 推荐(0) 编辑
摘要:/** 该文件中的两个函数read_pipe和write_pipe是上层函数* read和write的底层实现*//** linux/fs/pipe.c** (C) 1991 Linus Torvalds*/#include <signal.h>#include <linux/sched.h>// 内存管理头文件。含有页面大小定义和一些页面释放函数原型#include <linux/mm.h> /* for get_free_page */#include <asm/segment.h&g 阅读全文
posted @ 2010-02-08 11:13 qiang.xu 阅读(1468) 评论(0) 推荐(0) 编辑
摘要:/** 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&g 阅读全文
posted @ 2010-02-08 11:08 qiang.xu 阅读(683) 评论(0) 推荐(0) 编辑
摘要:/** 该文件主要实现的是truncate函数,该函数是释放指定i* 节点在设备上占用的所有逻辑块,包括直接块、一次间* 接块和二次间接块*//** linux/fs/truncate.c** (C) 1991 Linus Torvalds*/#include <linux/sched.h>#include <sys/stat.h>/* 释放一次间接块,参数int dev, int block指明一次间接块的设备号 */static void free_ind(int dev,int block){ struct buffer_head 阅读全文
posted @ 2010-02-08 11:05 qiang.xu 阅读(1049) 评论(0) 推荐(0) 编辑
摘要:文件可能比较长,呵呵。/** linux/fs/namei.c** (C) 1991 Linus Torvalds*//** Some corrections by tytso.*/#include <linux/sched.h>#include <linux/kernel.h>#include <asm/segment.h>#include <string.h>#include <fcntl.h>#include <errno.h& 阅读全文
posted @ 2010-02-06 22:53 qiang.xu 阅读(1339) 评论(0) 推荐(0) 编辑
摘要:超级块描述了整个文件系统的信息,而文件作为存储的对象,它的信息是有inode节点来描述的。i节点位图描述了inode的使用情况。struct m_inode{unsigned short i_mode; //文件类型unsigned short i_uid;//文件宿主unsigned long i_size;//文件大小unsigned long i_mtime;//文件修改时间unsigned char i_guid; //文件组idunsigned char i_nlinks;//文件目录项连接数unsigned char i_zone[9];//文件所在的设备逻辑块号//以下的字段在内 阅读全文
posted @ 2010-02-04 10:12 qiang.xu 阅读(1283) 评论(0) 推荐(0) 编辑
摘要:文件系统和内存管理,以及进程管理是操作系统的核心部分。数据通常以文件的形式存储在设 备上,因此文件系统的基本功能就是以某种格式存取/控制文件。0.11版的内核中采用了minix1.0版的文件系统。在最新的2.6版内核中,借助于 VFS,系统支持50多种文件系统。首先介绍一下minix文件系统minix文件系统和标准unix文件系统基本相同。它由6个部分组 成,分别是:引导块,超级块,i节点位图,逻辑块位图,i节点,和数据区。如果存放文件系统的设备不是引导设备,那么引导块可以为空。PC机的块设备通常 以512字节为一个扇区,而文件系统则以盘块为单位使用之。minix中1个盘块等于2个扇区大小。从 阅读全文
posted @ 2010-02-04 10:10 qiang.xu 阅读(1428) 评论(0) 推荐(1) 编辑
摘要:/** 该文件实现rs232 串行通信中断处理*//** linux/kernel/rs_io.s** (C) 1991 Linus Torvalds*//** rs_io.s** This module implements the rs232 io interrupts.*/.text.globl _rs1_interrupt,_rs2_interrupt/* 读写队列缓冲区的长度 */size = 1024 /* must be power of two ! and must match the value in tty_io.c!!! *//* these 阅读全文
posted @ 2010-02-01 15:33 qiang.xu 阅读(719) 评论(0) 推荐(0) 编辑
摘要:参考《linux内核完全注释》和网上相关文章/** 控制台显示操作*//** linux/kernel/console.c** (C) 1991 Linus Torvalds*//** console.c** This module implements the console io functions* 'void con_init(void)'* 'void con_write(struct tty_queue * queue)'* Hopefully this will be a rather complete VT102 implementation.* 阅读全文
posted @ 2010-02-01 10:00 qiang.xu 阅读(1216) 评论(0) 推荐(0) 编辑
摘要:/** linux/kernel/keyboard.S** (C) 1991 Linus Torvalds*//** Thanks to Alfred Leung for US keyboard patches* Wolfgang Thiel for German keyboard patches* Marc Corsini for the French keyboard*/#include <linux/config.h> // 内核配置头文件.text.globl _keyboard_interrupt/** these are for the keyboa 阅读全文
posted @ 2010-01-29 22:49 qiang.xu 阅读(2223) 评论(0) 推荐(0) 编辑
摘要:/** linux/kernel/floppy.c** (C) 1991 Linus Torvalds*//** 02.12.91 - Changed to static variables to indicate need for reset* and recalibrate. This makes some things easier (output_byte reset* checking etc), and means less interrupt jumping in case of errors,* so the code is hopefully easier to unders 阅读全文
posted @ 2010-01-29 19:21 qiang.xu 阅读(1202) 评论(0) 推荐(0) 编辑
摘要:/** 2010-1-21* 该文件时内核中有关任务调度的函数程序,其中包含基本函数sleep_on,* wakeup,schedule等,以及一些简单的系统调用。同时将软盘的几个操作* 函数也放置在这里。** schedule函数首先对所有的任务检查,唤醒任何一个已经得到信号的任务,* 具体的方法是针对任务数组中的每个任务,检查其警报定时值alarm。如果任务* 的alarm已经超期(alarm < jiffies),则在它的信号位图中设置SIGALARM,然后* 情书alarm值。jiffies是系统自从开机之后算起的滴答数。在scheed.h中定义,* 如果进程信号的位图中 阅读全文
posted @ 2010-01-28 21:57 qiang.xu 阅读(1826) 评论(0) 推荐(0) 编辑