2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
8 #include <kernel_base.h>
9 #include <kernel_debug.h>
11 #define ALERT_WIDTH 80
13 static inline void PrintChars(char c
, ULONG n
, struct KernelBase
*KernelBase
)
16 krnPutC(c
, KernelBase
);
20 * This function calculates length of line.
21 * It's similar to strlen(), but stops also at LF and FF codes.
23 static inline int linelen(const char *str
)
27 for (l
= 0; str
[l
] && str
[l
] != '\n' && str
[l
] != 0x0F; l
++);
31 static const char *PrintCentered(const char *str
, struct KernelBase
*KernelBase
)
33 int len
= linelen(str
);
37 if (len
> (ALERT_WIDTH
- 2))
38 len
= (ALERT_WIDTH
- 2);
40 s
= ALERT_WIDTH
- 2 - len
;
42 krnPutC('#', KernelBase
);
44 krnPutC(' ', KernelBase
);
46 PrintChars(' ', s
, KernelBase
);
48 for (i
= 0; i
< len
; i
++)
49 krnPutC(*str
++, KernelBase
);
51 PrintChars(' ', s
, KernelBase
);
52 krnPutC('#', KernelBase
);
53 krnPutC('\n', KernelBase
);
58 static inline void PrintFrame(struct KernelBase
*KernelBase
)
60 PrintChars('#', ALERT_WIDTH
, KernelBase
);
61 krnPutC('\n', KernelBase
);
65 * This entry point just displays the message. It doesn't make any decisions
67 * Because of this it misses 'code' argument.
68 * The kernel can use it internally, for displaying messages about
69 * critical startup failures.
71 void krnDisplayAlert(const char *text
, struct KernelBase
*KernelBase
)
75 /* Make sure that the output starts from a new line */
76 krnPutC('\n', KernelBase
);
78 PrintFrame(KernelBase
);
80 /* Print first three lines (title, task and error) centered */
81 for (i
= 0; i
< 3; i
++)
83 text
= PrintCentered(text
, KernelBase
);
85 if (*text
== 0) /* Handle early NULL terminator */
88 text
++; /* Skip a newline */
91 PrintFrame(KernelBase
);
93 /* Print the rest of alert text (if any) */
97 krnPutC(*text
++, KernelBase
);
99 krnPutC('\n', KernelBase
);
100 PrintFrame(KernelBase
);