1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44#define EARLY_BOOTUP_DEBUG
45
46
47#include <linux/kernel.h>
48#include <linux/console.h>
49#include <linux/string.h>
50#include <linux/init.h>
51#include <linux/major.h>
52#include <linux/tty.h>
53#include <asm/pdc.h>
54
55static DEFINE_SPINLOCK(pdc_console_lock);
56
57static void pdc_console_write(struct console *co, const char *s, unsigned count)
58{
59 int i = 0;
60 unsigned long flags;
61
62 spin_lock_irqsave(&pdc_console_lock, flags);
63 do {
64 i += pdc_iodc_print(s + i, count - i);
65 } while (i < count);
66 spin_unlock_irqrestore(&pdc_console_lock, flags);
67}
68
69int pdc_console_poll_key(struct console *co)
70{
71 int c;
72 unsigned long flags;
73
74 spin_lock_irqsave(&pdc_console_lock, flags);
75 c = pdc_iodc_getc();
76 spin_unlock_irqrestore(&pdc_console_lock, flags);
77
78 return c;
79}
80
81static int pdc_console_setup(struct console *co, char *options)
82{
83 return 0;
84}
85
86#if defined(CONFIG_PDC_CONSOLE)
87#include <linux/vt_kern.h>
88
89static struct tty_driver * pdc_console_device (struct console *c, int *index)
90{
91 extern struct tty_driver console_driver;
92 *index = c->index ? c->index-1 : fg_console;
93 return &console_driver;
94}
95#else
96#define pdc_console_device NULL
97#endif
98
99static struct console pdc_cons = {
100 .name = "ttyB",
101 .write = pdc_console_write,
102 .device = pdc_console_device,
103 .setup = pdc_console_setup,
104 .flags = CON_BOOT | CON_PRINTBUFFER | CON_ENABLED,
105 .index = -1,
106};
107
108static int pdc_console_initialized;
109
110static void pdc_console_init_force(void)
111{
112 if (pdc_console_initialized)
113 return;
114 ++pdc_console_initialized;
115
116
117 if (PAGE0->mem_cons.cl_class == CL_DUPLEX)
118 memcpy(&PAGE0->mem_kbd, &PAGE0->mem_cons, sizeof(PAGE0->mem_cons));
119
120
121 register_console(&pdc_cons);
122}
123
124void __init pdc_console_init(void)
125{
126#if defined(EARLY_BOOTUP_DEBUG) || defined(CONFIG_PDC_CONSOLE)
127 pdc_console_init_force();
128#endif
129#ifdef EARLY_BOOTUP_DEBUG
130 printk(KERN_INFO "Initialized PDC Console for debugging.\n");
131#endif
132}
133
134
135
136
137
138
139
140
141
142
143void pdc_console_restart(void)
144{
145 struct console *console;
146
147 if (pdc_console_initialized)
148 return;
149
150
151 if (console_drivers != NULL)
152 pdc_cons.flags &= ~CON_PRINTBUFFER;
153
154 while ((console = console_drivers) != NULL)
155 unregister_console(console_drivers);
156
157
158 pdc_console_init_force();
159}
160