Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86, setup: Make the setup code also accept console=uart8250

Make the boot code also accept the console=uart8250,io,0x2f8,115200n
form of early console.

Also add back simple_guess_base(), otherwise those simple_strtoull(,,0)
are not going to work.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
LKML-Reference: <4C3CCE05.4090505@kernel.org>
Acked-by: Pekka Enberg <penberg@cs.helsinki.fi>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>

authored by

Yinghai Lu and committed by
H. Peter Anvin
ce0aa5dd fa97bdf9

+80 -1
+22
arch/x86/boot/string.c
··· 68 68 /* Works only for digits and letters, but small and fast */ 69 69 #define TOLOWER(x) ((x) | 0x20) 70 70 71 + static unsigned int simple_guess_base(const char *cp) 72 + { 73 + if (cp[0] == '0') { 74 + if (TOLOWER(cp[1]) == 'x' && isxdigit(cp[2])) 75 + return 16; 76 + else 77 + return 8; 78 + } else { 79 + return 10; 80 + } 81 + } 82 + 83 + /** 84 + * simple_strtoull - convert a string to an unsigned long long 85 + * @cp: The start of the string 86 + * @endp: A pointer to the end of the parsed string will be placed here 87 + * @base: The number base to use 88 + */ 89 + 71 90 unsigned long long simple_strtoull(const char *cp, char **endp, unsigned int base) 72 91 { 73 92 unsigned long long result = 0; 93 + 94 + if (!base) 95 + base = simple_guess_base(cp); 74 96 75 97 if (base == 16 && cp[0] == '0' && TOLOWER(cp[1]) == 'x') 76 98 cp += 2;
+58 -1
arch/x86/boot/tty.c
··· 170 170 outb(c & ~DLAB, early_serial_base + LCR); 171 171 } 172 172 173 - void console_init(void) 173 + static int parse_earlyprintk(void) 174 174 { 175 175 int baud = DEFAULT_BAUD; 176 176 char arg[32]; ··· 207 207 if (baud == 0 || arg + pos == e) 208 208 baud = DEFAULT_BAUD; 209 209 } 210 + 211 + return baud; 212 + } 213 + 214 + #define BASE_BAUD (1843200/16) 215 + static unsigned int probe_baud(int port) 216 + { 217 + unsigned char lcr, dll, dlh; 218 + unsigned int quot; 219 + 220 + lcr = inb(port + LCR); 221 + outb(lcr | DLAB, port + LCR); 222 + dll = inb(port + DLL); 223 + dlh = inb(port + DLH); 224 + outb(lcr, port + LCR); 225 + quot = (dlh << 8) | dll; 226 + 227 + return BASE_BAUD / quot; 228 + } 229 + 230 + static int parse_console_uart8250(void) 231 + { 232 + char optstr[64], *options; 233 + int baud = DEFAULT_BAUD; 234 + 235 + /* 236 + * console=uart8250,io,0x3f8,115200n8 237 + * need to make sure it is last one console ! 238 + */ 239 + if (cmdline_find_option("console", optstr, sizeof optstr) <= 0) 240 + return baud; 241 + 242 + options = optstr; 243 + 244 + if (!strncmp(options, "uart8250,io,", 12)) 245 + early_serial_base = simple_strtoull(options + 12, &options, 0); 246 + else if (!strncmp(options, "uart,io,", 8)) 247 + early_serial_base = simple_strtoull(options + 8, &options, 0); 248 + else 249 + return baud; 250 + 251 + if (options && (options[0] == ',')) 252 + baud = simple_strtoull(options + 1, &options, 0); 253 + else 254 + baud = probe_baud(early_serial_base); 255 + 256 + return baud; 257 + } 258 + 259 + void console_init(void) 260 + { 261 + int baud; 262 + 263 + baud = parse_earlyprintk(); 264 + 265 + if (!early_serial_base) 266 + baud = parse_console_uart8250(); 210 267 211 268 if (early_serial_base != 0) 212 269 early_serial_init(baud);