/* * $Id:$ */ #ifndef __ide_h__ #define __ide_h__ #include "io.h" struct Ide { Relative > data8; Relative > data16; Relative > errorCode; Relative > features; Relative > sectorCount; Relative > sectorNumber; Relative > cylinderLow; Relative > cylinderHigh; Relative > driveHead; Relative > status; Relative > command; Relative > altStatus; Relative > deviceCtrl; Relative > driveAddress; inline void sectorNumber32(unsigned v) { sectorNumber=v; cylinderLow=v>>8; cylinderHigh=v>>16; driveHead=0xe0|(v>>24); }; /* commands*/ static const U8 READ_SECT =0x20; static const U8 WRITE_SECT =0x30; static const U8 SEEK =0x70; static const U8 EXEC_DIAG =0x90; static const U8 INIT_DEV_PARAM=0x91; static const U8 SMART =0xB0; static const U8 READ_DMA =0xC8; static const U8 WRITE_DMA =0xCA; static const U8 CHECK_MODE =0xE5; static const U8 IDLE =0xE1; static const U8 IDLE_IMMEDIATE=0xE7; static const U8 FLUSH_CACHE =0xE7; static const U8 IDENTIFY =0xEC; static const U8 IDENTIFY_DMA =0xEE; static const U8 SET_FEATURES =0xEF; static const U8 READ_MAXLBA =0xF8; static const U8 featureCacheEnable=0x02; static const U8 featureCacheDisable=0x82; static const U8 featureXferMode=0x03; static const U8 featureAddressOffsetModeEnable=0x09; static const U8 AdvancedPowerManagementDisable=0x85; static const U8 ultraDmaMode=0x40; enum statusBits { busy=0x80, ready=0x40, fault=0x20, seekComplete=0x10, dataRequest=0x08, correctData=0x04, index=0x02, error=0x01 }; inline bool diskReady() { return (altStatus & (ready|busy)) == ready; } inline bool dataRequested() { return (altStatus & (dataRequest|busy)) == dataRequest; } inline bool pb() { return (altStatus & (error)) == error; } bool waitReady(int dcnt); void init(); inline void reset() { int dcnt=10; deviceCtrl=0x04; while(dcnt--) { U8 c; c=altStatus; } deviceCtrl=0; } bool verify(char *s=0); bool genericSet (U8 *req); bool genericGet (U8 *req); bool genericTo (U8 *req,U8*buf,U32 len); bool genericFrom(U8 *req,U8*buf,U32 len); U32 read(U32 sector,U32 qt,U16 *buf); U32 write(U32 sector,U32 qt,U16 *buf); bool seek(U32 sector); bool idle(U32 quintupleSec); bool idleImmediate(); #if 0 bool smart(int subCmd,int param=0,U16 *data=NULL,U16 *status=NULL); #endif bool identify(U8 *buf,int len); }; #define ide ((Ide* )0x1f0) #endif /* __ide_h__ */ /* * $Log:$ */