1 #include <aros/kernel.h>
2 #include <aros/libcall.h>
4 #include <kernel_base.h>
5 #include <kernel_debug.h>
9 static inline void PrintChars(char c
, ULONG n
, struct KernelBase
*KernelBase
)
12 krnPutC(c
, KernelBase
);
16 * This function calculates length of line.
17 * It's similar to strlen(), but stops also at LF and FF codes.
19 static inline int linelen(const char *str
)
23 for (l
= 0; str
[l
] && str
[l
] != '\n' && str
[l
] != 0x0F; l
++);
27 static const char *PrintCentered(const char *str
, struct KernelBase
*KernelBase
)
29 int len
= linelen(str
);
33 if (len
> (ALERT_WIDTH
- 2))
34 len
= (ALERT_WIDTH
- 2);
36 s
= ALERT_WIDTH
- 2 - len
;
38 krnPutC('#', KernelBase
);
40 krnPutC(' ', KernelBase
);
42 PrintChars(' ', s
, KernelBase
);
44 for (i
= 0; i
< len
; i
++)
45 krnPutC(*str
++, KernelBase
);
47 PrintChars(' ', s
, KernelBase
);
48 krnPutC('#', KernelBase
);
49 krnPutC('\n', KernelBase
);
54 static inline void PrintFrame(struct KernelBase
*KernelBase
)
56 PrintChars('#', ALERT_WIDTH
, KernelBase
);
57 krnPutC('\n', KernelBase
);
60 /*****************************************************************************
63 #include <proto/kernel.h>
65 AROS_LH2(void, KrnDisplayAlert
,
68 AROS_LHA(uint32_t, code
, D0
),
69 AROS_LHA(const char *, text
, A0
),
72 struct KernelBase
*, KernelBase
, 35, Kernel
)
75 Inform the user about critical system failure.
78 code - Corresponding alert code.
79 text - A NULL-terminated text to print out.
81 First three lines are assumed to be a header. Some implementations
82 may print them centered inside a frame.
85 None. This function is not guaranteed to return.
88 This function exists for system internal purposes. Please do not
89 call it from within regular applications! In 99% of cases this function
90 will halt or reboot the machine. Certain structures in RAM, as well as
91 video hardware state, will be irreversibly destroyed.
93 'code' parameter is passed for convenience. Based on it, the system
94 can make a decision to log the alert in debug output and continue,
95 instead of displaying a message and halting.
97 This function is currently experimental. Its definition may change.
107 ******************************************************************************/
112 * This is a generic version that simply formats the text into debug log.
113 * It can be replaced with machine-specific implementation which can do more.
117 /* Make sure that the output starts from a new line */
118 krnPutC('\n', KernelBase
);
120 PrintFrame(KernelBase
);
122 /* Print first three lines (title, task and error) centered */
123 for (i
= 0; i
< 3; i
++)
125 text
= PrintCentered(text
, KernelBase
);
126 text
++; /* Skip a newline */
129 PrintFrame(KernelBase
);
131 /* Print the rest of alert text */
133 krnPutC(*text
++, KernelBase
);
135 krnPutC('\n', KernelBase
);
136 PrintFrame(KernelBase
);