📄 ide.h
字号:
#ifndef __IDE_H__
#define __IDE_H__
#ifdef __cplusplus
extern "C" {
#endif
#define SECTOR_BYTES 512
#define SECTOR_WORDS (SECTOR_BYTES/2)
#define PRIMARY 0
#define SLAVE 1
#define MAKE_LBA(d, c, h, s) ( (unsigned long) \
( ((c & 0xffff) << 16) | ((d & 0x1) << 12) \
| ((h & 0xf) << 8) | (s & 0xff) ) )
struct DriveId
{
unsigned short cylinders;
unsigned short heads;
unsigned short bytes_per_track;
unsigned short bytes_per_sector;
unsigned short sectors_per_track;
unsigned short vendor_id;
unsigned char serial_number[20+2];
unsigned char firmware_version[8+2];
unsigned char model_number[40+2];
unsigned short minimum_pio;
unsigned short minimum_dma;
};
struct Sector
{
unsigned char data[SECTOR_BYTES];
};
enum DrvErr
{
DRV_ERR_NOERR = 0x01, /* No error detected. */
DRV_ERR_FORMAT = 0x02, /* Formatter device error. */
DRV_ERR_BUFFER = 0x03, /* Sector buffer error. */
DRV_ERR_ECC = 0x04, /* ECC circuitry error. */
DRV_ERR_CONTROLLER = 0x05, /* Controller microprocessor error. */
DRV_ERR_DRIVE1 = 0x80 /* 8X Drive 1 failed. */
};
#define ERR_NOERR 0x0
#define ERR_AMNF 0x1
#define ERR_TKONF 0x2
#define ERR_ABRT 0x4
#define ERR_IDNF 0x10
#define ERR_UNC 0x40
#define ERR_BBK 0x80
extern int IDE_Init(int drive);
extern unsigned int IDE_Diagnostics(int drive, enum DrvErr *err);
extern unsigned int IDE_Identification(int drive, struct DriveId *id);
extern unsigned int IDE_ReadSectors(unsigned long lba,
struct Sector *buf, unsigned char count);
extern unsigned int IDE_WriteSectors(unsigned long lba,
const struct Sector *buf, unsigned char count);
extern const char* IDE_GetStatusString(unsigned long status);
extern const char* IDE_GetErrorString(enum DrvErr err);
#ifdef __cplusplus
}
#endif
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -