author | Gareth Stockwell <gareth.stockwell@accenture.com> |
Fri, 24 Sep 2010 13:30:20 +0100 | |
branch | graphics-phase-3 |
changeset 114 | 19c4533e1567 |
parent 71 | d00bf4f57250 |
permissions | -rw-r--r-- |
45
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
1 |
/* |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
2 |
* This component and the accompanying materials are made available |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
3 |
* under the terms of the License "Eclipse Public License v1.0" |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
4 |
* which accompanies this distribution, and is available |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
5 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
6 |
* |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
7 |
* Initial Contributors: |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
8 |
* Accenture Ltd |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
9 |
* |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
10 |
* Contributors: |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
11 |
* |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
12 |
* Description: This file is a part of sound driver for Syborg adaptation. |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
13 |
* |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
14 |
*/ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
15 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
16 |
#include "virtio_iohandler.h" |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
17 |
#include "virtio_queue.h" |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
18 |
#include "virtio_io.h" |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
19 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
20 |
namespace VirtIo |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
21 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
22 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
23 |
DIoHandler::DIoHandler( TAny* aVirtIoBase, TUint aIntNum, TDfcQue* aDfcQue ) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
24 |
: iVirtIoBase( aVirtIoBase ), iIntNum( aIntNum ), iDfcQue( aDfcQue ), |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
25 |
iDfc( ServeDfc, this, 0 ), |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
26 |
iVirtIo( 0 ), iQueueCount( 3 ), iQueue( 0 ), |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
27 |
iClientCount( 0 ) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
28 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
29 |
SYBORG_VIRTIO_DEBUG("DIoHandler IoBase %x DfcQ %x", iVirtIoBase, iDfcQue); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
30 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
31 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
32 |
TInt DIoHandler::Construct() |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
33 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
34 |
TInt err = KErrNone; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
35 |
TUint i; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
36 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
37 |
SYBORG_VIRTIO_DEBUG("Creating DIo"); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
38 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
39 |
InstallIsr(); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
40 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
41 |
iVirtIo = new DIo(iVirtIoBase); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
42 |
if (iVirtIo == NULL ) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
43 |
{ return KErrNoMemory; } |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
44 |
iVirtIo->SetStatus( EStatusAcknowledge |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
45 |
| EStatusDriverFound ); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
46 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
47 |
iQueue = new DQueue*[iQueueCount]; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
48 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
49 |
if (iQueue == NULL ) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
50 |
{ Wipe(); return KErrNoMemory; } |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
51 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
52 |
// This is to make Wipe work |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
53 |
for ( i = 0; i < iQueueCount; ++i ) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
54 |
{ iQueue[i] = NULL; } |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
55 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
56 |
for ( i = 0; i < iQueueCount; ++i ) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
57 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
58 |
SYBORG_VIRTIO_DEBUG("Creating DQueue %d",i); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
59 |
DQueue* q = new DQueue( |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
60 |
*iVirtIo, i, iVirtIo->GetQueueCount( i ) ); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
61 |
if (!q) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
62 |
{ Wipe(); return KErrNoMemory; } |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
63 |
err = q->Construct(); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
64 |
if (err != KErrNone) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
65 |
{ Wipe(); return err; } |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
66 |
iQueue[i] = q; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
67 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
68 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
69 |
iVirtIo->SetStatus( |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
70 |
EStatusAcknowledge |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
71 |
| EStatusDriverFound |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
72 |
| EStatusDriverInitialised ); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
73 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
74 |
iVirtIo->EnableInterrupt( ETrue ); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
75 |
Interrupt::Enable(iIntNum); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
76 |
return KErrNone; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
77 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
78 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
79 |
void DIoHandler::Wipe() |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
80 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
81 |
if (iQueue) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
82 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
83 |
for ( TUint i = 0; i < iQueueCount; ++i ) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
84 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
85 |
if (iQueue[i]) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
86 |
{ delete iQueue[i]; } |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
87 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
88 |
delete[] iQueue; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
89 |
iQueue = NULL; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
90 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
91 |
if (iVirtIo) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
92 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
93 |
delete iVirtIo; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
94 |
iVirtIo = NULL; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
95 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
96 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
97 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
98 |
DIoHandler::~DIoHandler() |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
99 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
100 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
101 |
Interrupt::Disable(iIntNum); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
102 |
UninstallIsr(); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
103 |
iVirtIo->EnableInterrupt( EFalse ); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
104 |
iDfc.Cancel(); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
105 |
iVirtIo->ClearInteruptStatus(); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
106 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
107 |
WaitForCompletion(); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
108 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
109 |
iVirtIo->SetStatus( EStatusAcknowledge |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
110 |
| EStatusDriverFound ); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
111 |
iVirtIo->SetStatus( EStatusAcknowledge ); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
112 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
113 |
Wipe(); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
114 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
115 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
116 |
MQueue& DIoHandler::Queue( TUint id ) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
117 |
{ return *(iQueue[id]); } |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
118 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
119 |
void DIoHandler::ScheduleCallback() |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
120 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
121 |
iDfc.Enque(); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
122 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
123 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
124 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
125 |
// Waits until device processes all pending requests |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
126 |
// This code should be really handled by each queue individually |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
127 |
void DIoHandler::WaitForCompletion() |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
128 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
129 |
SYBORG_VIRTIO_DEBUG("WaitForCompletion : {"); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
130 |
|
71
d00bf4f57250
Fix bug 873. Fixes to syborg virtio-audio code as well as to the audio driver
Maciej Jablonski <maciej.jablonski@sosco.com>
parents:
45
diff
changeset
|
131 |
TInt st = Kern::PollingWait( &DIoHandler::CheckProcessing, this, 50, 100 ); |
45
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
132 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
133 |
ASSERT( st == KErrNone ); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
134 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
135 |
for ( TUint i = 0; i < iQueueCount; ++i ) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
136 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
137 |
while ( iQueue[i]->Completed() ) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
138 |
{ InterruptHandler(); } |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
139 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
140 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
141 |
SYBORG_VIRTIO_DEBUG("WaitForCompletion : }"); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
142 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
143 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
144 |
TBool DIoHandler::CheckProcessing( TAny* aSelf ) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
145 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
146 |
DIoHandler* self = reinterpret_cast<DIoHandler*>( aSelf ); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
147 |
for ( TUint i = 0; i < self->iQueueCount; ++i ) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
148 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
149 |
if (self->iQueue[i]->Processing()!=0) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
150 |
{ return EFalse; } |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
151 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
152 |
return ETrue; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
153 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
154 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
155 |
void DIoHandler::InstallIsr() |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
156 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
157 |
iDfc.SetDfcQ( iDfcQue ); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
158 |
Interrupt::Bind(iIntNum,ServeIsr,this); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
159 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
160 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
161 |
void DIoHandler::UninstallIsr() |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
162 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
163 |
Interrupt::Unbind(iIntNum); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
164 |
iDfc.Cancel(); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
165 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
166 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
167 |
void DIoHandler::ServeIsr( TAny* aSelf ) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
168 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
169 |
DIoHandler* self = reinterpret_cast<DIoHandler*>( aSelf ); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
170 |
Interrupt::Clear( self->iIntNum ); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
171 |
self->iVirtIo->ClearInteruptStatus(); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
172 |
self->iDfc.Add(); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
173 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
174 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
175 |
void DIoHandler::ServeDfc( TAny* aSelf ) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
176 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
177 |
reinterpret_cast<DIoHandler*>( aSelf )->InterruptHandler(); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
178 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
179 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
180 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
181 |
// Although the function notifies all clients |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
182 |
// usually only one of them is an adressee |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
183 |
// the rest would just check flags/compare numbers and return. |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
184 |
// If at least one client did some crucial processing |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
185 |
// (indicating that by returning EFalse from VirtIoCallback) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
186 |
// then NotifyClients returns EFalse as well. |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
187 |
TBool DIoHandler::NotifyClients( MQueue& aQueue, Token aToken, TUint aBytesTransferred ) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
188 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
189 |
TBool r = ETrue; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
190 |
for ( TUint i = 0 ; i < iClientCount; ++i ) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
191 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
192 |
r &= iClients[i]->VirtIoCallback( *this, aQueue, aToken, aBytesTransferred ); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
193 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
194 |
return r; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
195 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
196 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
197 |
// Here buffers processed by the device are iterated. |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
198 |
// After the first serious buffer processing (as indicated by NotifyClients) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
199 |
// further buffer processing is Deferred in another DFC callback. |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
200 |
void DIoHandler::InterruptHandler() |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
201 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
202 |
for ( TUint q = 0; q < iQueueCount; ++q ) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
203 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
204 |
TUint transferred; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
205 |
TUint cnt = ETrue; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
206 |
do |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
207 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
208 |
Token t = Queue(q).GetBuf(transferred); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
209 |
if (t) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
210 |
{ cnt = NotifyClients( Queue(q), t, transferred); } |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
211 |
else |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
212 |
{ break; } |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
213 |
} while(cnt); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
214 |
if (!cnt) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
215 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
216 |
ScheduleCallback(); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
217 |
break; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
218 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
219 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
220 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
221 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
222 |
void DIoHandler::UnregisterClient( MIoCallback* aClient ) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
223 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
224 |
ASSERT( iClientCount ); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
225 |
TUint i; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
226 |
for ( i = 0; i < iClientCount; ++i) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
227 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
228 |
if (iClients[i] == aClient ) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
229 |
{ break; } |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
230 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
231 |
ASSERT( i < iClientCount ); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
232 |
--iClientCount; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
233 |
// move the rest of the table one slot to the front |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
234 |
for ( ; i < iClientCount; ++i) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
235 |
{ iClients[i] = iClients[i+1]; } |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
236 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
237 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
238 |
} // namespace VirtIo |