aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/sibyte/cfe/console.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/mips/sibyte/cfe/console.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'arch/mips/sibyte/cfe/console.c')
-rw-r--r--arch/mips/sibyte/cfe/console.c80
1 files changed, 80 insertions, 0 deletions
diff --git a/arch/mips/sibyte/cfe/console.c b/arch/mips/sibyte/cfe/console.c
new file mode 100644
index 000000000000..53a5c1eb5611
--- /dev/null
+++ b/arch/mips/sibyte/cfe/console.c
@@ -0,0 +1,80 @@
1#include <linux/config.h>
2#include <linux/init.h>
3#include <linux/errno.h>
4#include <linux/console.h>
5
6#include <asm/sibyte/board.h>
7
8#include "cfe_api.h"
9#include "cfe_error.h"
10
11extern int cfe_cons_handle;
12
13static void cfe_console_write(struct console *cons, const char *str,
14 unsigned int count)
15{
16 int i, last, written;
17
18 for (i=0,last=0; i<count; i++) {
19 if (!str[i])
20 /* XXXKW can/should this ever happen? */
21 return;
22 if (str[i] == '\n') {
23 do {
24 written = cfe_write(cfe_cons_handle, &str[last], i-last);
25 if (written < 0)
26 ;
27 last += written;
28 } while (last < i);
29 while (cfe_write(cfe_cons_handle, "\r", 1) <= 0)
30 ;
31 }
32 }
33 if (last != count) {
34 do {
35 written = cfe_write(cfe_cons_handle, &str[last], count-last);
36 if (written < 0)
37 ;
38 last += written;
39 } while (last < count);
40 }
41
42}
43
44static int cfe_console_setup(struct console *cons, char *str)
45{
46 char consdev[32];
47 /* XXXKW think about interaction with 'console=' cmdline arg */
48 /* If none of the console options are configured, the build will break. */
49 if (cfe_getenv("BOOT_CONSOLE", consdev, 32) >= 0) {
50#ifdef CONFIG_SIBYTE_SB1250_DUART
51 if (!strcmp(consdev, "uart0")) {
52 setleds("u0cn");
53 } else if (!strcmp(consdev, "uart1")) {
54 setleds("u1cn");
55#endif
56#ifdef CONFIG_VGA_CONSOLE
57 } else if (!strcmp(consdev, "pcconsole0")) {
58 setleds("pccn");
59#endif
60 } else
61 return -ENODEV;
62 }
63 return 0;
64}
65
66static struct console sb1250_cfe_cons = {
67 .name = "cfe",
68 .write = cfe_console_write,
69 .setup = cfe_console_setup,
70 .flags = CON_PRINTBUFFER,
71 .index = -1,
72};
73
74static int __init sb1250_cfe_console_init(void)
75{
76 register_console(&sb1250_cfe_cons);
77 return 0;
78}
79
80console_initcall(sb1250_cfe_console_init);