|
1 /* |
|
2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 /** |
|
21 @file |
|
22 @publishedPartner |
|
23 @test |
|
24 */ |
|
25 |
|
26 #ifndef _PCI_PRIV_H |
|
27 #define _PCI_PRIV_H |
|
28 |
|
29 #include <kernel/kernel.h> |
|
30 |
|
31 /** |
|
32 An object of this type will be passed in to the chunk cleanup |
|
33 callback. |
|
34 A concrete class will be derived by the PSL as the exact information |
|
35 needed in order to cleanup may vary. |
|
36 */ |
|
37 class TChunkCleanup : public TDfc |
|
38 { |
|
39 public: |
|
40 inline TChunkCleanup(); |
|
41 inline virtual ~TChunkCleanup() |
|
42 {} |
|
43 inline virtual void Destroy()=0; |
|
44 private: |
|
45 inline static void ChunkDestroyed(TChunkCleanup* aCleanup); |
|
46 }; |
|
47 |
|
48 |
|
49 TChunkCleanup::TChunkCleanup() |
|
50 :TDfc(reinterpret_cast<TDfcFn>(ChunkDestroyed), this, Kern::DfcQue0(), 0) |
|
51 { |
|
52 } |
|
53 |
|
54 /** |
|
55 The static function called by the DFC |
|
56 */ |
|
57 void TChunkCleanup::ChunkDestroyed(TChunkCleanup* aCleanup) |
|
58 { |
|
59 Pci::ChunkCleanupCallback(aCleanup); |
|
60 } |
|
61 |
|
62 /** |
|
63 Interface to PCI Host Bridge |
|
64 */ |
|
65 class DPciBridge : public DBase |
|
66 { |
|
67 public: |
|
68 ~DPciBridge(); |
|
69 TInt Register(); |
|
70 |
|
71 virtual TInt Initialise() =0; |
|
72 virtual TPciFunction* Function(TInt aBus, TInt aDevice, TInt aFunction) =0; |
|
73 virtual TInt CreateChunk(DPlatChunkHw*& aChunk, TInt aSize, TUint aAttributes, TUint32& aPciAddress)=0; |
|
74 virtual TInt CreateChunk(DChunk*& aChunk, TChunkCreateInfo &aAttributes, TUint aOffset, TUint aSize, TUint32& aPciAddress)=0; |
|
75 virtual TInt RemoveChunk(DPlatChunkHw* aChunk)=0; |
|
76 virtual TInt CreateMapping(TUint32 aPhysicalAddress, TInt aSize, TUint32& aPciAddress)=0; |
|
77 virtual TInt RemoveMapping(TUint32 aPhysicalAddress)=0; |
|
78 virtual TInt GetPciAddress(TUint32 aPhysicalAddress, TUint32& aPciAddress)=0; |
|
79 virtual TInt GetPhysicalAddress(TUint32 aPciAddress, TUint32& aPhysicalAddress)=0; |
|
80 |
|
81 virtual void ConfigurationComplete()=0; |
|
82 |
|
83 virtual TUint8 ReadConfig8(TInt aBus, TInt aDevice, TInt aFunction, TUint aOffset) const =0; |
|
84 virtual TUint16 ReadConfig16(TInt aBus, TInt aDevice, TInt aFunction, TUint aOffset) const =0; |
|
85 virtual TUint32 ReadConfig32(TInt aBus, TInt aDevice, TInt aFunction, TUint aOffset) const =0; |
|
86 |
|
87 virtual void WriteConfig8(TInt aBus, TInt aDevice, TInt aFunction, TUint aOffset, TUint8 aValue)=0; |
|
88 virtual void WriteConfig16(TInt aBus, TInt aDevice, TInt aFunction, TUint aOffset, TUint16 aValue)=0; |
|
89 virtual void WriteConfig32(TInt aBus, TInt aDevice, TInt aFunction, TUint aOffset, TUint32 aValue)=0; |
|
90 |
|
91 virtual void ModifyConfig8(TInt aBus, TInt aDevice, TInt aFunction, TUint aOffset, TUint8 aClearMask, TUint8 aSetMask)=0; |
|
92 virtual void ModifyConfig16(TInt aBus, TInt aDevice, TInt aFunction, TUint aOffset, TUint16 aClearMask, TUint16 aSetMask)=0; |
|
93 virtual void ModifyConfig32(TInt aBus, TInt aDevice, TInt aFunction, TUint aOffset, TUint32 aClearMask, TUint32 aSetMask)=0; |
|
94 protected: |
|
95 DPciBridge(); |
|
96 }; |
|
97 |
|
98 |
|
99 /** |
|
100 Gives access to one of a PCI functions's memory spaces |
|
101 */ |
|
102 class TMemorySpace : public TAddrSpace |
|
103 { |
|
104 public: |
|
105 TMemorySpace(TUint32 aBaseAddress, TUint aSize); |
|
106 |
|
107 READ(8); |
|
108 READ(16); |
|
109 READ(32); |
|
110 |
|
111 WRITE(8); |
|
112 WRITE(16); |
|
113 WRITE(32); |
|
114 |
|
115 MODIFY(8); |
|
116 MODIFY(16); |
|
117 MODIFY(32); |
|
118 private: |
|
119 TUint32 iBaseAddress; |
|
120 }; |
|
121 |
|
122 class TPciFunction; |
|
123 /** |
|
124 Access to a PCI function's config space |
|
125 */ |
|
126 class TConfigSpace : public TAddrSpace |
|
127 { |
|
128 public: |
|
129 TConfigSpace(TPciFunction& aFunction, DPciBridge& aBridge); |
|
130 |
|
131 READ(8); |
|
132 READ(16); |
|
133 READ(32); |
|
134 |
|
135 WRITE(8); |
|
136 WRITE(16); |
|
137 WRITE(32); |
|
138 |
|
139 MODIFY(8); |
|
140 MODIFY(16); |
|
141 MODIFY(32); |
|
142 |
|
143 private: |
|
144 TPciFunction& iFunction; //!< The function which owns this config space |
|
145 DPciBridge& iBridge; //!< The Host bridge which iFunction is on |
|
146 }; |
|
147 |
|
148 /** |
|
149 Represents a single Function on a (possibly multi-function) PCI device. |
|
150 */ |
|
151 class TPciFunction |
|
152 { |
|
153 public: |
|
154 TPciFunction(TInt aBus, TInt aDevice, TInt aFunction, TPciVendorId aVid, TDeviceId aDid, DPciBridge& aBridge); |
|
155 ~TPciFunction(); |
|
156 |
|
157 TInt AddMemorySpace(TUint32 aSize, TUint32 aAddress, TInt aBarIndex); |
|
158 IMPORT_C TAddrSpace* GetMemorySpace(TInt aBar=0); |
|
159 IMPORT_C TAddrSpace* GetConfigSpace(); |
|
160 |
|
161 inline TInt Bus() {return iBus;} |
|
162 inline TInt Device() {return iDevice;} |
|
163 inline TInt Function() {return iFunction;} |
|
164 inline TPciVendorId VendorId() {return iVid;} |
|
165 inline TDeviceId DeviceId() {return iDid;} |
|
166 |
|
167 inline DPciBridge& GetBridge() {return iBridge;} |
|
168 |
|
169 inline TBool IsBridge() {return iIsBridge;} |
|
170 inline TBool IsMultiFunc() {return iIsMultiFunc;} |
|
171 |
|
172 protected: |
|
173 const TInt iBus; |
|
174 const TInt iDevice; |
|
175 const TInt iFunction; |
|
176 |
|
177 const TPciVendorId iVid; |
|
178 const TDeviceId iDid; |
|
179 |
|
180 DPciBridge& iBridge; //!< The Host bridge which this TPciFunction is on |
|
181 TAddrSpace* iConfigSpace; |
|
182 RPointerArray<TMemorySpace> iMemorySpaces; |
|
183 TBool iIsBridge; |
|
184 TBool iIsMultiFunc; |
|
185 }; |
|
186 |
|
187 |
|
188 #endif //_PCI_PRIV_H |