📄 hd.h
字号:
// Kernel
// Default Driver IDE
#ifndef __HD_H
#define __HD_H
#include <devices.h>
// HD Ports
#define IDE_PRIMARY 0x01f0
#define IDE_SECONDARY 0x0170
#define HDP_PRI_BASE 0x01f0
#define HDP_SEC_BASE 0x0170
#define HDPA_DATA 0x0000
#define HDPA_ERR 0x0001
#define HDPA_WPC4 0x0001
#define HDPA_SECCNT 0x0002
#define HDPA_SECNUM 0x0003
#define HDPA_CYLLO 0x0004
#define HDPA_CYLHI 0x0005
#define HDPA_HEAD 0x0006
#define HDPA_STATUS 0x0007
#define HDPA_CMD 0x0007
#define HDP_PRI(a) (HDP_PRI_BASE+(a))
#define HDP_SEC(a) (HDP_SEC_BASE+(a))
#define HDP_CTL_PRI 0x03f6
#define HDP_CTL_SEC 0x0376
typedef struct _DRIVE
{
int port_base;
int drive_id;
_u32 n_cylinders;
_u32 n_heads;
_u32 n_sectors;
_u32 n_LBAsectors;
_u32 capbilities;
_u32 n_multimax;
_u32 n_dwtrans;
char serial_number[24];
char model_number[44];
} DRIVE;
#define DRIVE_VALID(drv) ((drv).port_base==IDE_PRIMARY || (drv).port_base==IDE_SECONDARY)
// HD capbilities
#define HDC_LBA 0x0200
#define HDC_DMA 0x0100
// HD hardware error bits
#define HDE_DAM 0x0001 // DAM not found (always 0 for CP-3022)
#define HDE_TRACK0 0x0002 // couldn't find track 0
#define HDE_ABORT 0x0004 // command aborted prematurely
#define HDE_ID 0x0010 // ID found
#define HDE_ECC 0x0040 // uncorrectable ECC error
#define HDE_BAD 0x0080 // bad block detected
// HD software defined errors
#define HDE_INVALID 0x0100 // invalidate drive
#define HDE_ADDRESS 0x0200 // incorrect address specified
#define HDE_READY 0x0400 // controller not ready
#define HDE_TIMEOUT 0x0800 // operation time out
#define HDE_NOTDONE 0x1000 // job not complete
// Device parameters
typedef struct _HDDEVICE
{
int drive;
int partition;
int type;
char magic[16];
_u32 base, length; // base / length in sector
} HDDEVICE;
#ifdef __cplusplus
extern "C"
#endif
long __syscall drvDefaultIDE(_u32, _u32, _u32);
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -