diff options
Diffstat (limited to 'arch/x86_64/kernel/early_printk.c')
-rw-r--r-- | arch/x86_64/kernel/early_printk.c | 90 |
1 files changed, 45 insertions, 45 deletions
diff --git a/arch/x86_64/kernel/early_printk.c b/arch/x86_64/kernel/early_printk.c index a8a6aa70d695..13af920b6594 100644 --- a/arch/x86_64/kernel/early_printk.c +++ b/arch/x86_64/kernel/early_printk.c | |||
@@ -60,7 +60,7 @@ static struct console early_vga_console = { | |||
60 | .index = -1, | 60 | .index = -1, |
61 | }; | 61 | }; |
62 | 62 | ||
63 | /* Serial functions loosely based on a similar package from Klaus P. Gerlicher */ | 63 | /* Serial functions loosely based on a similar package from Klaus P. Gerlicher */ |
64 | 64 | ||
65 | static int early_serial_base = 0x3f8; /* ttyS0 */ | 65 | static int early_serial_base = 0x3f8; /* ttyS0 */ |
66 | 66 | ||
@@ -80,30 +80,30 @@ static int early_serial_base = 0x3f8; /* ttyS0 */ | |||
80 | #define DLL 0 /* Divisor Latch Low */ | 80 | #define DLL 0 /* Divisor Latch Low */ |
81 | #define DLH 1 /* Divisor latch High */ | 81 | #define DLH 1 /* Divisor latch High */ |
82 | 82 | ||
83 | static int early_serial_putc(unsigned char ch) | 83 | static int early_serial_putc(unsigned char ch) |
84 | { | 84 | { |
85 | unsigned timeout = 0xffff; | 85 | unsigned timeout = 0xffff; |
86 | while ((inb(early_serial_base + LSR) & XMTRDY) == 0 && --timeout) | 86 | while ((inb(early_serial_base + LSR) & XMTRDY) == 0 && --timeout) |
87 | cpu_relax(); | 87 | cpu_relax(); |
88 | outb(ch, early_serial_base + TXR); | 88 | outb(ch, early_serial_base + TXR); |
89 | return timeout ? 0 : -1; | 89 | return timeout ? 0 : -1; |
90 | } | 90 | } |
91 | 91 | ||
92 | static void early_serial_write(struct console *con, const char *s, unsigned n) | 92 | static void early_serial_write(struct console *con, const char *s, unsigned n) |
93 | { | 93 | { |
94 | while (*s && n-- > 0) { | 94 | while (*s && n-- > 0) { |
95 | early_serial_putc(*s); | 95 | early_serial_putc(*s); |
96 | if (*s == '\n') | 96 | if (*s == '\n') |
97 | early_serial_putc('\r'); | 97 | early_serial_putc('\r'); |
98 | s++; | 98 | s++; |
99 | } | 99 | } |
100 | } | 100 | } |
101 | 101 | ||
102 | #define DEFAULT_BAUD 9600 | 102 | #define DEFAULT_BAUD 9600 |
103 | 103 | ||
104 | static __init void early_serial_init(char *s) | 104 | static __init void early_serial_init(char *s) |
105 | { | 105 | { |
106 | unsigned char c; | 106 | unsigned char c; |
107 | unsigned divisor; | 107 | unsigned divisor; |
108 | unsigned baud = DEFAULT_BAUD; | 108 | unsigned baud = DEFAULT_BAUD; |
109 | char *e; | 109 | char *e; |
@@ -112,7 +112,7 @@ static __init void early_serial_init(char *s) | |||
112 | ++s; | 112 | ++s; |
113 | 113 | ||
114 | if (*s) { | 114 | if (*s) { |
115 | unsigned port; | 115 | unsigned port; |
116 | if (!strncmp(s,"0x",2)) { | 116 | if (!strncmp(s,"0x",2)) { |
117 | early_serial_base = simple_strtoul(s, &e, 16); | 117 | early_serial_base = simple_strtoul(s, &e, 16); |
118 | } else { | 118 | } else { |
@@ -136,16 +136,16 @@ static __init void early_serial_init(char *s) | |||
136 | outb(0x3, early_serial_base + MCR); /* DTR + RTS */ | 136 | outb(0x3, early_serial_base + MCR); /* DTR + RTS */ |
137 | 137 | ||
138 | if (*s) { | 138 | if (*s) { |
139 | baud = simple_strtoul(s, &e, 0); | 139 | baud = simple_strtoul(s, &e, 0); |
140 | if (baud == 0 || s == e) | 140 | if (baud == 0 || s == e) |
141 | baud = DEFAULT_BAUD; | 141 | baud = DEFAULT_BAUD; |
142 | } | 142 | } |
143 | 143 | ||
144 | divisor = 115200 / baud; | 144 | divisor = 115200 / baud; |
145 | c = inb(early_serial_base + LCR); | 145 | c = inb(early_serial_base + LCR); |
146 | outb(c | DLAB, early_serial_base + LCR); | 146 | outb(c | DLAB, early_serial_base + LCR); |
147 | outb(divisor & 0xff, early_serial_base + DLL); | 147 | outb(divisor & 0xff, early_serial_base + DLL); |
148 | outb((divisor >> 8) & 0xff, early_serial_base + DLH); | 148 | outb((divisor >> 8) & 0xff, early_serial_base + DLH); |
149 | outb(c & ~DLAB, early_serial_base + LCR); | 149 | outb(c & ~DLAB, early_serial_base + LCR); |
150 | } | 150 | } |
151 | 151 | ||
@@ -202,68 +202,68 @@ struct console *early_console = &early_vga_console; | |||
202 | static int early_console_initialized = 0; | 202 | static int early_console_initialized = 0; |
203 | 203 | ||
204 | void early_printk(const char *fmt, ...) | 204 | void early_printk(const char *fmt, ...) |
205 | { | 205 | { |
206 | char buf[512]; | 206 | char buf[512]; |
207 | int n; | 207 | int n; |
208 | va_list ap; | 208 | va_list ap; |
209 | 209 | ||
210 | va_start(ap,fmt); | 210 | va_start(ap,fmt); |
211 | n = vscnprintf(buf,512,fmt,ap); | 211 | n = vscnprintf(buf,512,fmt,ap); |
212 | early_console->write(early_console,buf,n); | 212 | early_console->write(early_console,buf,n); |
213 | va_end(ap); | 213 | va_end(ap); |
214 | } | 214 | } |
215 | 215 | ||
216 | static int __initdata keep_early; | 216 | static int __initdata keep_early; |
217 | 217 | ||
218 | int __init setup_early_printk(char *opt) | 218 | int __init setup_early_printk(char *opt) |
219 | { | 219 | { |
220 | char *space; | 220 | char *space; |
221 | char buf[256]; | 221 | char buf[256]; |
222 | 222 | ||
223 | if (early_console_initialized) | 223 | if (early_console_initialized) |
224 | return -1; | 224 | return -1; |
225 | 225 | ||
226 | strlcpy(buf,opt,sizeof(buf)); | 226 | strlcpy(buf,opt,sizeof(buf)); |
227 | space = strchr(buf, ' '); | 227 | space = strchr(buf, ' '); |
228 | if (space) | 228 | if (space) |
229 | *space = 0; | 229 | *space = 0; |
230 | 230 | ||
231 | if (strstr(buf,"keep")) | 231 | if (strstr(buf,"keep")) |
232 | keep_early = 1; | 232 | keep_early = 1; |
233 | 233 | ||
234 | if (!strncmp(buf, "serial", 6)) { | 234 | if (!strncmp(buf, "serial", 6)) { |
235 | early_serial_init(buf + 6); | 235 | early_serial_init(buf + 6); |
236 | early_console = &early_serial_console; | 236 | early_console = &early_serial_console; |
237 | } else if (!strncmp(buf, "ttyS", 4)) { | 237 | } else if (!strncmp(buf, "ttyS", 4)) { |
238 | early_serial_init(buf); | 238 | early_serial_init(buf); |
239 | early_console = &early_serial_console; | 239 | early_console = &early_serial_console; |
240 | } else if (!strncmp(buf, "vga", 3) | 240 | } else if (!strncmp(buf, "vga", 3) |
241 | && SCREEN_INFO.orig_video_isVGA == 1) { | 241 | && SCREEN_INFO.orig_video_isVGA == 1) { |
242 | max_xpos = SCREEN_INFO.orig_video_cols; | 242 | max_xpos = SCREEN_INFO.orig_video_cols; |
243 | max_ypos = SCREEN_INFO.orig_video_lines; | 243 | max_ypos = SCREEN_INFO.orig_video_lines; |
244 | current_ypos = SCREEN_INFO.orig_y; | 244 | current_ypos = SCREEN_INFO.orig_y; |
245 | early_console = &early_vga_console; | 245 | early_console = &early_vga_console; |
246 | } else if (!strncmp(buf, "simnow", 6)) { | 246 | } else if (!strncmp(buf, "simnow", 6)) { |
247 | simnow_init(buf + 6); | 247 | simnow_init(buf + 6); |
248 | early_console = &simnow_console; | 248 | early_console = &simnow_console; |
249 | keep_early = 1; | 249 | keep_early = 1; |
250 | } | 250 | } |
251 | early_console_initialized = 1; | 251 | early_console_initialized = 1; |
252 | register_console(early_console); | 252 | register_console(early_console); |
253 | return 0; | 253 | return 0; |
254 | } | 254 | } |
255 | 255 | ||
256 | void __init disable_early_printk(void) | 256 | void __init disable_early_printk(void) |
257 | { | 257 | { |
258 | if (!early_console_initialized || !early_console) | 258 | if (!early_console_initialized || !early_console) |
259 | return; | 259 | return; |
260 | if (!keep_early) { | 260 | if (!keep_early) { |
261 | printk("disabling early console\n"); | 261 | printk("disabling early console\n"); |
262 | unregister_console(early_console); | 262 | unregister_console(early_console); |
263 | early_console_initialized = 0; | 263 | early_console_initialized = 0; |
264 | } else { | 264 | } else { |
265 | printk("keeping early console\n"); | 265 | printk("keeping early console\n"); |
266 | } | 266 | } |
267 | } | 267 | } |
268 | 268 | ||
269 | __setup("earlyprintk=", setup_early_printk); | 269 | __setup("earlyprintk=", setup_early_printk); |