static inline void uart_report_port(struct uart_driver *drv, struct uart_port *port) { char address[64]; switch (port->iotype) { case UPIO_PORT: snprintf(address, sizeof(address), "I/O 0x%lx", port->iobase); break; case UPIO_HUB6: snprintf(address, sizeof(address), "I/O 0x%lx offset 0x%x", port->iobase, port->hub6); break; case UPIO_MEM: case UPIO_MEM32: case UPIO_AU: case UPIO_TSI: snprintf(address, sizeof(address), "MMIO 0x%llx", (unsigned long long)port->mapbase); break; default: strlcpy(address, "*unknown*", sizeof(address)); break; } printk(KERN_INFO "%s%s%s%d at %s (irq = %d) is a %s\n", port->dev ? dev_name(port->dev) : "", port->dev ? ": " : "", drv->dev_name, drv->tty_driver->name_base + port->line, address, port->irq, uart_type(port)); }
main() {int i; char * UARTname [] = { "8250 without FIFO", "16450 without FIFO", "16550 with FIFO", "16550A with FIFO"}; clrscr(); puts("Port Base addr UART type"); printf( "COM1 ");if((i=uart_type(0))!=-1)printf(UARTname[i-1]);else printf("Not found"); printf("\nCOM2 ");if((i=uart_type(1))!=-1)printf(UARTname[i-1]);else printf("Not found"); printf("\nCOM3 ");if((i=uart_type(2))!=-1)printf(UARTname[i-1]);else printf("Not found"); printf("\nCOM4 ");if((i=uart_type(3))!=-1)printf(UARTname[i-1]);else printf("Not found"); puts(""); }
static void serial_get(const char *device, enum print_mode mode) { int fd, ret; const char *uart, *prefix, *postfix; struct serial_struct serinfo; fd = serial_open(device, /*quiet:*/ mode == PRINT_SUMMARY); if (fd < 0) return; ret = serial_ctl(fd, CTL_GET | CTL_CLOSE | CTL_NODIE, &serinfo); if (ret < 0) return; uart = uart_type(serinfo.type); prefix = ", Flags: "; postfix = ""; switch (mode) { case PRINT_NORMAL: printf("%s, UART: %s, Port: 0x%.4x, IRQ: %d", device, uart, serinfo.port, serinfo.irq); break; case PRINT_SUMMARY: if (!serinfo.type) return; printf("%s at 0x%.4x (irq = %d) is a %s", device, serinfo.port, serinfo.irq, uart); prefix = " ("; postfix = ")"; break; case PRINT_FEDBACK: printf("%s uart %s port 0x%.4x irq %d baud_base %d", device, uart, serinfo.port, serinfo.irq, serinfo.baud_base); prefix = " "; break; case PRINT_ALL: printf("%s, Line %d, UART: %s, Port: 0x%.4x, IRQ: %d\n", device, serinfo.line, uart, serinfo.port, serinfo.irq); printf("\tBaud_base: %d, close_delay: %u, divisor: %d\n", serinfo.baud_base, serinfo.close_delay, serinfo.custom_divisor); printf("\tclosing_wait: "); print_closing_wait(serinfo.closing_wait); prefix = "\tFlags: "; postfix = "\n"; break; default: assert(0); } print_serial_flags(serinfo.flags, mode, prefix, postfix); }
static void uart_line_info(struct seq_file *m, struct uart_driver *drv, int i) { struct uart_state *state = drv->state + i; struct tty_port *port = &state->port; int pm_state; struct uart_port *uport = state->uart_port; char stat_buf[32]; unsigned int status; int mmio; if (!uport) return; mmio = uport->iotype >= UPIO_MEM; seq_printf(m, "%d: uart:%s %s%08llX irq:%d", uport->line, uart_type(uport), mmio ? "mmio:0x" : "port:", mmio ? (unsigned long long)uport->mapbase : (unsigned long long)uport->iobase, uport->irq); if (uport->type == PORT_UNKNOWN) { seq_putc(m, '\n'); return; } if (capable(CAP_SYS_ADMIN)) { mutex_lock(&port->mutex); pm_state = state->pm_state; if (pm_state) uart_change_pm(state, 0); spin_lock_irq(&uport->lock); status = uport->ops->get_mctrl(uport); spin_unlock_irq(&uport->lock); if (pm_state) uart_change_pm(state, pm_state); mutex_unlock(&port->mutex); seq_printf(m, " tx:%d rx:%d", uport->icount.tx, uport->icount.rx); if (uport->icount.frame) seq_printf(m, " fe:%d", uport->icount.frame); if (uport->icount.parity) seq_printf(m, " pe:%d", uport->icount.parity); if (uport->icount.brk) seq_printf(m, " brk:%d", uport->icount.brk); if (uport->icount.overrun) seq_printf(m, " oe:%d", uport->icount.overrun); #define INFOBIT(bit, str) \ if (uport->mctrl & (bit)) \ strncat(stat_buf, (str), sizeof(stat_buf) - \ strlen(stat_buf) - 2) #define STATBIT(bit, str) \ if (status & (bit)) \ strncat(stat_buf, (str), sizeof(stat_buf) - \ strlen(stat_buf) - 2) stat_buf[0] = '\0'; stat_buf[1] = '\0'; INFOBIT(TIOCM_RTS, "|RTS"); STATBIT(TIOCM_CTS, "|CTS"); INFOBIT(TIOCM_DTR, "|DTR"); STATBIT(TIOCM_DSR, "|DSR"); STATBIT(TIOCM_CAR, "|CD"); STATBIT(TIOCM_RNG, "|RI"); if (stat_buf[0]) stat_buf[0] = ' '; seq_puts(m, stat_buf); } seq_putc(m, '\n'); #undef STATBIT #undef INFOBIT }