static int __init kgdb_parse_options(char *options) { char c; int baud; /* Check for port spec (or use default) */ /* Determine port type and instance */ if (!memcmp(options, "tty", 3)) { struct kgdb_sermap *map = kgdb_serlist; while (map && memcmp(options, map->name, map->namelen)) map = map->next; if (!map) { KGDB_PRINTK("unknown port spec in %s\n", options); return -1; } kgdb_porttype = map; kgdb_serial_setup = map->setup_fn; kgdb_portnum = options[map->namelen] - '0'; options += map->namelen + 1; options = (*options == ',') ? options+1 : options; /* Read optional parameters (baud/parity/bits) */ baud = simple_strtoul(options, &options, 10); if (baud != 0) { kgdb_baud = baud; c = toupper(*options); if (c == 'E' || c == 'O' || c == 'N') { kgdb_parity = c; options++; } c = *options; if (c == '7' || c == '8') { kgdb_bits = c; options++; } options = (*options == ',') ? options+1 : options; } } /* Check for action specification */ if (!memcmp(options, "halt", 4)) { kgdb_halt = 1; options += 4; } else if (!memcmp(options, "disabled", 8)) { kgdb_enabled = 0; options += 8; } if (*options) { KGDB_PRINTK("ignored unknown options: %s\n", options); return 0; } return 1; }
/* * Initialize UART to configured/requested values. * (But we don't interrupts yet, or interact w/serial.c) */ static int kgdb_uart_setup(void) { int port; int lcr = 0; int bdiv = 0; if (kgdb_portnum >= UART_NPORTS) { KGDB_PRINTK("uart port %d invalid.\n", kgdb_portnum); return -1; } kgdb_uart_port = &uart_ports[kgdb_portnum]; /* Init sequence from gdb_hook_interrupt */ UART_IN(UART_RX); UART_OUT(UART_IER, 0); UART_IN(UART_RX); /* Serial driver comments say */ UART_IN(UART_IIR); /* this clears interrupt regs */ UART_IN(UART_MSR); /* Figure basic LCR values */ switch (kgdb_bits) { case '7': lcr |= UART_LCR_WLEN7; break; default: case '8': lcr |= UART_LCR_WLEN8; break; } switch (kgdb_parity) { case 'O': lcr |= UART_LCR_PARITY; break; case 'E': lcr |= (UART_LCR_PARITY | UART_LCR_EPAR); break; default: break; } /* Figure the baud rate divisor */ bdiv = (SB_BASE/kgdb_baud); /* Set the baud rate and LCR values */ UART_OUT(UART_LCR, (lcr | UART_LCR_DLAB)); UART_OUT(UART_DLL, (bdiv & 0xff)); UART_OUT(UART_DLM, ((bdiv >> 8) & 0xff)); UART_OUT(UART_LCR, lcr); /* Set the MCR */ UART_OUT(UART_MCR, SB_MCR); /* Turn off FIFOs for now */ UART_OUT(UART_FCR, 0); /* Setup complete: initialize function pointers */ kgdb_getchar = kgdb_uart_getchar; kgdb_putchar = kgdb_uart_putchar; return 0; }