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