Choco OS  V.0.16.9.0
Join to the chocolate world
oc_exchan.c
Go to the documentation of this file.
1 
27 #include <oc_exchan.h>
28 #include <oc_module.h>
29 #include <oc_sys_lld.h>
30 #include <oc_ktime.h>
31 #include <oc_userman.h>
32 #include <oc_debug.h>
33 #include <oc_process.h>
34 #include <oc_processman.h>
35 #include <oc_intman.h>
36 #include <oc_kprint.h>
37 #include <oc_streamman.h>
38 #include <oc_threadman.h>
39 #include <oc_clock_lld.h>
40 #include <oc_memman.h>
41 #include <oc_dynamic_config.h>
42 
48 #define _________________________________________DEFINITIONS_SECTION________________________________________________________________________
49 
50 #define MAX_LOGGED_EVENTS 30
51 
52 #undef _________________________________________DEFINITIONS_SECTION________________________________________________________________________
53 
54 
60 #define _________________________________________TYPES_SECTION______________________________________________________________________________
61 
62 typedef struct
63 {
64  bool Used;
65  const char * EventName;
66  char AdditionalInfo[150];
67  oC_Timestamp_t Timestamp;
68  oC_Thread_t ExpectedThread;
69  oC_Thread_t RealThread;
70  bool AchievedRedZone;
71  bool StackAddressCorrect;
72  bool InterruptsEnabled;
73  oC_ExcHan_ExceptionType_t ExceptionType;
74  bool ErrorInSystemContext;
75  void * StackAddress;
76  oC_Process_t Process;
77  oC_Int_t FreeStackBytes;
78 } EventLog_t;
79 
80 #undef _________________________________________TYPES_SECTION______________________________________________________________________________
81 
82 
88 #define _________________________________________PROTOTYPES_SECTION_________________________________________________________________________
89 
90 static void SystemEventHandler ( oC_SYS_LLD_EventFlags_t EventFlags , oC_SYS_LLD_Context_t * Context , void * MemoryAddress );
91 static void MemoryEventHandler ( void * Address , MemoryEventFlags_t Event , const char * Function, uint32_t LineNumber );
92 static void LogEvent ( const char * Name , char * AdditionalInfo , oC_Thread_t Thread , oC_SYS_LLD_Context_t * Context , oC_ExcHan_ExceptionType_t Type );
93 static void DaemonThreadHandler ( void * Context );
94 
95 #undef _________________________________________PROTOTYPES_SECTION_________________________________________________________________________
96 
102 #define _________________________________________VARIABLES_SECTION__________________________________________________________________________
103 
104 static const oC_SYS_LLD_EventFlags_t EnabledSystemEvents = oC_SYS_LLD_EventFlags_DivideBy0
110 
111 static const oC_Allocator_t Allocator = {
112  .Name = "ExcHan"
113 };
114 
115 static EventLog_t LoggedEvents[MAX_LOGGED_EVENTS] = {{ 0 }};
116 static oC_Event_t EventLogged = NULL;
117 static oC_Process_t DaemonProcess = NULL;
118 static oC_Thread_t DaemonThread = NULL;
119 uintptr_t __stack_chk_guard = 0xfdecbaba;
120 
121 #undef _________________________________________VARIABLES_SECTION__________________________________________________________________________
122 
123 
129 #define _________________________________________INTERFACE_FUNCTIONS_SECTION________________________________________________________________
130 
135 //==========================================================================================================================================
139 //==========================================================================================================================================
140 oC_ErrorCode_t oC_ExcHan_TurnOn( void )
141 {
142  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
143 
144  oC_IntMan_EnterCriticalSection();
145 
146  if(oC_Module_TurnOffVerification(&errorCode, oC_Module_ExcHan))
147  {
148  errorCode = oC_SYS_LLD_TurnOnDriver();
149 
150  if(
151  ( !oC_ErrorOccur(errorCode) || errorCode == oC_ErrorCode_ModuleIsTurnedOn )
152  && ErrorCode(oC_SYS_LLD_SetEventInterruptHandler(SystemEventHandler , EnabledSystemEvents ))
153  )
154  {
155  errorCode = oC_MemMan_TurnOn();
156 
157  if(
158  ( !oC_ErrorOccur(errorCode) || errorCode == oC_ErrorCode_ModuleIsTurnedOn )
160  )
161  {
162  EventLogged = NULL;
163  DaemonProcess = NULL;
164  __stack_chk_guard = 0xfeedbaba;
165  oC_Module_TurnOn(oC_Module_ExcHan);
166  errorCode = oC_ErrorCode_None;
167  }
168  }
169 
170  }
171 
172  oC_IntMan_ExitCriticalSection();
173 
174  return errorCode;
175 }
176 
177 //==========================================================================================================================================
181 //==========================================================================================================================================
182 oC_ErrorCode_t oC_ExcHan_TurnOff( void )
183 {
184  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
185 
186  oC_IntMan_EnterCriticalSection();
187 
188  if(oC_Module_TurnOnVerification(&errorCode, oC_Module_ExcHan))
189  {
190  oC_Module_TurnOff(oC_Module_ExcHan);
191  errorCode = oC_ErrorCode_None;
192  }
193 
194  oC_IntMan_ExitCriticalSection();
195 
196  return errorCode;
197 }
198 
199 //==========================================================================================================================================
205 //==========================================================================================================================================
207 {
208  oC_ARRAY_FOREACH_IN_ARRAY(LoggedEvents,log)
209  {
210  oC_IntMan_EnterCriticalSection();
211  if(log->Used)
212  {
213  char string[250];
214 
215  bzero(string,sizeof(string));
216 
217  oC_KPrint_Printf(string,sizeof(string),oC_IoFlags_WaitForAllElements | oC_IoFlags_WriteToStdError, oC_VT100_FG_RED oC_VT100_BG_BLACK);
218 
219  kdebuglog(oC_LogType_Error, "ExcHan - %s: 0x%X", log->EventName, log->ExceptionType);
220 
221  if(log->ExceptionType & oC_ExcHan_ExceptionType_HardFault)
222  {
223  bzero(string,sizeof(string));
224 
225  oC_KPrint_Printf(string,sizeof(string),oC_IoFlags_WaitForSomeElements | oC_IoFlags_WriteToStdError,"\n--- HARD FAULT --- \n");
226 
227  }
228 
229 
230  if(log->ExceptionType & oC_ExcHan_ExceptionType_KernelPanic)
231  {
232  bzero(string,sizeof(string));
233 
234  oC_KPrint_Printf(string,sizeof(string),oC_IoFlags_WaitForSomeElements | oC_IoFlags_WriteToStdError,"\n--- KERNEL PANIC --- \n");
235 
236  }
237 
238  if(log->ExceptionType & oC_ExcHan_ExceptionType_MemoryAccess)
239  {
240  bzero(string,sizeof(string));
241 
242  oC_KPrint_Printf(string,sizeof(string),oC_IoFlags_WaitForSomeElements | oC_IoFlags_WriteToStdError,"\n--- MEMORY ACCESS --- \n");
243 
244  }
245 
246  if(log->ExceptionType & oC_ExcHan_ExceptionType_MemoryAllocationError)
247  {
248  bzero(string,sizeof(string));
249 
250  oC_KPrint_Printf(string,sizeof(string),oC_IoFlags_WaitForSomeElements | oC_IoFlags_WriteToStdError,"\n--- MEMORY ALLOCATION ERROR --- \n");
251 
252  }
253 
254  if(log->ExceptionType & oC_ExcHan_ExceptionType_RequiredReboot)
255  {
256  bzero(string,sizeof(string));
257 
258  oC_KPrint_Printf(string,sizeof(string),oC_IoFlags_WaitForSomeElements | oC_IoFlags_WriteToStdError,"\n--- REQUIRE REBOOT --- \n");
259 
260  }
261 
262  if(log->ExceptionType & oC_ExcHan_ExceptionType_ProcessDamaged)
263  {
264  bzero(string,sizeof(string));
265 
266  oC_KPrint_Printf(string,sizeof(string),oC_IoFlags_WaitForSomeElements | oC_IoFlags_WriteToStdError,"\n--- PROCESS DAMAGED --- \n");
267 
268  }
269 
270  bzero(string,sizeof(string));
271 
272  oC_KPrint_Printf(string,sizeof(string),oC_IoFlags_WaitForSomeElements | oC_IoFlags_WriteToStdError,"System Event [%f s]: %s\n", log->Timestamp, log->EventName);
273 
274 
275  bzero(string,sizeof(string));
276 
277  oC_KPrint_Printf(string,sizeof(string),oC_IoFlags_WaitForSomeElements | oC_IoFlags_WriteToStdError,"Additional info: %s\n", log->AdditionalInfo);
278 
279 
280 
281 
282  bzero(string,sizeof(string));
283 
284  oC_KPrint_Printf(string,sizeof(string),oC_IoFlags_WaitForSomeElements | oC_IoFlags_WriteToStdError," Harmful process: [%p] %s\n", log->Process, oC_Process_GetName(log->Process));
285 
286 
287 
288  bzero(string,sizeof(string));
289 
290  oC_KPrint_Printf(string,sizeof(string),oC_IoFlags_WaitForSomeElements | oC_IoFlags_WriteToStdError," Expected thread: [%p] %s\n", log->ExpectedThread, oC_Thread_GetName(log->ExpectedThread));
291 
292 
293  bzero(string,sizeof(string));
294 
295  oC_KPrint_Printf(string,sizeof(string),oC_IoFlags_WaitForSomeElements | oC_IoFlags_WriteToStdError," Real thread: [%p] %s\n", log->RealThread, oC_Thread_GetName(log->RealThread));
296 
297 
298  if(log->AchievedRedZone)
299  {
300  bzero(string,sizeof(string));
301 
302  oC_KPrint_Printf(string,sizeof(string),oC_IoFlags_WaitForSomeElements | oC_IoFlags_WriteToStdError," Thread has achieved the red zone - stack is exhausted (lack of %d bytes)\n",
303  0 - oC_Thread_GetFreeStackSize( log->RealThread == NULL ? log->ExpectedThread : log->RealThread, true));
304  }
305 
306  if(log->StackAddressCorrect == false)
307  {
308  bzero(string,sizeof(string));
309 
310  oC_KPrint_Printf(string,sizeof(string),oC_IoFlags_WaitForSomeElements | oC_IoFlags_WriteToStdError," Stack pointer (%p) is out of the thread stack! - lack of %d bytes\n", log->StackAddress, log->FreeStackBytes);
311  }
312  else
313  {
314  bzero(string,sizeof(string));
315 
316  oC_KPrint_Printf(string,sizeof(string),oC_IoFlags_WaitForSomeElements | oC_IoFlags_WriteToStdError," Stack pointer (%p) is correct. Free stack: %d bytes\n", log->StackAddress, log->FreeStackBytes);
317  }
318 
319  bzero(string,sizeof(string));
320 
321  oC_KPrint_Printf(string,sizeof(string),oC_IoFlags_WaitForSomeElements | oC_IoFlags_WriteToStdError," Interrupts %s\n", log->InterruptsEnabled ? "enabled" : "disabled");
322 
323  if(log->ErrorInSystemContext)
324  {
325  bzero(string,sizeof(string));
326 
327  oC_KPrint_Printf(string,sizeof(string),oC_IoFlags_WaitForSomeElements | oC_IoFlags_WriteToStdError," Error occurs in the system context\n");
328  }
329 
330  if(log->ExceptionType & oC_ExcHan_ExceptionType_RequiredReboot)
331  {
332  oC_Boot_Restart(oC_Boot_Reason_SystemException,oC_UserMan_GetRootUser());
333  }
334 
335  log->Used = false;
336 
337  }
338  oC_IntMan_ExitCriticalSection();
339  }
340 }
341 
342 //==========================================================================================================================================
346 //==========================================================================================================================================
347 void oC_ExcHan_LogEvent( const char * Name , char * AdditionalInfo , void * Stack , oC_Thread_t Thread , oC_ExcHan_ExceptionType_t Type )
348 {
349  if(isaddresscorrect(Name))
350  {
351  LogEvent(Name,AdditionalInfo,Stack,Thread,Type);
352  }
353 }
354 
355 //==========================================================================================================================================
361 //==========================================================================================================================================
362 oC_ErrorCode_t oC_ExcHan_RunDaemon( void )
363 {
364  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
365 
366  if(oC_Module_TurnOnVerification(&errorCode, oC_Module_ExcHan))
367  {
368  DaemonProcess = oC_Process_New( oC_Process_Priority_SystemSecurityDeamon, "exc-han", oC_UserMan_GetRootUser(), 0, NULL, oC_StreamMan_GetStdErrorStream(), oC_StreamMan_GetStdErrorStream());
369 
370  if(ErrorCondition(DaemonProcess != NULL, oC_ErrorCode_AllocationError))
371  {
372  DaemonThread = oC_Thread_New(0, kB(1), DaemonProcess,"events handler", DaemonThreadHandler, NULL);
373 
374  if(ErrorCondition(DaemonThread != NULL , oC_ErrorCode_AllocationError))
375  {
376  EventLogged = oC_Event_New(oC_Event_State_Inactive, &Allocator, AllocationFlags_Default);
377 
378  if(
379  ErrorCondition ( EventLogged != NULL, oC_ErrorCode_AllocationError)
380  && ErrorCode ( oC_ProcessMan_AddProcess(DaemonProcess) )
381  && ErrorCondition ( oC_Thread_Run(DaemonThread) , oC_ErrorCode_CannotRunThread )
382  )
383  {
384  errorCode = oC_ErrorCode_None;
385  }
386  else
387  {
388  oC_SaveIfFalse("ExcHan - cannot delete daemon thread" , oC_Thread_Delete(&DaemonThread) , oC_ErrorCode_ReleaseError);
389  oC_SaveIfFalse("ExcHan - cannot delete daemon process" , oC_Process_Delete(&DaemonProcess) , oC_ErrorCode_ReleaseError);
390  oC_SaveIfFalse("ExcHan - cannot delete event" , EventLogged == NULL || oC_Event_Delete(&EventLogged,AllocationFlags_Default) , oC_ErrorCode_ReleaseError);
391  }
392  }
393  else
394  {
395  oC_SaveIfFalse("ExcHan - cannot delete daemon process", oC_Process_Delete(&DaemonProcess) , oC_ErrorCode_ReleaseError);
396  }
397  }
398  }
399 
400  return errorCode;
401 }
402 
404 #undef _________________________________________INTERFACE_FUNCTIONS_SECTION________________________________________________________________
405 
411 #define _________________________________________LOCAL_FUNCTIONS_SECTION____________________________________________________________________
412 
413 //==========================================================================================================================================
417 //==========================================================================================================================================
418 static void SystemEventHandler( oC_SYS_LLD_EventFlags_t EventFlags , oC_SYS_LLD_Context_t * Context , void * MemoryAddress )
419 {
420  if(EventFlags & oC_SYS_LLD_EventFlags_HardFault)
421  {
422  char string[60] = {0};
423 
424  sprintf(string, "Error during accessing %p address\n", MemoryAddress);
425 
426  LogEvent("Hard Fault", string, NULL, Context, oC_ExcHan_ExceptionType_HardFault);
427 
429 
431 
432  oC_Boot_Restart(oC_Boot_Reason_SystemException, oC_UserMan_GetRootUser());
433  }
434 }
435 
436 //==========================================================================================================================================
440 //==========================================================================================================================================
441 static void MemoryEventHandler( void * Address , MemoryEventFlags_t Event , const char * Function, uint32_t LineNumber )
442 {
443  if(Event & MemoryEventFlags_ModuleTurningOff)
444  {
445  LogEvent("Memory Manager has been disabled", NULL, NULL, NULL, oC_ExcHan_ExceptionType_MemoryAccess);
446  }
447  if(Event & MemoryEventFlags_DataSectionOverflow)
448  {
449  LogEvent("Overflow in the DATA ram section", NULL, NULL, NULL, oC_ExcHan_ExceptionType_KernelPanic);
450  }
451  if(Event & MemoryEventFlags_BufferOverflow)
452  {
453  Allocator_t allocator = oC_MemMan_GetAllocatorOfAddress(Address);
454 
455  char string[100] = {0};
456 
457  if(allocator != NULL)
458  {
459  sprintf(string, "Buffer overflow at address %p of allocator %s (allocated in %s at line %d)\n", Address, allocator->Name, Function, LineNumber);
460  }
461  else
462  {
463  sprintf(string, "Buffer overflow at address %p of unknown allocator\n", Address);
464  }
465 
466  LogEvent("Overflow in the DATA ram section", string, NULL, NULL, oC_ExcHan_ExceptionType_ProcessDamaged);
467  }
468  if(Event & MemoryEventFlags_PanicMemoryExhausted)
469  {
470  static oC_Timestamp_t nextLogTimestamp = 0;
471 
472  if(nextLogTimestamp <= oC_KTime_GetTimestamp())
473  {
474  nextLogTimestamp = oC_KTime_GetTimestamp() + oC_DynamicConfig_GetValue(ExcHan,MemoryEventsLoggingPeriod);
475  LogEvent("Panic memory limit exhausted", "Check your configuration in the command 'system'", NULL, NULL, oC_ExcHan_ExceptionType_KernelPanic);
476  }
477  }
478  if(Event & MemoryEventFlags_MemoryExhausted)
479  {
480  static oC_Timestamp_t nextLogTimestamp = 0;
481 
482  if(nextLogTimestamp <= oC_KTime_GetTimestamp())
483  {
484  nextLogTimestamp = oC_KTime_GetTimestamp() + oC_DynamicConfig_GetValue(ExcHan,MemoryEventsLoggingPeriod);
485  LogEvent("First memory limit exhausted", "Check your configuration in the command 'system'", NULL, NULL, oC_ExcHan_ExceptionType_MemoryAccess);
486  }
487  }
488  if(Event & MemoryEventFlags_MemoryFault)
489  {
490  LogEvent("Memory access fault", NULL, NULL, NULL, oC_ExcHan_ExceptionType_MemoryAccess);
491  }
492  if(Event & MemoryEventFlags_BusFault)
493  {
494  LogEvent("Bus Fault", NULL, NULL, NULL, oC_ExcHan_ExceptionType_HardFault);
495 
497 
499 
500  oC_Boot_Restart(oC_Boot_Reason_SystemException, oC_UserMan_GetRootUser());
501  }
502 }
503 
504 //==========================================================================================================================================
508 //==========================================================================================================================================
509 static void LogEvent( const char * Name , char * AdditionalInfo , oC_Thread_t Thread , oC_SYS_LLD_Context_t * Context , oC_ExcHan_ExceptionType_t Type )
510 {
511  bool interruptsTurnedOn = oC_IntMan_AreInterruptsTurnedOn();
512  oC_IntMan_EnterCriticalSection();
513 
514  oC_Event_SetState(EventLogged, oC_Event_State_Active);
515 
516  oC_ARRAY_FOREACH_IN_ARRAY(LoggedEvents,log)
517  {
518  if(log->Used == false)
519  {
520  if(Context == NULL)
521  {
522  Context = oC_SYS_LLD_GetCurrentContext();
523  }
524  if(Thread == NULL)
525  {
526  Thread = oC_ThreadMan_GetCurrentThread();
527  }
528 
529  void * stackPointer = oC_SYS_LLD_GetLastProcessStackPointer();
530  log->Used = true;
531  log->StackAddress = stackPointer;
532  log->EventName = Name;
533  log->ExpectedThread = oC_ThreadMan_GetCurrentThread();
534  log->RealThread = oC_ThreadMan_GetThreadOfContext( Context );
535  log->Timestamp = oC_KTime_GetTimestamp();
536  log->InterruptsEnabled = interruptsTurnedOn;
537  log->ExceptionType = Type;
538  log->ErrorInSystemContext = oC_SYS_LLD_GetSystemContext() == Context;
539 
540  if(AdditionalInfo)
541  {
542  strncpy(log->AdditionalInfo,AdditionalInfo,sizeof(log->AdditionalInfo));
543  log->AdditionalInfo[sizeof(log->AdditionalInfo) - 1] = 0;
544  }
545  else
546  {
547  memset(log->AdditionalInfo,0,sizeof(log->AdditionalInfo));
548  }
549 
550  if(log->ErrorInSystemContext == false)
551  {
552  log->Process = oC_ProcessMan_GetCurrentProcess();
553  }
554  else
555  {
556  log->Process = NULL;
557  }
558 
559  if(oC_Thread_IsCorrect(log->RealThread))
560  {
561  log->StackAddressCorrect = oC_Thread_IsOwnedByStack(log->RealThread, stackPointer, &log->AchievedRedZone);
562  log->FreeStackBytes = oC_Thread_GetFreeStackSize(log->RealThread,true);
563  }
564  else
565  {
566  log->StackAddressCorrect = oC_Thread_IsOwnedByStack(log->ExpectedThread, stackPointer, &log->AchievedRedZone);
567  log->FreeStackBytes = oC_Thread_GetFreeStackSize(log->ExpectedThread,true);
568  }
569  break;
570  }
571  }
572 
573  oC_IntMan_ExitCriticalSection();
574 }
575 
576 //==========================================================================================================================================
580 //==========================================================================================================================================
581 static void DaemonThreadHandler( void * Context )
582 {
583  while(1)
584  {
585  if(oC_Event_WaitForState(EventLogged, oC_Event_State_Active, oC_Event_StateMask_Full, min(20)))
586  {
588 
589  oC_Event_SetState(EventLogged, oC_Event_State_Inactive);
590  }
591  }
592 }
593 
594 //==========================================================================================================================================
598 //==========================================================================================================================================
599 __attribute__((noreturn)) void __stack_chk_fail(void)
600 {
601  oC_Thread_t thread = oC_ThreadMan_GetCurrentThread();
602  char info[100] = {0};
603 
604  sprintf(info, "Behavior of the thread `%s` [%p] was unexpected - closing", oC_Thread_GetName(thread), thread);
605 
606  LogEvent("Segmentation fault", info, thread, NULL, oC_ExcHan_ExceptionType_ProcessDamaged );
607 
608  if(__stack_chk_guard != 0)
609  {
610  oC_Thread_Cancel(&thread);
611  }
612 
613  while(1);
614 }
615 
616 #undef _________________________________________LOCAL_FUNCTIONS_SECTION____________________________________________________________________
617 
#define min(time)
Number of min.
Definition: oc_cfg.h:138
Hard fault, divide by 0 detected.
Definition: oc_sys_lld.h:156
oC_SYS_LLD_Context_t * oC_SYS_LLD_GetSystemContext(void)
returns pointer to the system context
Definition: oc_sys_lld.c:408
oC_SYS_LLD_EventFlags_t
event flags handled by the module.
Definition: oc_sys_lld.h:153
oC_ErrorCode_t oC_ExcHan_TurnOff(void)
turns off exception handler
Definition: oc_exchan.c:182
bool oC_Event_WaitForState(oC_Event_t Event, oC_Event_State_t State, oC_Event_StateMask_t StateMask, oC_Time_t Timeout)
Definition: oc_event.c:245
FILE__DESCRIPTION
void oC_ExcHan_PrintLoggedEvents(void)
prints logged events in the STD out
Definition: oc_exchan.c:206
static void LogEvent(const char *Name, char *AdditionalInfo, oC_Thread_t Thread, oC_SYS_LLD_Context_t *Context, oC_ExcHan_ExceptionType_t Type)
logs event
Definition: oc_exchan.c:509
oC_ErrorCode_t oC_ExcHan_RunDaemon(void)
starts daemon of the Exception Handler
Definition: oc_exchan.c:362
const char * Name
Definition: oc_stdlib.h:161
identifier for allocations
Definition: oc_stdlib.h:159
oC_SYS_LLD_Context_t * oC_SYS_LLD_GetCurrentContext(void)
returns pointer to the current context
Definition: oc_sys_lld.c:397
static void DaemonThread(void *Argument)
main thread for handling network interfaces
Definition: oc_netifman.c:1170
The file with interface for process manager.
File with interface for user system manager.
oC_ErrorCode_t oC_SYS_LLD_TurnOnDriver(void)
initializes the driver to work
Definition: oc_sys_lld.c:103
static void DaemonThreadHandler(void *Context)
thread for printing logs
Definition: oc_exchan.c:581
void oC_SYS_LLD_Context_t
type for storing context of the machine
Definition: oc_sys_lld.h:143
oC_ErrorCode_t oC_MemMan_TurnOn(void)
turns on memory manager
Definition: oc_memman.c:251
Loading or storing data to memory occurs with not aligned address.
Definition: oc_sys_lld.h:157
The file with interface for the module library.
static void SystemEventHandler(oC_SYS_LLD_EventFlags_t EventFlags, oC_SYS_LLD_Context_t *Context, void *MemoryAddress)
handler for system events
Definition: oc_exchan.c:418
The file with interface for stream manager.
Allocator_t oC_MemMan_GetAllocatorOfAddress(const void *Address)
returns allocator of address
Definition: oc_memman.c:1098
void oC_Boot_Restart(oC_Boot_Reason_t Reason, oC_User_t User)
restarts the system
Definition: oc_boot.c:145
The file with LLD interface for the CLOCK driver.
The file with interface for kernel print operations.
void oC_ExcHan_LogEvent(const char *Name, char *AdditionalInfo, void *Stack, oC_Thread_t Thread, oC_ExcHan_ExceptionType_t Type)
logs system event
Definition: oc_exchan.c:347
The file with interface for interrupt manager.
Handles configuration of the Dynamic.
static void MemoryEventHandler(void *Address, MemoryEventFlags_t Event, const char *Function, uint32_t LineNumber)
handler for memory manager events
Definition: oc_exchan.c:441
oC_ErrorCode_t oC_ExcHan_TurnOn(void)
turns on exception handler
Definition: oc_exchan.c:140
static void oC_Module_TurnOn(oC_Module_t Module)
sets module as turned on
Definition: oc_module.h:170
oC_ErrorCode_t oC_SYS_LLD_SetEventInterruptHandler(oC_SYS_LLD_EventInterrupt_t EventHandler, oC_SYS_LLD_EventFlags_t EventsFlags)
sets event interrupt handler
Definition: oc_sys_lld.c:164
The file with memory manager interface.
The file with interface for process mechanism.
File with interface of Exception Handler.
static bool oC_Module_TurnOffVerification(oC_ErrorCode_t *outErrorCode, oC_Module_t Module)
verify if module is turned off
Definition: oc_module.h:155
static bool oC_Module_TurnOnVerification(oC_ErrorCode_t *outErrorCode, oC_Module_t Module)
verify if module is turned on
Definition: oc_module.h:138
The file with LLD interface for the SYS driver.
bool oC_Thread_IsOwnedByStack(oC_Thread_t Thread, const void *Address, bool *outAddressInRedZone)
checks if the given address is owned by the thread stack
Definition: oc_thread.c:272
#define kB(kBytes)
Number of kB.
Definition: oc_cfg.h:78
oC_ErrorCode_t oC_MemMan_SetEventHandler(MemoryEventHandler_t EventHandler)
sets event handler function
Definition: oc_memman.c:1035
The process is not correct, or the process stack was overflowed.
Definition: oc_sys_lld.h:160
void * oC_SYS_LLD_GetLastProcessStackPointer(void)
returns stack pointer of last executed process
Definition: oc_sys_lld.c:537
The file with interface for Thread Manager.
Undefined instruction detected.
Definition: oc_sys_lld.h:158
bool oC_CLOCK_LLD_DelayForMicroseconds(oC_UInt_t Microseconds)
perform a delay for us
Definition: oc_clock_lld.c:297
The file with interface of kernel time module.
Hard fault, reason is unknown.
Definition: oc_sys_lld.h:155
#define NULL
pointer to a zero
Definition: oc_null.h:37
static void oC_Module_TurnOff(oC_Module_t Module)
sets module as turned off
Definition: oc_module.h:185