📄 osal.c
字号:
/*----------------------------------------------------------------------------
COPYRIGHT (c) 1997 by Philips Semiconductors
THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY ONLY BE USED AND COPIED IN
ACCORDANCE WITH THE TERMS AND CONDITIONS OF SUCH A LICENSE AND WITH THE
INCLUSION OF THE THIS COPY RIGHT NOTICE. THIS SOFTWARE OR ANY OTHER COPIES
OF THIS SOFTWARE MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY OTHER
PERSON. THE OWNERSHIP AND TITLE OF THIS SOFTWARE IS NOT TRANSFERRED.
THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT ANY PRIOR NOTICE
AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY Philips Semiconductor.
PHILIPS ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY OF THIS SOFTWARE
ON PLATFORMS OTHER THAN THE ONE ON WHICH THIS SOFTWARE IS FURNISHED.
----------------------------------------------------------------------------*/
/*
HISTORY
#define TR Tilakraj Roy
960510 TR Created
961019 TR Moved the CTC 1.1 bug fix in IRQGen from IRQAck.
970521 TR Rewrote for Generic Target TMMan
*/
/*----------------------------------------------------------------------------
SYSTEM INCLUDE FILES
----------------------------------------------------------------------------*/
/* gates specific includes */
/*----------------------------------------------------------------------------
DRIVER SPECIFIC INCLUDE FILES
----------------------------------------------------------------------------*/
#include "tmmanlib.h"
#include "tmmanapi.h"
#include "AppSem.h"
#include "ops/custom_defs.h"
#include "ops/custom_ops.h"
#include "tm1/mmio.h"
#undef OPTION_LATENCY
#ifdef OPTION_LATENCY
static UInt32 EndCycles;
static UInt32 StartCycles;
#endif
typedef struct tagSynchObject
{
UInt32 SynchronizationFlags;
AppSem_Semaphore OSSynchObject;
void ( *CallbackFunction )(void);
} SynchObject;
/* Synchronization Object Abstraction Functions */
Bool syncobjCreate (
UInt32 SynchronizationFlags,
UInt32 OSSynchronizationHandle,
UInt32 *SynchronizationHandlePointer,
Int8* SynchronizationObjectName )
{
SynchObject* Object;
if ( ( Object = memAllocate (
sizeof(SynchObject) ) ) == Null )
{
return False;
}
Object->SynchronizationFlags = SynchronizationFlags;
switch ( Object->SynchronizationFlags )
{
case constTMManModuleTargetKernel:
case constTMManModuleTargetUser:
Object->OSSynchObject =
(AppSem_Semaphore)OSSynchronizationHandle;
break;
case constTMManModuleTargetCallback:
Object->CallbackFunction = OSSynchronizationHandle;
/*
DPF(0,("syncobjCreate:Callback[%x]:Registered\n",
Object->CallbackFunction ));
*/
break;
default :
memFree ( Object );
return False;
}
*SynchronizationHandlePointer = (UInt32)Object;
return True;
}
Bool syncobjSignal (
UInt32 SynchronizationHandle )
{
SynchObject* Object = (SynchObject*)SynchronizationHandle;
switch ( Object->SynchronizationFlags )
{
case constTMManModuleTargetKernel:
case constTMManModuleTargetUser:
AppSem_v(Object->OSSynchObject);
break;
case constTMManModuleTargetCallback:
/*
DPF(0,("syncobjSignal:Callback[%x]:Enter\n",
Object->CallbackFunction ));
*/
Object->CallbackFunction();
/*
DPF(0,("syncobjSignal:Callback[%x]:Return\n",
Object->CallbackFunction ));
*/
break;
default :
return False;
}
return True;
}
Bool syncobjDestroy (
UInt32 SynchronizationHandle )
{
SynchObject* Object = (SynchObject*)SynchronizationHandle;
memFree (Object);
return True;
}
Bool critsectCreate (
UInt32* CriticalSectionObjectPointer )
{
return True;
}
Bool critsectDestroy (
UInt32 CriticalSectionObject )
{
return True;
}
/* Note that the caller has to allocate storage
sizeof (UInt32) for nested context and pass the address
of that parameter to this function.
*/
Bool critsectEnter (
UInt32 CriticalSectionObject, Pointer NestedContext )
{
*((UInt32 *)NestedContext) = intClearIEN ();
#ifdef OPTION_LATENCY
/*
The maximum measured time interrupts were turned off
( interrupt latency ) using this stuff with all DPFs
turned off was 0x1000 cycles on a 100Mhz Board
plugged in a 333MHz Pentium II system.
*/
/*
DPF(0,("(" ));
*/
StartCycles = cycles();
#endif
return True;
}
Bool critsectLeave (
UInt32 CriticalSectionObject, Pointer NestedContext )
{
#ifdef OPTION_LATENCY
/*
DPF(0,(")" ));
*/
EndCycles = cycles();
#endif
intRestoreIEN ( *((UInt32 *)NestedContext) );
#ifdef OPTION_LATENCY
if ( EndCycles > StartCycles )
DPF (0, ("CYCLES[%x]\n", EndCycles - StartCycles ));
#endif
return True;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -