diff options
author | olivier <olivier@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2017-08-15 17:37:18 +0000 |
---|---|---|
committer | olivier <olivier@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2017-08-15 17:37:18 +0000 |
commit | 2faf491195fa9cd934690370ecd09a27846973dc (patch) | |
tree | fa6eb71ee6c48e7c776857eb0eaeec65046041b6 | |
parent | 0b806144531cc78f6f2d7e0d2ceb4245cba1b67b (diff) | |
download | fpc-2faf491195fa9cd934690370ecd09a27846973dc.tar.gz |
+ Empty UEFI ThreadManager implementation (based on the Native NT target).
This avoid crash when adding a uses on SysUtils in a program.
A critical section is used in TEncoding class functions (see sysencoding.inc)
and require an implementation that, at least, do not crash ;-)
git-svn-id: https://svn.freepascal.org/svn/fpc/branches/olivier@36921 3ad0048d-3df7-0310-abae-a5850022a9f2
-rw-r--r-- | uefi/rtl/uefi/systhrd.inc | 251 |
1 files changed, 248 insertions, 3 deletions
diff --git a/uefi/rtl/uefi/systhrd.inc b/uefi/rtl/uefi/systhrd.inc index dde4a7f9ec..5a9a7d9980 100644 --- a/uefi/rtl/uefi/systhrd.inc +++ b/uefi/rtl/uefi/systhrd.inc @@ -1,8 +1,11 @@ { - Basic UEFI definitions - This file is part of the Free Pascal run time library. - Copyright (c) 2014 by Olivier Coursière + Copyright (c) 2010 by Sven Barth + Copyright (c) 2017 by Olivier Coursière + + Basic UEFI definitions + Empty threading implementation for the UEFI target. + Based on Native NT threading support implementation See the file COPYING.FPC, included in this distribution, for details about the copyright. @@ -12,3 +15,245 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. **********************************************************************} + +const + STATUS_NOT_IMPLEMENTED = LongInt($C0000002); + +{***************************************************************************** + Threadvar support +*****************************************************************************} + + const + threadvarblocksize : dword = 0; + + procedure SysInitThreadvar(var offset : dword;size : dword); + begin + offset:=threadvarblocksize; + {$ifdef CPUARM} + // Data must be allocated at 4 bytes boundary for ARM + size:=(size + 3) and not dword(3); + {$endif CPUARM} + inc(threadvarblocksize,size); + end; + + + procedure SysAllocateThreadVars; + begin + end; + + procedure SysInitMultithreading; + begin + end; + + + procedure SysFiniMultithreading; + begin + end; + + function SysRelocateThreadvar(offset : dword) : pointer; + begin + SysRelocateThreadvar:=Pointer(Offset); + end; + + + procedure SysReleaseThreadVars; + begin + end; + +{***************************************************************************** + Thread starting +*****************************************************************************} + + function SysBeginThread(sa : Pointer;stacksize : ptruint; + ThreadFunction : tthreadfunc;p : pointer; + creationFlags : dword;var ThreadId : TThreadID) : TThreadID; + begin + ThreadId := 0; + Result := 0; + end; + + + procedure SysEndThread(ExitCode : DWord); + begin + DoneThread; + end; + + + procedure SysThreadSwitch; + begin + end; + + + function SysSuspendThread (threadHandle : TThreadID) : dword; + begin + Result := STATUS_NOT_IMPLEMENTED; + end; + + + function SysResumeThread (threadHandle : TThreadID) : dword; + begin + Result := STATUS_NOT_IMPLEMENTED; + end; + + + function SysKillThread (threadHandle : TThreadID) : dword; + begin + Result := STATUS_NOT_IMPLEMENTED; + end; + + function SysCloseThread (threadHandle : TThreadID) : dword; + begin + Result := STATUS_NOT_IMPLEMENTED; + end; + + function SysWaitForThreadTerminate (threadHandle : TThreadID; TimeoutMs : longint) : dword; + begin + Result := STATUS_NOT_IMPLEMENTED; + end; + + + function SysThreadSetPriority (threadHandle : TThreadID; Prio: longint): boolean; {-15..+15, 0=normal} + begin + Result := False; + end; + + + function SysThreadGetPriority (threadHandle : TThreadID): longint; + begin + Result := 0; + end; + + function SysGetCurrentThreadId : TThreadID; + begin + Result := 0; + end; + +{***************************************************************************** + Delphi/Win32 compatibility +*****************************************************************************} + +procedure SysInitCriticalSection(var cs); +begin + Pointer(cs) := GetMem(SizeOf(Pointer)); +end; + + +procedure SysDoneCriticalSection(var cs); +begin + FreeMem(Pointer(cs)); +end; + + +procedure SysEnterCriticalSection(var cs); +begin +end; + +function SysTryEnterCriticalSection(var cs):longint; +begin + Result := STATUS_NOT_IMPLEMENTED; +end; + +procedure SysLeaveCriticalSection(var cs); +begin +end; + + +function intBasicEventCreate(EventAttributes : Pointer; +AManualReset,InitialState : Boolean;const Name : ansistring):pEventState; +begin + Result := GetMem(SizeOf(Pointer)); +end; + +procedure intbasiceventdestroy(state:peventstate); +begin + FreeMem(state); +end; + +procedure intbasiceventResetEvent(state:peventstate); +begin + +end; + +procedure intbasiceventSetEvent(state:peventstate); +begin +end; + +function intbasiceventWaitFor(Timeout : Cardinal;state:peventstate) : longint; +begin + Result := STATUS_NOT_IMPLEMENTED; +end; + +function intRTLEventCreate: PRTLEvent; +begin + Result := GetMem(SizeOf(Pointer)); +end; + +procedure intRTLEventDestroy(AEvent: PRTLEvent); +begin + FreeMem(AEvent); +end; + +procedure intRTLEventSetEvent(AEvent: PRTLEvent); +begin + +end; + +procedure intRTLEventResetEvent(AEvent: PRTLEvent); +begin + +end; + +procedure intRTLEventWaitFor(AEvent: PRTLEvent); +begin + +end; + +procedure intRTLEventWaitForTimeout(AEvent: PRTLEvent;timeout : longint); +begin + +end; + + +Var + UEFIThreadManager : TThreadManager; + +Procedure InitSystemThreads; +begin + With UEFIThreadManager do + begin + InitManager :=Nil; + DoneManager :=Nil; + BeginThread :=@SysBeginThread; + EndThread :=@SysEndThread; + SuspendThread :=@SysSuspendThread; + ResumeThread :=@SysResumeThread; + KillThread :=@SysKillThread; + ThreadSwitch :=@SysThreadSwitch; + CloseThread :=@SysCloseThread; + WaitForThreadTerminate :=@SysWaitForThreadTerminate; + ThreadSetPriority :=@SysThreadSetPriority; + ThreadGetPriority :=@SysThreadGetPriority; + GetCurrentThreadId :=@SysGetCurrentThreadId; + InitCriticalSection :=@SysInitCriticalSection; + DoneCriticalSection :=@SysDoneCriticalSection; + EnterCriticalSection :=@SysEnterCriticalSection; + TryEnterCriticalSection:=@SysTryEnterCriticalSection; + LeaveCriticalSection :=@SysLeaveCriticalSection; + InitThreadVar :=@SysInitThreadVar; + RelocateThreadVar :=@SysRelocateThreadVar; + AllocateThreadVars :=@SysAllocateThreadVars; + ReleaseThreadVars :=@SysReleaseThreadVars; + BasicEventCreate :=@intBasicEventCreate; + BasicEventDestroy :=@intBasicEventDestroy; + BasicEventResetEvent :=@intBasicEventResetEvent; + BasicEventSetEvent :=@intBasicEventSetEvent; + BasiceventWaitFor :=@intBasiceventWaitFor; + RTLEventCreate :=@intRTLEventCreate; + RTLEventDestroy :=@intRTLEventDestroy; + RTLEventSetEvent :=@intRTLEventSetEvent; + RTLEventResetEvent :=@intRTLEventResetEvent; + RTLEventWaitFor :=@intRTLEventWaitFor; + RTLEventWaitForTimeout :=@intRTLEventWaitForTimeout; + end; + SetThreadManager(UEFIThreadManager); +end; |