|
1 /* |
|
2 * This component and the accompanying materials are made available |
|
3 * under the terms of the License "Eclipse Public License v1.0" |
|
4 * which accompanies this distribution, and is available |
|
5 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
6 * |
|
7 * Initial Contributors: |
|
8 * Accenture Ltd |
|
9 * |
|
10 * Contributors: |
|
11 * |
|
12 * Description: This file is a part of sound driver for Syborg adaptation. |
|
13 * |
|
14 */ |
|
15 |
|
16 #ifndef VIRTIO_IO_H |
|
17 #define VIRTIO_IO_H |
|
18 |
|
19 #include "virtio.h" |
|
20 #include <e32def.h> |
|
21 |
|
22 namespace VirtIo |
|
23 { |
|
24 |
|
25 class DIo : public DBase, public MIo |
|
26 { |
|
27 public: |
|
28 DIo( TAny* aIoBase ): iIoBase( reinterpret_cast<TUint32*>( aIoBase ) ) |
|
29 { } |
|
30 |
|
31 virtual void GetDeviceIds( TUint32 &aPeripheralId, TUint32 &aDeviceId ); |
|
32 |
|
33 virtual void SetQueueBase( TUint aQId, TAny* iDescRegion ); |
|
34 |
|
35 virtual TAny* GetQueueBase( TUint aQId); |
|
36 |
|
37 virtual TUint GetQueueCount( TUint aQId ) |
|
38 { |
|
39 write(EIoQueueSelect, aQId); |
|
40 return read(EIoQueueSize); |
|
41 } |
|
42 |
|
43 virtual void PostQueue( TUint aQId ) |
|
44 { write(EIoQueueNotify, aQId); SYBORG_VIRTIO_DEBUG("PostQueue Q%d", aQId ); } |
|
45 |
|
46 virtual TBool EnableInterrupt( TBool aEnable ) |
|
47 { return swap(EIoInterruptEnable, aEnable?1:0); } |
|
48 |
|
49 virtual void SetStatus( TUint status ) |
|
50 { write(EIoStatus, status ); } |
|
51 |
|
52 virtual void ClearInteruptStatus() |
|
53 { write( EIoInterruptStatus, 1 ); } |
|
54 |
|
55 virtual TBool InteruptStatus() |
|
56 { return read( EIoInterruptStatus ); } |
|
57 |
|
58 |
|
59 void Reset() |
|
60 { SetStatus( EStatusReset ); }; |
|
61 |
|
62 |
|
63 private: |
|
64 void write(TUint idx, TUint32 value ) |
|
65 { iIoBase[idx] = value; } |
|
66 |
|
67 TUint32 read(TUint idx) |
|
68 { return iIoBase[idx]; } |
|
69 |
|
70 TUint32 swap(TUint idx, TUint32 value ) |
|
71 { |
|
72 TUint32 t = iIoBase[idx]; |
|
73 iIoBase[idx] = value; |
|
74 return t; |
|
75 } |
|
76 |
|
77 volatile TUint32* iIoBase; |
|
78 |
|
79 }; |
|
80 |
|
81 } // namespace VirtIo |
|
82 |
|
83 #endif |