Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * PDC Console support - ie use firmware to dump text via boot console | |
3 | * | |
4 | * Copyright (C) 1999-2003 Matthew Wilcox <willy at parisc-linux.org> | |
5 | * Copyright (C) 2000 Martin K Petersen <mkp at mkp.net> | |
6 | * Copyright (C) 2000 John Marvin <jsm at parisc-linux.org> | |
7 | * Copyright (C) 2000-2003 Paul Bame <bame at parisc-linux.org> | |
8 | * Copyright (C) 2000 Philipp Rumpf <prumpf with tux.org> | |
9 | * Copyright (C) 2000 Michael Ang <mang with subcarrier.org> | |
10 | * Copyright (C) 2000 Grant Grundler <grundler with parisc-linux.org> | |
11 | * Copyright (C) 2001-2002 Ryan Bradetich <rbrad at parisc-linux.org> | |
12 | * Copyright (C) 2001 Helge Deller <deller at parisc-linux.org> | |
13 | * Copyright (C) 2001 Thomas Bogendoerfer <tsbogend at parisc-linux.org> | |
14 | * Copyright (C) 2002 Randolph Chung <tausq with parisc-linux.org> | |
15 | * | |
16 | * | |
17 | * This program is free software; you can redistribute it and/or modify | |
18 | * it under the terms of the GNU General Public License as published by | |
19 | * the Free Software Foundation; either version 2 of the License, or | |
20 | * (at your option) any later version. | |
21 | * | |
22 | * This program is distributed in the hope that it will be useful, | |
23 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
24 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
25 | * GNU General Public License for more details. | |
26 | * | |
27 | * You should have received a copy of the GNU General Public License | |
28 | * along with this program; if not, write to the Free Software | |
29 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
30 | */ | |
31 | ||
32 | /* | |
33 | * The PDC console is a simple console, which can be used for debugging | |
34 | * boot related problems on HP PA-RISC machines. | |
35 | * | |
36 | * This code uses the ROM (=PDC) based functions to read and write characters | |
37 | * from and to PDC's boot path. | |
38 | * Since all character read from that path must be polled, this code never | |
39 | * can or will be a fully functional linux console. | |
40 | */ | |
41 | ||
42 | /* Define EARLY_BOOTUP_DEBUG to debug kernel related boot problems. | |
43 | * On production kernels EARLY_BOOTUP_DEBUG should be undefined. */ | |
7c92e972 | 44 | #define EARLY_BOOTUP_DEBUG |
1da177e4 LT |
45 | |
46 | ||
1da177e4 LT |
47 | #include <linux/kernel.h> |
48 | #include <linux/console.h> | |
49 | #include <linux/string.h> | |
50 | #include <linux/init.h> | |
1da177e4 LT |
51 | #include <linux/major.h> |
52 | #include <linux/tty.h> | |
1da177e4 LT |
53 | #include <asm/pdc.h> /* for iodc_call() proto and friends */ |
54 | ||
55 | ||
56 | static void pdc_console_write(struct console *co, const char *s, unsigned count) | |
57 | { | |
721fdf34 | 58 | pdc_iodc_print(s, count); |
1da177e4 LT |
59 | } |
60 | ||
1da177e4 LT |
61 | int pdc_console_poll_key(struct console *co) |
62 | { | |
63 | return pdc_iodc_getc(); | |
64 | } | |
65 | ||
66 | static int pdc_console_setup(struct console *co, char *options) | |
67 | { | |
68 | return 0; | |
69 | } | |
70 | ||
71 | #if defined(CONFIG_PDC_CONSOLE) | |
a8f340e3 JS |
72 | #include <linux/vt_kern.h> |
73 | ||
1da177e4 LT |
74 | static struct tty_driver * pdc_console_device (struct console *c, int *index) |
75 | { | |
76 | extern struct tty_driver console_driver; | |
77 | *index = c->index ? c->index-1 : fg_console; | |
78 | return &console_driver; | |
79 | } | |
80 | #else | |
7c92e972 | 81 | #define pdc_console_device NULL |
1da177e4 LT |
82 | #endif |
83 | ||
84 | static struct console pdc_cons = { | |
85 | .name = "ttyB", | |
86 | .write = pdc_console_write, | |
7c92e972 | 87 | .device = pdc_console_device, |
1da177e4 | 88 | .setup = pdc_console_setup, |
7c92e972 | 89 | .flags = CON_BOOT | CON_PRINTBUFFER | CON_ENABLED, |
1da177e4 LT |
90 | .index = -1, |
91 | }; | |
92 | ||
93 | static int pdc_console_initialized; | |
1da177e4 LT |
94 | |
95 | static void pdc_console_init_force(void) | |
96 | { | |
97 | if (pdc_console_initialized) | |
98 | return; | |
99 | ++pdc_console_initialized; | |
100 | ||
101 | /* If the console is duplex then copy the COUT parameters to CIN. */ | |
102 | if (PAGE0->mem_cons.cl_class == CL_DUPLEX) | |
103 | memcpy(&PAGE0->mem_kbd, &PAGE0->mem_cons, sizeof(PAGE0->mem_cons)); | |
104 | ||
105 | /* register the pdc console */ | |
106 | register_console(&pdc_cons); | |
107 | } | |
108 | ||
109 | void __init pdc_console_init(void) | |
110 | { | |
111 | #if defined(EARLY_BOOTUP_DEBUG) || defined(CONFIG_PDC_CONSOLE) | |
112 | pdc_console_init_force(); | |
113 | #endif | |
114 | #ifdef EARLY_BOOTUP_DEBUG | |
115 | printk(KERN_INFO "Initialized PDC Console for debugging.\n"); | |
116 | #endif | |
117 | } | |
118 | ||
119 | ||
1da177e4 LT |
120 | /* |
121 | * Used for emergencies. Currently only used if an HPMC occurs. If an | |
122 | * HPMC occurs, it is possible that the current console may not be | |
7c92e972 MW |
123 | * properly initialised after the PDC IO reset. This routine unregisters |
124 | * all of the current consoles, reinitializes the pdc console and | |
1da177e4 LT |
125 | * registers it. |
126 | */ | |
127 | ||
128 | void pdc_console_restart(void) | |
129 | { | |
130 | struct console *console; | |
131 | ||
132 | if (pdc_console_initialized) | |
133 | return; | |
134 | ||
7c92e972 MW |
135 | /* If we've already seen the output, don't bother to print it again */ |
136 | if (console_drivers != NULL) | |
137 | pdc_cons.flags &= ~CON_PRINTBUFFER; | |
138 | ||
1da177e4 LT |
139 | while ((console = console_drivers) != NULL) |
140 | unregister_console(console_drivers); | |
141 | ||
1da177e4 LT |
142 | /* force registering the pdc console */ |
143 | pdc_console_init_force(); | |
144 | } |