27#ifndef INC_CINOSBUSHOOKS_H
28#define INC_CINOSBUSHOOKS_H
47#define DF_INOS_BUS_HOOK_ORDER_PRE_AXIS -20
48#define DF_INOS_BUS_HOOK_ORDER_AXIS_PRE_MAP -10
49#define DF_INOS_BUS_HOOK_ORDER_AXIS_MAP 0
50#define DF_INOS_BUS_HOOK_ORDER_CONTROL 0
51#define DF_INOS_BUS_HOOK_ORDER_AXIS_PST_MAP 10
52#define DF_INOS_BUS_HOOK_ORDER_PST_AXIS 20
53#define DF_INOS_BUS_HOOK_ORDER_DEFAULT 20
66 uint8 auCyclenumber, int32 aiOrder, uint32 auCycletime,
67 void* apHandler,
void* apObject, uint32 auFlags);
76 eFlgNone = 0x00000000,
77 eFlgEnabled = 0x00000001,
78 eFlgSingle = 0x00000002,
80 eFlgDeletePending = 0x40000000,
81 eFlgDynamic = 0x80000000,
104 friend class CINCOBusHook;
105 friend class CINCOBusHooks;
118 uint8 m_uCyclenumber;
145 uint8 auCyclenumber, int32 aiOrder, uint32 auCycletime,
146 void* apHandler,
void* apObject, uint32 auFlags, uint32 auInterval,
159 m_uInterval = auInterval ? auInterval : 1;
160 m_uIntervalAct = m_uInterval;
168 {
return m_uInterval; };
175 {
return m_uIntervalAct; };
196 uint32 m_uIntervalAct{};
266 friend class CINCOBusHooksSequence;
274 void GetHookIdMap(std::map<uintid,uintid>& aHooks);
323 eFlgNone = 0x00000000,
324 eFlgEnabled = 0x00000001,
332 uint32
Setup(uint32 auCycletime, uint32 auFlags);
380 uint32 m_uCycletimeNs{};
419 uint32
SetupCategory(uint8 auCategory, uint32 auCycletimeNs, uint32 auFlags);
488 eOptNone = 0x00000000,
491 #if defined(INOS_CPP_EXCEPTION_SUPPORT)
496 #if defined(INOS_TESTING)
497 eOptDeleteImmediate = 0x80000000,
503 eFlgNone = 0x00000000,
504 eFlgDelete = 0x000000001,
505 eFlgNegative = 0x000000002,
506 eFlgPositive = 0x000000004,
513 eDcCycletime = 0xffffffff,
514 eDcCyclenumber = 0xff,
533 {
return m_eState; };
547 uint32
Setup(uint8 auCores = 1, uint8 auCoreId = 0, uint32 auOptions = eOptNone);
565 uint32
SetupCategory(uint8 auCoreId, uint8 auCategory, uint32 auCycletimeNs, uint32 auFlags = CINOSBusHookCategory::eFlgEnabled);
663 uint32
RegisterHook(uintid& aoHookId,
void* apHandler,
void* apObject, int32 aiOrder, uint8 auCategory, uint32 auCycletime,
CINOSBusHook::EFlags auFlags = CINOSBusHook::eFlgEnabled);
677 uint32
RegisterHook(uintid& aoHookId,
void* apHandler,
void* apObject, int32 aiOrder, uint8 auCategory, uint32 auCycletime, uint8 auCyclenumber,
CINOSBusHook::EFlags auFlags = CINOSBusHook::eFlgEnabled);
692 uint32
RegisterHook(uintid& aoHookId,
void* apHandler,
void* apObject, int32 aiOrder, uint8 auCategory, uint32 auCycletime, uint8 auCyclenumber, uint8 auCoreId,
CINOSBusHook::EFlags auFlags = CINOSBusHook::eFlgEnabled);
783 uint32
MoveHooks(uint8 auCoreId, uint8 auSrc, uint8 auDst);
793 uint32
HandleHooks(uint8 auCategory = 0, uint8 auCycle = 0, uint32 auFlags = eFlgNone);
810 friend class CINOSBusHookExTest;
811 friend class CINCOBusHooksMain;
812 friend class CINCOBusHooks;
813 friend class CINOSHwTarget;
861 uint32
iHookCheck(
void* apHandler,
void* apObject, int32& aiOrder, uint8& auCategory, uint32& auCycletime, uint8& auCyclenumber, uint8& auCoreId);
884 #if defined(INOS_DESKTOP)
888 uint32 uMsr = INOSDisableInterrupts();
893 INOSEnableInterrupts(uMsr);
899 #if defined(INOS_CPU_CORTEXA9)
905 "0: ldrex %0,[%2]" "\n\t"
908 " ldr %1,[%0]" "\n\t"
909 " strex %3,%1,[%2]" "\n\t"
913 :
"=r" (node),
"=r" (next),
"=r" (p),
"=&r" (res)
915 #elif defined(INOS_CPU_CORTEXA72)
920 "0: ldaxr %0,[%2]" "\n\t"
923 " ldr %1,[%0]" "\n\t"
924 " stlxr %w3,%1,[%2]" "\n\t"
928 :
"=r" (node),
"=r" (next),
"=r" (p),
"=&r" (res)
934 "0: lwarx %0, 0, %2" "\n\t"
935 " cmpwi %0, 0" "\n\t"
937 " lwz %1, 0(%0)" "\n\t"
938 " stwcx. %1, 0, %2" "\n\t"
941 :
"=r" (node),
"=r" (next),
"=r" (p)
958 #if defined(INOS_DESKTOP)
960 uint32 uMsr = INOSDisableInterrupts();
965 INOSEnableInterrupts(uMsr);
970 #if defined(INOS_CPU_CORTEXA9)
976 "0: ldrex %0,[%2]" "\n\t"
977 " str %4,[%3]" "\n\t"
978 " strex %1,%3,[%2]" "\n\t"
982 :
"=r" (node),
"=&r" (res)
983 :
"r" (p),
"r" (apNode),
"0" (node));
984 #elif defined(INOS_CPU_CORTEXA72)
989 "0: ldaxr %0,[%2]" "\n\t"
990 " str %4,[%3,#0]" "\n\t"
991 " stlxr %w1,%3,[%2]" "\n\t"
995 :
"=r" (node),
"=&r" (res)
996 :
"r" (p),
"r" (apNode),
"0" (node));
1001 "0: lwarx %0, 0, %1" "\n\t"
1002 " stw %4, 0(%3)" "\n\t"
1003 " stwcx. %2, 0, %1" "\n\t"
1007 :
"r" (p),
"r" (apNode),
"r" (apNode),
"0" (node));
1022 if (
nullptr == apNode) {
1031 while (lst->m_pNext){
1036 #if defined(INOS_DESKTOP)
1038 uint32 uMsr = INOSDisableInterrupts();
1043 INOSEnableInterrupts(uMsr);
1048 #if defined(INOS_CPU_CORTEXA9)
1054 "0: ldrex %0,[%2]" "\n\t"
1055 " str %5,[%4]" "\n\t"
1056 " strex %1,%3,[%2]" "\n\t"
1060 :
"=r" (node),
"=&r" (res)
1061 :
"r" (p),
"r" (apNode),
"r" (lst),
"0" (node));
1062 #elif defined(INOS_CPU_CORTEXA72)
1067 "0: ldaxr %0,[%2]" "\n\t"
1068 " str %5,[%4]" "\n\t"
1069 " stlxr %w1,%3,[%2]" "\n\t"
1070 " cmp %w1,#0" "\n\t"
1073 :
"=r" (node),
"=&r" (res)
1074 :
"r" (p),
"r" (apNode),
"r" (lst),
"0" (node));
1079 "0: lwarx %0, 0, %1" "\n\t"
1080 " stw %4, 0(%3)" "\n\t"
1081 " stwcx. %2, 0, %1" "\n\t"
1085 :
"r" (p),
"r" (apNode),
"r" (lst),
"0" (node));
1138 int32 GetNodesAllocated()
1148 SINOSBusHookNode* GetHookListInsert(uint8 auCoreId, uint8 auCategory, uint8 auCycle)
1158 SINOSBusHookNode* GetHookListSequence(uint8 auCoreId, uint8 auCategory, uint8 auCycle)
1165 CINCOObject* GetRegister(
const char* apName);
1171 void GetHookIdMap(std::map<uintid,uintid>& aHooks);
1175 static void Create();
1177 #if defined(INOS_TESTING) or defined(INOS_TESTING_BASE_SUPPORT)
1178 friend class CINOSTestManager;
1181 static void WaitIdle();
1187 EState m_eState = eStaIdle;
1189 uint32 m_uOptions = eOptNone;
1226 #if defined(INOS_CPU_CORTEXA9)
1230 uint8 m_uActCategory{};
1232 uint8 m_uActCycle{};
#define DECLARE_DYNAMIC(aClass)
Definition cinospartitionmemory.h:328
Definition inos_1ms.h:225
Definition cinosbushooks.h:308
uint32 Enable()
Enable category.
uint32 Setup(uint32 auCycletime, uint32 auFlags)
Setup hook category with given cycle time.
uint32 SetupDone(uint16 auHooks)
Finalysing hook category setup with given max. number of hooks.
EFlags
Category flags.
Definition cinosbushooks.h:322
uint32 Disable()
Disable category.
bool IsCyclenumberValid(uint8 auCyclenumber)
Check whether the given cycle number is in a valid range.
~CINOSBusHookCategory()
Destroy bus hook category handler.
CINOSBusHookCategory()
Create bus hook category handler.
uint32 m_uCycles
Definition cinosbushooks.h:382
CINOSBusHookCycle * m_pCycles
Definition cinosbushooks.h:384
bool IsCycletimeValid(uint32 auCycletimeNs)
Check whether the given cycle time is valid.
uint32 Shutdown(class CINOSBusHooks *apParent)
Shutdown hook category.
Definition cinosbushooks.h:393
uint32 Setup(uint8 auCategories)
Setup hook core with the given number of categories.
CINOSBusHookCore()
Create bus hook core handler.
uint32 SetupDone(uint16 auHooks)
Finalysing hook core setup with given max. number of hooks.
~CINOSBusHookCore()
Destroy bus hook core handler.
uint32 Shutdown(class CINOSBusHooks *apParent)
Shutdown hook core handler.
bool IsCategoryValid(uint8 auCategory)
Check whether the given category number is valid.
CINOSBusHookCategory * m_pCategories
Definition cinosbushooks.h:458
bool IsCategoryEnabled(uint8 auCategory)
Check whether the given category number is enabled.
uint32 m_uCategories
Definition cinosbushooks.h:456
uint32 SetupCategory(uint8 auCategory, uint32 auCycletimeNs, uint32 auFlags)
Setup hook category.
Definition cinosbushooks.h:233
uint32 Shutdown(class CINOSBusHooks *apParent)
Shutdown hook cycle.
~CINOSBusHookCycle()
Destroy bus hook cycle handler.
uint32 Setup()
Setup hook cycle.
class CINCOBusHooksSequence * m_pInco
Definition cinosbushooks.h:287
SINOSBusHookNode * m_pSequence
Definition cinosbushooks.h:279
uint32 SetupDone(uint16 auHooks)
Finalysing hook cycle setup with given max. number of hooks.
SINOSBusHookNode * m_pInsert
Definition cinosbushooks.h:281
CINOSBusHookCycle()
Create bus hook cycle handler.
Definition cinosbushooks.h:139
void SetIntervalCmd(uint32 auInterval)
Set hook interval.
Definition cinosbushooks.h:157
CINOSBusHookEx(uint8 auCoreId, uint8 auCategory, uint8 auCyclenumber, int32 aiOrder, uint32 auCycletime, void *apHandler, void *apObject, uint32 auFlags, uint32 auInterval, uint32 auCount=0)
Create extended bus hook.
virtual ~CINOSBusHookEx()
Destroy extended bus hook.
virtual void Action()
Base hook handler.
uint32 GetIntervalAct() const
Get actual hook interval counter.
Definition cinosbushooks.h:174
virtual void Call()
Base hook caller.
virtual CINOSBusHook * Clone()
Clone hook.
uint32 GetIntervalCmd()
Get commanded hook interval.
Definition cinosbushooks.h:167
Definition cinosbushooks.h:60
virtual CINOSBusHook * Clone()
Clone hook.
uint32 Disable()
Disable hook.
EFlags
Hook flags.
Definition cinosbushooks.h:75
@ eFlgNoException
do not throw an exception in case of a failure
Definition cinosbushooks.h:79
uint32 Enable()
Enable hook.
CINOSBusHook(uint8 auCoreId, uint8 auCategory, uint8 auCyclenumber, int32 aiOrder, uint32 auCycletime, void *apHandler, void *apObject, uint32 auFlags)
Create bus hook.
uintid GetId()
Get id.
Definition cinosbushooks.h:86
virtual ~CINOSBusHook()
Destroy bus hook.
Definition cinosbushooks.h:467
uint8 m_uCoreIdBase
Definition cinosbushooks.h:1211
std::atomic< uint32 > m_uNodesMax
Definition cinosbushooks.h:1220
uint32 RegisterHook(uintid &aoHookId, void *apHandler, void *apObject, int32 aiOrder, uint8 auCategory, uint32 auCycletime, uint8 auCyclenumber, uint8 auCoreId, CINOSBusHook::EFlags auFlags=CINOSBusHook::eFlgEnabled)
Register a hook with the given parameters.
uint32 SetupCore(uint8 auCoreId, uint8 auCategories)
Setup hook core handler.
uint32 Shutdown()
Shutdown hooks handler.
uint32 EnableCategory(uint8 auCategory)
Enable given category of all cores.
CINCOObject * m_pRegister
Definition cinosbushooks.h:1236
uint32 Setup(uint8 auCores=1, uint8 auCoreId=0, uint32 auOptions=eOptNone)
Setup hooks handler with the given number of cores.
uint8 GetHookCyclenumber(uintid auHookId)
Get hook cycle number.
uint32 RegisterHook(uintid &aoHookId, void *apHandler, void *apObject, int32 aiOrder, CINOSBusHook::EFlags auFlags=CINOSBusHook::eFlgEnabled)
Register a hook with the given parameters.
CINOSBusHookCore * m_pCores
Definition cinosbushooks.h:1215
uint32 MoveHooks(uint8 auCoreId, uint8 auSrc, uint8 auDst)
Move all hooks of given core from one category to an other.
EState GetState()
Get hooks handler state.
Definition cinosbushooks.h:532
uint32 RegisterHook(uintid &aoHookId, void *apHandler, void *apObject, int32 aiOrder, uint8 auCategory, uint32 auCycletime, CINOSBusHook::EFlags auFlags=CINOSBusHook::eFlgEnabled)
Register a hook with the given parameters.
uint32 SetHookHandler(uintid auHookId, void *apHandler)
Set hook handler.
uint8 m_uGroupId
Definition cinosbushooks.h:1192
uint8 m_uCores
Definition cinosbushooks.h:1213
std::atomic< int32 > m_uHooksAct
Definition cinosbushooks.h:1206
bool HasHooks(uint32 auNumber)
Check whether the given number of hooks are still available.
Definition cinosbushooks.h:847
uint32 EnableCategory(uint8 auCoreId, uint8 auCategory)
Enable given category of given core.
std::atomic< int32 > m_iNodesAct
Definition cinosbushooks.h:1222
uint32 RegisterHook(uintid &aoHookId, void *apHandler, void *apObject, int32 aiOrder, uint8 auCategory, CINOSBusHook::EFlags auFlags=CINOSBusHook::eFlgEnabled)
Register a hook with the given parameters.
@ eOptCategoryDc
use 'don't care category' if the requested is not available
Definition cinosbushooks.h:489
@ eOptExceptionEx
return always a value because exception handling not available
Definition cinosbushooks.h:494
@ eOptException
throw an exception in case of an error (instead of a return value)
Definition cinosbushooks.h:490
SINOSBusHookNode * ListGet(SINOSBusHookNode **apHead)
Atomically detach list from given head and set head = nullptr.
uint32 m_uHooksMax
Definition cinosbushooks.h:1204
uint32 iHookRegister(CINOSBusHook *apHook)
Internal register given hook.
void ListDestroy(SINOSBusHookNode **apHead)
Destroy given nodes list.
std::atomic< uint32 > m_uHookIdCnt
Definition cinosbushooks.h:1198
@ eCnsGroupIdBits
number of group id bits
Definition cinosbushooks.h:483
uint32 EnableHook(uintid auHookId)
Enable given hook.
void ListInsert(SINOSBusHookNode *&apHead, SINOSBusHookNode *apNode)
Insert node into list in ascending order.
uint32 UnregisterHook(CINOSBusHook *apHook, uint32 auFlags=eFlgNone)
Unregister given hook.
uint32 DisableCategory(uint8 auCoreId, uint8 auCategory)
Disable given category of given core.
void FreeNodes(SINOSBusHookNode *apNode)
Free list of hook nodes.
Definition cinosbushooks.h:1019
void FreeNode(SINOSBusHookNode *apNode)
Free given hook node.
Definition cinosbushooks.h:956
uint32 RegisterHook(uintid &aoHookId, void *apHandler, void *apObject, CINOSBusHook::EFlags auFlags=CINOSBusHook::eFlgEnabled)
Register a hook with the given parameters.
SINOSBusHookNode * m_pNodes
Definition cinosbushooks.h:1224
static uint32 GetGroupId(uintid auHookId)
Get group id from hook id.
Definition cinosbushooks.h:799
uint32 m_uCycletimeSlowest
Definition cinosbushooks.h:1217
uint32 iHookIdCheck(uintid auHookId, CINOSBusHook *&apHook)
Check if the given hook id is valid.
uint32 RegisterHook(CINOSBusHook *apHook)
Register given hook.
uint32 GetHookCycleTime(uintid auHookId, uint32 &auCycletime)
Get hook cycle time.
uint32 GetIndex(uintid auHookId)
Return hook index from given hook id.
Definition cinosbushooks.h:837
uint32 SetupCategory(uint8 auCoreId, uint8 auCategory, uint32 auCycletimeNs, uint32 auFlags=CINOSBusHookCategory::eFlgEnabled)
Setup hook category of given core handler.
uint32 DisableHook(uintid auHookId)
Disable given hook.
uint32 * m_pHooksActive
Definition cinosbushooks.h:1202
uint32 m_uHookIdShift
Definition cinosbushooks.h:1196
bool ListSet(SINOSBusHookNode **apHead, SINOSBusHookNode *apList)
Atomically try to set head of list.
CINOSBusHooks(uint8 auGroupId=0)
Create bus hooks handler.
uint32 SetupDone(uint16 auHooks)
Finalysing hooks handler setup with given max. number of hooks.
SINOSBusHookNode * AllocNode()
Allocate a hook node.
Definition cinosbushooks.h:882
uint32 HandleHooks(uint8 auCategory=0, uint8 auCycle=0, uint32 auFlags=eFlgNone)
Call all hook handlers of the given category and cycle assigned to the actual core id.
uint32 RequestId(uintid &aoHookId)
Request a hook id.
uint32 DisableCategory(uint8 auCategory)
Disable given category of all cores.
void * GetHookHandler(uintid auHookId)
Get hook handler.
uint32 RegisterHook(uintid &aoHookId, void *apHandler, CINOSBusHook::EFlags auFlags=CINOSBusHook::eFlgEnabled)
Register a hook with the given parameters.
class CINCOBusHooksMain * m_pInco
Definition cinosbushooks.h:1238
uint32 GetHookCategory(uintid auHookId, uint8 &auCategory)
Get hook category.
uint32 iHookCheck(void *apHandler, void *apObject, int32 &aiOrder, uint8 &auCategory, uint32 &auCycletime, uint8 &auCyclenumber, uint8 &auCoreId)
Check if the given hook parameters are valid.
CINOSBusHook ** m_pHooks
Definition cinosbushooks.h:1208
uint32 ReleaseId(uintid auHookId)
Release given hook id.
uint32 GetHookCycleTime(uintid auHookId)
Get hook cycle time.
uint32 UnregisterHook(uintid auHookId)
Unregister given hook.
uint32 m_uHookIndexMask
Definition cinosbushooks.h:1194
uint32 m_uHooksActive
Definition cinosbushooks.h:1200
~CINOSBusHooks()
Destroy bus hooks handler.
static class CINOSBusHooksHelper * m_pInstance[DF_INOS_MAX_CORES]
Definition cinosbushooks.h:1241
uint32 RegisterHook(uintid &aoHookId, void *apHandler, void *apObject, int32 aiOrder, uint8 auCategory, uint32 auCycletime, uint8 auCyclenumber, CINOSBusHook::EFlags auFlags=CINOSBusHook::eFlgEnabled)
Register a hook with the given parameters.
Definition cinosbus.h:600
#define DF_INOS_CPU_CACHE_LINE_SIZE
Definition inosdefine.h:94
#define DF_INOS_MAX_CORES
Definition inosdefine.h:164
Definition cinosbushooks.h:211