/*
* This file contains some defines for the AT-hd-controller.
* Various sources. Check out some definitions (see comments with
* a ques).
*/
/*
* ļһЩAT Ӳ̿Ķ塣Ըϡ֤ĳЩ
* 壨ʺŵעͣ
*/
#ifndef _HDREG_H
#define _HDREG_H

/* Hd controller regs. Ref: IBM AT Bios-listing */
/* Ӳ̿Ĵ˿ڡμIBM AT Bios  */
#define HD_DATA 0x1f0		/* _CTL when writing */
#define HD_ERROR 0x1f1		/* see err-bits */
#define HD_NSECTOR 0x1f2	/* nr of sectors to read/write */
#define HD_SECTOR 0x1f3		/* starting sector */
#define HD_LCYL 0x1f4		/* starting cylinder */
#define HD_HCYL 0x1f5		/* high byte of starting cyl */
#define HD_CURRENT 0x1f6	/* 101dhhhh , d=drive, hhhh=head */
#define HD_STATUS 0x1f7		/* see status-bits */
#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		// ƼĴ˿ڡ

/* Bits of HD_STATUS */
/* Ӳ״̬ĴλĶ(HD_STATUS) */
#define ERR_STAT 0x01		// ִд
#define INDEX_STAT 0x02		// յ
#define ECC_STAT 0x04 /* Corrected error */	// ECC У
#define DRQ_STAT 0x08		// 
#define SEEK_STAT 0x10		// Ѱ
#define WRERR_STAT 0x20		// ϡ
#define READY_STAT 0x40		// ׼ã
#define BUSY_STAT 0x80		// æµ

/* Values for HD_COMMAND */
/* ӲֵHD_CMD */
#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	// 

/* Bits for HD_ERROR */
/* Ĵλĺ壨HD_ERROR */
// ִпʱʱĲֱͬг
// ==================================================
// ʱ ʱ
// --------------------------------------------------
// 0x01 ޴ ݱ־ʧ
// 0x02  ŵ0 
// 0x03 
// 0x04 ECC  
// 0x05 ƴ
// 0x10 ID δҵ
// 0x40 ECC 
// 0x80 
//---------------------------------------------------
#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		/* ? */

// Ӳ̷ṹμбϢ
struct partition
{
  unsigned char boot_ind;	/* 0x80 - active (unused) */
  unsigned char head;		/* ? */
  unsigned char sector;		/* ? */
  unsigned char cyl;		/* ? */
  unsigned char sys_ind;	/* ? */
  unsigned char end_head;	/* ? */
  unsigned char end_sector;	/* ? */
  unsigned char end_cyl;	/* ? */
  unsigned int start_sect;	/* starting sector counting from 0 */
  unsigned int nr_sects;	/* nr of sectors in partition */
};

#endif
