source: rtems/c/src/lib/libbsp/nios2/nios2_iss/console/console.c @ 6279149

4.115
Last change on this file since 6279149 was 6279149, checked in by Joel Sherrill <joel.sherrill@…>, on Oct 8, 2014 at 9:04:56 PM

Add console-polled.h and update all BSPs that should use it.

The file console-polled.h provides the prototypes for the three
required methods when implementing a single port polled console
driver. This paradigm is common on simulators and simple hardware.

+ Updated the BSPs Makefile.am to make console-polled.h available.
+ Regenerated the BSPs preinstall.sm.
+ Updated console support files to include <bsp/console-polled.h>.
+ Updated console support files to make printk() support method static.

  • Property mode set to 100644
File size: 2.4 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 ((altera_avalon_jtag_uart_regs*)NIOS2_IO_BASE(JTAG_UART_BASE)) */
24
25/*  is_character_ready
26 *
27 *  If a character is available, this routine reads it and stores
28 *  it in
29 *  reads the character and stores
30 *
31 *  Input parameters: NONE
32 *
33 *  Output parameters:  NONE
34 *
35 *  Return values:
36 */
37
38bool is_character_ready(
39  char *ch
40)
41{
42    altera_avalon_jtag_uart_regs *ajur = NIOS2_IO_BASE(JTAG_UART_BASE);
43    unsigned int data = ajur->data;
44
45    if (data & ALTERA_AVALON_JTAG_UART_DATA_RVALID_MSK)
46    {
47        *ch = (data & ALTERA_AVALON_JTAG_UART_DATA_DATA_MSK)
48              >> ALTERA_AVALON_JTAG_UART_DATA_DATA_OFST;
49        return true;
50    };
51
52    return false;
53}
54
55void console_initialize_hardware(void)
56{
57}
58
59/*
60 *  This routine reads a character from the SOURCE.
61 *
62 *  Input parameters: NONE
63 *
64 *  Output parameters:  NONE
65 *
66 *  Return values:
67 *    character read from SOURCE
68 */
69
70int console_inbyte_nonblocking(
71  int port
72)
73{
74  char ch;
75  /*
76   *  Wait until a character is available.
77   */
78
79  if (is_character_ready(&ch))
80    return ch;
81  return -1;
82}
83
84/*
85 *  This routine transmits a character out the SOURCE.  It may support
86 *  XON/XOFF flow control.
87 *
88 *  Input parameters:
89 *    ch  - character to be transmitted
90 *
91 *  Output parameters:  NONE
92 */
93
94void console_outbyte_polled(
95  int  port,
96  char ch
97)
98{
99  altera_avalon_jtag_uart_regs *ajur = NIOS2_IO_BASE(JTAG_UART_BASE);
100  /*
101   *  Wait for the transmitter to be ready.
102   *  Check for flow control requests and process.
103   *  Then output the character.
104   */
105
106  while ((ajur->control & ALTERA_AVALON_JTAG_UART_CONTROL_WSPACE_MSK) == 0);
107
108  ajur->data = ch;
109}
110
111/*
112 * To support printk
113 */
114
115#include <rtems/bspIo.h>
116
117
118static void ISS_output_char(char c) { console_outbyte_polled( 0, c ); }
119
120BSP_output_char_function_type           BSP_output_char = ISS_output_char;
121BSP_polling_getchar_function_type       BSP_poll_char = NULL;
122
Note: See TracBrowser for help on using the repository browser.