blob: 9197c6486c1f5b90d079e3df77a73a6545859433 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
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;
|