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

📄 def_hd.h

📁 小型操作系统,以VC为开发环境,需要boachs调试
💻 H
字号:
/***************************************************************************
**     File name   : Def_hd.h
**     Author      : x.cheng
**     Create date :
**
**	   Comment:
**        硬盘驱动头文件
**
**     Revisions:
**     $Log: def_hd.h,v $
**     Revision 1.1.1.1  2005/07/27 06:53:15  x.cheng
**     add into repositories
**
**
***************************************************************************/
#ifndef __JCINX_DRV_INC_HD_H__
#define __JCINX_DRV_INC_HD_H__

//#define _DEBUG_HD__

#define SECTOR_SIZE	512
#define HD_MBR_SECTOR 0
/*********************AT-硬盘控制寄存器*******************/
#define HD_DATA		0x1f0	/* _CTL配置控制寄存器 when writing */
#define HD_ERROR	0x1f1	/* 参考错误位 */
#define HD_NSECTOR	0x1f2	/* 读写的扇区数 */
#define HD_SECTOR	0x1f3	/* 开始扇区 */
#define HD_LCYL		0x1f4	/* 开始柱面 */
#define HD_HCYL		0x1f5	/* 开始柱面的高字节 */
#define HD_CURRENT	0x1f6	/* 101dhhhh , d=drive, hhhh=head */
#define HD_STATUS	0x1f7	/* read=状态位 , write=命令寄存器 */
#define HD_PRECOMP HD_ERROR	/* same io address, read=error, write=precomp */
#define HD_COMMAND HD_STATUS	/* 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 WIN_RESTORE		0x10	/* 驱动器重新校正 */
#define WIN_READ		0x20	/* 读扇区 */
#define WIN_WRITE		0x30	/* 写扇区 */
#define WIN_VERIFY		0x40	/* 扇区校验 */
#define WIN_FORMAT		0x50	/* 格式化磁道 */
#define WIN_INIT		0x60	/* 控制器初始化 */
#define WIN_SEEK 		0x70	/* 寻道 */
#define WIN_DIAGNOSE	0x90	/* 控制器诊断 */
#define WIN_SPECIFY		0x91	/* 建立驱动器参数 */

#define WIN_READINFO	 0xec	/* 读硬盘信息 */

/***********错误寄存器(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	/* ? */

///////////////////////////////////////////////////////
/************** 记录硬盘硬件信息的结构******************/
typedef struct HardDiskInfo_Struct{
	unsigned short uiCylinders;
	unsigned char  ucHeads;
	unsigned short uiDummy1;
	unsigned short uiCompensatePreWrites;
	unsigned char  ucDummy2;
	unsigned char  ucCtrlByte;
	unsigned char  aucDummy3[3];
	unsigned short uiZones;
	unsigned char  ucSectorsPerTrack;
	unsigned char  ucDummy4;
}ts_HardDiskInfo;

/************** 记录硬盘分区信息的结构******************/
typedef struct PartitionInfo_Struct{
	unsigned char ucName;		/* C, D, E, ...*/
	unsigned char ucBootIndecator;	/*0x80 - active*/
	unsigned char ucStartHead;
	unsigned char ucStartSector;	/* 2 hight bits of cylinder #*/
	unsigned char ucStartCylinder;  /* low bits of cylinder #*/
	unsigned char ucSysIndecator;
	unsigned char ucEndHead;
	unsigned char ucEndSector;	/* # 2 hight bits of cylinder */
	unsigned char ucEndCylinder;    /* # low bits of cylinder */
	unsigned long ulPhyStartSector;	/*LBA(从0算起的分区表的绝对起始扇区)*/
	unsigned long ulSectors;	/* 分区的总扇区数目 */
}ts_PartitionInfo;


#endif /* end of __JCINX_DRV_INC_HD_H__ */

⌨️ 快捷键说明

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