From cf811a4eb2358d66f403cd1397b29829e1827220 Mon Sep 17 00:00:00 2001 From: Amaan Cheval Date: Mon, 9 Jul 2018 16:42:57 +0530 Subject: x86_64/console: Add NS16550 polled console driver This addition allows us to successfully run the sample hello.exe test. Updates #2898. --- bsps/x86_64/amd64/console/console.c | 123 +++++++++--------------------------- 1 file changed, 30 insertions(+), 93 deletions(-) (limited to 'bsps/x86_64/amd64/console/console.c') diff --git a/bsps/x86_64/amd64/console/console.c b/bsps/x86_64/amd64/console/console.c index b272b679d7..5408c57fe7 100644 --- a/bsps/x86_64/amd64/console/console.c +++ b/bsps/x86_64/amd64/console/console.c @@ -24,112 +24,49 @@ * SUCH DAMAGE. */ -#include +#include #include -#include - -/* console_initialize - * - * This routine initializes the console IO driver. - * - * Input parameters: NONE - * - * Output parameters: NONE - * - * Return values: - */ +#include +#include +#include -rtems_device_driver console_initialize( - rtems_device_major_number major, - rtems_device_minor_number minor, - void *arg -) +static uint8_t amd64_uart_get_register(uintptr_t addr, uint8_t i) { - (void) major; - (void) minor; - (void) arg; - return RTEMS_SUCCESSFUL; + return inport_byte(addr + i); } -/* - * Open entry point - */ - -rtems_device_driver console_open( - rtems_device_major_number major, - rtems_device_minor_number minor, - void * arg -) +static void amd64_uart_set_register(uintptr_t addr, uint8_t i, uint8_t val) { - (void) major; - (void) minor; - (void) arg; - return RTEMS_SUCCESSFUL; + outport_byte(addr + i, val); } -/* - * Close entry point - */ - -rtems_device_driver console_close( - rtems_device_major_number major, - rtems_device_minor_number minor, - void * arg -) -{ - (void) major; - (void) minor; - (void) arg; - return RTEMS_SUCCESSFUL; -} +static ns16550_context amd64_uart_context = { + .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("UART"), + .get_reg = amd64_uart_get_register, + .set_reg = amd64_uart_set_register, + .port = (uintptr_t) COM1_BASE_IO, + .initial_baud = COM1_CLOCK_RATE +}; /* - * read bytes from the serial port. We only have stdin. + * XXX: We should use the interrupt based handler once interrupts are supported */ +const console_device console_device_table[] = { + { + .device_file = "/dev/console", + .probe = console_device_probe_default, + .handler = &ns16550_handler_polled, + .context = &amd64_uart_context.base + } +}; +const size_t console_device_count = RTEMS_ARRAY_SIZE(console_device_table); -rtems_device_driver console_read( - rtems_device_major_number major, - rtems_device_minor_number minor, - void * arg -) +static void output_char(char c) { - (void) major; - (void) minor; - (void) arg; - return RTEMS_SUCCESSFUL; -} + rtems_termios_device_context *ctx = console_device_table[0].context; -/* - * write bytes to the serial port. Stdout and stderr are the same. - */ - -rtems_device_driver console_write( - rtems_device_major_number major, - rtems_device_minor_number minor, - void * arg -) -{ - (void) major; - (void) minor; - (void) arg; - return 0; -} - -/* - * IO Control entry point - */ - -rtems_device_driver console_control( - rtems_device_major_number major, - rtems_device_minor_number minor, - void * arg -) -{ - (void) major; - (void) minor; - (void) arg; - return RTEMS_SUCCESSFUL; + ns16550_polled_putchar(ctx, c); } -BSP_output_char_function_type BSP_output_char = NULL; -BSP_polling_getchar_function_type BSP_poll_char = NULL; +BSP_output_char_function_type BSP_output_char = output_char; +BSP_polling_getchar_function_type BSP_poll_char = NULL; -- cgit v1.2.3