kernel/eka/drivers/medata/ata.h
changeset 0 a41df078684a
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // e32\drivers\medata\ata.h
       
    15 // 
       
    16 //
       
    17 
       
    18 #include <partitions.h>
       
    19 
       
    20 #if defined (SELECT_PRIMARY_IO_CONFIG)
       
    21 //
       
    22 // ATA Register addresses (for primary)
       
    23 // 
       
    24 const TUint KAtaDataRdWr16=0x000001F0;
       
    25 const TUint KAtaDataRdWr8=0x000001F0;
       
    26 
       
    27 const TUint KAtaErrorRd8=0x000001F1;
       
    28 const TUint KAtaFeaturesWr8=0x000001F1;
       
    29 
       
    30 const TUint KAtaSectorCountRdWr8=0x000001F2;
       
    31 
       
    32 const TUint KAtaSectorNoRdWr8=0x000001F3;
       
    33 const TUint KAtaLba7_0RdWr8=0x000001F3;
       
    34 
       
    35 const TUint KAtaCylinderLowRdWr8=0x000001F4;
       
    36 const TUint KAtaLba15_8RdWr8=0x000001F4;
       
    37 
       
    38 const TUint KAtaCylinderHighRdWr8=0x000001F5;
       
    39 const TUint KAtaLba23_16RdWr8=0x000001F5;
       
    40 
       
    41 const TUint KAtaSelectDriveHeadRdWr8=0x000001F6;
       
    42 const TUint KAtaDriveLba27_24RdWr8=0x000001F6;
       
    43 
       
    44 const TUint KAtaStatusRd8=0x000001F7;
       
    45 const TUint KAtaCommandWr8=0x000001F7;
       
    46 
       
    47 #else
       
    48 //
       
    49 // ATA Register addresses (for either contiguous I/O or memory mapped)
       
    50 // 
       
    51 const TUint KAtaDataRdWr16=0x00000000;
       
    52 const TUint KAtaDataRdWr8=0x00000000;
       
    53 const TUint KAtaDataRdWrWinBase16=0x00000400;	// Memory mapped only
       
    54 const TUint KAtaDataRdWrWinBase8=0x00000400;	// Memory mapped only
       
    55 
       
    56 const TUint KAtaErrorRd8=0x00000001;
       
    57 const TUint KAtaFeaturesWr8=0x00000001;
       
    58 
       
    59 const TUint KAtaSectorCountRdWr8=0x00000002;
       
    60 
       
    61 const TUint KAtaSectorNoRdWr8=0x00000003;
       
    62 const TUint KAtaLba7_0RdWr8=0x00000003;
       
    63 
       
    64 const TUint KAtaCylinderLowRdWr8=0x00000004;
       
    65 const TUint KAtaLba15_8RdWr8=0x00000004;
       
    66 
       
    67 const TUint KAtaCylinderHighRdWr8=0x00000005;
       
    68 const TUint KAtaLba23_16RdWr8=0x00000005;
       
    69 
       
    70 const TUint KAtaSelectDriveHeadRdWr8=0x00000006;
       
    71 const TUint KAtaDriveLba27_24RdWr8=0x00000006;
       
    72 
       
    73 const TUint KAtaStatusRd8=0x00000007;
       
    74 const TUint KAtaCommandWr8=0x00000007;
       
    75 #endif
       
    76 
       
    77 //
       
    78 // ATA Register addresses (for contiguous I/O or memory mapped)
       
    79 // 
       
    80 const TUint KAtaDupEvenDataRdWr8=0x00000008;
       
    81 const TUint KAtaDupOddDataRdWr8=0x00000009;
       
    82 const TUint KAtaDupErrorRd8=0x0000000D;
       
    83 const TUint KAtaDupFeaturesWr8=0x0000000D;
       
    84 const TUint KAtaAltStatusRd8=0x0000000E;
       
    85 const TUint KAtaDeviceCtlWr8=0x0000000E;
       
    86 const TUint KAtaDriveAddressRd8=0x0000000F;
       
    87 
       
    88 //
       
    89 // ATA Register bit fields 
       
    90 // 
       
    91 // KAtaErrorRd8
       
    92 const TUint8	KAtaErrorAmnf=0x01;
       
    93 const TUint8	KAtaErrorAbort=0x04;
       
    94 const TUint8	KAtaErrorIdnf=0x10;
       
    95 const TUint8	KAtaErrorUnc=0x40;
       
    96 const TUint8	KAtaErrorBbk=0x80;
       
    97 
       
    98 // KAtaSelectDriveHeadRdWr8
       
    99 // KAtaDriveLba27_24RdWr8
       
   100 const TUint8	KAtaDrvHeadLba27_24=0x0F;
       
   101 const TUint8	KAtaDrvHeadDrive1=0x10;
       
   102 const TUint8	KAtaDrvHeadLbaOn=0x40;
       
   103 
       
   104 // KAtaStatusRd8
       
   105 const TUint8	KAtaStatusErr=0x01;
       
   106 const TUint8	KAtaStatusCorr=0x04;
       
   107 const TUint8	KAtaStatusDrq=0x08;
       
   108 const TUint8	KAtaStatusDsc=0x10;
       
   109 const TUint8	KAtaStatusDwf=0x20;
       
   110 const TUint8	KAtaStatusRdy=0x40;
       
   111 const TUint8	KAtaStatusBusy=0x80;
       
   112 
       
   113 // KAtaDeviceCtlWr8
       
   114 const TUint8	KAtaDeviceCtlIntDis=0x02;
       
   115 const TUint8	KAtaDeviceCtlSwRes=0x04;
       
   116 
       
   117 //
       
   118 // ATA commands
       
   119 // 
       
   120 const TUint8 KAtaCmdIdentifyDrive=0xEC;
       
   121 const TUint8 KAtaCmdReadSectors=0x20;
       
   122 const TUint8 KAtaCmdWriteSectors=0x30;
       
   123 const TUint8 KAtaCmdSetFeatures=0xEF;
       
   124 const TUint8 KAtaCmdRequestSense=0x03;
       
   125 const TUint8 KAtaCmdFormatTrack=0x50;
       
   126 const TUint8 KAtaCmdIdle=0xE3;
       
   127 
       
   128 //
       
   129 // Defines for Identify Drive Command
       
   130 //
       
   131 const TInt KAtaIdDefaultCylinders=2;			// Offset in bytes
       
   132 const TInt KAtaIdDefaultHeads=6;			
       
   133 const TInt KAtaIdDefaultSectorsPerTrack=12;			
       
   134 const TInt KAtaIdCapabilities=98;			
       
   135 const TUint16	KAtaIdCapLbaSupported=0x0200;
       
   136 const TInt KAtaIdTranslationParams=106;		
       
   137 const TUint16 	KAtaIdTrParamsValid=0x0001;		
       
   138 const TInt KAtaIdCurrentCylinders=108;		
       
   139 const TInt KAtaIdCurrentHeads=110;			
       
   140 const TInt KAtaIdCurrentSectorsPerTrack=112;			
       
   141 const TInt KAtaIdCurrentTotalSectors=114;			
       
   142 const TInt KAtaIdTotalSectorsInLba=120;		
       
   143 
       
   144 //
       
   145 // Drive parameters
       
   146 //
       
   147 class TDriveParameters
       
   148 	{
       
   149 public:
       
   150 	TInt iCylinders;
       
   151 	TInt iHeads;
       
   152 	TInt iSectorsPerTrack;
       
   153 	TInt iSectorsPerCylinder;
       
   154 	TBool iSupportsLba;
       
   155 	TInt iTotalSectorsInLba;
       
   156 	};
       
   157 
       
   158 const TInt KAtaSectorSize=512;
       
   159 const TInt KAtaSectorSizeMinusOne=(KAtaSectorSize-1);
       
   160 const TInt KAtaSectorShift=9;
       
   161 const TUint KAtaSectorMask=0xFFFFFE00;
       
   162 
       
   163 const TInt KMaxSectorsPerCmd=256; // Maximum sectors that can be transfered in single command
       
   164 
       
   165 enum TAtaDriveSelect
       
   166 	{
       
   167 	ESelectDrive1=KAtaDrvHeadDrive1,
       
   168 	ESelectDrive0=0x00
       
   169 	};
       
   170