summaryrefslogtreecommitdiffstats
path: root/bsps/nios2
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2018-04-19 06:28:01 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2018-04-20 13:08:32 +0200
commitd7d66d7d4523b904c8ccc6aea3709dc0d5aa5bdc (patch)
treecaa54b4229e86a68c84ab5961af34e087dce5302 /bsps/nios2
parentbsps/powerpc: Move shared btimer support (diff)
downloadrtems-d7d66d7d4523b904c8ccc6aea3709dc0d5aa5bdc.tar.bz2
bsps: Move console drivers to bsps
This patch is a part of the BSP source reorganization. Update #3285.
Diffstat (limited to 'bsps/nios2')
-rw-r--r--bsps/nios2/nios2_iss/console/console.c98
1 files changed, 98 insertions, 0 deletions
diff --git a/bsps/nios2/nios2_iss/console/console.c b/bsps/nios2/nios2_iss/console/console.c
new file mode 100644
index 0000000000..9197c6486c
--- /dev/null
+++ b/bsps/nios2/nios2_iss/console/console.c
@@ -0,0 +1,98 @@
+/*
+ * This file implements simple console IO via JTAG UART.
+ */
+
+/*
+ * COPYRIGHT (c) 1989-1999.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * Altera-specific code is
+ * COPYRIGHT (c) 2005-2006 Kolja Waschk, rtemsdev/ixo.de
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#define NO_BSP_INIT
+
+#include <bsp.h>
+#include <bsp/console-polled.h>
+#include <rtems/libio.h>
+
+/* #define JTAG_UART_REGS \
+ ((altera_avalon_jtag_uart_regs*)NIOS2_IO_BASE(JTAG_UART_BASE)) */
+
+/* is_character_ready
+ *
+ * If a character is available, this routine reads it and stores
+ * it in reads the character and stores
+ */
+static bool is_character_ready(
+ char *ch
+)
+{
+ altera_avalon_jtag_uart_regs *ajur = NIOS2_IO_BASE(JTAG_UART_BASE);
+ unsigned int data = ajur->data;
+
+ if (data & ALTERA_AVALON_JTAG_UART_DATA_RVALID_MSK) {
+ *ch = (data & ALTERA_AVALON_JTAG_UART_DATA_DATA_MSK)
+ >> ALTERA_AVALON_JTAG_UART_DATA_DATA_OFST;
+ return true;
+ }
+
+ return false;
+}
+
+void console_initialize_hardware(void)
+{
+}
+
+/*
+ * This routine reads a character from the SOURCE.
+ */
+int console_inbyte_nonblocking(
+ int port
+)
+{
+ char ch;
+
+ /*
+ * Wait until a character is available.
+ */
+ if (is_character_ready(&ch))
+ return ch;
+ return -1;
+}
+
+/*
+ * This routine transmits a character out the SOURCE.
+ */
+void console_outbyte_polled(
+ int port,
+ char ch
+)
+{
+ altera_avalon_jtag_uart_regs *ajur = NIOS2_IO_BASE(JTAG_UART_BASE);
+
+ /*
+ * Wait for the transmitter to be ready.
+ * Check for flow control requests and process.
+ * Then output the character.
+ */
+ while ((ajur->control & ALTERA_AVALON_JTAG_UART_CONTROL_WSPACE_MSK) == 0);
+
+ ajur->data = ch;
+}
+
+/*
+ * To support printk
+ */
+
+#include <rtems/bspIo.h>
+
+static void ISS_output_char(char c) { console_outbyte_polled( 0, c ); }
+
+BSP_output_char_function_type BSP_output_char = ISS_output_char;
+BSP_polling_getchar_function_type BSP_poll_char = NULL;
+