Go to the documentation of this file.
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{};
422 uint32
Setup(uint8 auCategories);
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);
568 uint32
SetupCore(uint8 auCoreId, uint8 auCategories);
578 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,
CINOSBusHook::EFlags auFlags = CINOSBusHook::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_ARMV8)
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_ARMV8)
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_ARMV8)
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{};
1304 #endif // INC_CINOSBUSHOOKS_H
Definition: cinosbus.h:564
virtual CINOSBusHook * Clone()
Clone hook.
std::atomic< uint32 > m_uNodesMax
Definition: cinosbushooks.h:1273
uint32 SetupCategory(uint8 auCategory, uint32 auCycletimeNs, uint32 auFlags)
Setup hook category.
uint32 EnableCategory(uint8 auCategory)
Enable given category of all cores.
uint32 GetIndex(uintid auHookId)
Return hook index from given hook id.
Definition: cinosbushooks.h:877
SINOSBusHookNode * m_pInsert
Definition: cinosbushooks.h:287
uint32 m_uCategories
Definition: cinosbushooks.h:468
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.
@ eOptCategoryDc
use 'don't care category' if the requested is not available
Definition: cinosbushooks.h:501
uint32 Shutdown(class CINOSBusHooks *apParent)
Shutdown hook cycle.
uint32 m_uCycletimeSlowest
Definition: cinosbushooks.h:1270
uint32 Enable()
Enable hook.
void SetIntervalCmd(uint32 auInterval)
Set hook interval.
Definition: cinosbushooks.h:163
uint32 Setup(uint8 auCategories)
Setup hook core with the given number of categories.
Definition: cinosbushooks.h:478
uint32 SetupDone(uint16 auHooks)
Finalysing hooks handler setup with given max. number of hooks.
@ eOptExceptionEx
return always a value because exception handling not available
Definition: cinosbushooks.h:506
virtual ~CINOSBusHookEx()
Destroy extended bus hook.
uint32 m_uHooksMax
Definition: cinosbushooks.h:1257
#define DF_INOS_MAX_CORES
Definition: inosdefine.h:164
uint32 Shutdown()
Shutdown hooks handler.
uint32 Setup(uint32 auCycletime, uint32 auFlags)
Setup hook category with given cycle time.
uint32 iHookRegister(CINOSBusHook *apHook)
Internal register given hook.
void FreeNodes(SINOSBusHookNode *apNode)
Free list of hook nodes.
Definition: cinosbushooks.h:1059
uint32 SetupDone(uint16 auHooks)
Finalysing hook category setup with given max. number of hooks.
CINOSBusHook(uint8 auCoreId, uint8 auCategory, uint8 auCyclenumber, int32 aiOrder, uint32 auCycletime, void *apHandler, void *apObject, uint32 auFlags)
Create bus hook.
uint8 GetHookCyclenumber(uintid auHookId)
Get hook cycle number.
@ eFlgNoException
do not throw an exception in case of a failure
Definition: cinosbushooks.h:79
SINOSBusHookNode * m_pSequence
Definition: cinosbushooks.h:285
virtual ~CINOSBusHook()
Destroy bus hook.
class CINCOBusHooksSequence * m_pInco
Definition: cinosbushooks.h:299
uint32 SetupCore(uint8 auCoreId, uint8 auCategories)
Setup hook core handler.
SINOSBusHookNode * AllocNode()
Allocate a hook node.
Definition: cinosbushooks.h:922
uint32 SetupDone(uint16 auHooks)
Finalysing hook cycle setup with given max. number of hooks.
Definition: cinosbushooks.h:238
uint32 Setup(uint8 auCores=1, uint8 auCoreId=0, uint32 auOptions=eOptNone)
Setup hooks handler with the given number of cores.
CINOSBusHookCore * m_pCores
Definition: cinosbushooks.h:1268
void ListDestroy(SINOSBusHookNode **apHead)
Destroy given nodes list.
uint32 DisableCategory(uint8 auCategory)
Disable given category of all cores.
uint32 m_uCycles
Definition: cinosbushooks.h:394
~CINOSBusHookCategory()
Destroy bus hook category handler.
uint32 Setup()
Setup hook cycle.
std::atomic< uint32 > m_uHookIdCnt
Definition: cinosbushooks.h:1251
uint32 UnregisterHook(uintid auHookId)
Unregister given hook.
uint32 RegisterHook(uintid &aoHookId, void *apHandler, CINOSBusHook::EFlags auFlags=CINOSBusHook::eFlgEnabled)
Register a hook with the given parameters.
uint8 m_uCoreIdBase
Definition: cinosbushooks.h:1264
CINOSBusHookCategory * m_pCategories
Definition: cinosbushooks.h:470
uint32 Shutdown(class CINOSBusHooks *apParent)
Shutdown hook core handler.
uint8 m_uGroupId
Definition: cinosbushooks.h:1245
uint32 GetIntervalAct() const
Get actual hook interval counter.
Definition: cinosbushooks.h:180
uint32 RequestId(uintid &aoHookId)
Request a hook id.
uint32 iHookCheck(void *apHandler, void *apObject, int32 &aiOrder, uint8 &auCategory, uint32 &auCycletime, uint8 &auCyclenumber, uint8 &auCoreId)
Check if the given hook parameters are valid.
Definition: cinosbushooks.h:144
class CINCOBusHooksMain * m_pInco
Definition: cinosbushooks.h:1291
CINOSBusHooks(uint8 auGroupId=0)
Create bus hooks handler.
uint32 EnableHook(uintid auHookId)
Enable given hook.
uint32 GetIntervalCmd()
Get commanded hook interval.
Definition: cinosbushooks.h:173
EFlags
Category flags.
Definition: cinosbushooks.h:334
virtual void Call()
Base hook caller.
uint32 DisableHook(uintid auHookId)
Disable given hook.
~CINOSBusHookCycle()
Destroy bus hook cycle handler.
#define DF_INOS_CPU_CACHE_LINE_SIZE
Definition: inosdefine.h:94
uint32 SetHookHandler(uintid auHookId, void *apHandler)
Set hook handler.
uint32 GetHookCycleTime(uintid auHookId)
Get hook cycle time.
uint32 Disable()
Disable category.
~CINOSBusHooks()
Destroy bus hooks handler.
std::atomic< int32 > m_uHooksAct
Definition: cinosbushooks.h:1259
CINOSBusHookCycle * m_pCycles
Definition: cinosbushooks.h:396
CINCOObject * m_pRegister
Definition: cinosbushooks.h:1289
uint32 Disable()
Disable hook.
void * GetHookHandler(uintid auHookId)
Get hook handler.
Definition: inos_1ms.h:172
uint32 m_uHookIdShift
Definition: cinosbushooks.h:1249
std::atomic< int32 > m_iNodesAct
Definition: cinosbushooks.h:1275
bool ListSet(SINOSBusHookNode **apHead, SINOSBusHookNode *apList)
Atomically try to set head of list.
bool IsCategoryValid(uint8 auCategory)
Check whether the given category number is valid.
static uint32 GetGroupId(uintid auHookId)
Get group id from hook id.
Definition: cinosbushooks.h:812
uint32 SetupDone(uint16 auHooks)
Finalysing hook core setup with given max. number of hooks.
SINOSBusHookNode * ListGet(SINOSBusHookNode **apHead)
Atomically detach list from given head and set head = nullptr.
uintid GetId()
Get id.
Definition: cinosbushooks.h:86
CINOSBusHookCycle()
Create bus hook cycle handler.
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.
void FreeNode(SINOSBusHookNode *apNode)
Free given hook node.
Definition: cinosbushooks.h:996
EFlags
Hook flags.
Definition: cinosbushooks.h:75
virtual CINOSBusHook * Clone() override
Clone hook.
uint32 * m_pHooksActive
Definition: cinosbushooks.h:1255
uint32 Enable()
Enable category.
bool IsCategoryEnabled(uint8 auCategory)
Check whether the given category number is enabled.
uint32 MoveHooks(uint8 auCoreId, uint8 auSrc, uint8 auDst)
Move all hooks of given core from one category to an other.
uint32 Shutdown(class CINOSBusHooks *apParent)
Shutdown hook category.
Definition: cinosbushooks.h:216
CINOSBusHookCategory()
Create bus hook category handler.
uint32 m_uHookIndexMask
Definition: cinosbushooks.h:1247
~CINOSBusHookCore()
Destroy bus hook core handler.
uint32 ReleaseId(uintid auHookId)
Release given hook id.
Definition: cinosbushooks.h:59
uint32 SetupCategory(uint8 auCoreId, uint8 auCategory, uint32 auCycletimeNs, uint32 auFlags=CINOSBusHookCategory::eFlgEnabled)
Setup hook category of given core handler.
void ListInsert(SINOSBusHookNode *&apHead, SINOSBusHookNode *apNode)
Insert node into list in ascending order.
bool IsCycletimeValid(uint32 auCycletimeNs)
Check whether the given cycle time is valid.
@ eOptException
throw an exception in case of an error (instead of a return value)
Definition: cinosbushooks.h:502
@ eCnsGroupIdBits
number of group id bits
Definition: cinosbushooks.h:495
SINOSBusHookNode * m_pNodes
Definition: cinosbushooks.h:1277
#define DECLARE_DYNAMIC(aClass)
Definition: cinospartitionmemory.h:328
static class CINOSBusHooksHelper * m_pInstance[DF_INOS_MAX_CORES]
Definition: cinosbushooks.h:1294
uint32 m_uHooksActive
Definition: cinosbushooks.h:1253
uint8 m_uCores
Definition: cinosbushooks.h:1266
Definition: cinosbushooks.h:319
virtual void Action()
Base hook handler.
@ eFlgTimeMeasure
enable hook time measuring of all hooks
Definition: cinosbushooks.h:519
CINOSBusHookCore()
Create bus hook core handler.
uint32 iHookIdCheck(uintid auHookId, CINOSBusHook *&apHook)
Check if the given hook id is valid.
EState GetState()
Get hooks handler state.
Definition: cinosbushooks.h:545
uint32 GetHookCategory(uintid auHookId, uint8 &auCategory)
Get hook category.
bool IsCyclenumberValid(uint8 auCyclenumber)
Check whether the given cycle number is in a valid range.
bool HasHooks(uint32 auNumber)
Check whether the given number of hooks are still available.
Definition: cinosbushooks.h:887
Definition: cinosbushooks.h:404
CINOSBusHook ** m_pHooks
Definition: cinosbushooks.h:1261