2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
6 #include <bootconsole.h>
9 #include <kernel_base.h>
10 #include <kernel_debug.h>
11 #include "alert_arch.h"
14 * Display alert on the screen using libbootconsole.
15 * Very useful for early alerts, while the display driver not started yet.
16 * In this case the user gets a nice GURU. Not painted in red yet. :)
19 static inline void PrintChars(char c
, ULONG n
, struct KernelBase
*KernelBase
)
22 krnPutC(c
, KernelBase
);
26 * This function calculates length of line.
27 * It's similar to strlen(), but stops also at LF and FF codes.
29 static inline int linelen(const char *str
)
33 for (l
= 0; str
[l
] && str
[l
] != '\n' && str
[l
] != 0x0F; l
++);
37 static const char *PrintCentered(const char *str
, struct KernelBase
*KernelBase
)
39 int len
= linelen(str
);
43 if (len
> (scr_Width
- 2))
44 len
= (scr_Width
- 2);
46 s
= scr_Width
- 2 - len
;
48 krnPutC(0xDB, KernelBase
);
50 krnPutC(' ', KernelBase
);
52 PrintChars(' ', s
, KernelBase
);
54 for (i
= 0; i
< len
; i
++)
55 krnPutC(*str
++, KernelBase
);
57 PrintChars(' ', s
, KernelBase
);
58 krnPutC(0xDB, KernelBase
);
59 krnPutC('\n', KernelBase
);
64 static inline void PrintFrame(char c
, struct KernelBase
*KernelBase
)
66 krnPutC(0xDB, KernelBase
);
67 PrintChars(c
, scr_Width
- 2, KernelBase
);
68 krnPutC(0xDB, KernelBase
);
69 krnPutC('\n', KernelBase
);
72 void krnDisplayAlert(const char *text
, struct KernelBase
*KernelBase
)
76 if (scr_Type
== SCR_UNKNOWN
)
78 /* Default alert width (for possible serial output). */
82 /* Make sure that the output starts from a new line */
83 krnPutC('\n', KernelBase
);
85 PrintFrame(0xDF, KernelBase
);
87 /* Print first three lines (title, task and error) centered */
88 for (i
= 0; i
< 3; i
++)
90 text
= PrintCentered(text
, KernelBase
);
91 if (*text
== 0) /* Handle early NULL terminator */
93 text
++; /* Skip a newline */
96 PrintFrame(0xDC, KernelBase
);
98 /* Print the rest of alert text (if any) */
101 PrintString(text
, KernelBase
);
103 /* Print a line in the bottom */
104 krnPutC('\n', KernelBase
);
105 PrintChars(0xDC, scr_Width
, KernelBase
);
106 krnPutC('\n', KernelBase
);