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;
131 #if defined(INOS_BUS_HOOK_TIME_MEASUREMENTS)
151 uint8 auCyclenumber, int32 aiOrder, uint32 auCycletime,
152 void* apHandler,
void* apObject, uint32 auFlags, uint32 auInterval,
165 m_uInterval = auInterval ? auInterval : 1;
166 m_uIntervalAct = m_uInterval;
174 {
return m_uInterval; };
181 {
return m_uIntervalAct; };
202 uint32 m_uIntervalAct{};
272 friend class CINCOBusHooksSequence;
280 void GetHookIdMap(std::map<uintid,uintid>& aHooks);
291 #if defined(INOS_BUS_HOOK_TIME_MEASUREMENTS)
293 uint32 m_uTicksMax{};
295 uint32 m_uTimeReset{};
335 eFlgNone = 0x00000000,
336 eFlgEnabled = 0x00000001,
344 uint32
Setup(uint32 auCycletime, uint32 auFlags);
392 uint32 m_uCycletimeNs{};
431 uint32
SetupCategory(uint8 auCategory, uint32 auCycletimeNs, uint32 auFlags);
500 eOptNone = 0x00000000,
503 #if defined(INOS_CPP_EXCEPTION_SUPPORT)
508 #if defined(INOS_TESTING) or defined(INOS_TESTING_BASE_SUPPORT)
509 eOptDeleteImmediate = 0x80000000,
515 eFlgNone = 0x00000000,
516 eFlgDelete = 0x000000001,
517 eFlgNegative = 0x000000002,
518 eFlgPositive = 0x000000004,
526 eDcCycletime = 0xffffffff,
527 eDcCyclenumber = 0xff,
546 {
return m_eState; };
560 uint32
Setup(uint8 auCores = 1, uint8 auCoreId = 0, uint32 auOptions = eOptNone);
578 uint32
SetupCategory(uint8 auCoreId, uint8 auCategory, uint32 auCycletimeNs, uint32 auFlags = CINOSBusHookCategory::eFlgEnabled);
676 uint32
RegisterHook(uintid& aoHookId,
void* apHandler,
void* apObject, int32 aiOrder, uint8 auCategory, uint32 auCycletime,
CINOSBusHook::EFlags auFlags = CINOSBusHook::eFlgEnabled);
690 uint32
RegisterHook(uintid& aoHookId,
void* apHandler,
void* apObject, int32 aiOrder, uint8 auCategory, uint32 auCycletime, uint8 auCyclenumber,
CINOSBusHook::EFlags auFlags = CINOSBusHook::eFlgEnabled);
705 uint32
RegisterHook(uintid& aoHookId,
void* apHandler,
void* apObject, int32 aiOrder, uint8 auCategory, uint32 auCycletime, uint8 auCyclenumber, uint8 auCoreId,
CINOSBusHook::EFlags auFlags = CINOSBusHook::eFlgEnabled);
796 uint32
MoveHooks(uint8 auCoreId, uint8 auSrc, uint8 auDst);
806 uint32
HandleHooks(uint8 auCategory = 0, uint8 auCycle = 0, uint32 auFlags = eFlgNone);
818 #if defined(INOS_BUS_HOOK_TIME_MEASUREMENTS)
830 uint32 TimeFreeze(uint32 auTicks = 0);
836 uint32 TimeMeasure();
842 uint32 TimeFreezeTrigger(uint32 auNs);
850 friend class CINOSBusHookExTest;
851 friend class CINCOBusHooksMain;
852 friend class CINCOBusHooks;
853 friend class CINOSHwTarget;
901 uint32
iHookCheck(
void* apHandler,
void* apObject, int32& aiOrder, uint8& auCategory, uint32& auCycletime, uint8& auCyclenumber, uint8& auCoreId);
924 #if defined(INOS_DESKTOP)
928 uint32 uMsr = INOSDisableInterrupts();
933 INOSEnableInterrupts(uMsr);
939 #if defined(INOS_CPU_CORTEXA9)
945 "0: ldrex %0,[%2]" "\n\t"
948 " ldr %1,[%0]" "\n\t"
949 " strex %3,%1,[%2]" "\n\t"
953 :
"=r" (node),
"=r" (next),
"=r" (p),
"=&r" (res)
955 #elif defined(INOS_CPU_CORTEXA72)
960 "0: ldaxr %0,[%2]" "\n\t"
963 " ldr %1,[%0]" "\n\t"
964 " stlxr %w3,%1,[%2]" "\n\t"
968 :
"=r" (node),
"=r" (next),
"=r" (p),
"=&r" (res)
974 "0: lwarx %0, 0, %2" "\n\t"
975 " cmpwi %0, 0" "\n\t"
977 " lwz %1, 0(%0)" "\n\t"
978 " stwcx. %1, 0, %2" "\n\t"
981 :
"=r" (node),
"=r" (next),
"=r" (p)
998 #if defined(INOS_DESKTOP)
1000 uint32 uMsr = INOSDisableInterrupts();
1005 INOSEnableInterrupts(uMsr);
1010 #if defined(INOS_CPU_CORTEXA9)
1016 "0: ldrex %0,[%2]" "\n\t"
1017 " str %4,[%3]" "\n\t"
1018 " strex %1,%3,[%2]" "\n\t"
1022 :
"=r" (node),
"=&r" (res)
1023 :
"r" (p),
"r" (apNode),
"0" (node));
1024 #elif defined(INOS_CPU_CORTEXA72)
1029 "0: ldaxr %0,[%2]" "\n\t"
1030 " str %4,[%3,#0]" "\n\t"
1031 " stlxr %w1,%3,[%2]" "\n\t"
1032 " cmp %w1,#0" "\n\t"
1035 :
"=r" (node),
"=&r" (res)
1036 :
"r" (p),
"r" (apNode),
"0" (node));
1041 "0: lwarx %0, 0, %1" "\n\t"
1042 " stw %4, 0(%3)" "\n\t"
1043 " stwcx. %2, 0, %1" "\n\t"
1047 :
"r" (p),
"r" (apNode),
"r" (apNode),
"0" (node));
1062 if (
nullptr == apNode) {
1071 while (lst->m_pNext){
1076 #if defined(INOS_DESKTOP)
1078 uint32 uMsr = INOSDisableInterrupts();
1083 INOSEnableInterrupts(uMsr);
1088 #if defined(INOS_CPU_CORTEXA9)
1094 "0: ldrex %0,[%2]" "\n\t"
1095 " str %5,[%4]" "\n\t"
1096 " strex %1,%3,[%2]" "\n\t"
1100 :
"=r" (node),
"=&r" (res)
1101 :
"r" (p),
"r" (apNode),
"r" (lst),
"0" (node));
1102 #elif defined(INOS_CPU_CORTEXA72)
1107 "0: ldaxr %0,[%2]" "\n\t"
1108 " str %5,[%4]" "\n\t"
1109 " stlxr %w1,%3,[%2]" "\n\t"
1110 " cmp %w1,#0" "\n\t"
1113 :
"=r" (node),
"=&r" (res)
1114 :
"r" (p),
"r" (apNode),
"r" (lst),
"0" (node));
1119 "0: lwarx %0, 0, %1" "\n\t"
1120 " stw %4, 0(%3)" "\n\t"
1121 " stwcx. %2, 0, %1" "\n\t"
1125 :
"r" (p),
"r" (apNode),
"r" (lst),
"0" (node));
1178 int32 GetNodesAllocated()
1188 SINOSBusHookNode* GetHookListInsert(uint8 auCoreId, uint8 auCategory, uint8 auCycle)
1198 SINOSBusHookNode* GetHookListSequence(uint8 auCoreId, uint8 auCategory, uint8 auCycle)
1205 CINCOObject* GetRegister(
const char* apName);
1211 void GetHookIdMap(std::map<uintid,uintid>& aHooks);
1215 static void Create();
1217 #if defined(INOS_TESTING) or defined(INOS_TESTING_BASE_SUPPORT)
1218 friend class CINOSTestManager;
1221 static void WaitIdle();
1227 EState m_eState = eStaIdle;
1229 uint32 m_uOptions = eOptNone;
1232 #if defined(INOS_BUS_HOOK_TIME_MEASUREMENTS)
1234 std::atomic<uint32> m_uTimeReset{};
1236 uint32 m_uTimeFreezeTriggerTicks{};
1238 uint32 eTimeFreeze(uint32 auNs);
1240 uint32 m_ueFreezeTrigger{};
1241 uint32 m_ueReturn{};
1279 #if defined(INOS_CPU_CORTEXA9)
1283 uint8 m_uActCategory{};
1285 uint8 m_uActCycle{};
#define DECLARE_DYNAMIC(aClass)
Definition cinospartitionmemory.h:328
Definition inos_1ms.h:173
Definition cinosbushooks.h:320
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:334
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:394
CINOSBusHookCycle * m_pCycles
Definition cinosbushooks.h:396
bool IsCycletimeValid(uint32 auCycletimeNs)
Check whether the given cycle time is valid.
uint32 Shutdown(class CINOSBusHooks *apParent)
Shutdown hook category.
Definition cinosbushooks.h:405
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:470
bool IsCategoryEnabled(uint8 auCategory)
Check whether the given category number is enabled.
uint32 m_uCategories
Definition cinosbushooks.h:468
uint32 SetupCategory(uint8 auCategory, uint32 auCycletimeNs, uint32 auFlags)
Setup hook category.
Definition cinosbushooks.h:239
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:299
SINOSBusHookNode * m_pSequence
Definition cinosbushooks.h:285
uint32 SetupDone(uint16 auHooks)
Finalysing hook cycle setup with given max. number of hooks.
SINOSBusHookNode * m_pInsert
Definition cinosbushooks.h:287
CINOSBusHookCycle()
Create bus hook cycle handler.
Definition cinosbushooks.h:145
void SetIntervalCmd(uint32 auInterval)
Set hook interval.
Definition cinosbushooks.h:163
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 CINOSBusHook * Clone() override
Clone hook.
virtual void Action()
Base hook handler.
uint32 GetIntervalAct() const
Get actual hook interval counter.
Definition cinosbushooks.h:180
virtual void Call()
Base hook caller.
uint32 GetIntervalCmd()
Get commanded hook interval.
Definition cinosbushooks.h:173
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:479
uint8 m_uCoreIdBase
Definition cinosbushooks.h:1264
std::atomic< uint32 > m_uNodesMax
Definition cinosbushooks.h:1273
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:1289
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:1268
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:545
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:1245
uint8 m_uCores
Definition cinosbushooks.h:1266
std::atomic< int32 > m_uHooksAct
Definition cinosbushooks.h:1259
bool HasHooks(uint32 auNumber)
Check whether the given number of hooks are still available.
Definition cinosbushooks.h:887
uint32 EnableCategory(uint8 auCoreId, uint8 auCategory)
Enable given category of given core.
std::atomic< int32 > m_iNodesAct
Definition cinosbushooks.h:1275
uint32 RegisterHook(uintid &aoHookId, void *apHandler, void *apObject, int32 aiOrder, uint8 auCategory, CINOSBusHook::EFlags auFlags=CINOSBusHook::eFlgEnabled)
Register a hook with the given parameters.
@ eCnsGroupIdBits
number of group id bits
Definition cinosbushooks.h:495
SINOSBusHookNode * ListGet(SINOSBusHookNode **apHead)
Atomically detach list from given head and set head = nullptr.
uint32 m_uHooksMax
Definition cinosbushooks.h:1257
uint32 iHookRegister(CINOSBusHook *apHook)
Internal register given hook.
void ListDestroy(SINOSBusHookNode **apHead)
Destroy given nodes list.
std::atomic< uint32 > m_uHookIdCnt
Definition cinosbushooks.h:1251
uint32 EnableHook(uintid auHookId)
Enable given hook.
@ eOptCategoryDc
use 'don't care category' if the requested is not available
Definition cinosbushooks.h:501
@ eOptExceptionEx
return always a value because exception handling not available
Definition cinosbushooks.h:506
@ eOptException
throw an exception in case of an error (instead of a return value)
Definition cinosbushooks.h:502
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:1059
void FreeNode(SINOSBusHookNode *apNode)
Free given hook node.
Definition cinosbushooks.h:996
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:1277
static uint32 GetGroupId(uintid auHookId)
Get group id from hook id.
Definition cinosbushooks.h:812
uint32 m_uCycletimeSlowest
Definition cinosbushooks.h:1270
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.
@ eFlgTimeMeasure
enable hook time measuring of all hooks
Definition cinosbushooks.h:519
uint32 GetIndex(uintid auHookId)
Return hook index from given hook id.
Definition cinosbushooks.h:877
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:1255
uint32 m_uHookIdShift
Definition cinosbushooks.h:1249
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:922
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:1291
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:1261
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:1247
uint32 m_uHooksActive
Definition cinosbushooks.h:1253
~CINOSBusHooks()
Destroy bus hooks handler.
static class CINOSBusHooksHelper * m_pInstance[DF_INOS_MAX_CORES]
Definition cinosbushooks.h:1294
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:563
#define DF_INOS_CPU_CACHE_LINE_SIZE
Definition inosdefine.h:94
#define DF_INOS_MAX_CORES
Definition inosdefine.h:164
Definition cinosbushooks.h:217