Main Page   Modules   Alphabetical List   Data Structures   File List   Data Fields   Globals   Related Pages  

Ide.h File Reference

IDE driver header. More...

#include <const.h>

Go to the source code of this file.

Data Structures

struct  BusMaster_Struct

Defines

#define IDE_DEBUG   1
#define CC_PRIMARY   0
#define CC_SECONDARY   1
#define CC_DATA   0
#define CC_ERR   1
#define CC_FEAT   1
#define CC_SECC   2
#define CC_SECN   3
#define CC_CYLL   4
#define CC_CYLH   5
#define CC_DEVH   6
#define CC_STAT   7
#define CC_CMD   7
#define CC_ASTAT   8
#define CC_DEVC   8
#define CC_ADDR   9
#define CC_DEV0   0
#define CC_DEV1   1
#define CC_DEVTYPE_NONE   0
#define CC_DEVTYPE_UNKN   1
#define CC_DEVTYPE_ATA   2
#define CC_DEVTYPE_ATAPI   3
#define GETBITB(Data, nBit)   ( ((byte) Data >> nBit) & 0x01 )
#define GETBITW(Data, nBit)   ( ((word) Data >> nBit) & 0x0001 )
#define GETBITD(Data, nBit)   ( ((dword) Data >> nBit) & 0x00000001 )
#define GETNIBBLEB(Data, nNibble)   ( ((byte) Data >> (nNibble<<2)) & 0x0F)
#define GETNIBBLEW(Data, nNibble)   ( ((word) Data >> (nNibble<<2)) & 0x000F)
#define GETNIBBLED(Data, nNibble)   ( ((dword) Data >> (nNibble<<2)) & 0x0000000F)
#define GETBYTEW(Data, nByte)   ( ((word) Data >> (nByte<<3)) & 0x00FF )
#define GETBYTED(Data, nByte)   ( ((dword) Data >> (nByte<<3)) & 0x000000FF)
#define GETWORDD(Data, nWord)   ( ((dword) Data >> (nWord<<4)) & 0x0000FFFF )
#define MAKEDWORDW(Word1, Word0)   ( (((dword) Word1 << 16) | (word) Word0) )
#define SWAPBYTEW(Data)   ( (GETBYTEW(Data,0) << 8) | (GETBYTEW(Data,1)) )
#define Bit2YesNo(Exp)   ( (char *) (Exp ? "YES" : "NO ") )
#define BMCR_IO_ADDR   0xFF00
#define BM_COMMAND_REG   0
#define BM_CR_MASK_READ   0x00
#define BM_CR_MASK_WRITE   0x08
#define BM_CR_MASK_START   0x01
#define BM_CR_MASK_STOP   0x00
#define BM_STATUS_REG   2
#define BM_SR_MASK_SIMPLEX   0x80
#define BM_SR_MASK_DRV1   0x40
#define BM_SR_MASK_DRV0   0x20
#define BM_SR_MASK_INT   0x04
#define BM_SR_MASK_ERR   0x02
#define BM_SR_MASK_ACT   0x01
#define BM_PRD_ADDR_LOW   4
#define BM_PRD_ADDR_HIGH   6

Typedefs

typedef BusMaster_Struct BusMaster_Struct

Functions

void ShowDeviceSubData (int Dev)
void ShowIdeSubData ()
int ScanDevice (int UseInterrupt)
int IdentifyDevice (int Dev)
void ShowDeviceDataRowName (char *Name, int Col)
void ShowDeviceDataRowValue (char *Name, int Col, char *Format, dword Value)
void ShowDeviceDataRowString (char *Name, int Col, char *Value)
void ShowDeviceDataRowSup (char *Name, int Col, byte Supported)
void ShowDeviceDataRowSupEn (char *Name, int Col, byte Supported, byte Enabled)
void ShowDeviceDataRowBitNum (word BitCode, byte StartFrom, byte EndTo, byte StartPrintNum)
void ShowDeviceData (int Dev, int Col)
void InitIde ()
int ReadSectorsLba (int Dev, uint64 Lba, int NumSect, word *Buffer, int UseInterrupt)
int WriteSectorsLba (int Dev, uint64 Lba, int NumSect, word *Buffer, int UseInterrupt)


Detailed Description

IDE driver header.

Author:
Luca Giovacchini
Date:
Last update: 2003-11-07
Note:
Copyright (©) 2003 Luca Giovacchini
This driver is based on Atadrv by Hale Landis but it is completely rearranged for the minirighi32.
IMPORTANT!!!
Here you can find what the driver should expose to the rest of the world.

Read IdeAta, IdeLow, IdeDebug and IdeTimer comments for better understand how this driver works. Implementing new ide commands is very very simple. All the major part of the Ata protocol is in "IdeAta.c". You only need to look for Ata-4 references, search for a command and see what protocol and what parameter you have to use. I have written specific subroutines to read, write and identify identifying devices, but they only simplify the interface for the more generic ata protocol.

I have already set inizialization of Ide Driver in main.c so you only need to:

Definition in file Ide.h.


Define Documentation

#define Bit2YesNo Exp       ( (char *) (Exp ? "YES" : "NO ") )
 

Definition at line 88 of file Ide.h.

#define BM_COMMAND_REG   0
 

Definition at line 140 of file Ide.h.

#define BM_CR_MASK_READ   0x00
 

Definition at line 141 of file Ide.h.

#define BM_CR_MASK_START   0x01
 

Definition at line 143 of file Ide.h.

#define BM_CR_MASK_STOP   0x00
 

Definition at line 144 of file Ide.h.

#define BM_CR_MASK_WRITE   0x08
 

Definition at line 142 of file Ide.h.

#define BM_PRD_ADDR_HIGH   6
 

Definition at line 155 of file Ide.h.

#define BM_PRD_ADDR_LOW   4
 

Definition at line 154 of file Ide.h.

#define BM_SR_MASK_ACT   0x01
 

Definition at line 152 of file Ide.h.

#define BM_SR_MASK_DRV0   0x20
 

Definition at line 149 of file Ide.h.

#define BM_SR_MASK_DRV1   0x40
 

Definition at line 148 of file Ide.h.

#define BM_SR_MASK_ERR   0x02
 

Definition at line 151 of file Ide.h.

#define BM_SR_MASK_INT   0x04
 

Definition at line 150 of file Ide.h.

#define BM_SR_MASK_SIMPLEX   0x80
 

Definition at line 147 of file Ide.h.

#define BM_STATUS_REG   2
 

Definition at line 146 of file Ide.h.

#define BMCR_IO_ADDR   0xFF00
 

Definition at line 139 of file Ide.h.

#define CC_ADDR   9
 

Definition at line 62 of file Ide.h.

#define CC_ASTAT   8
 

Definition at line 60 of file Ide.h.

#define CC_CMD   7
 

Definition at line 59 of file Ide.h.

#define CC_CYLH   5
 

Definition at line 56 of file Ide.h.

#define CC_CYLL   4
 

Definition at line 55 of file Ide.h.

#define CC_DATA   0
 

Definition at line 50 of file Ide.h.

#define CC_DEV0   0
 

Definition at line 64 of file Ide.h.

#define CC_DEV1   1
 

Definition at line 65 of file Ide.h.

#define CC_DEVC   8
 

Definition at line 61 of file Ide.h.

#define CC_DEVH   6
 

Definition at line 57 of file Ide.h.

#define CC_DEVTYPE_ATA   2
 

Definition at line 68 of file Ide.h.

#define CC_DEVTYPE_ATAPI   3
 

Definition at line 69 of file Ide.h.

#define CC_DEVTYPE_NONE   0
 

Definition at line 66 of file Ide.h.

#define CC_DEVTYPE_UNKN   1
 

Definition at line 67 of file Ide.h.

#define CC_ERR   1
 

Definition at line 51 of file Ide.h.

#define CC_FEAT   1
 

Definition at line 52 of file Ide.h.

#define CC_PRIMARY   0
 

Definition at line 46 of file Ide.h.

#define CC_SECC   2
 

Definition at line 53 of file Ide.h.

#define CC_SECN   3
 

Definition at line 54 of file Ide.h.

#define CC_SECONDARY   1
 

Definition at line 47 of file Ide.h.

#define CC_STAT   7
 

Definition at line 58 of file Ide.h.

#define GETBITB Data,
nBit       ( ((byte) Data >> nBit) & 0x01 )
 

Definition at line 75 of file Ide.h.

#define GETBITD Data,
nBit       ( ((dword) Data >> nBit) & 0x00000001 )
 

Definition at line 77 of file Ide.h.

#define GETBITW Data,
nBit       ( ((word) Data >> nBit) & 0x0001 )
 

Definition at line 76 of file Ide.h.

#define GETBYTED Data,
nByte       ( ((dword) Data >> (nByte<<3)) & 0x000000FF)
 

Definition at line 82 of file Ide.h.

#define GETBYTEW Data,
nByte       ( ((word) Data >> (nByte<<3)) & 0x00FF )
 

Definition at line 81 of file Ide.h.

#define GETNIBBLEB Data,
nNibble       ( ((byte) Data >> (nNibble<<2)) & 0x0F)
 

Definition at line 78 of file Ide.h.

#define GETNIBBLED Data,
nNibble       ( ((dword) Data >> (nNibble<<2)) & 0x0000000F)
 

Definition at line 80 of file Ide.h.

#define GETNIBBLEW Data,
nNibble       ( ((word) Data >> (nNibble<<2)) & 0x000F)
 

Definition at line 79 of file Ide.h.

#define GETWORDD Data,
nWord       ( ((dword) Data >> (nWord<<4)) & 0x0000FFFF )
 

Definition at line 83 of file Ide.h.

#define IDE_DEBUG   1
 

Definition at line 39 of file Ide.h.

#define MAKEDWORDW Word1,
Word0       ( (((dword) Word1 << 16) | (word) Word0) )
 

Definition at line 84 of file Ide.h.

#define SWAPBYTEW Data       ( (GETBYTEW(Data,0) << 8) | (GETBYTEW(Data,1)) )
 

Definition at line 85 of file Ide.h.


Typedef Documentation

typedef struct BusMaster_Struct BusMaster_Struct
 


Function Documentation

int IdentifyDevice int    Dev
 

Definition at line 145 of file Ide.c.

00146 {
00147         int i;
00148         word Buffer[256];
00149         word * Tmp;
00150         int Err=0;
00151         DeviceInfo_Struct * TmpDev=(DeviceInfo_Struct *) &(CurrentChannel->Device[Dev].Info);
00152 
00153         //kprintf("\n\rIdentify Dev=%d",Dev);
00154 
00155         // Be sure to reset the buffer
00156         memsetw( &Buffer, 0, 256);
00157 
00158         // Get 256 word of device info
00159         Err = IdePioDataInLba(Dev, HDC_CMD_IDENTIFY_DEVICE, 0, 0, 0L, (word *) &Buffer , 1, 0, TRUE);
00160         if ( Err ) 
00161                 return Err;
00162 
00163         // now the buffer contain raw word of info
00164         // we must translate it in a more readable struct
00165         //kprintf("\n\r Fill Structure");
00166         TmpDev->Ata                     =(byte) GETBITW(Buffer[0],15);
00167         TmpDev->Removable               =(byte) GETBITW(Buffer[0],7);
00168         TmpDev->NotRemovable            =(byte) GETBITW(Buffer[0],6);
00169         TmpDev->LogicalCylinders        =(word) Buffer[1];
00170         TmpDev->LogicalHeads            =(word) Buffer[3];
00171         TmpDev->LogicalSectorsPerTrack=(word) Buffer[6];
00172 
00173         Tmp=(word *) &(TmpDev->SerialNumber);
00174         for (i=10;i<=19;i++)
00175         {
00176                 *Tmp=SWAPBYTEW(Buffer[i]);
00177                 Tmp++;
00178         }
00179         TmpDev->SerialNumber[21]='\0';
00180         
00181 
00182         Tmp=(word *) &(TmpDev->FirmwareRev);
00183         for (i=23;i<=26;i++)
00184         {
00185                 *Tmp=SWAPBYTEW(Buffer[i]);
00186                 Tmp++;
00187         }
00188         TmpDev->FirmwareRev[9]='\0';
00189 
00190         Tmp=(word *) &(TmpDev->ModelNumber);
00191         for (i=27;i<=46;i++)
00192         {
00193                 *Tmp=SWAPBYTEW(Buffer[i]);
00194                 Tmp++;
00195         }
00196         TmpDev->ModelNumber[41]='\0';
00197 
00198         TmpDev->MaxMulitSectPerBlock    = (byte) GETBYTEW(Buffer[47],0);
00199         TmpDev->StandByTimerSupport     = (byte) GETBITW(Buffer[49],13);
00200         TmpDev->IORDYSupport            = (byte) GETBITW(Buffer[49],11);
00201         TmpDev->IORDYDisabled           = (byte) GETBITW(Buffer[49],10);        
00202         TmpDev->PioMode                 = (byte) GETBYTEW(Buffer[51],1);
00203         TmpDev->ValidUDMAMode           = (byte) GETBITW(Buffer[53],2);
00204         TmpDev->ValidCycleTime          = (byte) GETBITW(Buffer[53],1);
00205         TmpDev->ValidCurLogicalValue= (byte) GETBITW(Buffer[53],0);
00206         TmpDev->CurLogicalCylinders = (word) Buffer[54];
00207         TmpDev->CurLogicalHeads     = (word) Buffer[55];
00208         TmpDev->CurLogicalSectorsPerTrack = (word) Buffer[56];
00209         TmpDev->CapacityInSectors   = (dword) MAKEDWORDW(Buffer[58],Buffer[57]);
00210         TmpDev->ValidCurMultiSectPerInt  = (byte) GETBITW(Buffer[59],8);
00211         TmpDev->CurMultiSectPerInt  = (byte) GETBYTEW(Buffer[59],0);
00212         TmpDev->CapacityLba         = (dword) MAKEDWORDW(Buffer[61],Buffer[60]);
00213 
00214         TmpDev->MultiDMASupported = ((byte) GETBYTEW(Buffer[63],1)) & 0x07; // only 3 least sig bit
00215         TmpDev->MultiDMASelected  = ((byte) GETBYTEW(Buffer[63],0)) & 0x07; // only 3 least sig bit
00216 
00217         TmpDev->AdvPioModeSupported = (byte) GETBYTEW(Buffer[64],0);
00218         TmpDev->MinCycleTime        = (word) Buffer[65];
00219         TmpDev->RecCycleTime        = (word) Buffer[66];
00220         TmpDev->MinPioCycleTime     = (word) Buffer[67];
00221         TmpDev->MinPioCyleTimeFlow  = (word) Buffer[68];
00222         TmpDev->QueueDepth          = (byte) GETBYTEW(Buffer[75],0) & 0x1F;
00223         
00224         TmpDev->AtaSupported        = (word) Buffer[80];
00225 
00226         i=14;
00227         while ( i>0 && (GETBITW(Buffer[80],i)==0) )
00228                 i--;
00229 
00230         TmpDev->HighestAtaSupported=(byte) i;
00231 
00232         if ( Buffer[81]==0xFFFF )
00233                 TmpDev->MinorVersion    = (word) Buffer[81];
00234         else
00235                 TmpDev->MinorVersion    = (word) Buffer[81];
00236         
00237         TmpDev->SFSNopSupported            = (byte) GETBITW(Buffer[82],14);
00238         TmpDev->SFSReadBufferSupported     = (byte) GETBITW(Buffer[82],13);
00239         TmpDev->SFSWriteBufferSupported    = (byte) GETBITW(Buffer[82],12);
00240         TmpDev->SFSProtectedAreaSupported  = (byte) GETBITW(Buffer[82],10);
00241         TmpDev->SFSDeviceResetSupported    = (byte) GETBITW(Buffer[82],9);
00242         TmpDev->SFSServiceIntSupported     = (byte) GETBITW(Buffer[82],8);
00243         TmpDev->SFSReleaseIntSupported     = (byte) GETBITW(Buffer[82],7);
00244         TmpDev->SFSLookAheadSupported      = (byte) GETBITW(Buffer[82],6);
00245         TmpDev->SFSWriteCacheSupported     = (byte) GETBITW(Buffer[82],5);
00246         TmpDev->SFSPacketSupported         = (byte) GETBITW(Buffer[82],4);
00247         TmpDev->SFSPowerManagSupported     = (byte) GETBITW(Buffer[82],3);
00248         TmpDev->SFSRemovableMediaSupported = (byte) GETBITW(Buffer[82],2);
00249         TmpDev->SFSSecurityModeSupported   = (byte) GETBITW(Buffer[82],1);
00250         TmpDev->SFSSmartSupported          = (byte) GETBITW(Buffer[82],0);
00251         TmpDev->SFSRemMediaNotifSupported  = (byte) GETBITW(Buffer[83],4);
00252         TmpDev->SFSAdvPowerManagSupported  = (byte) GETBITW(Buffer[83],3);
00253         TmpDev->SFSCFASupported            = (byte) GETBITW(Buffer[83],2);
00254         TmpDev->SFSRWDmaQueuedSupported    = (byte) GETBITW(Buffer[83],1);
00255         TmpDev->SFSDownMicrocodeSupported  = (byte) GETBITW(Buffer[83],1);
00256 
00257         TmpDev->SFEServiceIntEnalbed       = (byte) GETBITW(Buffer[85],8);
00258         TmpDev->SFEReleaseIntEnabled       = (byte) GETBITW(Buffer[85],7);
00259         TmpDev->SFELookAheadEnabled        = (byte) GETBITW(Buffer[85],6);
00260         TmpDev->SFEWriteCacheEnabled       = (byte) GETBITW(Buffer[85],5);
00261         TmpDev->SFESecurityModeEnabled     = (byte) GETBITW(Buffer[85],1);
00262         TmpDev->SFESmartEnabled            = (byte) GETBITW(Buffer[85],0);
00263         TmpDev->SFERemMediaNotifEnabled    = (byte) GETBITW(Buffer[86],4);
00264         TmpDev->SFEAdvPowerManagEnabled    = (byte) GETBITW(Buffer[86],3);
00265 
00266         TmpDev->UDMASelected = ((byte) GETBYTEW(Buffer[88],1)) & 0x3F; // filtro i primi 2 bit
00267         TmpDev->UDMASupported =((byte) GETBYTEW(Buffer[88],0)) & 0x3F;
00268         
00269         i=5;
00270         while ( i>=0 && (GETBITW(Buffer[88],i)==0) )
00271                 i--;
00272 
00273         TmpDev->HighestUDMASupported=(byte) i;
00274 
00275         TmpDev->SecurityEraseTime    = (word) Buffer[89];
00276         TmpDev->SecurityEnEraseTime  = (word) Buffer[90];
00277         TmpDev->CurAPMValue          = (word) Buffer[91];
00278 
00279         TmpDev->SecurityLevel        = (byte) GETBITW(Buffer[128],8);
00280         TmpDev->SecurityEnErase      = (byte) GETBITW(Buffer[128],5);
00281         TmpDev->SecurityCountExpired = (byte) GETBITW(Buffer[128],4);
00282         TmpDev->SecurityFrozen       = (byte) GETBITW(Buffer[128],3);
00283         TmpDev->SecurityLocked       = (byte) GETBITW(Buffer[128],2);
00284         TmpDev->SecurityEnabled      = (byte) GETBITW(Buffer[128],1);
00285         TmpDev->SecuritySupported    = (byte) GETBITW(Buffer[128],0);
00286 
00287         Tmp=(word *) &(TmpDev->VendorSpecific);
00288         for (i=129;i<=159;i++)
00289         {
00290                 *Tmp=(word) Buffer[i];
00291                 Tmp++;
00292         }
00293         return 0;
00294 }

void InitIde  
 

Definition at line 534 of file Ide.c.

00535 {
00536         extern void Ide_Handler_Pri, Ide_Handler_Sec;
00537 
00538         // --- modified by: Andrea Righi -------------------------------//
00539         // Install the IRQ handlers for both IDE channels               //
00540         install_irq_handler(IDEP_IRQ, &Ide_Handler_Pri);
00541         install_irq_handler(IDES_IRQ, &Ide_Handler_Sec);
00542         // -------------------------------------------------------------//
00543 
00544         // Initialize structure for primary channel
00545         SelectAtaChannel(CC_PRIMARY);
00546         SetAtaRegisterIoPort(HDC_BASEPRI,HDC_BASEPRI+HDC_CONTROLGAP,HDC_INTPRI);
00547 
00548         // Initialize devices
00549         ScanDevice(TRUE);
00550         if ( CurrentChannel->Device[CC_DEV0].Type==CC_DEVTYPE_ATA )
00551                 IdentifyDevice(CC_DEV0);
00552         if ( CurrentChannel->Device[CC_DEV1].Type==CC_DEVTYPE_ATA )
00553                 IdentifyDevice(CC_DEV1);
00554 
00555         // Initialize structure for secondary channel
00556         SelectAtaChannel(CC_SECONDARY);
00557         SetAtaRegisterIoPort(HDC_BASESEC,HDC_BASESEC+HDC_CONTROLGAP,HDC_INTSEC);
00558 
00559         // Initialize devices
00560         ScanDevice(TRUE);
00561         if ( CurrentChannel->Device[CC_DEV0].Type==CC_DEVTYPE_ATA )
00562                 IdentifyDevice(CC_DEV0);
00563         if ( CurrentChannel->Device[CC_DEV1].Type==CC_DEVTYPE_ATA )
00564                 IdentifyDevice(CC_DEV1);
00565 }

int ReadSectorsLba int    Dev,
uint64    Lba,
int    NumSect,
word   Buffer,
int    UseInterrupt
 

Definition at line 572 of file Ide.c.

00573 {
00574 
00575         // kprintf("\n\rReadSectorLba: Dev=%d,Lba=%i,NumSect=%i,UseInt=%i",Dev,(int) Lba,NumSect,UseInterrupt);
00576         return IdePioDataInLba(Dev,HDC_CMD_READ_SECTORS,0,NumSect,Lba,Buffer,NumSect,1,UseInterrupt);
00577 }

int ScanDevice int    UseInterrupt
 

Definition at line 98 of file Ide.c.

00099 {
00100         byte DevCtrl;
00101         int Err=FALSE;
00102 
00103         // HDC_DEVC_HD15 is not needed in recent ata (is for compatibility)
00104         DevCtrl= HDC_DEVC_HD15 | ( UseInterrupt ? 0 : HDC_DEVC_NIEN );
00105 
00106         // Send To Device Control Register his Initialization Parameter
00107         OutPortAta(CC_DEVC,DevCtrl);
00108 
00109         // Try to chek for some sort of device before
00110         // execute some sort of command on it
00111         IdeDeviceDetection(CC_DEV0);
00112         IdeDeviceDetection(CC_DEV1);
00113 
00114         // select device 0
00115         SetDevBit(CC_DEV0);
00116         // Know that you know what devices exist you can
00117         // do a soft reset. The reset is for both device,
00118         // after the reset we will select Dev0 if possible
00119         Err=IdeSoftReset( FALSE, UseInterrupt );
00120 
00121         // Now we can issue command because we know how many devices
00122         // are on the channel and we have done the reset on they so:
00123         // is device really there? is it ATA or ATAPI?
00124         IdeDeviceTypeDetection(CC_DEV0);
00125         IdeDeviceTypeDetection(CC_DEV1);
00126 
00127         // Select first selectable device
00128         SetFirstDevBit();
00129         // take in mind that error from this function
00130         // are not critical, the caller can continue
00131         // to do his normal operation in respect
00132         // to DeviceType field of CurrentChannel->Device[Dev]
00133         return Err;
00134         // END: Now we have each device type in CurrentChannel
00135 }

void ShowDeviceData int    Dev,
int    Col
 

Definition at line 349 of file Ide.c.

00350 {
00351 
00352         DeviceInfo_Struct * TmpDev=(DeviceInfo_Struct *) &(CurrentChannel->Device[Dev].Info);
00353 
00354         kprintf("\n\r***** GENERAL INFORMATION *****");
00355         ShowDeviceDataRowString("\n\rModel Name",Col,TmpDev->ModelNumber);      
00356         ShowDeviceDataRowString("\n\rFirmware Revision",Col,TmpDev->FirmwareRev);
00357         ShowDeviceDataRowString("\n\rSerial Number",Col,TmpDev->SerialNumber);
00358 
00359         ShowDeviceDataRowName("\n\rType",Col);
00360         if (CurrentChannel->Device[Dev].Type==CC_DEVTYPE_ATA )
00361                 kprintf("ATA");
00362         else if (CurrentChannel->Device[Dev].Type==CC_DEVTYPE_ATAPI )
00363                 kprintf("ATAPI");
00364         else if (CurrentChannel->Device[Dev].Type==CC_DEVTYPE_UNKN )
00365                 kprintf("UNKNOW");
00366 
00367         if ( TmpDev->Removable )
00368                 kprintf(" - Removable");
00369         if ( TmpDev->NotRemovable )
00370                 kprintf(" - Not Removable");
00371 
00372 
00373         kprintf("\n\r\n\r***** STANDARD SUPPORTED AND SELECTED *****");
00374 
00375         ShowDeviceDataRowName("\n\rAta Supported",Col); 
00376         if ( (TmpDev->AtaSupported == 0x0000) || (TmpDev->AtaSupported == 0xFFFF) )
00377                 kprintf("UNKNOW");
00378         else
00379                 // bit 0 is reserved
00380                 ShowDeviceDataRowBitNum(TmpDev->AtaSupported,1,14,1);
00381 
00382         ShowDeviceDataRowName("\n\rUdma Supported",Col);        
00383         if ( TmpDev->ValidUDMAMode )
00384         {
00385                 
00386                 if ( TmpDev->UDMASupported )
00387                         // Udma star from 0
00388                         ShowDeviceDataRowBitNum((word) TmpDev->UDMASupported,0,7,0);                    
00389                 else
00390                         kprintf("NONE");
00391         }
00392         else
00393                 kprintf("UNKNOW");
00394 
00395 
00396         ShowDeviceDataRowName("\n\rUdma Selected",Col);
00397         if ( TmpDev->ValidUDMAMode )
00398         {
00399                 if ( TmpDev->UDMASelected )
00400                         ShowDeviceDataRowBitNum((word) TmpDev->UDMASelected,0,7,0);                     
00401                 else
00402                         kprintf("NONE");
00403         }
00404         else
00405                 kprintf("UNKNOW");
00406 
00407         ShowDeviceDataRowName("\n\rMultiDma Supported",Col);
00408         if ( TmpDev->MultiDMASupported )
00409                 ShowDeviceDataRowBitNum((word) TmpDev->UDMASupported,0,2,0);            
00410         else
00411                 kprintf("NONE");
00412 
00413         ShowDeviceDataRowName("\n\rMultiDma Selected",Col);
00414         if ( TmpDev->MultiDMASelected  )
00415                 ShowDeviceDataRowBitNum((word) TmpDev->UDMASelected,0,2,0);             
00416         else
00417                 kprintf("NONE");
00418 
00419 
00420         ShowDeviceDataRowValue("\n\rStandard Pio Mode",Col,"%d",TmpDev->PioMode);
00421 
00422         ShowDeviceDataRowName("\n\rAdvanced Pio Mode Supported",Col);   
00423         if ( TmpDev->AdvPioModeSupported )
00424                 ShowDeviceDataRowBitNum(TmpDev->AdvPioModeSupported,0,7,3);     
00425         else
00426                 kprintf("NONE");
00427         
00428         WaitKeyPress(MSG_PRESSKEY);     
00429 
00430         kprintf("\n\r\n\r***** DEVICE LOGICAL INFORMATION *****");
00431         ShowDeviceDataRowValue("\n\rLogical Cylinders",Col,"%u",TmpDev->LogicalCylinders);
00432         ShowDeviceDataRowValue("\n\rLogical Heads",Col,"%u",TmpDev->LogicalHeads);
00433         ShowDeviceDataRowValue("\n\rLogical Sectors",Col,"%u",TmpDev->LogicalSectorsPerTrack);
00434         if ( TmpDev->ValidCurLogicalValue )
00435         {
00436                 ShowDeviceDataRowValue("\n\rCurrent Logical Cylinders",Col, "%u",TmpDev->CurLogicalCylinders);
00437                 ShowDeviceDataRowValue("\n\rCurrent Logical Heads",Col,"%u",TmpDev->CurLogicalHeads);
00438                 ShowDeviceDataRowValue("\n\rCurrent Logical Sectors",Col,"%u",TmpDev->CurLogicalSectorsPerTrack);
00439         }
00440         else
00441         {
00442                 ShowDeviceDataRowString("\n\rCurrent Logical Cylinders",Col,"UNKNOW");
00443                 ShowDeviceDataRowString("\n\rCurrent Logical Heads",Col,"UNKNOW");
00444                 ShowDeviceDataRowString("\n\rCurrent Logical Sectors",Col,"UNKNOW");
00445         }
00446         ShowDeviceDataRowValue("\n\rCapacity Sectors Current CHS",Col,"%u",TmpDev->CapacityInSectors);
00447         ShowDeviceDataRowValue("\n\rCapacity Sectors",Col,"%u",TmpDev->CapacityLba);
00448         ShowDeviceDataRowValue("\n\rCapacity in MB",Col,"%u",TmpDev->CapacityLba / 2 / 1024);
00449 
00450         ShowDeviceDataRowSupEn("\n\rIORDY",Col,TmpDev->IORDYSupport,TmpDev->IORDYDisabled);
00451         
00452         WaitKeyPress(MSG_PRESSKEY);     
00453 
00454         kprintf("\n\r\n\r***** DEVICE FEATURES AND SETTING INFORMATION *****");
00455         ShowDeviceDataRowSup("\n\rR W Dma Queued",Col,TmpDev->SFSRWDmaQueuedSupported);
00456         ShowDeviceDataRowValue("\n\rQueue Depth",Col,"%u",TmpDev->QueueDepth);
00457         ShowDeviceDataRowValue("\n\rMax Sect Per Block (in Multi)",Col,"%u",TmpDev->MaxMulitSectPerBlock);
00458         ShowDeviceDataRowSupEn("\n\rAdv Power Management",Col,TmpDev->SFSAdvPowerManagSupported,TmpDev->SFEAdvPowerManagEnabled);
00459         ShowDeviceDataRowValue("\n\rAdv Power Management Level",Col,"%u",TmpDev->CurAPMValue);
00460 
00461         ShowDeviceDataRowSupEn("\n\rLook Ahead",Col,TmpDev->SFSLookAheadSupported,TmpDev->SFELookAheadEnabled);
00462         ShowDeviceDataRowSupEn("\n\rRelease Interrupt",Col,TmpDev->SFSReleaseIntSupported,TmpDev->SFEReleaseIntEnabled);
00463         ShowDeviceDataRowSupEn("\n\rRemovable Media Notif",Col,TmpDev->SFSRemMediaNotifSupported,TmpDev->SFERemMediaNotifEnabled);
00464         ShowDeviceDataRowSupEn("\n\rService Interrupt",Col,TmpDev->SFSServiceIntSupported,TmpDev->SFEServiceIntEnalbed);
00465         ShowDeviceDataRowSupEn("\n\rSmart",Col,TmpDev->SFSSmartSupported,TmpDev->SFESmartEnabled);
00466         ShowDeviceDataRowSupEn("\n\rWrite Cache",Col,TmpDev->SFSWriteCacheSupported,TmpDev->SFEWriteCacheEnabled);
00467         ShowDeviceDataRowSup("\n\rRead Buffer",Col,TmpDev->SFSReadBufferSupported);
00468         ShowDeviceDataRowSup("\n\rWrite Buffer",Col,TmpDev->SFSWriteBufferSupported);
00469         ShowDeviceDataRowSup("\n\rNop",Col,TmpDev->SFSNopSupported);
00470         ShowDeviceDataRowSup("\n\rPacket",Col,TmpDev->SFSPacketSupported);
00471         ShowDeviceDataRowSup("\n\rPower Management",Col,TmpDev->SFSPowerManagSupported);
00472         ShowDeviceDataRowSup("\n\rProtected Area",Col,TmpDev->SFSProtectedAreaSupported);
00473         ShowDeviceDataRowSup("\n\rDownload Microcode",Col,TmpDev->SFSDownMicrocodeSupported);
00474         ShowDeviceDataRowSup("\n\rCFA",Col,TmpDev->SFSCFASupported);
00475         ShowDeviceDataRowSup("\n\rDevice Reset",Col,TmpDev->SFSDeviceResetSupported);
00476         ShowDeviceDataRowSup("\n\rStandBy Timer",Col,TmpDev->StandByTimerSupport);
00477 
00478         WaitKeyPress(MSG_PRESSKEY);     
00479 
00480 
00481         kprintf("\n\r\n\r***** DEVICE TIMING INFORMATION *****");
00482         ShowDeviceDataRowSup("\n\rStandBy Timer",Col,TmpDev->StandByTimerSupport);
00483         
00484         if (TmpDev->ValidCycleTime )
00485         {
00486                 ShowDeviceDataRowValue("\n\rMin Multi Dma Cycle Time (ns)",Col,"%u",TmpDev->MinCycleTime);
00487                 ShowDeviceDataRowValue("\n\rRecc MultiDma Cycle Time (ns)",Col,"%u",TmpDev->RecCycleTime);
00488                 ShowDeviceDataRowValue("\n\rMin Pio Cycle Time (ns)",Col,"%u",TmpDev->MinPioCycleTime);
00489                 ShowDeviceDataRowValue("\n\rMin Pio Cycle Time Flow (ns)",Col,"%u",TmpDev->MinPioCyleTimeFlow);
00490         }
00491         else
00492         {
00493                 kprintf("\n\rTiming Information Unavaiable");
00494         }
00495 
00496         kprintf("\n\r\n\r***** SECURITY INFORMATION *****");
00497         ShowDeviceDataRowSupEn("\n\rSecurity",Col,TmpDev->SecuritySupported,TmpDev->SecurityEnabled);
00498         ShowDeviceDataRowSupEn("\n\rSecurity Mode",Col,TmpDev->SFSSecurityModeSupported,TmpDev->SFESecurityModeEnabled);
00499         ShowDeviceDataRowValue("\n\rSecurity Erase Time (min)",Col,"%u",(int) TmpDev->SecurityEraseTime*2);
00500         ShowDeviceDataRowValue("\n\rEnh Security Erase Time (min)",Col,"%u",(int) TmpDev->SecurityEnEraseTime*2);
00501         
00502         ShowDeviceDataRowName("\n\rSecurity Level",Col);        
00503         if ( TmpDev->SFESecurityModeEnabled )
00504         {
00505                 if (TmpDev->SecurityLevel)
00506                         kprintf("Max");
00507                 else
00508                         kprintf("High");
00509         }
00510         else
00511         {
00512                 kprintf("Disabled");
00513         }
00514 
00515         ShowDeviceDataRowString("\n\rSecurity Frozen",Col,Bit2YesNo(TmpDev->SecurityFrozen));
00516         kprintf("\n\rSecurity CountExpired");
00517         gotoxy(Col,-1);
00518         kprintf("=%s",Bit2YesNo(TmpDev->SecurityCountExpired));
00519         kprintf("\n\rSecurity Locked");
00520         gotoxy(Col,-1);
00521         kprintf("=%s",Bit2YesNo(TmpDev->SecurityLocked));
00522         ShowDeviceDataRowSup("\n\rSecurity Enh Erase Supported",Col,TmpDev->SecurityEnErase);
00523 
00524         kprintf("\n\r\n\r END DEVICE INFORMATION \n\r");
00525 }

void ShowDeviceDataRowBitNum word    BitCode,
byte    StartFrom,
byte    EndTo,
byte    StartPrintNum
 

Definition at line 332 of file Ide.c.

00333 {
00334         int i;
00335         byte Val=BitCode;
00336 
00337         if ( StartFrom )
00338                 Val=Val >> StartFrom;
00339 
00340         for (i=0;i<=EndTo-StartFrom;i++)
00341         {
00342                 if (Val & 0x01)
00343                         kprintf("%d  ",StartPrintNum+i);
00344                 Val=Val >> 1;
00345         }
00346 }

void ShowDeviceDataRowName char *    Name,
int    Col
 

Definition at line 297 of file Ide.c.

00298 {
00299         kprintf(Name);
00300         gotoxy(Col,-1);
00301         kprintf("=");
00302 }

void ShowDeviceDataRowString char *    Name,
int    Col,
char *    Value
 

Definition at line 311 of file Ide.c.

00312 {
00313         ShowDeviceDataRowName(Name,Col);
00314         kprintf("%s", Value);
00315 }

void ShowDeviceDataRowSup char *    Name,
int    Col,
byte    Supported
 

Definition at line 318 of file Ide.c.

00319 {
00320         ShowDeviceDataRowName(Name,Col);
00321         kprintf("Supported:%s",Bit2YesNo(Supported));
00322 }

void ShowDeviceDataRowSupEn char *    Name,
int    Col,
byte    Supported,
byte    Enabled
 

Definition at line 324 of file Ide.c.

00325 {
00326         ShowDeviceDataRowName(Name,Col);
00327         kprintf("Supported:%s",Bit2YesNo(Supported));
00328         kprintf("  -  ");
00329         kprintf("Enabled:%s",Bit2YesNo(Enabled));
00330 }

void ShowDeviceDataRowValue char *    Name,
int    Col,
char *    Format,
dword    Value
 

Definition at line 305 of file Ide.c.

00306 {
00307         ShowDeviceDataRowName(Name,Col);
00308         kprintf(Format, Value);
00309 }

void ShowDeviceSubData int    Dev
 

Definition at line 56 of file Ide.c.

00057 {
00058 
00059         Device_Struct * CurDev=&CurrentChannel->Device[Dev];
00060 
00061         if ( CurDev->Type==CC_DEVTYPE_ATA )
00062         {
00063                 kprintf("\n\rDevice %d: %s",Dev, CurDev->Info.ModelNumber);
00064                 kprintf("\n\r    Type: ATA %d - UDMA %d",
00065                         CurDev->Info.HighestAtaSupported,
00066                         CurDev->Info.HighestUDMASupported);
00067                 kprintf("\n\r    Firmware Rev: %s", CurDev->Info.FirmwareRev);
00068                 kprintf("\n\r    SerialNumber: %s", CurDev->Info.SerialNumber);
00069                 kprintf("\n\r    Capacity: %i MB",CurDev->Info.CapacityLba / 2 / 1024);
00070         }
00071         else if ( CurDev->Type==CC_DEVTYPE_NONE )
00072                 kprintf("\n\rDevice %d NOT FOUND",Dev);
00073         else if ( CurDev->Type==CC_DEVTYPE_ATAPI )
00074                 kprintf("\n\rDevice %d FOUND Type: ATAPI",Dev);
00075         else
00076                 kprintf("\n\rDevice %d FOUND Type: UNKNOW",Dev);
00077 }

void ShowIdeSubData  
 

Definition at line 79 of file Ide.c.

00080 {
00081         SelectAtaChannel(CC_PRIMARY);
00082         kprintf("\n\rPRIMARY CHANNEL");
00083         ShowDeviceSubData(CC_DEV0);
00084         ShowDeviceSubData(CC_DEV1);
00085         kprintf("\n\r");
00086         SelectAtaChannel(CC_SECONDARY);
00087         kprintf("\n\rSECONDARY CHANNEL");
00088         ShowDeviceSubData(CC_DEV0);
00089         ShowDeviceSubData(CC_DEV1);
00090 }

int WriteSectorsLba int    Dev,
uint64    Lba,
int    NumSect,
word   Buffer,
int    UseInterrupt
 

Definition at line 582 of file Ide.c.

00583 {
00584         return IdePioDataOutLba(Dev,HDC_CMD_WRITE_SECTORS,0,NumSect,Lba,Buffer,NumSect,1,UseInterrupt);
00585 }


Generated on Fri Feb 20 15:32:18 2004 for Minirighi by doxygen1.2.18