Subversion Repositories Kolibri OS

Rev

Rev 859 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1.  
  2. #define OS_BASE 0xE0000000
  3.  
  4.  
  5. void printf (const char *format, ...);
  6.  
  7. #define CALLER ((addr_t) __builtin_return_address(0))
  8.  
  9. extern void panic_printf(char *fmt, ...) __attribute__((noreturn));
  10.  
  11. #ifdef CONFIG_DEBUG
  12.  
  13. # define panic(format, ...) \
  14.                 panic_printf("Kernel panic in %s() at %s:%u: " format, __func__, \
  15.                 __FILE__, __LINE__, ##__VA_ARGS__);
  16.  
  17. #       define ASSERT(expr) \
  18.                 if (!(expr)) { \
  19.                         panic("assertion failed (%s), caller=%p\n", #expr, CALLER); \
  20.                 }
  21. #else
  22. #       define panic(format, ...) \
  23.                 panic_printf("Kernel panic: " format, ##__VA_ARGS__);
  24.  
  25. # define ASSERT(expr)
  26. #endif
  27.  
  28.  
  29. static inline eflags_t safe_cli(void)
  30. {
  31.   eflags_t tmp;
  32.         asm volatile (
  33.     "pushf\n\t"
  34.     "pop %0\n\t"
  35.                 "cli\n"
  36.     : "=r" (tmp)
  37.         );
  38.   return tmp;
  39. }
  40.  
  41. static inline void safe_sti(eflags_t efl)
  42. {
  43.         asm volatile (
  44.     "push %0\n\t"
  45.                 "popf\n"
  46.     : : "r" (efl)
  47.         );
  48. }
  49.