INOS
cinosbushooks.h
Go to the documentation of this file.
1//******************************************************************************
26//******************************************************************************
27#ifndef INC_CINOSBUSHOOKS_H
28#define INC_CINOSBUSHOOKS_H
29//------------------------------------------------------------------------------
30// includes
31//------------------------------------------------------------------------------
32//
33// system
34#include <inos.h>
35//
36// C++
37#include <map>
38//
39// project
40//
41//------------------------------------------------------------------------------
42// defines
43//------------------------------------------------------------------------------
44
45// --- inos bus hook priorities ------------------------------------------------
46//
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
54
55//------------------------------------------------------------------------------
56// class definition
57//------------------------------------------------------------------------------
58//
60{
61 // public member functions
62 public :
65 CINOSBusHook (uint8 auCoreId, uint8 auCategory,
66 uint8 auCyclenumber, int32 aiOrder, uint32 auCycletime,
67 void* apHandler, void* apObject, uint32 auFlags);
68
71 virtual ~CINOSBusHook ();
72
75 enum EFlags {
76 eFlgNone = 0x00000000,
77 eFlgEnabled = 0x00000001,
78 eFlgSingle = 0x00000002,
79 eFlgNoException = 0x00000004,
80 eFlgDeletePending = 0x40000000,
81 eFlgDynamic = 0x80000000,
82 };
83
86 uintid GetId()
87 { return m_uId; }
88
91 uint32 Enable();
92
95 uint32 Disable();
96
99 virtual CINOSBusHook* Clone();
100
101 //--- internals --------------------------------------------------------
102
103 friend class CINOSBusHooks;
104 friend class CINCOBusHook;
105 friend class CINCOBusHooks;
106
107 // protected members
108 protected :
109 /* hook flags */
110 uint32 m_uFlags;
111 /* hook id */
112 uintid m_uId;
113 /* core id */
114 uint8 m_uCoreId;
115 /* category */
116 uint8 m_uCategory;
117 /* base cycle number */
118 uint8 m_uCyclenumber;
119 /* this hook is registered in this number of cycles */
120 int8 m_iCycles;
121 /* hook order */
122 int32 m_iOrder;
123 /* hook cycletime */
124 uint32 m_uCycletime;
125 /* pointer to hook handler */
126 void* m_pHandler;
127 /* pointer to hook handler object (if any) */
128 void* m_pObject;
129 /* hook ticks */
130 uint32 m_uTicks;
131 #if defined(INOS_BUS_HOOK_TIME_MEASUREMENTS)
132 /* hook max ticks */
133 uint32 m_uTicksMax;
134 /* hook time reset */
135 uint32 m_uTimeReset;
136 #endif
137
138 // dynamic object handling
140};
141
142//------------------------------------------------------------------------------
143//
145{
146 // public member functions
147 public :
150 CINOSBusHookEx (uint8 auCoreId, uint8 auCategory,
151 uint8 auCyclenumber, int32 aiOrder, uint32 auCycletime,
152 void* apHandler, void* apObject, uint32 auFlags, uint32 auInterval,
153 uint32 auCount = 0);
154
157 virtual ~CINOSBusHookEx ();
158
163 void SetIntervalCmd(uint32 auInterval)
164 {
165 m_uInterval = auInterval ? auInterval : 1;
166 m_uIntervalAct = m_uInterval;
167 };
168
174 { return m_uInterval; };
175
180 uint32 GetIntervalAct() const
181 { return m_uIntervalAct; };
182
185 virtual void Action();
186
189 virtual void Call();
190
193 virtual CINOSBusHook* Clone() override;
194
195 //--- internals --------------------------------------------------------
196
197 // protected members
198 protected :
199 /* hook commanded interval */
200 uint32 m_uInterval;
201 /* hook actual interval */
202 uint32 m_uIntervalAct{};
203 /* hook count (0 -> endless) */
204 uint32 m_uCount{};
205 /* pointer to original hook handler */
206 void* m_pOrgHandler;
207 /* pointer to original hook handler object (if any) */
208 void* m_pOrgObject;
209
210 // dynamic object handling
212};
213
214//------------------------------------------------------------------------------
215//
217{
218 /* pointer to next node in list */
219 SINOSBusHookNode* m_pNext;
220 /* id of hook this node represents */
221 uintid m_uHookId;
222 /* order of hook this node represents */
223 int32 m_iOrder;
224 /*
225 * Ensure the size of a cache line to get 'load reserve' and 'store conditional'
226 * mechanism running.
227 */
228 uint32 m_uAlign[
230 sizeof(m_pNext)-
231 sizeof(m_uHookId)-
232 sizeof(m_iOrder))>>2
233 ];
234};
235
236//------------------------------------------------------------------------------
237//
239{
240 // public member functions
241 public :
242
246
250
253 uint32 Setup();
254
260 uint32 SetupDone(uint16 auHooks);
261
267 uint32 Shutdown(class CINOSBusHooks* apParent);
268
269 //--- internals --------------------------------------------------------
270
271 friend class CINOSBusHooks;
272 friend class CINCOBusHooksSequence;
273
274 // private members
275 private :
280 void GetHookIdMap(std::map<uintid,uintid>& aHooks);
281
282 // protected members
283 protected :
288
289 /* cycle ticks */
290 uint32 m_uTicks{};
291 #if defined(INOS_BUS_HOOK_TIME_MEASUREMENTS)
292 /* cycle max ticks */
293 uint32 m_uTicksMax{};
294 /* hook time reset */
295 uint32 m_uTimeReset{};
296 #endif
297
299 class CINCOBusHooksSequence* m_pInco{};
300
301 /*
302 * Ensure the size of a cache line to get 'load reserve' and 'store conditional'
303 * mechanism running.
304 */
305 uint32 m_uAlign[
307 sizeof(m_pSequence)-
308 sizeof(m_pInsert)-
309 sizeof(m_uTicks)-
310 sizeof(m_pInco))>>2
311 ];
312
313 // dynamic object handling
315};
316
317//------------------------------------------------------------------------------
318//
320{
321 // public member functions
322 public :
323
327
331
334 enum EFlags {
335 eFlgNone = 0x00000000,
336 eFlgEnabled = 0x00000001,
337 };
338
344 uint32 Setup(uint32 auCycletime, uint32 auFlags);
345
351 uint32 SetupDone(uint16 auHooks);
352
358 uint32 Shutdown(class CINOSBusHooks* apParent);
359
362 uint32 Enable();
363
366 uint32 Disable();
367
373 bool IsCyclenumberValid(uint8 auCyclenumber);
374
380 bool IsCycletimeValid(uint32 auCycletimeNs);
381
382 //--- internals --------------------------------------------------------
383
384 friend class CINOSBusHooks;
385 friend class CINOSBusHookCore;
386
387 // protected members
388 protected :
389 /* category flags */
390 uint32 m_uFlags{};
391 /* category cycletime [ns] */
392 uint32 m_uCycletimeNs{};
394 uint32 m_uCycles{};
397
398 // dynamic object handling
400};
401
402//------------------------------------------------------------------------------
403//
405{
406 // public member functions
407 public :
408
412
416
422 uint32 Setup(uint8 auCategories);
423
431 uint32 SetupCategory(uint8 auCategory, uint32 auCycletimeNs, uint32 auFlags);
432
438 uint32 SetupDone(uint16 auHooks);
439
445 uint32 Shutdown(class CINOSBusHooks* apParent);
446
452 bool IsCategoryValid(uint8 auCategory);
453
459 bool IsCategoryEnabled(uint8 auCategory);
460
461 //--- internals --------------------------------------------------------
462
463 friend class CINOSBusHooks;
464
465 // protected members
466 protected :
471
472 // dynamic object handling
474};
475
476//------------------------------------------------------------------------------
477//
479{
480 //--- user interface ---------------------------------------------------
481
482 // public member functions
483 public :
484
485 /* hook handler states */
486 enum EState {
487 eStaIdle = 0,
488 eStaSetup = 1,
489 eStaReady = 2,
490 eStaShutdown = 3,
491 };
492
493 /* hooks constants */
494 enum {
496 };
497
498 /* hooks options */
499 enum {
500 eOptNone = 0x00000000,
501 eOptCategoryDc = 0x000000001,
502 eOptException = 0x000000002,
503 #if defined(INOS_CPP_EXCEPTION_SUPPORT)
505 #else
506 eOptExceptionEx = eOptNone,
507 #endif
508 #if defined(INOS_TESTING) or defined(INOS_TESTING_BASE_SUPPORT)
509 eOptDeleteImmediate = 0x80000000,
510 #endif
511 };
512
513 /* hooks flags */
514 enum {
515 eFlgNone = 0x00000000,
516 eFlgDelete = 0x000000001,
517 eFlgNegative = 0x000000002,
518 eFlgPositive = 0x000000004,
519 eFlgTimeMeasure = 0x00000008,
520 };
521
522 /* hook don't care values */
523 enum {
524 eDcOrder = 20,
525 eDcCategory = 0xff,
526 eDcCycletime = 0xffffffff,
527 eDcCyclenumber = 0xff,
528 eDcCoreId = 0x3f,
529 };
530
535 CINOSBusHooks (uint8 auGroupId = 0);
536
540
545 EState GetState()
546 { return m_eState; };
547
560 uint32 Setup(uint8 auCores = 1, uint8 auCoreId = 0, uint32 auOptions = eOptNone);
561
568 uint32 SetupCore(uint8 auCoreId, uint8 auCategories);
569
578 uint32 SetupCategory(uint8 auCoreId, uint8 auCategory, uint32 auCycletimeNs, uint32 auFlags = CINOSBusHookCategory::eFlgEnabled);
579
585 uint32 SetupDone(uint16 auHooks);
586
591 uint32 Shutdown();
592
598 uint32 EnableCategory(uint8 auCategory);
599
606 uint32 EnableCategory(uint8 auCoreId, uint8 auCategory);
607
613 uint32 DisableCategory(uint8 auCategory);
614
621 uint32 DisableCategory(uint8 auCoreId, uint8 auCategory);
622
630 uint32 RegisterHook(uintid& aoHookId, void* apHandler, CINOSBusHook::EFlags auFlags = CINOSBusHook::eFlgEnabled);
631
640 uint32 RegisterHook(uintid& aoHookId, void* apHandler, void* apObject, CINOSBusHook::EFlags auFlags = CINOSBusHook::eFlgEnabled);
641
651 uint32 RegisterHook(uintid& aoHookId, void* apHandler, void* apObject, int32 aiOrder, CINOSBusHook::EFlags auFlags = CINOSBusHook::eFlgEnabled);
652
663 uint32 RegisterHook(uintid& aoHookId, void* apHandler, void* apObject, int32 aiOrder, uint8 auCategory, CINOSBusHook::EFlags auFlags = CINOSBusHook::eFlgEnabled);
664
676 uint32 RegisterHook(uintid& aoHookId, void* apHandler, void* apObject, int32 aiOrder, uint8 auCategory, uint32 auCycletime, CINOSBusHook::EFlags auFlags = CINOSBusHook::eFlgEnabled);
677
690 uint32 RegisterHook(uintid& aoHookId, void* apHandler, void* apObject, int32 aiOrder, uint8 auCategory, uint32 auCycletime, uint8 auCyclenumber, CINOSBusHook::EFlags auFlags = CINOSBusHook::eFlgEnabled);
691
705 uint32 RegisterHook(uintid& aoHookId, void* apHandler, void* apObject, int32 aiOrder, uint8 auCategory, uint32 auCycletime, uint8 auCyclenumber, uint8 auCoreId, CINOSBusHook::EFlags auFlags = CINOSBusHook::eFlgEnabled);
706
712 uint32 RegisterHook(CINOSBusHook* apHook);
713
719 uint32 UnregisterHook(uintid auHookId);
720
727 uint32 UnregisterHook(CINOSBusHook* apHook, uint32 auFlags = eFlgNone);
728
734 uint32 EnableHook(uintid auHookId);
735
741 uint32 DisableHook(uintid auHookId);
742
748 void* GetHookHandler(uintid auHookId);
749
756 uint32 SetHookHandler(uintid auHookId, void* apHandler);
757
763 uint8 GetHookCyclenumber(uintid auHookId);
764
769 uint32 GetHookCycleTime(uintid auHookId);
770
776 uint32 GetHookCycleTime(uintid auHookId, uint32& auCycletime);
777
783 uint32 GetHookCategory(uintid auHookId, uint8& auCategory);
784
796 uint32 MoveHooks(uint8 auCoreId, uint8 auSrc, uint8 auDst);
797
806 uint32 HandleHooks(uint8 auCategory = 0, uint8 auCycle = 0, uint32 auFlags = eFlgNone);
807
812 static uint32 GetGroupId(uintid auHookId)
813 {
814 // mask it out
815 return ((uint32) auHookId)>>(32-eCnsGroupIdBits);
816 }
817
818 #if defined(INOS_BUS_HOOK_TIME_MEASUREMENTS)
823 uint32 TimeReset();
824
830 uint32 TimeFreeze(uint32 auTicks = 0);
831
836 uint32 TimeMeasure();
837
842 uint32 TimeFreezeTrigger(uint32 auNs);
843 #endif
844
845 //--- internals --------------------------------------------------------
846
847 friend class CINOS1ms;
848 friend class CINOSBus;
849 friend class CINOSBusHookCycle;
850 friend class CINOSBusHookExTest;
851 friend class CINCOBusHooksMain;
852 friend class CINCOBusHooks;
853 friend class CINOSHwTarget;
854
855 // protected methods
856 protected :
857
863 uint32 RequestId(uintid& aoHookId);
864
870 uint32 ReleaseId(uintid auHookId);
871
877 uint32 GetIndex(uintid auHookId)
878 {
879 return auHookId & m_uHookIndexMask;
880 }
881
887 bool HasHooks(uint32 auNumber)
888 { return (m_uHooksAct + auNumber) <= m_uHooksMax; };
889
901 uint32 iHookCheck(void* apHandler, void* apObject, int32& aiOrder, uint8& auCategory, uint32& auCycletime, uint8& auCyclenumber, uint8& auCoreId);
902
909 uint32 iHookIdCheck(uintid auHookId, CINOSBusHook*& apHook);
910
917
923 {
924 #if defined(INOS_DESKTOP)
925 // locals
926 SINOSBusHookNode* node;
927 // enter critical section
928 uint32 uMsr = INOSDisableInterrupts();
929 // parts back to pool
930 node = m_pNodes;
931 m_pNodes = (SINOSBusHookNode*) *((uintptr*) node);
932 // exit critical section
933 INOSEnableInterrupts(uMsr);
934 #else
935 // locals
936 SINOSBusHookNode* next;
937 SINOSBusHookNode* node;
938 uintptr p = (uintptr) &m_pNodes;
939 #if defined(INOS_CPU_CORTEXA9)
940 // locals
941 uint32 res;
942 // try to alloc node
943 asm volatile (
944 " dsb" "\n\t"
945 "0: ldrex %0,[%2]" "\n\t"
946 " cmp %0,#0" "\n\t"
947 " beq 1f" "\n\t"
948 " ldr %1,[%0]" "\n\t"
949 " strex %3,%1,[%2]" "\n\t"
950 " cmp %3,#0" "\n\t"
951 " bne 0b" "\n\t"
952 "1: isb" "\n\t"
953 : "=r" (node), "=r" (next), "=r" (p), "=&r" (res)
954 : "2" (p));
955 #elif defined(INOS_CPU_CORTEXA72)
956 // locals
957 uint32 res;
958 // try to alloc node
959 asm volatile (
960 "0: ldaxr %0,[%2]" "\n\t"
961 " cmp %0,#0" "\n\t"
962 " beq 1f" "\n\t"
963 " ldr %1,[%0]" "\n\t"
964 " stlxr %w3,%1,[%2]" "\n\t"
965 " cmp %w3,#0" "\n\t"
966 " bne 0b" "\n\t"
967 "1: isb" "\n\t"
968 : "=r" (node), "=r" (next), "=r" (p), "=&r" (res)
969 : "2" (p));
970 #else
971 // try to alloc node
972 asm volatile (
973 " sync" "\n\t"
974 "0: lwarx %0, 0, %2" "\n\t"
975 " cmpwi %0, 0" "\n\t"
976 " beq 1f" "\n\t"
977 " lwz %1, 0(%0)" "\n\t"
978 " stwcx. %1, 0, %2" "\n\t"
979 " bne- 0b" "\n\t"
980 "1: isync" "\n\t"
981 : "=r" (node), "=r" (next), "=r" (p)
982 : "2" (p));
983 #endif
984 #endif
985
986 // inc number of allocated nodes
987 if (node) m_iNodesAct++;
988 // return result
989 return node;
990 }
991
997 {
998 #if defined(INOS_DESKTOP)
999 // enter critical section
1000 uint32 uMsr = INOSDisableInterrupts();
1001 // parts back to pool
1002 apNode->m_pNext = m_pNodes;
1003 m_pNodes = apNode;
1004 // exit critical section
1005 INOSEnableInterrupts(uMsr);
1006 #else
1007 // locals
1008 SINOSBusHookNode* node = nullptr;
1009 uintptr p = (uintptr) &m_pNodes;
1010 #if defined(INOS_CPU_CORTEXA9)
1011 // locals
1012 uint32 res;
1013 // try to alloc part
1014 asm volatile (
1015 " dsb" "\n\t"
1016 "0: ldrex %0,[%2]" "\n\t"
1017 " str %4,[%3]" "\n\t"
1018 " strex %1,%3,[%2]" "\n\t"
1019 " cmp %1,#0" "\n\t"
1020 " bne 0b" "\n\t"
1021 " isb" "\n\t"
1022 : "=r" (node), "=&r" (res)
1023 : "r" (p), "r" (apNode), "0" (node));
1024 #elif defined(INOS_CPU_CORTEXA72)
1025 // locals
1026 uint32 res;
1027 // try to alloc part
1028 asm volatile (
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"
1033 " bne 0b" "\n\t"
1034 " isb" "\n\t"
1035 : "=r" (node), "=&r" (res)
1036 : "r" (p), "r" (apNode), "0" (node));
1037 #else
1038 // try to alloc part
1039 asm volatile (
1040 " sync" "\n\t"
1041 "0: lwarx %0, 0, %1" "\n\t"
1042 " stw %4, 0(%3)" "\n\t"
1043 " stwcx. %2, 0, %1" "\n\t"
1044 " bne- 0b" "\n\t"
1045 " isync" "\n\t"
1046 : "=r" (node)
1047 : "r" (p), "r" (apNode), "r" (apNode), "0" (node));
1048 #endif
1049 #endif
1050
1051 // dec number of allocated nodes
1052 m_iNodesAct--;
1053 }
1054
1060 {
1061 // something to free ?
1062 if (nullptr == apNode) {
1063 // no
1064 return;
1065 }
1066
1067 // locals
1068 int32 iCount = 1;
1069 SINOSBusHookNode* lst = apNode;
1070 // count number of nodes
1071 while (lst->m_pNext){
1072 lst = lst->m_pNext;
1073 iCount++;
1074 }
1075
1076 #if defined(INOS_DESKTOP)
1077 // enter critical section
1078 uint32 uMsr = INOSDisableInterrupts();
1079 // parts back to pool
1080 lst->m_pNext = m_pNodes;
1081 m_pNodes = apNode;
1082 // exit critical section
1083 INOSEnableInterrupts(uMsr);
1084 #else
1085 // locals
1086 SINOSBusHookNode* node = nullptr;
1087 uintptr p = (uintptr) &m_pNodes;
1088 #if defined(INOS_CPU_CORTEXA9)
1089 // locals
1090 uint32 res;
1091 // try to alloc part
1092 asm volatile (
1093 " dsb" "\n\t"
1094 "0: ldrex %0,[%2]" "\n\t"
1095 " str %5,[%4]" "\n\t"
1096 " strex %1,%3,[%2]" "\n\t"
1097 " cmp %1,#0" "\n\t"
1098 " bne 0b" "\n\t"
1099 " isb" "\n\t"
1100 : "=r" (node), "=&r" (res)
1101 : "r" (p), "r" (apNode), "r" (lst), "0" (node));
1102 #elif defined(INOS_CPU_CORTEXA72)
1103 // locals
1104 uint32 res;
1105 // try to alloc part
1106 asm volatile (
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"
1111 " bne 0b" "\n\t"
1112 " isb" "\n\t"
1113 : "=r" (node), "=&r" (res)
1114 : "r" (p), "r" (apNode), "r" (lst), "0" (node));
1115 #else
1116 // try to alloc part
1117 asm volatile (
1118 " sync" "\n\t"
1119 "0: lwarx %0, 0, %1" "\n\t"
1120 " stw %4, 0(%3)" "\n\t"
1121 " stwcx. %2, 0, %1" "\n\t"
1122 " bne- 0b" "\n\t"
1123 " isync" "\n\t"
1124 : "=r" (node)
1125 : "r" (p), "r" (apNode), "r" (lst), "0" (node));
1126 #endif
1127 #endif
1128
1129 // dec number of allocated nodes
1130 m_iNodesAct -= iCount;
1131 }
1132
1139
1147
1155
1161
1162 //--- testing ---------------------------------------------------------
1163
1164 // private members
1165 private :
1166
1171 uint32 GetNodes()
1172 { return m_uNodesMax; }
1173
1178 int32 GetNodesAllocated()
1179 { return m_iNodesAct; }
1180
1188 SINOSBusHookNode* GetHookListInsert(uint8 auCoreId, uint8 auCategory, uint8 auCycle)
1189 { return m_pCores[auCoreId].m_pCategories[auCategory].m_pCycles[auCycle].m_pInsert; }
1190
1198 SINOSBusHookNode* GetHookListSequence(uint8 auCoreId, uint8 auCategory, uint8 auCycle)
1199 { return m_pCores[auCoreId].m_pCategories[auCategory].m_pCycles[auCycle].m_pSequence; }
1200
1205 CINCOObject* GetRegister(const char* apName);
1206
1211 void GetHookIdMap(std::map<uintid,uintid>& aHooks);
1212
1215 static void Create();
1216
1217 #if defined(INOS_TESTING) or defined(INOS_TESTING_BASE_SUPPORT)
1218 friend class CINOSTestManager;
1221 static void WaitIdle();
1222 #endif
1223
1224 // protected members
1225 protected :
1226 /* hook handler state */
1227 EState m_eState = eStaIdle;
1228 /* hook handler options */
1229 uint32 m_uOptions = eOptNone;
1230 /* hook flags */
1231 uint32 m_uFlags = eFlgTimeMeasure;
1232 #if defined(INOS_BUS_HOOK_TIME_MEASUREMENTS)
1233 /* hook time reset counter*/
1234 std::atomic<uint32> m_uTimeReset{};
1235 /* hook freeze trigger ticks */
1236 uint32 m_uTimeFreezeTriggerTicks{};
1237 /* external time freeze */
1238 uint32 eTimeFreeze(uint32 auNs);
1240 uint32 m_ueFreezeTrigger{};
1241 uint32 m_ueReturn{};
1242 #endif
1243
1245 uint8 m_uGroupId{};
1251 std::atomic<uint32> m_uHookIdCnt = {1};
1257 uint32 m_uHooksMax{};
1259 std::atomic<int32> m_uHooksAct = {0};
1262
1266 uint8 m_uCores{};
1270 uint32 m_uCycletimeSlowest{1000000};
1271
1273 std::atomic<uint32> m_uNodesMax = {0};
1275 std::atomic<int32> m_iNodesAct = {0};
1278
1279 #if defined(INOS_CPU_CORTEXA9)
1281 uint8 m_uActCore{};
1283 uint8 m_uActCategory{};
1285 uint8 m_uActCycle{};
1286 #endif
1287
1289 CINCOObject* m_pRegister{};
1291 class CINCOBusHooksMain* m_pInco{};
1292
1294 static class CINOSBusHooksHelper* m_pInstance[DF_INOS_MAX_CORES];
1295
1296 // dynamic object handling
1298};
1299
1300//------------------------------------------------------------------------------
1301// end of file
1302//------------------------------------------------------------------------------
1303
1304#endif // INC_CINOSBUSHOOKS_H
#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