From 08b4fd431b415ea97ad99cc54fbece4eb1317545 Mon Sep 17 00:00:00 2001 From: Daniel Leung Date: Tue, 1 Dec 2015 08:42:20 -0800 Subject: [PATCH] console/uart: use device name instead of index Use device name to find the UART device for console usage, instead of relying on an arbitrary index. Change-Id: Iebe01c9bf392dfee6d8284367f67647f7d47561a Signed-off-by: Daniel Leung --- arch/arc/platforms/generic_arc/Kconfig | 11 ++++ arch/arc/platforms/generic_arc/board.h | 4 -- arch/arm/defconfig | 3 +- arch/arm/platforms/fsl_frdm_k64f/Kconfig | 11 ++++ arch/arm/platforms/fsl_frdm_k64f/board.h | 4 -- arch/arm/platforms/ti_lm3s6965/Kconfig | 11 ++++ arch/arm/platforms/ti_lm3s6965/board.h | 10 ---- arch/x86/core/driver_static_irq_stubs.S | 6 -- arch/x86/platforms/galileo/Kconfig | 15 +++-- arch/x86/platforms/galileo/board.h | 9 --- arch/x86/platforms/ia32/Kconfig | 11 ++++ arch/x86/platforms/ia32/board.h | 10 ---- arch/x86/platforms/ia32_pci/Kconfig | 14 ++++- arch/x86/platforms/ia32_pci/board.h | 9 --- arch/x86/platforms/quark_d2000/Kconfig | 11 ++++ arch/x86/platforms/quark_d2000/board.h | 25 -------- arch/x86/platforms/quark_se/Kconfig | 11 ++++ arch/x86/platforms/quark_se/board.h | 8 --- configs/basic_cortex_m3_defconfig | 2 - configs/fsl_frdm_k64f_defconfig | 2 - configs/quark_se_defconfig | 1 - drivers/console/Kconfig | 28 +++++---- drivers/console/Makefile | 2 +- drivers/console/uart_console.c | 60 +++++++++---------- .../console/uart_console_static_irq_stubs.S | 38 ++++++++++++ 25 files changed, 173 insertions(+), 143 deletions(-) create mode 100644 drivers/console/uart_console_static_irq_stubs.S diff --git a/arch/arc/platforms/generic_arc/Kconfig b/arch/arc/platforms/generic_arc/Kconfig index 30c1a8a609..094c3e3352 100644 --- a/arch/arc/platforms/generic_arc/Kconfig +++ b/arch/arc/platforms/generic_arc/Kconfig @@ -65,4 +65,15 @@ config UART_NSIM_PORT_0_BASE_ADDR default 0x4242 depends on NSIM +if UART_CONSOLE + +config UART_CONSOLE_ON_DEV_NAME + default "UART_0" +config UART_CONSOLE_IRQ + default 41 +config UART_CONSOLE_IRQ_PRI + default 0 + +endif + endif diff --git a/arch/arc/platforms/generic_arc/board.h b/arch/arc/platforms/generic_arc/board.h index 5d76991ce0..fa531437be 100644 --- a/arch/arc/platforms/generic_arc/board.h +++ b/arch/arc/platforms/generic_arc/board.h @@ -133,11 +133,7 @@ * - only polled mode is supported (interrupt-driven mode is NOT supported); and * - only the target console is supported (hostserver driver is NOT supported). */ -#define CONFIG_UART_CONSOLE_CLK_FREQ SYSCLK_DEFAULT_IOSC_HZ -#define CONFIG_UART_CONSOLE_BAUDRATE 115200 #define CONFIG_UART_CONSOLE_REGS PERIPH_ADDR_BASE_UART0 -#define CONFIG_UART_CONSOLE_IRQ IRQ_UART0_INTR -#define CONFIG_UART_CONSOLE_INT_PRI 0 #endif /* !_ASMLANGUAGE */ diff --git a/arch/arm/defconfig b/arch/arm/defconfig index 710c5de070..6a41599777 100644 --- a/arch/arm/defconfig +++ b/arch/arm/defconfig @@ -3,8 +3,7 @@ CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=12000000 CONFIG_PLATFORM_TI_LM3S6965=y CONFIG_CONSOLE=y CONFIG_UART_CONSOLE=y -CONFIG_UART_CONSOLE_INDEX=0 -CONFIG_UART_CONSOLE_BAUDRATE=115200 +CONFIG_UART_CONSOLE_ON_DEV_NAME="UART_0" CONFIG_SERIAL=y CONFIG_CORTEX_M_SYSTICK=y CONFIG_FLASH_SIZE=256 diff --git a/arch/arm/platforms/fsl_frdm_k64f/Kconfig b/arch/arm/platforms/fsl_frdm_k64f/Kconfig index 636e5fed9a..1fd3ff45c7 100644 --- a/arch/arm/platforms/fsl_frdm_k64f/Kconfig +++ b/arch/arm/platforms/fsl_frdm_k64f/Kconfig @@ -135,4 +135,15 @@ endif endif # UART_K20 +if UART_CONSOLE + +config UART_CONSOLE_ON_DEV_NAME + default "UART_0" +config UART_CONSOLE_IRQ + default 31 +config UART_CONSOLE_IRQ_PRI + default 3 + +endif + endif diff --git a/arch/arm/platforms/fsl_frdm_k64f/board.h b/arch/arm/platforms/fsl_frdm_k64f/board.h index 73124b92b5..7fcc461d25 100644 --- a/arch/arm/platforms/fsl_frdm_k64f/board.h +++ b/arch/arm/platforms/fsl_frdm_k64f/board.h @@ -166,10 +166,6 @@ extern struct device * const uart_devs[]; #define CONFIG_UART_CONSOLE_PORT_TX_PIN 17 #define CONFIG_UART_CONSOLE_PORT_MUX_FUNC PCR_MUX_ALT3 #define CONFIG_UART_CONSOLE_CLK_FREQ SYSCLK_DEFAULT_IOSC_HZ -#define CONFIG_UART_CONSOLE_IRQ IRQ_UART0_STATUS -#define CONFIG_UART_CONSOLE_INT_PRI 3 - -#define UART_CONSOLE_DEV (uart_devs[CONFIG_UART_CONSOLE_INDEX]) #endif /* CONFIG_UART_CONSOLE */ diff --git a/arch/arm/platforms/ti_lm3s6965/Kconfig b/arch/arm/platforms/ti_lm3s6965/Kconfig index a5f42c97d4..299ec4005c 100644 --- a/arch/arm/platforms/ti_lm3s6965/Kconfig +++ b/arch/arm/platforms/ti_lm3s6965/Kconfig @@ -100,4 +100,15 @@ endif endif # UART_STELLARIS +if UART_CONSOLE + +config UART_CONSOLE_ON_DEV_NAME + default "UART_0" +config UART_CONSOLE_IRQ + default 5 +config UART_CONSOLE_IRQ_PRI + default 3 + +endif + endif diff --git a/arch/arm/platforms/ti_lm3s6965/board.h b/arch/arm/platforms/ti_lm3s6965/board.h index bfe5ee150e..b4d3d4b615 100644 --- a/arch/arm/platforms/ti_lm3s6965/board.h +++ b/arch/arm/platforms/ti_lm3s6965/board.h @@ -96,16 +96,6 @@ extern struct device * const uart_devs[]; -/* Uart console configuration */ -#if defined(CONFIG_UART_CONSOLE) - -#define CONFIG_UART_CONSOLE_IRQ IRQ_UART0 -#define CONFIG_UART_CONSOLE_INT_PRI 3 - -#define UART_CONSOLE_DEV (uart_devs[CONFIG_UART_CONSOLE_INDEX]) - -#endif /* CONFIG_UART_CONSOLE */ - /* Bluetooth UART definitions */ #if defined(CONFIG_BLUETOOTH_UART) diff --git a/arch/x86/core/driver_static_irq_stubs.S b/arch/x86/core/driver_static_irq_stubs.S index dd92c8f278..a4008ce83e 100644 --- a/arch/x86/core/driver_static_irq_stubs.S +++ b/arch/x86/core/driver_static_irq_stubs.S @@ -43,12 +43,6 @@ by x86 platforms. #endif /* CONFIG_IOAPIC */ #endif /* CONFIG_BLUETOOTH_UART */ -#if defined(CONFIG_CONSOLE_HANDLER) -#if defined(CONFIG_IOAPIC) - ioapic_mkstub console uart_console_isr 0 -#endif /* CONFIG_IOAPIC */ -#endif /* CONFIG_CONSOLE_HANDLER */ - #if defined(CONFIG_UART_PIPE) #if defined(CONFIG_IOAPIC) ioapic_mkstub uart_pipe uart_pipe_isr 0 diff --git a/arch/x86/platforms/galileo/Kconfig b/arch/x86/platforms/galileo/Kconfig index e8e535a192..225cf830e9 100644 --- a/arch/x86/platforms/galileo/Kconfig +++ b/arch/x86/platforms/galileo/Kconfig @@ -39,9 +39,6 @@ config ROM_SIZE config SYS_CLOCK_HW_CYCLES_PER_SEC default 25000000 if HPET_TIMER -config UART_CONSOLE_INDEX - default 1 - config PINMUX def_bool y @@ -410,7 +407,6 @@ config ETH_DW_0_IRQ_SHARED_NAME default SHARED_IRQ_0_NAME if SHARED_IRQ endif - config KERNEL_INIT_PRIORITY_DEFAULT default 40 @@ -464,4 +460,15 @@ config PINMUX_INIT_PRIORITY config UART_CONSOLE_PRIORITY default 70 +if UART_CONSOLE + +config UART_CONSOLE_ON_DEV_NAME + default "UART_1" +config UART_CONSOLE_IRQ + default 17 +config UART_CONSOLE_IRQ_PRI + default 3 + +endif + endif # PLATFORM_GALILEO diff --git a/arch/x86/platforms/galileo/board.h b/arch/x86/platforms/galileo/board.h index cfd652e881..e3f3a789f5 100644 --- a/arch/x86/platforms/galileo/board.h +++ b/arch/x86/platforms/galileo/board.h @@ -59,15 +59,6 @@ extern struct device * const uart_devs[]; #endif -#if defined(CONFIG_UART_CONSOLE) - -#define CONFIG_UART_CONSOLE_IRQ CONFIG_UART_NS16550_PORT_1_IRQ -#define CONFIG_UART_CONSOLE_INT_PRI CONFIG_UART_NS16550_PORT_1_IRQ_PRI - -#define UART_CONSOLE_DEV (uart_devs[CONFIG_UART_CONSOLE_INDEX]) - -#endif /* CONFIG_UART_CONSOLE */ - #ifdef CONFIG_GPIO_DW_0 #if defined(CONFIG_GPIO_DW_0_FALLING_EDGE) #define GPIO_DW_0_IRQ_FLAGS (IOAPIC_EDGE | IOAPIC_LOW) diff --git a/arch/x86/platforms/ia32/Kconfig b/arch/x86/platforms/ia32/Kconfig index f2388a27b3..cf6f0674f1 100644 --- a/arch/x86/platforms/ia32/Kconfig +++ b/arch/x86/platforms/ia32/Kconfig @@ -105,4 +105,15 @@ endif # UART_NS16550_PORT_1 endif # UART_NS16550 +if UART_CONSOLE + +config UART_CONSOLE_ON_DEV_NAME + default "UART_0" +config UART_CONSOLE_IRQ + default 4 +config UART_CONSOLE_IRQ_PRI + default 3 + +endif + endif diff --git a/arch/x86/platforms/ia32/board.h b/arch/x86/platforms/ia32/board.h index cf97cae3fa..74c845c548 100644 --- a/arch/x86/platforms/ia32/board.h +++ b/arch/x86/platforms/ia32/board.h @@ -66,16 +66,6 @@ extern struct device * const uart_devs[]; #endif -/* Console definitions */ -#if defined(CONFIG_UART_CONSOLE) - -#define CONFIG_UART_CONSOLE_IRQ CONFIG_UART_NS16550_PORT_0_IRQ -#define CONFIG_UART_CONSOLE_INT_PRI CONFIG_UART_NS16550_PORT_0_IRQ_PRI - -#define UART_CONSOLE_DEV (uart_devs[CONFIG_UART_CONSOLE_INDEX]) - -#endif /* CONFIG_UART_CONSOLE */ - /* Bluetooth UART definitions */ #if defined(CONFIG_BLUETOOTH_UART) diff --git a/arch/x86/platforms/ia32_pci/Kconfig b/arch/x86/platforms/ia32_pci/Kconfig index 80d7f80a04..fa6382cbea 100644 --- a/arch/x86/platforms/ia32_pci/Kconfig +++ b/arch/x86/platforms/ia32_pci/Kconfig @@ -42,9 +42,6 @@ config SYS_CLOCK_HW_CYCLES_PER_SEC default 150000000 if LOAPIC_TIMER default 25000000 if HPET_TIMER -config UART_CONSOLE_INDEX - default 1 - config KERNEL_INIT_PRIORITY_DEFAULT default 40 @@ -137,4 +134,15 @@ endif # UART_NS16550_PORT_1 endif # UART_NS16550 +if UART_CONSOLE + +config UART_CONSOLE_ON_DEV_NAME + default "UART_1" +config UART_CONSOLE_IRQ + default 17 +config UART_CONSOLE_IRQ_PRI + default 3 + +endif + endif diff --git a/arch/x86/platforms/ia32_pci/board.h b/arch/x86/platforms/ia32_pci/board.h index d34c3c3408..18cbd91bf3 100644 --- a/arch/x86/platforms/ia32_pci/board.h +++ b/arch/x86/platforms/ia32_pci/board.h @@ -60,15 +60,6 @@ extern struct device * const uart_devs[]; #endif -#if defined(CONFIG_UART_CONSOLE) - -#define CONFIG_UART_CONSOLE_IRQ CONFIG_UART_NS16550_PORT_1_IRQ -#define CONFIG_UART_CONSOLE_INT_PRI CONFIG_UART_NS16550_PORT_1_IRQ_PRI - -#define UART_CONSOLE_DEV (uart_devs[CONFIG_UART_CONSOLE_INDEX]) - -#endif /* CONFIG_UART_CONSOLE */ - #ifdef CONFIG_GPIO_DW_0 #if defined(CONFIG_GPIO_DW_0_FALLING_EDGE) #define GPIO_DW_0_IRQ_FLAGS (IOAPIC_EDGE | IOAPIC_LOW) diff --git a/arch/x86/platforms/quark_d2000/Kconfig b/arch/x86/platforms/quark_d2000/Kconfig index 88db997e55..b3ed4c16ff 100644 --- a/arch/x86/platforms/quark_d2000/Kconfig +++ b/arch/x86/platforms/quark_d2000/Kconfig @@ -107,4 +107,15 @@ endif # UART_NS16550_PORT_1 endif # UART_NS16550 +if UART_CONSOLE + +config UART_CONSOLE_ON_DEV_NAME + default "UART_0" +config UART_CONSOLE_IRQ + default 40 +config UART_CONSOLE_IRQ_PRI + default 3 + +endif + endif diff --git a/arch/x86/platforms/quark_d2000/board.h b/arch/x86/platforms/quark_d2000/board.h index 7c89d8977c..9bb4b61a54 100644 --- a/arch/x86/platforms/quark_d2000/board.h +++ b/arch/x86/platforms/quark_d2000/board.h @@ -126,35 +126,10 @@ struct scss_interrupt { /* UART uses level triggered interrupt, low level */ #define UART_IOAPIC_FLAGS (IOAPIC_LEVEL) -/* uart configuration settings */ - -#define CONFIG_UART0_CONSOLE_IRQ CONFIG_UART_NS16550_PORT_0_IRQ -#define CONFIG_UART0_CONSOLE_INT_PRI CONFIG_UART_NS16550_PORT_0_IRQ_PRI - -#define CONFIG_UART1_CONSOLE_IRQ CONFIG_UART_NS16550_PORT_1_IRQ -#define CONFIG_UART1_CONSOLE_INT_PRI CONFIG_UART_NS16550_PORT_1_IRQ_PRI - #ifndef _ASMLANGUAGE extern struct device * const uart_devs[]; #endif -/* Setup console from config value, */ -#if defined(CONFIG_UART_CONSOLE) - -#if (CONFIG_UART_CONSOLE_INDEX == 0) -#define CONFIG_UART_BAUDRATE CONFIG_UART_NS16550_PORT_0_BAUD_RATE -#define CONFIG_UART_CONSOLE_INT_PRI CONFIG_UART0_CONSOLE_INT_PRI -#define CONFIG_UART_CONSOLE_IRQ CONFIG_UART0_CONSOLE_IRQ -#elif (CONFIG_UART_CONSOLE_INDEX == 1) -#define CONFIG_UART_BAUDRATE CONFIG_UART_NS16550_PORT_1_BAUD_RATE -#define CONFIG_UART_CONSOLE_IRQ CONFIG_UART1_CONSOLE_IRQ -#define CONFIG_UART_CONSOLE_INT_PRI CONFIG_UART1_CONSOLE_INT_PRI -#endif /* CONFIG_UART_CONSOLE_INDEX */ - -#define UART_CONSOLE_DEV (uart_devs[CONFIG_UART_CONSOLE_INDEX]) - -#endif /* CONFIG_UART_CONSOLE */ - /* Watchdog */ #define WDT_BASE_ADDR 0xB0000000 #define INT_WDT_IRQ 0x10 diff --git a/arch/x86/platforms/quark_se/Kconfig b/arch/x86/platforms/quark_se/Kconfig index 572bb8bf5b..a048eb07d7 100644 --- a/arch/x86/platforms/quark_se/Kconfig +++ b/arch/x86/platforms/quark_se/Kconfig @@ -233,4 +233,15 @@ endif # UART_NS16550_PORT_1 endif # UART_NS16550 +if UART_CONSOLE + +config UART_CONSOLE_ON_DEV_NAME + default "UART_1" +config UART_CONSOLE_IRQ + default 38 +config UART_CONSOLE_IRQ_PRI + default 3 + +endif + endif #PLATFORM_QUARK_SE_X86 diff --git a/arch/x86/platforms/quark_se/board.h b/arch/x86/platforms/quark_se/board.h index 2ec6dd7151..8545dd290a 100644 --- a/arch/x86/platforms/quark_se/board.h +++ b/arch/x86/platforms/quark_se/board.h @@ -93,14 +93,6 @@ extern struct device * const uart_devs[]; - /* Console definitions */ -#if defined(CONFIG_UART_CONSOLE) - -#define CONFIG_UART_CONSOLE_INT_PRI CONFIG_UART_NS16550_PORT1_IRQ -#define UART_CONSOLE_DEV (uart_devs[CONFIG_UART_CONSOLE_INDEX]) - -#endif /* CONFIG_UART_CONSOLE */ - #endif /* CONFIG_UART_NS16550 */ diff --git a/configs/basic_cortex_m3_defconfig b/configs/basic_cortex_m3_defconfig index 710c5de070..067cf1f21f 100644 --- a/configs/basic_cortex_m3_defconfig +++ b/configs/basic_cortex_m3_defconfig @@ -3,8 +3,6 @@ CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=12000000 CONFIG_PLATFORM_TI_LM3S6965=y CONFIG_CONSOLE=y CONFIG_UART_CONSOLE=y -CONFIG_UART_CONSOLE_INDEX=0 -CONFIG_UART_CONSOLE_BAUDRATE=115200 CONFIG_SERIAL=y CONFIG_CORTEX_M_SYSTICK=y CONFIG_FLASH_SIZE=256 diff --git a/configs/fsl_frdm_k64f_defconfig b/configs/fsl_frdm_k64f_defconfig index 96f81b9a9f..94e65bbd6c 100644 --- a/configs/fsl_frdm_k64f_defconfig +++ b/configs/fsl_frdm_k64f_defconfig @@ -3,8 +3,6 @@ CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=120000000 CONFIG_PLATFORM_FSL_FRDM_K64F=y CONFIG_CONSOLE=y CONFIG_UART_CONSOLE=y -CONFIG_UART_CONSOLE_INDEX=0 -CONFIG_UART_CONSOLE_BAUDRATE=115200 CONFIG_SERIAL=y CONFIG_CORTEX_M_SYSTICK=y CONFIG_FLASH_SIZE=1024 diff --git a/configs/quark_se_defconfig b/configs/quark_se_defconfig index d8cc9b7778..bcdc0b197c 100644 --- a/configs/quark_se_defconfig +++ b/configs/quark_se_defconfig @@ -11,4 +11,3 @@ CONFIG_IPI_QUARK_SE=y CONFIG_IPI_QUARK_SE_MASTER=y CONFIG_IPI_CONSOLE_RECEIVER=y CONFIG_ARC_INIT=y -CONFIG_UART_CONSOLE_INDEX=1 diff --git a/drivers/console/Kconfig b/drivers/console/Kconfig index 9981a80662..ffe3b36d98 100644 --- a/drivers/console/Kconfig +++ b/drivers/console/Kconfig @@ -63,25 +63,29 @@ config UART_CONSOLE select CONSOLE_HAS_DRIVER help Enable this option to use one UART for console. Make sure - CONFIG_UART_CONSOLE_INDEX is also set correctly. + CONFIG_UART_CONSOLE_ON_DEV_NAME is also set correctly. -config UART_CONSOLE_INDEX - int "UART Console Index" - default 0 - range 0 6 +config UART_CONSOLE_ON_DEV_NAME + string "Device Name of UART Device for UART Console" + default "UART_0" depends on UART_CONSOLE help - This option specifies index for the console uart port. + This option specifies the name of UART device to be used for + UART console. -config UART_CONSOLE_BAUDRATE - int "UART Console Baud Rate" - default 115200 +config UART_CONSOLE_IRQ + int "IRQ of UART Device for UART Console" depends on UART_CONSOLE help - This specifies the baud rate for the UART console. + This option specifies the IRQ of UART device to be used for + UART console. - Default is 115200, which should be usable for most RS232 - and USB adapters. +config UART_CONSOLE_IRQ_PRI + int "IRQ of UART Device for UART Console" + depends on UART_CONSOLE + help + This option specifies the IRQ priorityof UART device to be + used for UART console. config UART_CONSOLE_PRIORITY int diff --git a/drivers/console/Makefile b/drivers/console/Makefile index 0cc6a4440d..db665231a7 100644 --- a/drivers/console/Makefile +++ b/drivers/console/Makefile @@ -1,5 +1,5 @@ -obj-$(CONFIG_UART_CONSOLE) = uart_console.o obj-$(CONFIG_CONSOLE_HANDLER_SHELL) += console_handler_shell.o +obj-$(CONFIG_UART_CONSOLE) += uart_console.o uart_console_static_irq_stubs.o obj-$(CONFIG_RAM_CONSOLE) += ram_console.o obj-$(CONFIG_IPI_CONSOLE_RECEIVER) += ipi_console_receiver.o obj-$(CONFIG_IPI_CONSOLE_SENDER) += ipi_console_sender.o diff --git a/drivers/console/uart_console.c b/drivers/console/uart_console.c index 208930e115..191e368b66 100644 --- a/drivers/console/uart_console.c +++ b/drivers/console/uart_console.c @@ -39,6 +39,8 @@ #include #include +static struct device *uart_console_dev; + #if 0 /* NOTUSED */ /** * @@ -47,18 +49,14 @@ * @return the character or EOF if nothing present */ -static int consoleIn(void) +static int console_in(void) { -#ifdef UART_CONSOLE_DEV unsigned char c; - if (uart_poll_in(UART_CONSOLE_DEV, &c) < 0) + if (uart_poll_in(uart_console_dev, &c) < 0) return EOF; else return (int)c; -#else - return 0; -#endif } #endif @@ -69,22 +67,20 @@ static int consoleIn(void) * * Outputs both line feed and carriage return in the case of a '\n'. * + * @param c Character to output + * * @return The character passed as input. */ -static int consoleOut(int c /* character to output */ - ) +static int console_out(int c) { -#ifdef UART_CONSOLE_DEV - uart_poll_out(UART_CONSOLE_DEV, (unsigned char)c); + uart_poll_out(uart_console_dev, (unsigned char)c); if ('\n' == c) { - uart_poll_out(UART_CONSOLE_DEV, (unsigned char)'\r'); + uart_poll_out(uart_console_dev, (unsigned char)'\r'); } return c; -#else - return 0; -#endif } + #endif #if defined(CONFIG_STDOUT_CONSOLE) @@ -128,20 +124,20 @@ void uart_console_isr(void *unused) { ARG_UNUSED(unused); - while (uart_irq_update(UART_CONSOLE_DEV) - && uart_irq_is_pending(UART_CONSOLE_DEV)) { + while (uart_irq_update(uart_console_dev) + && uart_irq_is_pending(uart_console_dev)) { /* Character(s) have been received */ - if (uart_irq_rx_ready(UART_CONSOLE_DEV)) { + if (uart_irq_rx_ready(uart_console_dev)) { static struct uart_console_input *cmd; uint8_t byte; int rx; - rx = read_uart(UART_CONSOLE_DEV, &byte, 1); + rx = read_uart(uart_console_dev, &byte, 1); if (rx < 0) { return; } - if (uart_irq_input_hook(UART_CONSOLE_DEV, byte) != 0) { + if (uart_irq_input_hook(uart_console_dev, byte) != 0) { /* * The input hook indicates that no further processing * should be done by this handler. @@ -156,12 +152,12 @@ void uart_console_isr(void *unused) } /* Echo back to console */ - uart_poll_out(UART_CONSOLE_DEV, byte); + uart_poll_out(uart_console_dev, byte); if (byte == '\r' || byte == '\n' || pos == sizeof(cmd->line) - 1) { cmd->line[pos] = '\0'; - uart_poll_out(UART_CONSOLE_DEV, '\n'); + uart_poll_out(uart_console_dev, '\n'); pos = 0; nano_isr_fifo_put(lines_queue, cmd); @@ -175,24 +171,24 @@ void uart_console_isr(void *unused) } IRQ_CONNECT_STATIC(console, CONFIG_UART_CONSOLE_IRQ, - CONFIG_UART_CONSOLE_INT_PRI, uart_console_isr, 0, + CONFIG_UART_CONSOLE_IRQ_PRI, uart_console_isr, 0, UART_IRQ_FLAGS); static void console_input_init(void) { uint8_t c; - uart_irq_rx_disable(UART_CONSOLE_DEV); - uart_irq_tx_disable(UART_CONSOLE_DEV); - IRQ_CONFIG(console, uart_irq_get(UART_CONSOLE_DEV), 0); - irq_enable(uart_irq_get(UART_CONSOLE_DEV)); + uart_irq_rx_disable(uart_console_dev); + uart_irq_tx_disable(uart_console_dev); + IRQ_CONFIG(console, uart_irq_get(uart_console_dev), 0); + irq_enable(uart_irq_get(uart_console_dev)); /* Drain the fifo */ - while (uart_irq_rx_ready(UART_CONSOLE_DEV)) { - uart_fifo_read(UART_CONSOLE_DEV, &c, 1); + while (uart_irq_rx_ready(uart_console_dev)) { + uart_fifo_read(uart_console_dev, &c, 1); } - uart_irq_rx_enable(UART_CONSOLE_DEV); + uart_irq_rx_enable(uart_console_dev); } void uart_register_input(struct nano_fifo *avail, struct nano_fifo *lines) @@ -220,8 +216,8 @@ void uart_register_input(struct nano_fifo *avail, struct nano_fifo *lines) void uart_console_hook_install(void) { - __stdout_hook_install(consoleOut); - __printk_hook_install(consoleOut); + __stdout_hook_install(console_out); + __printk_hook_install(console_out); } /** @@ -234,6 +230,8 @@ static int uart_console_init(struct device *arg) { ARG_UNUSED(arg); + uart_console_dev = device_get_binding(CONFIG_UART_CONSOLE_ON_DEV_NAME); + uart_console_hook_install(); return DEV_OK; diff --git a/drivers/console/uart_console_static_irq_stubs.S b/drivers/console/uart_console_static_irq_stubs.S new file mode 100644 index 0000000000..2682697ee2 --- /dev/null +++ b/drivers/console/uart_console_static_irq_stubs.S @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2015, Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file + * @brief UART console interrupt stubs + */ + +#ifdef CONFIG_X86 + +#define _ASMLANGUAGE + +#include +#include +#include + +#if defined(CONFIG_CONSOLE_HANDLER) +#if defined(CONFIG_IOAPIC) + ioapic_mkstub console uart_console_isr 0 +#endif /* CONFIG_IOAPIC */ +#endif /* CONFIG_CONSOLE_HANDLER */ + +#undef _ASMLANGUAGE + +#endif /* CONFIG_X86 */