author | bugtracker-ml@nttdocomo.com |
Tue, 06 Apr 2010 18:41:44 +0100 | |
changeset 58 | 11e392ea2e63 |
parent 45 | 01c1ffcc4fca |
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.h" |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
17 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
18 |
namespace VirtIo |
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 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
21 |
#define MIN(x,y) (((x)<=(y))?(x):(y)) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
22 |
#define INVALID_PHYSADDR(x) ((x)==TPhysAddr(-1)) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
23 |
|
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
24 |
TInt LinearToSGL( TAny* aVirtual, TUint aSize, TAddrLen aSGL[], TUint& aSGLCount ) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
25 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
26 |
const TUint pageSize = Kern::RoundToPageSize(1); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
27 |
TUint8* virtAddr = reinterpret_cast<TUint8*>( aVirtual ); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
28 |
TPhysAddr physAddr = Epoc::LinearToPhysical( TLinAddr(virtAddr) ); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
29 |
if (INVALID_PHYSADDR(physAddr)) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
30 |
{ return KErrArgument; } |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
31 |
TUint sglLimit = aSGLCount; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
32 |
aSGLCount = 0; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
33 |
TUint left = aSize; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
34 |
while (left) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
35 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
36 |
TPhysAddr startPhysAddr = physAddr; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
37 |
TUint8* startVirtAddr = virtAddr; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
38 |
while ( (left) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
39 |
&& ( Epoc::LinearToPhysical( TLinAddr(virtAddr) ) == physAddr ) ) |
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 |
TUint size = MIN(left, pageSize); |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
42 |
physAddr += size; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
43 |
virtAddr += size; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
44 |
left -= size; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
45 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
46 |
if (INVALID_PHYSADDR(physAddr)) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
47 |
{ return KErrArgument; } |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
48 |
if ((aSGL) && (aSGLCount<sglLimit)) |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
49 |
{ |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
50 |
aSGL[aSGLCount].iAddr = (TUint32) startPhysAddr; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
51 |
aSGL[aSGLCount].iLen = virtAddr - startVirtAddr; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
52 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
53 |
aSGLCount++; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
54 |
} |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
55 |
return (aSGLCount<=sglLimit)?KErrNone:KErrNoMemory; |
01c1ffcc4fca
Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff
changeset
|
56 |
} |
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 |
} // namespace VirtIo |