0
|
1 |
/*
|
|
2 |
* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
* e32\personality\example\personality_int.h
|
|
16 |
* Internal header file for example RTOS personality.
|
|
17 |
* This will be included by the personality layer source files.
|
|
18 |
*
|
|
19 |
* WARNING: This file contains some APIs which are internal and are subject
|
|
20 |
* to change without notice. Such APIs should therefore not be used
|
|
21 |
* outside the Kernel and Hardware Services package.
|
|
22 |
*
|
|
23 |
*/
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
/**
|
|
28 |
@file
|
|
29 |
@internalComponent
|
|
30 |
*/
|
|
31 |
|
|
32 |
#ifndef __PERSONALITY_INT_H__
|
|
33 |
#define __PERSONALITY_INT_H__
|
|
34 |
|
|
35 |
// NThreadBase member data
|
|
36 |
#define __INCLUDE_NTHREADBASE_DEFINES__
|
|
37 |
|
|
38 |
#include <personality/example/personality.h>
|
|
39 |
#include <kernel/kern_priv.h>
|
|
40 |
|
|
41 |
// dummy constructor
|
|
42 |
inline NThreadBase::NThreadBase()
|
|
43 |
{
|
|
44 |
}
|
|
45 |
|
|
46 |
class PThread : public NThread
|
|
47 |
{
|
|
48 |
public:
|
|
49 |
enum PThreadState
|
|
50 |
{
|
|
51 |
EWaitMsgQ = NThreadBase::ENumNStates,
|
|
52 |
EWaitSemaphore
|
|
53 |
};
|
|
54 |
public:
|
|
55 |
static TInt Create(PThread*& aThread, const taskinfo* aInfo);
|
|
56 |
static void CreateAll(const taskinfo* aInfo);
|
|
57 |
static void MsgQIDfcFn(TAny*);
|
|
58 |
static void StateHandler(NThread* aThread, TInt aOp, TInt aParam);
|
|
59 |
static void ExceptionHandler(TAny* aContext, NThread* aThread);
|
|
60 |
public:
|
|
61 |
inline PThread() : iMsgQIDfc(0,0) {} // dummy constructor
|
|
62 |
void ISRPost(msghdr* aM);
|
|
63 |
void Post(msghdr* aFirst, msghdr* aLast);
|
|
64 |
msghdr* GetMsg();
|
|
65 |
void HandleSuspend();
|
|
66 |
void HandleResume();
|
|
67 |
void HandleRelease(TInt aReturnCode);
|
|
68 |
void HandlePriorityChange(TInt aNewPriority);
|
|
69 |
void HandleTimeout();
|
|
70 |
public:
|
|
71 |
TInt iTaskId;
|
|
72 |
TInt iSetPriority;
|
|
73 |
msghdr* iFirstMsg;
|
|
74 |
msghdr* iLastMsg;
|
|
75 |
TDfc iMsgQIDfc;
|
|
76 |
msghdr* iISRFirstMsg;
|
|
77 |
msghdr* iISRLastMsg;
|
|
78 |
public:
|
|
79 |
static TInt NumTasks;
|
|
80 |
static TInt MaxTaskId;
|
|
81 |
static PThread** TaskTable;
|
|
82 |
static const TUint8 NThreadPriorityTable[MAX_TASK_PRIORITY+1];
|
|
83 |
static const SNThreadHandlers Handlers;
|
|
84 |
};
|
|
85 |
|
|
86 |
class PMemPool;
|
|
87 |
struct SMemBlock
|
|
88 |
{
|
|
89 |
PMemPool* iPool;
|
|
90 |
SMemBlock* iNext; // only if free block
|
|
91 |
};
|
|
92 |
|
|
93 |
class PMemPool
|
|
94 |
{
|
|
95 |
public:
|
|
96 |
TInt Create(const poolinfo* aInfo);
|
|
97 |
void* Alloc();
|
|
98 |
void Free(void* aBlock);
|
|
99 |
public:
|
|
100 |
SMemBlock* iFirstFree;
|
|
101 |
size_t iBlockSize;
|
|
102 |
};
|
|
103 |
|
|
104 |
class PMemMgr
|
|
105 |
{
|
|
106 |
public:
|
|
107 |
static void Create(const poolinfo* aInfo);
|
|
108 |
static void* Alloc(size_t aSize);
|
|
109 |
static void Free(void* aBlock);
|
|
110 |
public:
|
|
111 |
TInt iPoolCount;
|
|
112 |
PMemPool iPools[1]; // extend
|
|
113 |
public:
|
|
114 |
static PMemMgr* TheMgr;
|
|
115 |
};
|
|
116 |
|
|
117 |
|
|
118 |
class PTimer : public NTimer
|
|
119 |
{
|
|
120 |
public:
|
|
121 |
PTimer();
|
|
122 |
static void CreateAll();
|
|
123 |
static void NTimerExpired(TAny*);
|
|
124 |
public:
|
|
125 |
TInt iPeriod; // 0 if single shot
|
|
126 |
TAny* iCookie;
|
|
127 |
PThread* iThread;
|
|
128 |
TUint iExpiryCount;
|
|
129 |
public:
|
|
130 |
static TInt NumTimers;
|
|
131 |
static PTimer* TimerTable;
|
|
132 |
};
|
|
133 |
|
|
134 |
|
|
135 |
class PSemaphore
|
|
136 |
{
|
|
137 |
public:
|
|
138 |
static void CreateAll();
|
|
139 |
public:
|
|
140 |
PSemaphore();
|
|
141 |
void WaitCancel(PThread* aThread);
|
|
142 |
void SuspendWaitingThread(PThread* aThread);
|
|
143 |
void ResumeWaitingThread(PThread* aThread);
|
|
144 |
void ChangeWaitingThreadPriority(PThread* aThread, TInt aNewPriority);
|
|
145 |
void Signal();
|
|
146 |
void ISRSignal();
|
|
147 |
static void IDfcFn(TAny*);
|
|
148 |
public:
|
|
149 |
TInt iCount;
|
|
150 |
TInt iISRCount;
|
|
151 |
TDfc iIDfc;
|
|
152 |
SDblQue iSuspendedQ;
|
|
153 |
TPriList<PThread, KNumPriorities> iWaitQ;
|
|
154 |
public:
|
|
155 |
static TInt NumSemaphores;
|
|
156 |
static PSemaphore* SemaphoreTable;
|
|
157 |
};
|
|
158 |
|
|
159 |
class TPMsgQ : public TDfc
|
|
160 |
{
|
|
161 |
public:
|
|
162 |
TPMsgQ(TDfcFn aFunction, TAny* aPtr, TDfcQue* aDfcQ, TInt aPriority);
|
|
163 |
void Receive();
|
|
164 |
msghdr* Get();
|
|
165 |
void CancelReceive();
|
|
166 |
public:
|
|
167 |
msghdr* iFirstMsg;
|
|
168 |
msghdr* iLastMsg;
|
|
169 |
TBool iReady;
|
|
170 |
public:
|
|
171 |
static TPMsgQ* ThePMsgQ;
|
|
172 |
};
|
|
173 |
|
|
174 |
|
|
175 |
#endif
|