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 10/08/14 at 21:04:56

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
RevLine 
[783669fc]1/*
2 *  This file implements simple console IO via JTAG UART.
[6279149]3 */
4
5/*
[783669fc]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
[c499856]14 *  http://www.rtems.org/license/LICENSE.
[783669fc]15 */
16
17#define NO_BSP_INIT
18
19#include <bsp.h>
[6279149]20#include <bsp/console-polled.h>
[783669fc]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
[359e537]28 *  it in
[783669fc]29 *  reads the character and stores
30 *
31 *  Input parameters: NONE
32 *
33 *  Output parameters:  NONE
34 *
35 *  Return values:
36 */
37
[fcd7483]38bool is_character_ready(
[783669fc]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;
[fcd7483]49        return true;
[783669fc]50    };
51
[fcd7483]52    return false;
[783669fc]53}
54
[d785ce4a]55void console_initialize_hardware(void)
56{
57}
58
[b96bd98]59/*
[783669fc]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
[b96bd98]70int console_inbyte_nonblocking(
71  int port
72)
[783669fc]73{
[b96bd98]74  char ch;
75  /*
76   *  Wait until a character is available.
77   */
78
79  if (is_character_ready(&ch))
[783669fc]80    return ch;
[b96bd98]81  return -1;
[783669fc]82}
83
[b96bd98]84/*
[783669fc]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
[b96bd98]94void console_outbyte_polled(
[359e537]95  int  port,
[783669fc]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/*
[5dd62f0]112 * To support printk
113 */
[783669fc]114
[b96bd98]115#include <rtems/bspIo.h>
[783669fc]116
117
[6279149]118static void ISS_output_char(char c) { console_outbyte_polled( 0, c ); }
[783669fc]119
[b96bd98]120BSP_output_char_function_type           BSP_output_char = ISS_output_char;
121BSP_polling_getchar_function_type       BSP_poll_char = NULL;
[783669fc]122
Note: See TracBrowser for help on using the repository browser.