diff --git a/arch/x86/kernel/uart.c b/arch/x86/kernel/uart.c index 521685bed..1962b885d 100644 --- a/arch/x86/kernel/uart.c +++ b/arch/x86/kernel/uart.c @@ -154,9 +154,6 @@ static int uart_config(void) /* disable interrupts */ write_to_uart(UART_IER, 0); - /* DTR + RTS */ - write_to_uart(UART_MCR, UART_MCR_DTR|UART_MCR_RTS); - /* * 8bit word length * 1 stop bit @@ -181,8 +178,6 @@ static int uart_config(void) return 0; } -extern const void kernel_start; - int uart_init(void) { if (is_uhyve()) diff --git a/arch/x86/loader/include/uart.h b/arch/x86/loader/include/uart.h index 0567aafa5..52d041b9c 100644 --- a/arch/x86/loader/include/uart.h +++ b/arch/x86/loader/include/uart.h @@ -34,17 +34,11 @@ extern "C" { #endif -/** @brief Initialize UART output - * - * @return Returns 0 on success - */ -int uart_init(void); - /** @brief Initialize UART output without a device check * * @return Returns 0 on success */ -int uart_early_init(char*); +int uart_init(const char*); /** @brief Simple string output on a serial device. * @@ -56,7 +50,7 @@ int uart_puts(const char *text); /** @brief Simple character output on a serial device. * - * @return The original input character casted to int + * @return The original input character casted to int */ int uart_putchar(unsigned char c); diff --git a/arch/x86/loader/main.c b/arch/x86/loader/main.c index 59df480c6..dcb8ad899 100644 --- a/arch/x86/loader/main.c +++ b/arch/x86/loader/main.c @@ -106,6 +106,7 @@ void main(void) cmdline_size = strlen(cmdline); } + // enable paging page_init(); if (mb_info) { diff --git a/arch/x86/loader/stdio.c b/arch/x86/loader/stdio.c index c4ee533fb..9c3e5f422 100644 --- a/arch/x86/loader/stdio.c +++ b/arch/x86/loader/stdio.c @@ -31,7 +31,7 @@ int koutput_init(void) { - uart_early_init((char*) mb_info->cmdline); + uart_init((const char*) (size_t)mb_info->cmdline); return 0; } diff --git a/arch/x86/loader/uart.c b/arch/x86/loader/uart.c index c5a75921e..3130260ba 100644 --- a/arch/x86/loader/uart.c +++ b/arch/x86/loader/uart.c @@ -150,9 +150,6 @@ static int uart_config(void) /* disable interrupts */ write_to_uart(UART_IER, 0); - /* DTR + RTS */ - write_to_uart(UART_MCR, UART_MCR_DTR|UART_MCR_RTS); - /* * 8bit word length * 1 stop bit @@ -177,65 +174,21 @@ static int uart_config(void) return 0; } -extern const void kernel_start; - -int uart_early_init(char* cmdline) +int uart_init(const char* cmdline) { - char* str = NULL; + char* str; - if (!cmdline || ((str = strstr(cmdline, "uart=io:")) == NULL)) { - // default value of our QEMU configuration + if (!uartport && cmdline && ((str = strstr(cmdline, "uart=io:")) != NULL)) + uartport = strtol(str+8, (char **)NULL, 16); + + if (!uartport) uartport = DEFAULT_UART_PORT; - } else { - uartport = strtol(str+8, (char **)NULL, 16); - if (!uartport) - uartport = DEFAULT_UART_PORT; - } - // configure uart - return uart_config(); -} - -int uart_init(void) -{ - if (uartport) + if (!uartport) return 0; -#ifdef CONFIG_PCI - pci_info_t pci_info; - uint32_t bar = 0; - - // Searching for Intel's UART device - if (pci_get_device_info(0x8086, 0x0936, &pci_info) == 0) - goto Lsuccess; - // Searching for Qemu's UART device - if (pci_get_device_info(0x1b36, 0x0002, &pci_info) == 0) - goto Lsuccess; - // Searching for Qemu's 2x UART device (pci-serial-2x) - if (pci_get_device_info(0x1b36, 0x0003, &pci_info) == 0) - goto Lsuccess; - // Searching for Qemu's 4x UART device (pci-serial-4x) - if (pci_get_device_info(0x1b36, 0x0004, &pci_info) == 0) - goto Lsuccess; - - uartport = DEFAULT_UART_PORT; - - return uart_config(); - -Lsuccess: - uartport = pci_info.base[bar]; - //irq_install_handler(32+pci_info.irq, uart_handler); - kprintf("UART uses io address 0x%x\n", uartport); - // configure uart return uart_config(); -#else - // default value of our QEMU configuration - uartport = DEFAULT_UART_PORT; - - // configure uart - return uart_config(); -#endif } #endif