Working on AO support.
--- a/kernel/eka/euser/epoc/symc/uc_exec.cpp Wed Apr 28 00:44:14 2010 +0200
+++ b/kernel/eka/euser/epoc/symc/uc_exec.cpp Thu Apr 29 17:37:22 2010 +0200
@@ -31,6 +31,7 @@
*/
enum TSymcExecPanic
{
+ ESymcExecPanicNotSupported,
ESymcExecPanicHeapAlreadyExists,
ESymcExecPanicCreateHeapFailed,
ESymcExecPanicNotUsed
@@ -43,6 +44,64 @@
}
+const TInt KTrapStackSize=256;
+
+/*
+TODO: should we use CObject?
+*/
+class TThread
+ {
+public:
+
+public:
+ RSemaphore iRequestSemaphore;
+ CActiveScheduler* iActiveScheduler; //Current active scheduler for this thread. Used.
+ TTrapHandler* iHandler; //This is our cleanup stack. Used.
+ //No idea why we need that trap stack
+ //TTrap* iTrapStack[KTrapStackSize];
+ //TInt iTrapCount;
+ };
+
+/*
+TODO: should we use CObject?
+Object used to store process globals for our pseudo kernel.
+That's typically going to be a singleton.
+*/
+class TProcess
+ {
+public:
+ void CreateHeap();
+ void Free();
+
+public:
+ RHeap* iAllocator;
+ TAny* iBase;
+ TThread iThread; //Single thread for now
+ };
+
+
+void TProcess::CreateHeap()
+ {
+ //iThread.iTrapCount=0;
+ //Define the size of our heap
+ const TInt KHeapMaxSize=1024*1024*10; // 10 Mo for now
+ __ASSERT_ALWAYS(iAllocator==NULL && iBase==NULL,Panic(ESymcExecPanicHeapAlreadyExists));
+ iBase=malloc(KHeapMaxSize);
+ __ASSERT_ALWAYS(iBase!=NULL,Panic(ESymcExecPanicCreateHeapFailed));
+ //TODO: is there anyway we could use variable size heap?
+ iAllocator=UserHeap::FixedHeap(iBase,KHeapMaxSize);
+ __ASSERT_ALWAYS(iAllocator!=NULL,Panic(ESymcExecPanicCreateHeapFailed));
+ }
+
+void TProcess::Free()
+ {
+ free(iBase);
+ }
+
+
+
+TProcess gProcess;
+
//
@@ -63,7 +122,8 @@
TInt __fastcall LazyDispatch(TInt aFunction, TInt* aArgs)
{
- //SL:
+ Panic(ESymcExecPanicNotSupported);
+ //
HINSTANCE kernel = GetModuleHandleA("ekern.dll");
//HINSTANCE kernel = GetModuleHandleA("ekern.exe");
if (kernel)
@@ -271,17 +331,11 @@
return Exec::BTraceOut(aHeader,aModuleUid,ext,aDataSize);
}
-__NAKED__ void ExecRequestComplete(TInt /*aHandle*/, TRequestStatus*& /*aStatus*/, TInt /*aReason*/)
+__NAKED__ void ExecRequestComplete(TInt aHandle, TRequestStatus*& aStatus, TInt aReason)
{
- _asm mov ecx, [esp+8] // ecx = TRequestStatus**
- _asm xor eax, eax //
- _asm lock xchg eax, [ecx] // eax=TRequestStatus*, zero TRequestStatus*
- _asm cmp eax, 0 //
- _asm je ExecRequestComplete_ret
- _asm mov ecx, [esp+12] // ecx = aReason
- _asm mov [eax], ecx // store aReason in request status
- __DISPATCH(EExecThreadRequestSignal|EXECUTIVE_SLOW)
- _asm ExecRequestComplete_ret: ret
+ //TODO: look our thread per handle
+ *aStatus=aReason;
+ gProcess.iThread.iRequestSemaphore.Signal();
}
@@ -355,66 +409,7 @@
//
#ifndef __GEN_USER_EXEC_CODE__
-const TInt KTrapStackSize=256;
-/*
-
-*/
-class TThread
- {
-public:
-
-public:
- RSemaphore iRequestSemaphore;
- CActiveScheduler* iActiveScheduler; //Current active scheduler for this thread. Used.
- TTrapHandler* iHandler; //This is our cleanup stack. Used.
- //No idea why we need that trap stack
- //TTrap* iTrapStack[KTrapStackSize];
- //TInt iTrapCount;
- };
-
-/*
-Object used to store process globals for our pseudo kernel.
-That's typically going to be a singleton.
-*/
-class TProcess
- {
-public:
- void CreateHeap();
- void Free();
-
-public:
- RHeap* iAllocator;
- TAny* iBase;
- TThread iThread; //Single thread for now
- };
-
-
-void TProcess::CreateHeap()
- {
- //iThread.iTrapCount=0;
- //Define the size of our heap
- const TInt KHeapMaxSize=1024*1024*10; // 10 Mo for now
- __ASSERT_ALWAYS(iAllocator==NULL && iBase==NULL,Panic(ESymcExecPanicHeapAlreadyExists));
- iBase=malloc(KHeapMaxSize);
- __ASSERT_ALWAYS(iBase!=NULL,Panic(ESymcExecPanicCreateHeapFailed));
- //TODO: is there anyway we could use variable size heap?
- iAllocator=UserHeap::FixedHeap(iBase,KHeapMaxSize);
- __ASSERT_ALWAYS(iAllocator!=NULL,Panic(ESymcExecPanicCreateHeapFailed));
- }
-
-void TProcess::Free()
- {
- free(iBase);
- }
-
-
-
-TProcess gProcess;
-
-
-
-//RHeap gAllocator;
__EXECDECL__ void Exec::WaitForAnyRequest()
{
@@ -453,12 +448,14 @@
__EXECDECL__ CActiveScheduler* Exec::ActiveScheduler()
{
- FAST_EXEC0(EFastExecActiveScheduler);
+ //FAST_EXEC0(EFastExecActiveScheduler);
+ return gProcess.iThread.iActiveScheduler;
}
-__EXECDECL__ void Exec::SetActiveScheduler(CActiveScheduler*)
+__EXECDECL__ void Exec::SetActiveScheduler(CActiveScheduler* aActiveScheduler)
{
- FAST_EXEC1(EFastExecSetActiveScheduler);
+ //FAST_EXEC1(EFastExecSetActiveScheduler);
+ gProcess.iThread.iActiveScheduler=aActiveScheduler;
}
__EXECDECL__ TTimerLockSpec Exec::LockPeriod()
@@ -1111,9 +1108,29 @@
SLOW_EXEC2(EExecMutexCreate);
}
-__EXECDECL__ TInt Exec::SemaphoreCreate(const TDesC8*, TInt, TOwnerType)
+__EXECDECL__ TInt Exec::SemaphoreCreate(const TDesC8* aName, TInt aCount, TOwnerType aType)
{
- SLOW_EXEC3(EExecSemaphoreCreate);
+ //SLOW_EXEC3(EExecSemaphoreCreate);
+#ifdef _WINDOWS
+ HANDLE semaphore = CreateSemaphore(
+ NULL, // default security attributes
+ aCount,
+ KMaxTInt,
+ //TODO: use the name
+ NULL); // unnamed mutex
+
+ if (semaphore)
+ {
+ //success
+ return (TInt)semaphore;
+ }
+
+ //failure
+ return NULL;
+#else
+ //TODO: pthread implementation
+ Panic(ESymcExecPanicNotSupported);
+#endif
}
__EXECDECL__ TInt Exec::ThreadOpenById(TUint, TOwnerType)
@@ -1686,7 +1703,9 @@
__EXECDECL__ void Exec::ThreadRequestSignal(TInt)
{
- SLOW_EXEC1(EExecThreadRequestSignal);
+ //SLOW_EXEC1(EExecThreadRequestSignal);
+ //TODO: look our thread per handle
+ gProcess.iThread.iRequestSemaphore.Signal();
}
__EXECDECL__ TBool Exec::MutexIsHeld(TInt)
--- a/kernel/eka/euser/epoc/win32/uc_epoc.cpp Wed Apr 28 00:44:14 2010 +0200
+++ b/kernel/eka/euser/epoc/win32/uc_epoc.cpp Thu Apr 29 17:37:22 2010 +0200
@@ -28,6 +28,7 @@
//For now we use this for basic testing on our SYMC implementation
+
class CBaseTest: public CBase
{
@@ -35,8 +36,7 @@
GLDEF_C void MainL()
- {
-
+ {
CBase* other=new(ELeave) CBase();
CleanupStack::PushL(other);
CBase* base=new(ELeave) CBase();
@@ -70,6 +70,7 @@
GLDEF_C TInt E32Main()
{
//What do we do then
+ //SetReturnedHandle
__UHEAP_MARK;
@@ -95,9 +96,17 @@
return KErrNoMemory;
}
+ CActiveScheduler* activeScheduler = new CActiveScheduler;
+ if (!activeScheduler)
+ {
+ return KErrNoMemory;
+ }
+ CActiveScheduler::Install(activeScheduler);
+
TInt err=KErrNone;
TRAP(err,MainL());
-
+
+ delete activeScheduler;
delete cleanupStack;
__UHEAP_MARKEND;
--- a/kernel/eka/include/e32cmn.inl Wed Apr 28 00:44:14 2010 +0200
+++ b/kernel/eka/include/e32cmn.inl Thu Apr 29 17:37:22 2010 +0200
@@ -3166,6 +3166,7 @@
@return KErrNone, if aHandle is a handle-number; the value of aHandleOrError, otherwise.
*/
{
+#ifndef __SYMC__
if(aHandleOrError>=0)
{
iHandle = aHandleOrError;
@@ -3173,6 +3174,19 @@
}
iHandle = 0;
return aHandleOrError;
+#elif defined(_WIN32)
+ //Our problem is that win32 handles can be negative
+ if (aHandleOrError==NULL)
+ {
+ //TODO: check GetLastError and return proper error code
+ return KErrUnknown;
+ }
+ //Valid handle
+ iHandle = aHandleOrError;
+ return KErrNone;
+#else
+#error "Platform not supported"
+#endif
}