sl@0
|
1 |
// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// e32test\mmu\d_asid.cpp
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#include <kernel/kern_priv.h>
|
sl@0
|
19 |
#include "d_asid.h"
|
sl@0
|
20 |
|
sl@0
|
21 |
//
|
sl@0
|
22 |
// Class definitions
|
sl@0
|
23 |
//
|
sl@0
|
24 |
|
sl@0
|
25 |
class DAsidFactory : public DLogicalDevice
|
sl@0
|
26 |
{
|
sl@0
|
27 |
public:
|
sl@0
|
28 |
~DAsidFactory();
|
sl@0
|
29 |
virtual TInt Install();
|
sl@0
|
30 |
virtual void GetCaps(TDes8& aDes) const;
|
sl@0
|
31 |
virtual TInt Create(DLogicalChannelBase*& aChannel);
|
sl@0
|
32 |
};
|
sl@0
|
33 |
|
sl@0
|
34 |
class DAsidChannel : public DLogicalChannelBase
|
sl@0
|
35 |
{
|
sl@0
|
36 |
public:
|
sl@0
|
37 |
DAsidChannel();
|
sl@0
|
38 |
~DAsidChannel();
|
sl@0
|
39 |
virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
|
sl@0
|
40 |
virtual TInt Request(TInt aFunction, TAny* a1, TAny* a2);
|
sl@0
|
41 |
public:
|
sl@0
|
42 |
DAsidFactory* iFactory;
|
sl@0
|
43 |
private:
|
sl@0
|
44 |
DThread* iThread;
|
sl@0
|
45 |
};
|
sl@0
|
46 |
|
sl@0
|
47 |
//
|
sl@0
|
48 |
// DAsidFactory
|
sl@0
|
49 |
//
|
sl@0
|
50 |
|
sl@0
|
51 |
TInt DAsidFactory::Install()
|
sl@0
|
52 |
{
|
sl@0
|
53 |
return SetName(&KMemoryTestLddName);
|
sl@0
|
54 |
}
|
sl@0
|
55 |
|
sl@0
|
56 |
DAsidFactory::~DAsidFactory()
|
sl@0
|
57 |
{
|
sl@0
|
58 |
}
|
sl@0
|
59 |
|
sl@0
|
60 |
void DAsidFactory::GetCaps(TDes8& /*aDes*/) const
|
sl@0
|
61 |
{
|
sl@0
|
62 |
// Not used but required as DLogicalDevice::GetCaps is pure virtual
|
sl@0
|
63 |
}
|
sl@0
|
64 |
|
sl@0
|
65 |
TInt DAsidFactory::Create(DLogicalChannelBase*& aChannel)
|
sl@0
|
66 |
{
|
sl@0
|
67 |
aChannel = NULL;
|
sl@0
|
68 |
DAsidChannel* channel=new DAsidChannel;
|
sl@0
|
69 |
if(!channel)
|
sl@0
|
70 |
return KErrNoMemory;
|
sl@0
|
71 |
channel->iFactory = this;
|
sl@0
|
72 |
aChannel = channel;
|
sl@0
|
73 |
return KErrNone;
|
sl@0
|
74 |
}
|
sl@0
|
75 |
|
sl@0
|
76 |
DECLARE_STANDARD_LDD()
|
sl@0
|
77 |
{
|
sl@0
|
78 |
return new DAsidFactory;
|
sl@0
|
79 |
}
|
sl@0
|
80 |
|
sl@0
|
81 |
//
|
sl@0
|
82 |
// DAsidChannel
|
sl@0
|
83 |
//
|
sl@0
|
84 |
|
sl@0
|
85 |
TInt DAsidChannel::DoCreate(TInt /*aUnit*/, const TDesC8* /*aInfo*/, const TVersion& /*aVer*/)
|
sl@0
|
86 |
{
|
sl@0
|
87 |
return KErrNone;
|
sl@0
|
88 |
}
|
sl@0
|
89 |
|
sl@0
|
90 |
DAsidChannel::DAsidChannel() : iThread(NULL)
|
sl@0
|
91 |
{
|
sl@0
|
92 |
}
|
sl@0
|
93 |
|
sl@0
|
94 |
DAsidChannel::~DAsidChannel()
|
sl@0
|
95 |
{
|
sl@0
|
96 |
if (iThread)
|
sl@0
|
97 |
iThread->Close(NULL);
|
sl@0
|
98 |
}
|
sl@0
|
99 |
|
sl@0
|
100 |
|
sl@0
|
101 |
TInt DAsidChannel::Request(TInt aFunction, TAny* a1, TAny* a2)
|
sl@0
|
102 |
{
|
sl@0
|
103 |
TInt r=KErrNotSupported;
|
sl@0
|
104 |
|
sl@0
|
105 |
switch(aFunction)
|
sl@0
|
106 |
{
|
sl@0
|
107 |
case RAsidLdd::EGetCurrentThread:
|
sl@0
|
108 |
{
|
sl@0
|
109 |
DThread* thread = &Kern::CurrentThread();
|
sl@0
|
110 |
kumemput32(a1, (TAny*)&thread, sizeof(DThread*));
|
sl@0
|
111 |
r = KErrNone;
|
sl@0
|
112 |
}
|
sl@0
|
113 |
break;
|
sl@0
|
114 |
|
sl@0
|
115 |
case RAsidLdd::EOpenThread:
|
sl@0
|
116 |
{
|
sl@0
|
117 |
if (iThread)
|
sl@0
|
118 |
{
|
sl@0
|
119 |
r = KErrInUse;
|
sl@0
|
120 |
break;
|
sl@0
|
121 |
}
|
sl@0
|
122 |
iThread = (DThread*) a1;
|
sl@0
|
123 |
iThread->Open();
|
sl@0
|
124 |
r = KErrNone;
|
sl@0
|
125 |
}
|
sl@0
|
126 |
break;
|
sl@0
|
127 |
|
sl@0
|
128 |
case RAsidLdd::ECloseThread:
|
sl@0
|
129 |
{
|
sl@0
|
130 |
if (!iThread)
|
sl@0
|
131 |
{
|
sl@0
|
132 |
r = KErrNotFound;
|
sl@0
|
133 |
break;
|
sl@0
|
134 |
}
|
sl@0
|
135 |
NKern::ThreadEnterCS();
|
sl@0
|
136 |
iThread->Close(NULL);
|
sl@0
|
137 |
iThread = NULL;
|
sl@0
|
138 |
r = KErrNone;
|
sl@0
|
139 |
NKern::ThreadLeaveCS();
|
sl@0
|
140 |
}
|
sl@0
|
141 |
break;
|
sl@0
|
142 |
|
sl@0
|
143 |
case RAsidLdd::EReadDesHeader:
|
sl@0
|
144 |
{
|
sl@0
|
145 |
SDesHeader hdr;
|
sl@0
|
146 |
TUint8* ptr;
|
sl@0
|
147 |
kumemget32((TAny*)&hdr, a2, sizeof(SDesHeader));
|
sl@0
|
148 |
r = Kern::ThreadGetDesInfo((DThread*)a1, hdr.iDes, hdr.iLength, hdr.iMaxLength, ptr, ETrue);
|
sl@0
|
149 |
if (r == KErrNone)
|
sl@0
|
150 |
{// copy the data back to user side struct.
|
sl@0
|
151 |
kumemput32(a2, &hdr, sizeof(SDesHeader));
|
sl@0
|
152 |
}
|
sl@0
|
153 |
}
|
sl@0
|
154 |
break;
|
sl@0
|
155 |
}
|
sl@0
|
156 |
return r;
|
sl@0
|
157 |
}
|