Alternative library and kernel for add-in development on fx-9860G and fx-CG50 under Linux.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

exc.h 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //---
  2. // gint:exc - Exception handling
  3. //
  4. // This small module is used to display exceptions and configure when the
  5. // exception handler displays these messages. This is for advanced users
  6. // only!
  7. //---
  8. #ifndef GINT_EXC
  9. #define GINT_EXC
  10. #include <gint/defs/attributes.h>
  11. #include <stdint.h>
  12. /* gint_panic(): Panic handler function
  13. This function is called when an uncaught CPU exception is generated. By
  14. default, it displays a full-screen error message with the event code and
  15. basic debugging information. Some custom event codes may be used for kernel
  16. failure scenarios. This function never returns. */
  17. GNORETURN void gint_panic(uint32_t code);
  18. /* gint_panic_set(): Change the panic handler function
  19. Sets up a different panic function instead of the default. It the argument
  20. is NULL, restores the default. */
  21. void gint_panic_set(GNORETURN void (*panic)(uint32_t code));
  22. /* gint_exc_catch(): Set a function to catch exceptions
  23. Sets up an exception-catching function. If an exception occurs, before a
  24. panic is raised, the exception-catching function is executed in interrupt
  25. mode and is given a chance to handle the exception. Passing NULL disables
  26. this feature.
  27. The exception-catching function can do anything that does not use interrupts
  28. or causes an exception, such as logging the exception or any other useful
  29. mechanism.
  30. What happens next depends on the return value:
  31. * If it returns 0, the exception is considered handled and execution
  32. continues normally at or after the offending instruction.
  33. * If it returns nonzero, a panic is raised.
  34. Please be aware that many exceptions are of re-execution type. When
  35. execution restarts after such an exception is handled, the offending
  36. instruction if re-executed. This can cause the exception handling mechanism
  37. to loop. Use gint_exc_skip() to skip over the offending instruction when
  38. needed. Whether an exception is of re-execution type depends on the
  39. exception code. */
  40. void gint_exc_catch(int (*handler)(uint32_t code));
  41. /* gint_exc_skip(): Skip pending exception instructions
  42. Many exceptions re-execute the offending instruction after the exception is
  43. handled. For instance the TLB miss handler is supposed to load the required
  44. page into memory, so that the instruction that accessed unmapped memory can
  45. be successfully re-executed.
  46. When an exception-catching function records an exception without solving it,
  47. this re-execution will fail again and the exception handling process will
  48. loop. In such a situation, gint_exc_skip() can be used to manually skip the
  49. offending instruction.
  50. @instructions Number of instructions to skip (usually only one) */
  51. void gint_exc_skip(int instructions);
  52. #endif /* GINT_EXC */