os/kernelhwsrv/kernel/eka/personality/example/personality_int.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kernel/eka/personality/example/personality_int.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,175 @@
     1.4 +/*
     1.5 +* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of the License "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description:
    1.18 +* e32\personality\example\personality_int.h
    1.19 +* Internal header file for example RTOS personality.
    1.20 +* This will be included by the personality layer source files.
    1.21 +* 
    1.22 +* WARNING: This file contains some APIs which are internal and are subject
    1.23 +*          to change without notice. Such APIs should therefore not be used
    1.24 +*          outside the Kernel and Hardware Services package.
    1.25 +*
    1.26 +*/
    1.27 +
    1.28 +
    1.29 +
    1.30 +/**
    1.31 + @file
    1.32 + @internalComponent
    1.33 +*/
    1.34 +
    1.35 +#ifndef __PERSONALITY_INT_H__
    1.36 +#define __PERSONALITY_INT_H__
    1.37 +
    1.38 +// NThreadBase member data
    1.39 +#define __INCLUDE_NTHREADBASE_DEFINES__
    1.40 +
    1.41 +#include <personality/example/personality.h>
    1.42 +#include <kernel/kern_priv.h>
    1.43 +
    1.44 +// dummy constructor
    1.45 +inline NThreadBase::NThreadBase()
    1.46 +	{
    1.47 +	}
    1.48 +
    1.49 +class PThread : public NThread
    1.50 +	{
    1.51 +public:
    1.52 +	enum PThreadState
    1.53 +		{
    1.54 +		EWaitMsgQ = NThreadBase::ENumNStates,
    1.55 +		EWaitSemaphore
    1.56 +		};
    1.57 +public:
    1.58 +	static TInt Create(PThread*& aThread, const taskinfo* aInfo);
    1.59 +	static void CreateAll(const taskinfo* aInfo);
    1.60 +	static void MsgQIDfcFn(TAny*);
    1.61 +	static void StateHandler(NThread* aThread, TInt aOp, TInt aParam);
    1.62 +	static void ExceptionHandler(TAny* aContext, NThread* aThread);
    1.63 +public:
    1.64 +	inline PThread() : iMsgQIDfc(0,0) {}	// dummy constructor
    1.65 +	void ISRPost(msghdr* aM);
    1.66 +	void Post(msghdr* aFirst, msghdr* aLast);
    1.67 +	msghdr* GetMsg();
    1.68 +	void HandleSuspend();
    1.69 +	void HandleResume();
    1.70 +	void HandleRelease(TInt aReturnCode);
    1.71 +	void HandlePriorityChange(TInt aNewPriority);
    1.72 +	void HandleTimeout();
    1.73 +public:
    1.74 +	TInt	iTaskId;
    1.75 +	TInt	iSetPriority;
    1.76 +	msghdr*	iFirstMsg;
    1.77 +	msghdr* iLastMsg;
    1.78 +	TDfc	iMsgQIDfc;
    1.79 +	msghdr* iISRFirstMsg;
    1.80 +	msghdr* iISRLastMsg;
    1.81 +public:
    1.82 +	static TInt NumTasks;
    1.83 +	static TInt MaxTaskId;
    1.84 +	static PThread** TaskTable;
    1.85 +	static const TUint8 NThreadPriorityTable[MAX_TASK_PRIORITY+1];
    1.86 +	static const SNThreadHandlers Handlers;
    1.87 +	};
    1.88 +
    1.89 +class PMemPool;
    1.90 +struct SMemBlock
    1.91 +	{
    1.92 +	PMemPool*	iPool;
    1.93 +	SMemBlock*	iNext;		// only if free block
    1.94 +	};
    1.95 +
    1.96 +class PMemPool
    1.97 +	{
    1.98 +public:
    1.99 +	TInt Create(const poolinfo* aInfo);
   1.100 +	void* Alloc();
   1.101 +	void Free(void* aBlock);
   1.102 +public:
   1.103 +	SMemBlock*	iFirstFree;
   1.104 +	size_t		iBlockSize;
   1.105 +	};
   1.106 +
   1.107 +class PMemMgr
   1.108 +	{
   1.109 +public:
   1.110 +	static void Create(const poolinfo* aInfo);
   1.111 +	static void* Alloc(size_t aSize);
   1.112 +	static void Free(void* aBlock);
   1.113 +public:
   1.114 +	TInt iPoolCount;
   1.115 +	PMemPool iPools[1];		// extend
   1.116 +public:
   1.117 +	static PMemMgr* TheMgr;
   1.118 +	};
   1.119 +
   1.120 +
   1.121 +class PTimer : public NTimer
   1.122 +	{
   1.123 +public:
   1.124 +	PTimer();
   1.125 +	static void CreateAll();
   1.126 +	static void NTimerExpired(TAny*);
   1.127 +public:
   1.128 +	TInt		iPeriod;	// 0 if single shot
   1.129 +	TAny*		iCookie;
   1.130 +	PThread*	iThread;
   1.131 +	TUint		iExpiryCount;
   1.132 +public:
   1.133 +	static TInt NumTimers;
   1.134 +	static PTimer* TimerTable;
   1.135 +	};
   1.136 +
   1.137 +
   1.138 +class PSemaphore
   1.139 +	{
   1.140 +public:
   1.141 +	static void CreateAll();
   1.142 +public:
   1.143 +	PSemaphore();
   1.144 +	void WaitCancel(PThread* aThread);
   1.145 +	void SuspendWaitingThread(PThread* aThread);
   1.146 +	void ResumeWaitingThread(PThread* aThread);
   1.147 +	void ChangeWaitingThreadPriority(PThread* aThread, TInt aNewPriority);
   1.148 +	void Signal();
   1.149 +	void ISRSignal();
   1.150 +	static void IDfcFn(TAny*);
   1.151 +public:
   1.152 +	TInt iCount;
   1.153 +	TInt iISRCount;
   1.154 +	TDfc iIDfc;
   1.155 +	SDblQue iSuspendedQ;
   1.156 +	TPriList<PThread, KNumPriorities> iWaitQ;
   1.157 +public:
   1.158 +	static TInt NumSemaphores;
   1.159 +	static PSemaphore* SemaphoreTable;
   1.160 +	};
   1.161 +
   1.162 +class TPMsgQ : public TDfc
   1.163 +	{
   1.164 +public:
   1.165 +	TPMsgQ(TDfcFn aFunction, TAny* aPtr, TDfcQue* aDfcQ, TInt aPriority);
   1.166 +	void Receive();
   1.167 +	msghdr* Get();
   1.168 +	void CancelReceive();
   1.169 +public:
   1.170 +	msghdr* iFirstMsg;
   1.171 +	msghdr* iLastMsg;
   1.172 +	TBool iReady;
   1.173 +public:
   1.174 +	static TPMsgQ* ThePMsgQ;
   1.175 +	};
   1.176 +
   1.177 +
   1.178 +#endif