资源简介
带中文注释的 linux 0.11 源代码

代码片段和文件信息
/*
* linux/fs/bitmap.c
*
* (C) 1991 Linus Torvalds
*/
/* bitmap.c contains the code that handles the inode and block bitmaps */
/* bitmap.c 程序含有处理i 节点和磁盘块位图的代码 */
#include // 字符串头文件。主要定义了一些有关字符串操作的嵌入函数。
// 主要使用了其中的memset()函数。
#include // 调度程序头文件,定义了任务结构task_struct、初始任务0 的数据,
// 还有一些有关描述符参数设置和获取的嵌入式汇编函数宏语句。
#include // 内核头文件。含有一些内核常用函数的原形定义。
//// 将指定地址(addr)处的一块内存清零。嵌入汇编程序宏。
// 输入:eax = 0,ecx = 数据块大小BLOCK_SIZE/4,edi = addr。
#define clear_block(addr) \
__asm__( “cld\n\t“ \ // 清方向位。
“rep\n\t“ \ // 重复执行存储数据(0)。
“stosl“::“a“ (0) “c“ (BLOCK_SIZE / 4) “D“ ((long) (addr)):“cx“ “di“)
//// 置位指定地址开始的第nr 个位偏移处的比特位(nr 可以大于32!)。返回原比特位(0 或1)。
// 输入:%0 - eax(返回值),%1 - eax(0);%2 - nr,位偏移值;%3 - (addr),addr 的内容。
#define set_bit(nraddr) ({\
register int res __asm__( “ax“); \
__asm__ __volatile__( “btsl %2%3\n\tsetb %%al“: \
“=a“ (res): ““ (0) “r“ (nr) “m“ (*(addr))); \
res;})
//// 复位指定地址开始的第nr 位偏移处的比特位。返回原比特位的反码(1 或0)。
// 输入:%0 - eax(返回值),%1 - eax(0);%2 - nr,位偏移值;%3 - (addr),addr 的内容。
#define clear_bit(nraddr) ({\
register int res __asm__( “ax“); \
__asm__ __volatile__( “btrl %2%3\n\tsetnb %%al“: \
“=a“ (res): ““ (0) “r“ (nr) “m“ (*(addr))); \
res;})
//// 从addr 开始寻找第1 个0 值比特位。
// 输入:%0 - ecx(返回值);%1 - ecx(0);%2 - esi(addr)。
// 在addr 指定地址开始的位图中寻找第1 个是0 的比特位,并将其距离addr 的比特位偏移值返回。
#define find_first_zero(addr) ({ \
int __res; \
__asm__( “cld\n“ \ // 清方向位。
“1:\tlodsl\n\t“ \ // 取[esi]??eax。
“notl %%eax\n\t“ \ // eax 中每位取反。
“bsfl %%eax%%edx\n\t“ \ // 从位0 扫描eax 中是1 的第1 个位,其偏移值??edx。
“je 2f\n\t“ \ // 如果eax 中全是0,则向前跳转到标号2 处(40 行)。
“addl %%edx%%ecx\n\t“ \ // 偏移值加入ecx(ecx 中是位图中首个是0 的比特位的偏移值)
“jmp 3f\n“ \ // 向前跳转到标号3 处(结束)。
“2:\taddl $32%%ecx\n\t“ \ // 没有找到0 比特位,则将ecx 加上1 个长字的位偏移量32。
“cmpl $8192%%ecx\n\t“ \ // 已经扫描了8192 位(1024 字节)了吗?
“jl 1b\n“ \ // 若还没有扫描完1 块数据,则向前跳转到标号1 处,继续。
“3:“ \ // 结束。此时ecx 中是位偏移量。
: “=c“ (__res): “c“ (0) “S“ (addr):“ax“ “dx“ “si“);
__res;
}
)
//// 释放设备dev 上数据区中的逻辑块block。
// 复位指定逻辑块block 的逻辑块位图比特位。
// 参数:dev 是设备号,block 是逻辑块号(盘块号)。
void free_block (int dev int block)
{
struct super_block *sb;
struct buffer_head *bh;
// 取指定设备dev 的超级块,如果指定设备不存在,则出错死机。
if (!(sb = get_super (dev)))
panic (“trying to free block on nonexistent device“);
// 若逻辑块号小于首个逻辑块号或者大于设备上总逻辑块数,则出错,死机。
if (block < sb->s_firstdatazone || block >= sb->s_nzones)
panic (“trying to free block not in datazone“);
// 从hash 表中寻找该块数据。若找到了则判断其有效性,并清已修改和更新标志,释放该数据块。
// 该段代码的主要用途是如果该逻辑块当前存在于高速缓冲中,就释放对应的缓冲块。
bh = get_hash_table (dev block);
if (bh)
{
if (bh->b_count != 1)
{
printk (“trying to free block (%04x:%d) count=%d\n“
dev block bh->b_count);
return;
}
bh->b_dirt = 0; // 复位脏(已修改)标志位。
bh->b_uptodate = 0; // 复位更新标志。
brelse (bh);
}
// 计算block 在数据区开始算起的数据逻辑块号(从1 开始计数)。然后对逻辑块(区块)位图进行操作,
// 复位对应的比特位。若对应比特位原来即是0,则出错,死机。
block -= sb->s_firstdatazone - 1; // block = block - ( -1) ;
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 12790 2004-01-08 21:38 带中文注释的 linux 0.11 源代码\boot\bootsect.s
文件 13541 2004-01-08 21:38 带中文注释的 linux 0.11 源代码\boot\head.s
文件 12721 2004-01-08 21:38 带中文注释的 linux 0.11 源代码\boot\setup.s
文件 8658 2004-09-02 13:12 带中文注释的 linux 0.11 源代码\fs\bitmap.c
文件 4046 2004-09-02 13:12 带中文注释的 linux 0.11 源代码\fs\block_dev.c
文件 18130 2004-09-02 13:12 带中文注释的 linux 0.11 源代码\fs\buffer.c
文件 4193 2004-09-02 13:12 带中文注释的 linux 0.11 源代码\fs\char_dev.c
文件 19351 2004-09-02 13:12 带中文注释的 linux 0.11 源代码\fs\exec.c
文件 3413 2004-09-02 13:12 带中文注释的 linux 0.11 源代码\fs\fcntl.c
文件 4933 2004-09-02 13:12 带中文注释的 linux 0.11 源代码\fs\file_dev.c
文件 209 2004-09-02 13:12 带中文注释的 linux 0.11 源代码\fs\file_table.c
文件 15283 2004-09-02 13:12 带中文注释的 linux 0.11 源代码\fs\inode.c
文件 1987 2004-09-02 13:12 带中文注释的 linux 0.11 源代码\fs\ioctl.c
文件 6964 2004-01-08 21:45 带中文注释的 linux 0.11 源代码\fs\Makefile
文件 38095 2004-09-02 13:12 带中文注释的 linux 0.11 源代码\fs\namei.c
文件 10243 2004-09-02 13:12 带中文注释的 linux 0.11 源代码\fs\open.c
文件 5552 2004-09-02 13:12 带中文注释的 linux 0.11 源代码\fs\pipe.c
文件 6003 2004-09-02 13:12 带中文注释的 linux 0.11 源代码\fs\read_write.c
文件 2756 2004-09-02 13:12 带中文注释的 linux 0.11 源代码\fs\stat.c
文件 13896 2004-09-02 13:12 带中文注释的 linux 0.11 源代码\fs\super.c
文件 2521 2004-09-02 13:12 带中文注释的 linux 0.11 源代码\fs\truncate.c
文件 8415 2004-09-02 13:14 带中文注释的 linux 0.11 源代码\include\a.out.h
文件 772 2004-09-02 13:14 带中文注释的 linux 0.11 源代码\include\asm\io.h
文件 1057 2004-01-08 22:13 带中文注释的 linux 0.11 源代码\include\asm\memory.h
文件 2556 2004-09-02 13:14 带中文注释的 linux 0.11 源代码\include\asm\segment.h
文件 4176 2004-09-02 13:14 带中文注释的 linux 0.11 源代码\include\asm\system.h
文件 589 2004-09-02 13:14 带中文注释的 linux 0.11 源代码\include\const.h
文件 1725 2004-09-02 13:14 带中文注释的 linux 0.11 源代码\include\ctype.h
文件 2356 2004-09-02 13:14 带中文注释的 linux 0.11 源代码\include\errno.h
文件 3380 2004-09-02 13:14 带中文注释的 linux 0.11 源代码\include\fcntl.h
............此处省略85个文件信息
相关资源
- uboot到linux logo显示不间断 补丁
- UNIX/LINUX编程实践教程的源码
- Linux任务管理器
- linux应用层的华容道游戏源代码
- ubuntu9.10 可加载内核模块和字符设备驱
- MP3文件ID3v2ID3v2APEv2标签读取
- 操作系统实验——虚存管理实验
- linux下的发包工具sendip
- 尚观培训linux许巍关于c 的笔记和讲义
- 尚观培训linux董亮老师关于数据结构的
- linux 线程池源码 c 版
- linux C 电梯程序练习
- linux下用多进程同步方法解决生产者
- Linux 操作系统实验(全)
- Linux From Scratch 中文手册
- linux 网络实验 ftp程序
- Linux命令大全离线版&在线版
- 操作系统共享内存实验
- dos 下运行Linux 命令--gnu_utils
- linux 0.12内核源代码
- linux简易shell C实现
- linux实验报告及心得体会
- 基于GTK的Linux环境下的简易任务管理器
- linux扫雷游戏代码
- CAN Linux驱动代码
- Linux系统教材
- intel 82579LM 网卡驱动Linux系统版 v1.9.
- SA1110处理器掌上电脑液晶显示器设计
- 基于Linux的串口服务器设计
- Windows下访问LINUX的利器-SSH
评论
共有 条评论