summaryrefslogtreecommitdiffstats
path: root/bsps/x86_64/amd64/console/console.c
diff options
context:
space:
mode:
authorAmaan Cheval <amaan.cheval@gmail.com>2018-07-09 16:42:57 +0530
committerJoel Sherrill <joel@rtems.org>2018-07-11 15:23:43 -0500
commitcf811a4eb2358d66f403cd1397b29829e1827220 (patch)
tree75036f8bbfe239009b3df5734e4e9848e19b5962 /bsps/x86_64/amd64/console/console.c
parent76c03152e110dcb770253b54277811228e8f78df (diff)
downloadrtems-cf811a4eb2358d66f403cd1397b29829e1827220.tar.bz2
x86_64/console: Add NS16550 polled console driver
This addition allows us to successfully run the sample hello.exe test. Updates #2898.
Diffstat (limited to 'bsps/x86_64/amd64/console/console.c')
-rw-r--r--bsps/x86_64/amd64/console/console.c123
1 files changed, 30 insertions, 93 deletions
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 <bsp.h>
+#include <libchip/ns16550.h>
#include <rtems/bspIo.h>
-#include <rtems/libio.h>
-
-/* console_initialize
- *
- * This routine initializes the console IO driver.
- *
- * Input parameters: NONE
- *
- * Output parameters: NONE
- *
- * Return values:
- */
+#include <bsp.h>
+#include <bsp/console-termios.h>
+#include <rtems/score/cpuimpl.h>
-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;