资源简介
斯坦福大学课程设计pintos-project3满分例程,ubuntu16.04 qemu 满分(修改userprog/Make.vars 默认qemu)。注释不多,部分内容参考github。代码仅供参考,请勿直接搬运。

代码片段和文件信息
#include “devices/block.h“
#include
#include
#include
#include “devices/ide.h“
#include “threads/malloc.h“
/* A block device. */
struct block
{
struct list_elem list_elem; /* Element in all_blocks. */
char name[16]; /* Block device name. */
enum block_type type; /* Type of block device. */
block_sector_t size; /* Size in sectors. */
const struct block_operations *ops; /* Driver operations. */
void *aux; /* Extra data owned by driver. */
unsigned long long read_cnt; /* Number of sectors read. */
unsigned long long write_cnt; /* Number of sectors written. */
};
/* List of all block devices. */
static struct list all_blocks = LIST_INITIALIZER (all_blocks);
/* The block block assigned to each Pintos role. */
static struct block *block_by_role[BLOCK_ROLE_CNT];
static struct block *list_elem_to_block (struct list_elem *);
/* Returns a human-readable name for the given block device
TYPE. */
const char *
block_type_name (enum block_type type)
{
static const char *block_type_names[BLOCK_CNT] =
{
“kernel“
“filesys“
“scratch“
“swap“
“raw“
“foreign“
};
ASSERT (type < BLOCK_CNT);
return block_type_names[type];
}
/* Returns the block device fulfilling the given ROLE or a null
pointer if no block device has been assigned that role. */
struct block *
block_get_role (enum block_type role)
{
ASSERT (role < BLOCK_ROLE_CNT);
return block_by_role[role];
}
/* Assigns BLOCK the given ROLE. */
void
block_set_role (enum block_type role struct block *block)
{
ASSERT (role < BLOCK_ROLE_CNT);
block_by_role[role] = block;
}
/* Returns the first block device in kernel probe order or a
null pointer if no block devices are registered. */
struct block *
block_first (void)
{
return list_elem_to_block (list_begin (&all_blocks));
}
/* Returns the block device following BLOCK in kernel probe
order or a null pointer if BLOCK is the last block device. */
struct block *
block_next (struct block *block)
{
return list_elem_to_block (list_next (&block->list_elem));
}
/* Returns the block device with the given NAME or a null
pointer if no block device has that name. */
struct block *
block_get_by_name (const char *name)
{
struct list_elem *e;
for (e = list_begin (&all_blocks); e != list_end (&all_blocks);
e = list_next (e))
{
struct block *block = list_entry (e struct block list_elem);
if (!strcmp (name block->name))
return block;
}
return NULL;
}
/* Verifies that SECTOR is a valid offset within BLOCK.
Panics if not. */
static void
check_sector (struct block *block block_sector_t sector)
{
if (sector >= block->size)
{
/* We do not use ASSERT because we want to panic here
regardless of whether NDEBUG is defined. */
PANIC (“Access past end of device %s
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2019-04-02 08:48 src\
文件 34 2019-04-02 08:48 src\.gitignore
文件 4621 2019-04-02 08:48 src\LICENSE
文件 1859 2019-04-02 08:48 src\Make.config
文件 628 2019-04-02 08:48 src\Makefile
文件 3928 2019-04-02 08:48 src\Makefile.build
文件 333 2019-04-02 08:48 src\Makefile.kernel
文件 1551 2019-04-02 08:48 src\Makefile.userprog
目录 0 2019-04-02 08:48 src\devices\
文件 6214 2019-04-02 08:48 src\devices\block.c
文件 2370 2019-04-02 08:48 src\devices\block.h
文件 15400 2019-04-02 08:48 src\devices\ide.c
文件 95 2019-04-02 08:48 src\devices\ide.h
文件 1029 2019-04-02 08:48 src\devices\input.c
文件 223 2019-04-02 08:48 src\devices\input.h
文件 2792 2019-04-02 08:48 src\devices\intq.c
文件 1429 2019-04-02 08:48 src\devices\intq.h
文件 5517 2019-04-02 08:48 src\devices\kbd.c
文件 145 2019-04-02 08:48 src\devices\kbd.h
文件 11102 2019-04-02 08:48 src\devices\partition.c
文件 144 2019-04-02 08:48 src\devices\partition.h
文件 2894 2019-04-02 08:48 src\devices\pit.c
文件 161 2019-04-02 08:48 src\devices\pit.h
文件 3725 2019-04-02 08:48 src\devices\rtc.c
文件 96 2019-04-02 08:48 src\devices\rtc.h
文件 6557 2019-04-02 08:48 src\devices\serial.c
文件 215 2019-04-02 08:48 src\devices\serial.h
文件 3134 2019-04-02 08:48 src\devices\shutdown.c
文件 544 2019-04-02 08:48 src\devices\shutdown.h
文件 2074 2019-04-02 08:48 src\devices\speaker.c
文件 169 2019-04-02 08:48 src\devices\speaker.h
............此处省略613个文件信息
相关资源
- FTP课程设计(服务端+客户端)
- 高频电子线路课程设计报告收音机
- 直流稳压电源的课程设计、安装及调
- EDA课程设计_密码锁
- 单片机课程设计 篮球计分器
- 数据结构课程设计 6 1 彩票系统
- 端口扫描课程设计详细的报告
- 步进电机课程设计(个人设计)
- 校园网络规划与设计课程设计
- 编译原理课程设计:词法语法编译器
-
simuli
nk 课程设计 qpsk - 武汉理工大学 单片机课程设计 16*16点
- 数据库VFP课程设计
- 分页系统模拟实验 操作系统 课程设
- 模拟段页式虚拟存储管理中地址转换
- 硬件课程设计—流水灯(quartus软件
- 超市收银系统eclipse access大学课程设计
- 航空订票系统_数据结构课程设计
- c 课程设计 职工信息管理系统
- 汇编语言,课程设计,红绿灯
- 机床液压系统课程设计卧式钻床动力
- 课程设计蔬菜大棚自动控制系统,包
- 密码学课程设计:DES加密解密算法的
- 操作系统课程设计完整版
- 磁盘调度算法的模拟实现及对比
- PL/0功能扩充break功能
- 数据库课程设计以及指导思想
- ATM自动取款机系统的分析与设计
- 留言板课程设计 报告加设计
- 数据结构课程设计——图书管理系统
评论
共有 条评论