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

📄 def_ata.h

📁 小型操作系统,以VC为开发环境,需要boachs调试
💻 H
字号:
/***************************************************************************
**     File name   : def_ata.h
**     Author      : x.cheng
**     Create date :
**
**	   Comment:
**        ata标准定义。
**        primary host adapter at I/O address 1FX/3FX 
**        secondary host adapter at I/O adress 17X/37X
**        Each host adapter can have up to two hard drives MASTER/SLAVED off it.
**        1FX  0001 1111 XXXX  Primary Command Registers
**        3FX  0011 1111 XXXX  Primary Control Registers
**
**        17X  0001 0111 XXXX  Alternate Command Registers
**        37X  0011 0111 XXXX  Alternate Control Registers
**
**        I/O Ports //
**        1FX and 17X use same command so we'll use they as a base port + command offset
**
**        For a very complete documentation of these ports and all commands you
**        must read T13 Documentation for ATA 1-2-3-4 etc. etc.,(for example you
**        can read (www.T13.org) d1153r18.pdf (330pag. all on ATA-4)
**
**     Revisions:
**     $Log: def_ata.h,v $
**     Revision 1.1  2005/08/14 09:50:23  x.cheng
**     add into repositories
**
**     Revision 1.2  2005/08/11 14:42:55  x.cheng
**     ide channel 1 supurted, attach cdrom to channel 1, master
**
**     Revision 1.1  2005/08/09 16:13:12  x.cheng
**     add into repositories
**
**
***************************************************************************/
#ifndef __DEF_ATA_H__
#define __DEF_ATA_H__


#define IDE_CHANNEL_0	0
#define IDE_CHANNEL_1	1
////////////////////////////////////////////////////////
//ata device register port
#define ATA_PRIMARY_BASE		0x1f0
#define ATA_PRIMARY_DATA		0x1f0	/* _CTL配置控制寄存器 when writing */
#define ATA_PRIMARY_ERROR		0x1f1	/* 参考错误位 */
#define ATA_PRIMARY_NSECTOR		0x1f2	/* 读写的扇区数 */
#define ATA_PRIMARY_SECTOR		0x1f3	/* 开始扇区 */
#define ATA_PRIMARY_LCYL		0x1f4	/* 开始柱面 */
#define ATA_PRIMARY_HCYL		0x1f5	/* 开始柱面的高字节 */
#define ATA_PRIMARY_CURRENT		0x1f6	/* 101dhhhh , d=drive, hhhh=head */
#define ATA_PRIMARY_STATUS		0x1f7	/* read=状态位 , write=命令寄存器 */
#define ATA_PRIMARY_PRECOMP ATA_PRIMARY_ERROR	/* same io address, read=error, write=precomp */
#define ATA_PRIMARY_COMMAND ATA_PRIMARY_STATUS	/* same io address, read=status, write=cmd */

#define ATA_PRIMARY_CMD			0x3f6	/*控制起存器端口*/


////////////////////////////////////////////////////////
//ata device status
#define ERR_STATUS		0x01	/* 命令执行错误 */
#define ATAPI_STATUS_CHECK	0x01	// check (ATAPI)
#define INDEX_STATUS	0x02	/* 收到索引 */
#define ECC_STATUS		0x04	/* ECC校验错 */
#define DRQ_STATUS		0x08	/* 请求服务 */
#define SEEK_STATUS		0x10	/* 寻道结束 */
#define WRERR_STATUS	0x20	/* 驱动器故障 */
#define READY_STATUS	0x40	/* 驱动器就绪 */
#define BUSY_STATUS		0x80    /* 控制器忙碌 */

////////////////////////////////////////////////////////
//ata device error
#define NO_SENSE			0x00
#define RECOVERED_ERROR		0x01
#define NOT_READY			0x02
#define UNIT_ATTENTION		0x06

////////////////////////////////////////////////////////
//atapi device register port, second adapter
#if(0)
#define ATAPI_PRIMARY_BASE		0x1f0
#define ATAPI_PRIMARY_DATA		0x1f0	/* _CTL配置控制寄存器 when writing */
#define ATAPI_PRIMARY_FEATURE	0x1f1	/*  */
#define ATAPI_PRIMARY_ERROR		0x1f1	/* 参考错误位 */
#define ATAPI_PRIMARY_IRR		0x1f2	/*  */
#define ATAPI_PRIMARY_SAMTAG	0x1f3	/*  */
#define ATAPI_PRIMARY_LOCYL		0x1f4	/* 开始柱面 */
#define ATAPI_PRIMARY_HICYL		0x1f5	/* 开始柱面的高字节 */
#define ATAPI_PRIMARY_CURRENT	0x1f6	/* 101dhhhh , d=drive(0,1), hhhh=head */
#define ATAPI_PRIMARY_STATUS	0x1f7	/* read=状态位 , write=命令寄存器 */
#define ATAPI_PRIMARY_PRECOMP ATAPI_PRIMARY_ERROR	/* same io address, read=error, write=precomp */
#define ATAPI_PRIMARY_COMMAND ATAPI_PRIMARY_STATUS	/* same io address, read=status, write=cmd */

#define ATAPI_PRIMARY_CMD		0x3f6	/*控制起存器端口*/
#endif

#define ATAPI_PRIMARY_BASE		0x170
#define ATAPI_PRIMARY_DATA		0x170	/* _CTL配置控制寄存器 when writing */
#define ATAPI_PRIMARY_FEATURE	0x171	/*  */
#define ATAPI_PRIMARY_ERROR		0x171	/* 参考错误位 */
#define ATAPI_PRIMARY_IRR		0x172	/*  */
#define ATAPI_PRIMARY_SAMTAG	0x173	/*  */
#define ATAPI_PRIMARY_LOCYL		0x174	/* 开始柱面 */
#define ATAPI_PRIMARY_HICYL		0x175	/* 开始柱面的高字节 */
#define ATAPI_PRIMARY_CURRENT	0x176	/* 101dhhhh , d=drive(0,1), hhhh=head */
#define ATAPI_PRIMARY_STATUS	0x177	/* read=状态位 , write=命令寄存器 */
#define ATAPI_PRIMARY_PRECOMP ATAPI_PRIMARY_ERROR	/* same io address, read=error, write=precomp */
#define ATAPI_PRIMARY_COMMAND ATAPI_PRIMARY_STATUS	/* same io address, read=status, write=cmd */

#define ATAPI_PRIMARY_CMD		0x376	/*控制起存器端口*/

////////////////////////////////////////////////////////
//atapi command
#define CMD_ATAPI_PACKET		0xA0
#define CMD_TEST_UNIT_READY		0x00
#define CMD_READ_10				0x28
#define CMD_ATAPI_RESET			0x08
#define CMD_READ_CDVD_CAPACITY	0x25
#define CMD_START_STOP_UNIT		0x1B
#define CMD_READ_TOC_PMA_ATIP	0x43
#define CMD_PLAY_AUDIO_MSF		0x47
#define CMD_PAUSE_RESUME		0x4B
#define CMD_READ_SUB_CHANNEL	0x42
#define CMD_STOP_AUDIO			0x4E



#define IDLE			0
#define DEV_TIMEOUT		1
#define BUSY			2
#define ERROR			3

#endif /* end of  __DEF_ATA_H__ */

⌨️ 快捷键说明

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