source: rtems/bsps/nios2/nios2_iss/console/console.c @ d7d66d7

5
Last change on this file since d7d66d7 was d7d66d7, checked in by Sebastian Huber <sebastian.huber@…>, on 04/19/18 at 04:28:01

bsps: Move console drivers to bsps

This patch is a part of the BSP source reorganization.

Update #3285.

  • Property mode set to 100644
File size: 2.0 KB
Line 
1/*
2 *  This file implements simple console IO via JTAG UART.
3 */
4
5/*
6 *  COPYRIGHT (c) 1989-1999.
7 *  On-Line Applications Research Corporation (OAR).
8 *
9 *  Altera-specific code is
10 *  COPYRIGHT (c) 2005-2006 Kolja Waschk, rtemsdev/ixo.de
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.org/license/LICENSE.
15 */
16
17#define NO_BSP_INIT
18
19#include <bsp.h>
20#include <bsp/console-polled.h>
21#include <rtems/libio.h>
22
23/* #define JTAG_UART_REGS \
24        ((altera_avalon_jtag_uart_regs*)NIOS2_IO_BASE(JTAG_UART_BASE)) */
25
26/*  is_character_ready
27 *
28 *  If a character is available, this routine reads it and stores
29 *  it in reads the character and stores
30 */
31static bool is_character_ready(
32  char *ch
33)
34{
35  altera_avalon_jtag_uart_regs *ajur = NIOS2_IO_BASE(JTAG_UART_BASE);
36  unsigned int data = ajur->data;
37
38  if (data & ALTERA_AVALON_JTAG_UART_DATA_RVALID_MSK) {
39    *ch = (data & ALTERA_AVALON_JTAG_UART_DATA_DATA_MSK)
40          >> ALTERA_AVALON_JTAG_UART_DATA_DATA_OFST;
41    return true;
42  }
43
44  return false;
45}
46
47void console_initialize_hardware(void)
48{
49}
50
51/*
52 *  This routine reads a character from the SOURCE.
53 */
54int console_inbyte_nonblocking(
55  int port
56)
57{
58  char ch;
59
60  /*
61   *  Wait until a character is available.
62   */
63  if (is_character_ready(&ch))
64    return ch;
65  return -1;
66}
67
68/*
69 *  This routine transmits a character out the SOURCE.
70 */
71void console_outbyte_polled(
72  int  port,
73  char ch
74)
75{
76  altera_avalon_jtag_uart_regs *ajur = NIOS2_IO_BASE(JTAG_UART_BASE);
77
78  /*
79   *  Wait for the transmitter to be ready.
80   *  Check for flow control requests and process.
81   *  Then output the character.
82   */
83  while ((ajur->control & ALTERA_AVALON_JTAG_UART_CONTROL_WSPACE_MSK) == 0);
84
85  ajur->data = ch;
86}
87
88/*
89 * To support printk
90 */
91
92#include <rtems/bspIo.h>
93
94static void ISS_output_char(char c) { console_outbyte_polled( 0, c ); }
95
96BSP_output_char_function_type           BSP_output_char = ISS_output_char;
97BSP_polling_getchar_function_type       BSP_poll_char = NULL;
98
Note: See TracBrowser for help on using the repository browser.