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

📄 ide_test.h

📁 源程序是在VisualDSP环境下开发出来的
💻 H
字号:
//ide_test.h

//define  Hard disk base address
#define IDE_BASE  0x08000000

/****************** Hard disk register address definition ****************/
/* (1) ATA data address */
#define DATA          *((volatile unsigned short *) (IDE_BASE + 0x0010))

/* (2) ATA status address */
#define ERRORREG      *((volatile unsigned char *) (IDE_BASE + 0x0011))
#define FEATURES      *((volatile unsigned char *) (IDE_BASE + 0x0011))

/* (3) ATA device sector */
#define SECTOR_COUNT  *((volatile unsigned char *) (IDE_BASE + 0x0012))
#define SECTOR_NUMBER *((volatile unsigned char *) (IDE_BASE + 0x0013))

/* (4) ATA cylinder information */
#define CYLINDER_LOW  *((volatile unsigned char *) (IDE_BASE + 0x0014))
#define CYLINDER_HIGH *((volatile unsigned char *) (IDE_BASE + 0x0015))

/* (5) ATA device information head */
#define DEV_HEAD      *((volatile unsigned char *) (IDE_BASE + 0x0016))
#define DEV_CONTROL   *((volatile unsigned char *) (IDE_BASE + 0x000E))
#define ATAALTSTATUS  *((volatile unsigned char *) (IDE_BASE + 0x000E))

/* (6) ATA status */
#define COMMAND       *((volatile unsigned char *) (IDE_BASE + 0x0017))
#define ATASTATUS     *((volatile unsigned char *) (IDE_BASE + 0x0017))

/* define operation code for setting ATA port address*/
#define READ_SECTORS    0x20	/* 0x 0010 0000 */
#define WRITE_SECTORS   0x30	/* 0x 0011 0000 */  
#define READ_MULTIPLE   0xC4	/* 0x 1100 0100 */
#define WRITE_MULTIPLE  0xC5	/* 0x 1100 0101 */
#define SET_MULTIPLE    0xC6	/* 0x 1100 0110 */
#define FLUSH_CACHE     0xE7	/* 0x 1110 0111 */
#define IDENTIFY_DEVICE 0xEC	/* 0x 1110 1100 */
#define SET_FEATURES    0xEF	/* 0x 1110 1111 */

/* ATASTATUS toggle bit */
#define ERRBIT  0x01	/* 0x 0000 0001 */ 
#define DRQBIT  0x08	/* 0x 0000 1000 */
#define DRDYBIT 0x40	/* 0x 0100 0000 */
#define BSYBIT  0x80	/* 0x 1000 0000 */

/* ATA lba mode for setting DEV_HEAD */
#define LBAMODE 0x40	/* 0x 0100 0000 */


/* while{} loop times : Timeouts for waiting for device ready signals*/
#define  LOOPTIME	1000000

struct PartitionTable
{
	unsigned char BootId;
	unsigned char PartitionType;
	unsigned int PartitionFirstSector;
	unsigned int PartitionSectorNum;
};

struct BPBTable
{
	unsigned short BytePerSector;
	unsigned char SectorPerGroup;
	unsigned short SectorReserved;
	unsigned char FATNum;
	unsigned short SectorPerHead;
	unsigned short HeadNum;
	unsigned int SectorHide;
	unsigned int LogicTotalSector;
	unsigned int SectorPerFAT;
	unsigned int BeginGroup;
    unsigned int FSInfo;
	unsigned char SectorPerBOOT;
};

struct FileReg
{
	unsigned char FileName[8];
	unsigned char FileExt[3];
	unsigned char Attrib;
	unsigned short LastTime;
	unsigned short LastDate;
	unsigned short BeginGroup;
	unsigned int FileLength;
};

struct FAT32LogicPartition
{
	struct BPBTable bpb;
	unsigned int FAT1BeginSector;
	unsigned int DATABeginSector;
};



⌨️ 快捷键说明

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