函数源码 |
Source File:arch\x86\boot\early_serial_console.c |
Create Date:2022-07-27 08:25:53 |
首页 | Copyright©Brick |
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | static void parse_earlyprintk( void ) { int baud = DEFAULT_BAUD; char arg[32]; int pos = 0; int port = 0; if (cmdline_find_option( "earlyprintk" , arg, sizeof (arg)) > 0) { char *e; if (! strncmp (arg, "serial" , 6)) { port = DEFAULT_SERIAL_PORT; pos += 6; } if (arg[pos] == ',' ) pos++; /* * make sure we have * "serial,0x3f8,115200" * "serial,ttyS0,115200" * "ttyS0,115200" */ if (pos == 7 && ! strncmp (arg + pos, "0x" , 2)) { port = simple_strtoull(arg + pos, &e, 16); if (port == 0 || arg + pos == e) port = DEFAULT_SERIAL_PORT; else pos = e - arg; } else if (! strncmp (arg + pos, "ttyS" , 4)) { static const int bases[] = { 0x3f8, 0x2f8 }; int idx = 0; /* += strlen("ttyS"); */ pos += 4; if (arg[pos++] == '1' ) idx = 1; port = bases[idx]; } if (arg[pos] == ',' ) pos++; baud = simple_strtoull(arg + pos, &e, 0); if (baud == 0 || arg + pos == e) baud = DEFAULT_BAUD; } if (port) early_serial_init(port, baud); } |