⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hd.h

📁 一个用于学习的操作系统
💻 H
字号:
/* * This file contains some defines for the AT-hd-controller. * Various sources. Check out some definitions (see comments with * a ques). */#ifndef _HD_H#define _HD_H/* 硬盘控制器寄存器 */#define HD_DATA     0x1f0    /* 数据寄存器           扇区数据(读、写、格式化)        _CTL when writing */#define HD_ERROR    0x1f1    /* 错误寄存器(错误状态)    |  写前预补偿寄存器          see err-bits */#define HD_NSECTOR  0x1f2    /* 扇区寄存器           扇区数(读、写、检验、格式化)    nr of sectors to read/write */#define HD_SECTOR   0x1f3    /* 扇区号寄存器         起始扇区(读、写、检验)          starting sector */#define HD_LCYL     0x1f4    /* 柱面号寄存器         柱面号低字节(读、写、检验、格式化)  starting cylinder */#define HD_HCYL     0x1f5    /* 柱面号寄存器         柱面号高字节(读、写、检验、格式化)  high byte of starting cyl */#define HD_CURRENT  0x1f6    /* 驱动器/磁头寄存器    驱动器号/磁头号(101dhhhh, d=驱动器号, h=磁头号)101dhhhh , d=drive, hhhh=head */#define HD_STATUS   0x1f7    /* 主状态寄存器         |   命令寄存器                  see status-bits */#define HD_PRECOMP  HD_ERROR    /* ----                 |   硬盘控制寄存器              same io address, read=error, write=precomp */#define HD_COMMAND  HD_STATUS/* 数字输入寄存器(与1.2MB软盘合用)                      same io address, read=status, write=cmd */#define HD_CMD        0x3f6/* 硬盘控制器状态位 */      /*--------------------------*/#define ERR_STAT    0x01    /*  命令执行错误            */#define INDEX_STAT  0x02    /*  收到索引                */#define ECC_STAT    0x04    /*  ECC校验错               */#define DRQ_STAT    0x08    /*  请求服务,表示可传输数据*/#define SEEK_STAT   0x10    /*  寻道结束                */#define WRERR_STAT  0x20    /*  驱动器故障              */#define READY_STAT  0x40    /*  驱动器准备号(就绪)      */#define BUSY_STAT   0x80    /*  控制器忙碌              *//* 硬盘控制器命令值 */#define HD_RESTORE     0x10    /*  驱动器重新校正(复位)    */#define HD_READ        0x20    /*  读扇区                  */#define HD_WRITE       0x30    /*  写扇区                  */#define HD_VERIFY      0x40    /*  扇区检验                */#define HD_FORMAT      0x50    /*  格式化磁道              */#define HD_INIT        0x60    /*  控制器初始化            */#define HD_SEEK        0x70    /*  寻道                    */#define HD_DIAGNOSE    0x90    /*  控制器诊断              */#define HD_SPECIFY     0x91    /*  建立驱动器参数           *//* Bits for HD_ERROR */#define MARK_ERR    0x01    /* Bad address mark ? */#define TRK0_ERR    0x02    /* couldn't find track 0 */#define ABRT_ERR    0x04    /* ? */#define ID_ERR      0x10    /* ? */#define ECC_ERR     0x40    /* ? */#define    BBD_ERR     0x80    /* ? *///硬盘分区表结构struct partition {    unsigned char boot_ind;        /* 0x80 - active (unused) */    unsigned char head;            /* 分区起始磁头号 */    unsigned char sector;        /* 分区起始扇区号(位0-5)和起始柱面号高2位(位6-7) */    unsigned char cyl;            /* 分区其实柱面号低8位 */    unsigned char sys_ind;        /* 分区类型字节 0x0B-DOS;0X80-OLD MINIX;0X83-LINUX*/    unsigned char end_head;        /* 分区的结束磁头号 */    unsigned char end_sector;    /* 结束扇区号(位0-5)和结束柱面号高2位(位6-7) */    unsigned char end_cyl;        /* 结束柱面号低8位 */    unsigned int start_sect;    /* 分区起始物理扇区号 */    unsigned int nr_sects;        /* 分区占用的扇区数 */};typedef struct {    s32 hd_cyl;         //柱面数    s32 hd_head;        //磁头数    s32 hd_wpcom;       //写前预补偿柱面号    s32 hd_ctl;         //控制字节    s32 hd_lzone;       //磁头着陆区柱面号    s32 hd_sect;        //每磁道扇区数} HD_INFO;extern HD_INFO hd_info;struct hd_request_struct{    unsigned char mode;    unsigned char device;    unsigned int block;    char* buffer;};#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -