| author | Gareth Stockwell <gareth.stockwell@accenture.com> |
| Fri, 24 Sep 2010 13:54:59 +0100 | |
| branch | bug235_bringup_0 |
| changeset 2 | 47632b7dfb88 |
| parent 0 | 91fe342bd9c4 |
| permissions | -rw-r--r-- |
|
0
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
1 |
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
2 |
// All rights reserved. |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
3 |
// This component and the accompanying materials are made available |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
4 |
// under the terms of "Eclipse Public License v1.0" |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
5 |
// which accompanies this distribution, and is available |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
7 |
// |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
8 |
// Initial Contributors: |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
9 |
// Nokia Corporation - initial contribution. |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
10 |
// |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
11 |
// Contributors: |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
12 |
// |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
13 |
// Description: |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
14 |
// Syborg Virtual Hardware Memory implementation |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
15 |
|
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
16 |
/** |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
17 |
@file |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
18 |
@internalTechnology |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
19 |
@prototype |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
20 |
*/ |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
21 |
|
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
22 |
#include "syborgvirtualhwmemory.h" |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
23 |
|
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
24 |
DVirtualHWMemoryManager::DVirtualHWMemoryManager(TUint32 aBase, TInt aMaxSize): |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
25 |
iRoot(0, aBase), |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
26 |
iLast(0, aBase + aMaxSize) |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
27 |
{
|
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
28 |
iRoot.iNext = &iLast; |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
29 |
} |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
30 |
|
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
31 |
TUint32 DVirtualHWMemoryManager::Allocate(TInt aSize) |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
32 |
{
|
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
33 |
TUint32 address(NULL); |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
34 |
TAllocatedCell* current(&iRoot); |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
35 |
TAllocatedCell* next(iRoot.iNext); |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
36 |
while (next) |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
37 |
{
|
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
38 |
const TInt freeBetweenCells = next->iBase - (current->iBase + current->iSize); |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
39 |
if (freeBetweenCells >= aSize ) |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
40 |
{
|
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
41 |
//Mark area as allocated |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
42 |
address = current->iBase + current->iSize; |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
43 |
TAllocatedCell* newCell = new TAllocatedCell(aSize, address); |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
44 |
if (!newCell) |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
45 |
{
|
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
46 |
return NULL; |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
47 |
} |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
48 |
newCell->iNext = next; |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
49 |
current->iNext = newCell; |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
50 |
break; |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
51 |
} |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
52 |
else |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
53 |
{
|
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
54 |
current = next; |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
55 |
next = next->iNext; |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
56 |
} |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
57 |
} |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
58 |
return address; |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
59 |
} |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
60 |
|
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
61 |
void DVirtualHWMemoryManager::Deallocate(const TUint32 aPhysicalAddress) |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
62 |
{
|
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
63 |
TAllocatedCell* prev(&iRoot); |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
64 |
TAllocatedCell* next(iRoot.iNext); |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
65 |
while (next) |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
66 |
{
|
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
67 |
if (next->iBase == aPhysicalAddress) |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
68 |
{
|
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
69 |
prev->iNext = next->iNext; |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
70 |
delete next; |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
71 |
next = NULL; |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
72 |
} |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
73 |
else |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
74 |
{
|
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
75 |
prev = next; |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
76 |
next = next->iNext; |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
77 |
} |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
78 |
} |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
79 |
} |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
80 |
|
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
81 |
DVirtualHWMemoryManager::~DVirtualHWMemoryManager() |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
82 |
{
|
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
83 |
TAllocatedCell* next(iRoot.iNext); |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
84 |
while (next) |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
85 |
{
|
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
86 |
TAllocatedCell* deletethis = next; |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
87 |
next = next->iNext; |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
88 |
if (deletethis != &iLast) |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
89 |
{
|
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
90 |
delete deletethis; |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
91 |
} |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
92 |
} |
|
91fe342bd9c4
Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff
changeset
|
93 |
} |