forked from Imagelibrary/rtems
bsps: Move console drivers to bsps
This patch is a part of the BSP source reorganization. Update #3285.
This commit is contained in:
83
bsps/sparc/erc32/console/debugputs.c
Normal file
83
bsps/sparc/erc32/console/debugputs.c
Normal file
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* COPYRIGHT (c) 1989-1999.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <bsp.h>
|
||||
#include <rtems/libio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/*
|
||||
* console_outbyte_polled
|
||||
*
|
||||
* This routine transmits a character using polling.
|
||||
*/
|
||||
void console_outbyte_polled(
|
||||
int port,
|
||||
unsigned char ch
|
||||
)
|
||||
{
|
||||
if ( port == 0 ) {
|
||||
while ( (ERC32_MEC.UART_Status & ERC32_MEC_UART_STATUS_THEA) == 0 );
|
||||
ERC32_MEC.UART_Channel_A = (unsigned int) ch;
|
||||
return;
|
||||
}
|
||||
|
||||
while ( (ERC32_MEC.UART_Status & ERC32_MEC_UART_STATUS_THEB) == 0 );
|
||||
ERC32_MEC.UART_Channel_B = (unsigned int) ch;
|
||||
}
|
||||
|
||||
/*
|
||||
* console_inbyte_nonblocking
|
||||
*
|
||||
* This routine polls for a character.
|
||||
*/
|
||||
int console_inbyte_nonblocking( int port )
|
||||
{
|
||||
int UStat;
|
||||
|
||||
UStat = ERC32_MEC.UART_Status;
|
||||
|
||||
switch (port) {
|
||||
|
||||
case 0:
|
||||
if (UStat & ERC32_MEC_UART_STATUS_ERRA) {
|
||||
ERC32_MEC.UART_Status = ERC32_MEC_UART_STATUS_CLRA;
|
||||
ERC32_MEC.Control = ERC32_MEC.Control;
|
||||
}
|
||||
|
||||
if ((UStat & ERC32_MEC_UART_STATUS_DRA) == 0)
|
||||
return -1;
|
||||
return (int) ERC32_MEC.UART_Channel_A;
|
||||
|
||||
case 1:
|
||||
if (UStat & ERC32_MEC_UART_STATUS_ERRB) {
|
||||
ERC32_MEC.UART_Status = ERC32_MEC_UART_STATUS_CLRB;
|
||||
ERC32_MEC.Control = ERC32_MEC.Control;
|
||||
}
|
||||
|
||||
if ((UStat & ERC32_MEC_UART_STATUS_DRB) == 0)
|
||||
return -1;
|
||||
return (int) ERC32_MEC.UART_Channel_B;
|
||||
|
||||
default:
|
||||
rtems_fatal_error_occurred( 'D' << 8 | (port & 0xffffff) );
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* To support printk
|
||||
*/
|
||||
|
||||
#include <rtems/bspIo.h>
|
||||
|
||||
static void BSP_output_char_f(char c) { console_outbyte_polled( 0, c ); }
|
||||
|
||||
BSP_output_char_function_type BSP_output_char = BSP_output_char_f;
|
||||
BSP_polling_getchar_function_type BSP_poll_char = NULL;
|
||||
337
bsps/sparc/erc32/console/erc32_console.c
Normal file
337
bsps/sparc/erc32/console/erc32_console.c
Normal file
@@ -0,0 +1,337 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @brief Driver for serial ports on the ERC32.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010 Tiemen Schut <T.Schut@sron.nl>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <termios.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <rtems.h>
|
||||
#include <rtems/libio.h>
|
||||
#include <rtems/console.h>
|
||||
#include <rtems/termiostypes.h>
|
||||
|
||||
#include <libchip/serial.h>
|
||||
#include <libchip/sersupp.h>
|
||||
|
||||
#include <bsp.h>
|
||||
#include <bspopts.h>
|
||||
|
||||
#define CONSOLE_BUF_SIZE (16)
|
||||
|
||||
#define CONSOLE_UART_A_TRAP ERC32_TRAP_TYPE(ERC32_INTERRUPT_UART_A_RX_TX)
|
||||
#define CONSOLE_UART_B_TRAP ERC32_TRAP_TYPE(ERC32_INTERRUPT_UART_B_RX_TX)
|
||||
|
||||
static uint8_t erc32_console_get_register(uintptr_t addr, uint8_t i)
|
||||
{
|
||||
volatile uint32_t *reg = (volatile uint32_t *)addr;
|
||||
return (uint8_t) reg [i];
|
||||
}
|
||||
|
||||
static void erc32_console_set_register(uintptr_t addr, uint8_t i, uint8_t val)
|
||||
{
|
||||
volatile uint32_t *reg = (volatile uint32_t *)addr;
|
||||
reg [i] = val;
|
||||
}
|
||||
|
||||
static int erc32_console_first_open(int major, int minor, void *arg);
|
||||
|
||||
#if (CONSOLE_USE_INTERRUPTS)
|
||||
static ssize_t erc32_console_write_support_int(
|
||||
int minor, const char *buf, size_t len);
|
||||
#else
|
||||
int console_inbyte_nonblocking( int port );
|
||||
static ssize_t erc32_console_write_support_polled(
|
||||
int minor, const char *buf, size_t len);
|
||||
#endif
|
||||
static void erc32_console_initialize(int minor);
|
||||
|
||||
#if (CONSOLE_USE_INTERRUPTS)
|
||||
const console_fns erc32_fns = {
|
||||
libchip_serial_default_probe, /* deviceProbe */
|
||||
erc32_console_first_open, /* deviceFirstOpen */
|
||||
NULL, /* deviceLastClose */
|
||||
NULL, /* deviceRead */
|
||||
erc32_console_write_support_int, /* deviceWrite */
|
||||
erc32_console_initialize, /* deviceInitialize */
|
||||
NULL, /* deviceWritePolled */
|
||||
NULL, /* deviceSetAttributes */
|
||||
TERMIOS_IRQ_DRIVEN /* deviceOutputUsesInterrupts */
|
||||
};
|
||||
#else
|
||||
const console_fns erc32_fns = {
|
||||
libchip_serial_default_probe, /* deviceProbe */
|
||||
erc32_console_first_open, /* deviceFirstOpen */
|
||||
NULL, /* deviceLastClose */
|
||||
console_inbyte_nonblocking, /* deviceRead */
|
||||
erc32_console_write_support_polled, /* deviceWrite */
|
||||
erc32_console_initialize, /* deviceInitialize */
|
||||
NULL, /* deviceWritePolled */
|
||||
NULL, /* deviceSetAttributes */
|
||||
TERMIOS_POLLED /* deviceOutputUsesInterrupts */
|
||||
};
|
||||
#endif
|
||||
|
||||
console_tbl Console_Configuration_Ports [] = {
|
||||
{
|
||||
.sDeviceName = "/dev/console_a",
|
||||
.deviceType = SERIAL_CUSTOM,
|
||||
.pDeviceFns = &erc32_fns,
|
||||
.deviceProbe = NULL,
|
||||
.pDeviceFlow = NULL,
|
||||
.ulMargin = 16,
|
||||
.ulHysteresis = 8,
|
||||
.pDeviceParams = (void *) -1, /* could be baud rate */
|
||||
.ulCtrlPort1 = 0,
|
||||
.ulCtrlPort2 = 0,
|
||||
.ulDataPort = 0,
|
||||
.getRegister = erc32_console_get_register,
|
||||
.setRegister = erc32_console_set_register,
|
||||
.getData = NULL,
|
||||
.setData = NULL,
|
||||
.ulClock = 16,
|
||||
.ulIntVector = ERC32_INTERRUPT_UART_A_RX_TX
|
||||
},
|
||||
{
|
||||
.sDeviceName = "/dev/console_b",
|
||||
.deviceType = SERIAL_CUSTOM,
|
||||
.pDeviceFns = &erc32_fns,
|
||||
.deviceProbe = NULL,
|
||||
.pDeviceFlow = NULL,
|
||||
.ulMargin = 16,
|
||||
.ulHysteresis = 8,
|
||||
.pDeviceParams = (void *) -1, /* could be baud rate */
|
||||
.ulCtrlPort1 = 0,
|
||||
.ulCtrlPort2 = 0,
|
||||
.ulDataPort = 0,
|
||||
.getRegister = erc32_console_get_register,
|
||||
.setRegister = erc32_console_set_register,
|
||||
.getData = NULL,
|
||||
.setData = NULL,
|
||||
.ulClock = 16,
|
||||
.ulIntVector = ERC32_INTERRUPT_UART_B_RX_TX
|
||||
},
|
||||
};
|
||||
|
||||
/* always exactly two uarts for erc32 */
|
||||
#define ERC32_UART_COUNT (2)
|
||||
|
||||
unsigned long Console_Configuration_Count = ERC32_UART_COUNT;
|
||||
|
||||
static int erc32_console_first_open(int major, int minor, void *arg)
|
||||
{
|
||||
/* Check minor number */
|
||||
if (minor < 0 || minor > 1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
rtems_libio_open_close_args_t *oca = arg;
|
||||
struct rtems_termios_tty *tty = oca->iop->data1;
|
||||
console_tbl *ct = Console_Port_Tbl [minor];
|
||||
console_data *cd = &Console_Port_Data [minor];
|
||||
|
||||
cd->termios_data = tty;
|
||||
rtems_termios_set_initial_baud(tty, (int32_t)ct->pDeviceParams);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if (CONSOLE_USE_INTERRUPTS)
|
||||
static ssize_t erc32_console_write_support_int(
|
||||
int minor, const char *buf, size_t len)
|
||||
{
|
||||
if (len > 0) {
|
||||
console_data *cd = &Console_Port_Data[minor];
|
||||
int k = 0;
|
||||
|
||||
if (minor == 0) { /* uart a */
|
||||
for (k = 0;
|
||||
k < len && (ERC32_MEC.UART_Status & ERC32_MEC_UART_STATUS_THEA);
|
||||
k ++) {
|
||||
ERC32_MEC.UART_Channel_A = (unsigned char)buf[k];
|
||||
}
|
||||
ERC32_Force_interrupt(ERC32_INTERRUPT_UART_A_RX_TX);
|
||||
} else { /* uart b */
|
||||
for (k = 0;
|
||||
k < len && (ERC32_MEC.UART_Status & ERC32_MEC_UART_STATUS_THEB);
|
||||
k ++) {
|
||||
ERC32_MEC.UART_Channel_B = (unsigned char)buf[k];
|
||||
}
|
||||
ERC32_Force_interrupt(ERC32_INTERRUPT_UART_B_RX_TX);
|
||||
}
|
||||
|
||||
cd->pDeviceContext = (void *)k;
|
||||
cd->bActive = true;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void erc32_console_isr_error(
|
||||
rtems_vector_number vector
|
||||
)
|
||||
{
|
||||
int UStat;
|
||||
|
||||
UStat = ERC32_MEC.UART_Status;
|
||||
|
||||
if (UStat & ERC32_MEC_UART_STATUS_ERRA) {
|
||||
ERC32_MEC.UART_Status = ERC32_MEC_UART_STATUS_CLRA;
|
||||
ERC32_MEC.Control = ERC32_MEC.Control;
|
||||
}
|
||||
|
||||
if (UStat & ERC32_MEC_UART_STATUS_ERRB) {
|
||||
ERC32_MEC.UART_Status = ERC32_MEC_UART_STATUS_CLRB;
|
||||
ERC32_MEC.Control = ERC32_MEC.Control;
|
||||
}
|
||||
|
||||
ERC32_Clear_interrupt( ERC32_INTERRUPT_UART_ERROR );
|
||||
}
|
||||
|
||||
static void erc32_console_isr_a(
|
||||
rtems_vector_number vector
|
||||
)
|
||||
{
|
||||
console_data *cd = &Console_Port_Data[0];
|
||||
|
||||
/* check for error */
|
||||
if (ERC32_MEC.UART_Status & ERC32_MEC_UART_STATUS_ERRA) {
|
||||
ERC32_MEC.UART_Status = ERC32_MEC_UART_STATUS_CLRA;
|
||||
ERC32_MEC.Control = ERC32_MEC.Control;
|
||||
}
|
||||
|
||||
do {
|
||||
int chars_to_dequeue = (int)cd->pDeviceContext;
|
||||
int rv = 0;
|
||||
int i = 0;
|
||||
char buf[CONSOLE_BUF_SIZE];
|
||||
|
||||
/* enqueue received chars */
|
||||
while (i < CONSOLE_BUF_SIZE) {
|
||||
if (!(ERC32_MEC.UART_Status & ERC32_MEC_UART_STATUS_DRA))
|
||||
break;
|
||||
buf[i] = ERC32_MEC.UART_Channel_A;
|
||||
++i;
|
||||
}
|
||||
if ( i )
|
||||
rtems_termios_enqueue_raw_characters(cd->termios_data, buf, i);
|
||||
|
||||
/* dequeue transmitted chars */
|
||||
if (ERC32_MEC.UART_Status & ERC32_MEC_UART_STATUS_THEA) {
|
||||
rv = rtems_termios_dequeue_characters(
|
||||
cd->termios_data, chars_to_dequeue);
|
||||
if ( !rv ) {
|
||||
cd->pDeviceContext = 0;
|
||||
cd->bActive = false;
|
||||
}
|
||||
ERC32_Clear_interrupt (ERC32_INTERRUPT_UART_A_RX_TX);
|
||||
}
|
||||
} while (ERC32_Is_interrupt_pending (ERC32_INTERRUPT_UART_A_RX_TX));
|
||||
}
|
||||
|
||||
static void erc32_console_isr_b(
|
||||
rtems_vector_number vector
|
||||
)
|
||||
{
|
||||
console_data *cd = &Console_Port_Data[1];
|
||||
|
||||
/* check for error */
|
||||
if (ERC32_MEC.UART_Status & ERC32_MEC_UART_STATUS_ERRB) {
|
||||
ERC32_MEC.UART_Status = ERC32_MEC_UART_STATUS_CLRB;
|
||||
ERC32_MEC.Control = ERC32_MEC.Control;
|
||||
}
|
||||
|
||||
do {
|
||||
int chars_to_dequeue = (int)cd->pDeviceContext;
|
||||
int rv = 0;
|
||||
int i = 0;
|
||||
char buf[CONSOLE_BUF_SIZE];
|
||||
|
||||
/* enqueue received chars */
|
||||
while (i < CONSOLE_BUF_SIZE) {
|
||||
if (!(ERC32_MEC.UART_Status & ERC32_MEC_UART_STATUS_DRB))
|
||||
break;
|
||||
buf[i] = ERC32_MEC.UART_Channel_B;
|
||||
++i;
|
||||
}
|
||||
if ( i )
|
||||
rtems_termios_enqueue_raw_characters(cd->termios_data, buf, i);
|
||||
|
||||
/* dequeue transmitted chars */
|
||||
if (ERC32_MEC.UART_Status & ERC32_MEC_UART_STATUS_THEB) {
|
||||
rv = rtems_termios_dequeue_characters(
|
||||
cd->termios_data, chars_to_dequeue);
|
||||
if ( !rv ) {
|
||||
cd->pDeviceContext = 0;
|
||||
cd->bActive = false;
|
||||
}
|
||||
ERC32_Clear_interrupt (ERC32_INTERRUPT_UART_B_RX_TX);
|
||||
}
|
||||
} while (ERC32_Is_interrupt_pending (ERC32_INTERRUPT_UART_B_RX_TX));
|
||||
}
|
||||
#else
|
||||
|
||||
extern void console_outbyte_polled( int port, unsigned char ch );
|
||||
|
||||
static ssize_t erc32_console_write_support_polled(
|
||||
int minor,
|
||||
const char *buf,
|
||||
size_t len
|
||||
)
|
||||
{
|
||||
int nwrite = 0;
|
||||
|
||||
while (nwrite < len) {
|
||||
console_outbyte_polled( minor, *buf++ );
|
||||
nwrite++;
|
||||
}
|
||||
return nwrite;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Console Device Driver Entry Points
|
||||
*
|
||||
*/
|
||||
|
||||
static void erc32_console_initialize(
|
||||
int minor
|
||||
)
|
||||
{
|
||||
console_data *cd = &Console_Port_Data [minor];
|
||||
|
||||
cd->bActive = false;
|
||||
cd->pDeviceContext = 0;
|
||||
|
||||
/*
|
||||
* Initialize the Termios infrastructure. If Termios has already
|
||||
* been initialized by another device driver, then this call will
|
||||
* have no effect.
|
||||
*/
|
||||
rtems_termios_initialize();
|
||||
|
||||
/*
|
||||
* Initialize Hardware
|
||||
*/
|
||||
#if (CONSOLE_USE_INTERRUPTS)
|
||||
set_vector(erc32_console_isr_a, CONSOLE_UART_A_TRAP, 1);
|
||||
set_vector(erc32_console_isr_b, CONSOLE_UART_B_TRAP, 1);
|
||||
set_vector(erc32_console_isr_error, CONSOLE_UART_ERROR_TRAP, 1);
|
||||
#endif
|
||||
|
||||
/* Clear any previous error flags */
|
||||
ERC32_MEC.UART_Status = ERC32_MEC_UART_STATUS_CLRA;
|
||||
ERC32_MEC.UART_Status = ERC32_MEC_UART_STATUS_CLRB;
|
||||
}
|
||||
437
bsps/sparc/leon2/console/console.c
Normal file
437
bsps/sparc/leon2/console/console.c
Normal file
@@ -0,0 +1,437 @@
|
||||
/**
|
||||
* @file
|
||||
* @ingroup sparc_leon2
|
||||
* @brief TTY driver driver for the serial ports on the LEON console
|
||||
*
|
||||
* This file contains the TTY driver for the serial ports on the LEON.
|
||||
*/
|
||||
|
||||
/*
|
||||
* COPYRIGHT (c) 1989-2014.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <rtems/console.h>
|
||||
#include <rtems/libio.h>
|
||||
#include <rtems/bspIo.h>
|
||||
#include <bsp.h>
|
||||
|
||||
/*
|
||||
* console_outbyte_polled
|
||||
*
|
||||
* This routine transmits a character using polling.
|
||||
*/
|
||||
void console_outbyte_polled(
|
||||
int port,
|
||||
unsigned char ch
|
||||
);
|
||||
|
||||
/* body is in debugputs.c */
|
||||
|
||||
/*
|
||||
* console_inbyte_nonblocking
|
||||
*
|
||||
* This routine polls for a character.
|
||||
*/
|
||||
|
||||
int console_inbyte_nonblocking( int port );
|
||||
|
||||
/* body is in debugputs.c */
|
||||
|
||||
/*
|
||||
* Interrupt driven console IO
|
||||
*/
|
||||
|
||||
#if (CONSOLE_USE_INTERRUPTS)
|
||||
|
||||
/*
|
||||
* Buffers between task and ISRs
|
||||
*/
|
||||
|
||||
#include <rtems/ringbuf.h>
|
||||
|
||||
Ring_buffer_t TX_Buffer[ 2 ];
|
||||
bool Is_TX_active[ 2 ];
|
||||
|
||||
void *console_termios_data[ 2 ];
|
||||
|
||||
/*
|
||||
* console_isr_a
|
||||
*
|
||||
* This routine is the console interrupt handler for Channel 1.
|
||||
*
|
||||
* Input parameters:
|
||||
* vector - vector number
|
||||
*
|
||||
* Output parameters: NONE
|
||||
*
|
||||
* Return values: NONE
|
||||
*/
|
||||
|
||||
rtems_isr console_isr_a(
|
||||
rtems_vector_number vector
|
||||
)
|
||||
{
|
||||
char ch;
|
||||
int UStat;
|
||||
|
||||
if ( (UStat = LEON_REG.UART_Status_1) & LEON_REG_UART_STATUS_DR ) {
|
||||
if (UStat & LEON_REG_UART_STATUS_ERR) {
|
||||
LEON_REG.UART_Status_1 = LEON_REG_UART_STATUS_CLR;
|
||||
}
|
||||
ch = LEON_REG.UART_Channel_1;
|
||||
|
||||
rtems_termios_enqueue_raw_characters( console_termios_data[ 0 ], &ch, 1 );
|
||||
}
|
||||
|
||||
if ( LEON_REG.UART_Status_1 & LEON_REG_UART_STATUS_THE ) {
|
||||
if ( !Ring_buffer_Is_empty( &TX_Buffer[ 0 ] ) ) {
|
||||
Ring_buffer_Remove_character( &TX_Buffer[ 0 ], ch );
|
||||
LEON_REG.UART_Channel_1 = (uint32_t) ch;
|
||||
} else
|
||||
Is_TX_active[ 0 ] = false;
|
||||
}
|
||||
|
||||
LEON_Clear_interrupt( LEON_INTERRUPT_UART_1_RX_TX );
|
||||
}
|
||||
|
||||
/*
|
||||
* console_isr_b
|
||||
*
|
||||
* This routine is the console interrupt handler for Channel 2.
|
||||
*
|
||||
* Input parameters:
|
||||
* vector - vector number
|
||||
*
|
||||
* Output parameters: NONE
|
||||
*
|
||||
* Return values: NONE
|
||||
*/
|
||||
|
||||
rtems_isr console_isr_b(
|
||||
rtems_vector_number vector
|
||||
)
|
||||
{
|
||||
char ch;
|
||||
int UStat;
|
||||
|
||||
if ( (UStat = LEON_REG.UART_Status_2) & LEON_REG_UART_STATUS_DR ) {
|
||||
if (UStat & LEON_REG_UART_STATUS_ERR) {
|
||||
LEON_REG.UART_Status_2 = LEON_REG_UART_STATUS_CLR;
|
||||
}
|
||||
ch = LEON_REG.UART_Channel_2;
|
||||
rtems_termios_enqueue_raw_characters( console_termios_data[ 1 ], &ch, 1 );
|
||||
|
||||
}
|
||||
|
||||
if ( LEON_REG.UART_Status_2 & LEON_REG_UART_STATUS_THE ) {
|
||||
if ( !Ring_buffer_Is_empty( &TX_Buffer[ 1 ] ) ) {
|
||||
Ring_buffer_Remove_character( &TX_Buffer[ 1 ], ch );
|
||||
LEON_REG.UART_Channel_2 = (uint32_t) ch;
|
||||
} else
|
||||
Is_TX_active[ 1 ] = false;
|
||||
}
|
||||
|
||||
LEON_Clear_interrupt( LEON_INTERRUPT_UART_2_RX_TX );
|
||||
}
|
||||
|
||||
/*
|
||||
* console_exit
|
||||
*
|
||||
* This routine allows the console to exit by masking its associated interrupt
|
||||
* vectors.
|
||||
*
|
||||
* Input parameters: NONE
|
||||
*
|
||||
* Output parameters: NONE
|
||||
*
|
||||
* Return values: NONE
|
||||
*/
|
||||
|
||||
void console_exit()
|
||||
{
|
||||
uint32_t port;
|
||||
uint32_t ch;
|
||||
|
||||
/*
|
||||
* Although the interrupts for the UART are unmasked, the PIL is set to
|
||||
* disable all external interrupts. So we might as well do this first.
|
||||
*/
|
||||
|
||||
LEON_Mask_interrupt( LEON_INTERRUPT_UART_1_RX_TX );
|
||||
LEON_Mask_interrupt( LEON_INTERRUPT_UART_2_RX_TX );
|
||||
|
||||
for ( port=0 ; port <= 1 ; port++ ) {
|
||||
while ( !Ring_buffer_Is_empty( &TX_Buffer[ port ] ) ) {
|
||||
Ring_buffer_Remove_character( &TX_Buffer[ port ], ch );
|
||||
console_outbyte_polled( port, ch );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Now wait for all the data to actually get out ... the send register
|
||||
* should be empty.
|
||||
*/
|
||||
|
||||
while ( (LEON_REG.UART_Status_1 & LEON_REG_UART_STATUS_THE) !=
|
||||
LEON_REG_UART_STATUS_THE );
|
||||
|
||||
while ( (LEON_REG.UART_Status_2 & LEON_REG_UART_STATUS_THE) !=
|
||||
LEON_REG_UART_STATUS_THE );
|
||||
|
||||
LEON_REG.UART_Control_1 = 0;
|
||||
LEON_REG.UART_Control_2 = 0;
|
||||
LEON_REG.UART_Status_1 = 0;
|
||||
LEON_REG.UART_Status_2 = 0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
#define CONSOLE_UART_1_TRAP LEON_TRAP_TYPE( LEON_INTERRUPT_UART_1_RX_TX )
|
||||
#define CONSOLE_UART_2_TRAP LEON_TRAP_TYPE( LEON_INTERRUPT_UART_2_RX_TX )
|
||||
|
||||
/*
|
||||
* console_initialize_interrupts
|
||||
*
|
||||
* This routine initializes the console's receive and transmit
|
||||
* ring buffers and loads the appropriate vectors to handle the interrupts.
|
||||
*
|
||||
* Input parameters: NONE
|
||||
*
|
||||
* Output parameters: NONE
|
||||
*
|
||||
* Return values: NONE
|
||||
*/
|
||||
|
||||
#ifdef RDB_BREAK_IN
|
||||
extern uint32_t trap_table[];
|
||||
#endif
|
||||
|
||||
void console_initialize_interrupts( void )
|
||||
{
|
||||
Ring_buffer_Initialize( &TX_Buffer[ 0 ] );
|
||||
Ring_buffer_Initialize( &TX_Buffer[ 1 ] );
|
||||
|
||||
Is_TX_active[ 0 ] = false;
|
||||
Is_TX_active[ 1 ] = false;
|
||||
|
||||
atexit( console_exit );
|
||||
|
||||
LEON_REG.UART_Control_1 |= LEON_REG_UART_CTRL_RI | LEON_REG_UART_CTRL_TI;
|
||||
LEON_REG.UART_Control_2 |= LEON_REG_UART_CTRL_RI | LEON_REG_UART_CTRL_TI;
|
||||
|
||||
set_vector( console_isr_a, CONSOLE_UART_1_TRAP, 1 );
|
||||
#ifdef RDB_BREAK_IN
|
||||
if (trap_table[0x150/4] == 0x91d02000)
|
||||
#endif
|
||||
set_vector( console_isr_b, CONSOLE_UART_2_TRAP, 1 );
|
||||
}
|
||||
|
||||
/*
|
||||
* console_outbyte_interrupt
|
||||
*
|
||||
* This routine transmits a character out.
|
||||
*
|
||||
* Input parameters:
|
||||
* port - port to transmit character to
|
||||
* ch - character to be transmitted
|
||||
*
|
||||
* Output parameters: NONE
|
||||
*
|
||||
* Return values: NONE
|
||||
*/
|
||||
|
||||
void console_outbyte_interrupt(
|
||||
int port,
|
||||
char ch
|
||||
)
|
||||
{
|
||||
/*
|
||||
* If this is the first character then we need to prime the pump
|
||||
*/
|
||||
|
||||
if ( Is_TX_active[ port ] == false ) {
|
||||
Is_TX_active[ port ] = true;
|
||||
console_outbyte_polled( port, ch );
|
||||
return;
|
||||
}
|
||||
|
||||
while ( Ring_buffer_Is_full( &TX_Buffer[ port ] ) );
|
||||
|
||||
Ring_buffer_Add_character( &TX_Buffer[ port ], ch );
|
||||
}
|
||||
|
||||
#endif /* CONSOLE_USE_INTERRUPTS */
|
||||
|
||||
/*
|
||||
* Console Termios Support Entry Points
|
||||
*
|
||||
*/
|
||||
|
||||
static ssize_t console_write_support (int minor, const char *buf, size_t len)
|
||||
{
|
||||
int nwrite = 0;
|
||||
|
||||
while (nwrite < len) {
|
||||
#if (CONSOLE_USE_INTERRUPTS)
|
||||
console_outbyte_interrupt( minor, *buf++ );
|
||||
#else
|
||||
console_outbyte_polled( minor, *buf++ );
|
||||
#endif
|
||||
nwrite++;
|
||||
}
|
||||
return nwrite;
|
||||
}
|
||||
|
||||
/*
|
||||
* Console Device Driver Entry Points
|
||||
*
|
||||
*/
|
||||
|
||||
rtems_device_driver console_initialize(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *arg
|
||||
)
|
||||
{
|
||||
rtems_status_code status;
|
||||
|
||||
rtems_termios_initialize();
|
||||
|
||||
/*
|
||||
* Register Device Names
|
||||
*/
|
||||
|
||||
status = rtems_io_register_name( "/dev/console", major, 0 );
|
||||
if (status != RTEMS_SUCCESSFUL)
|
||||
rtems_fatal_error_occurred(status);
|
||||
|
||||
status = rtems_io_register_name( "/dev/console_b", major, 1 );
|
||||
if (status != RTEMS_SUCCESSFUL)
|
||||
rtems_fatal_error_occurred(status);
|
||||
|
||||
/*
|
||||
* Initialize Hardware
|
||||
*/
|
||||
|
||||
LEON_REG.UART_Control_1 |= LEON_REG_UART_CTRL_RE | LEON_REG_UART_CTRL_TE;
|
||||
LEON_REG.UART_Control_2 |= LEON_REG_UART_CTRL_RE | LEON_REG_UART_CTRL_TE |
|
||||
LEON_REG_UART_CTRL_RI; /* rx irq default enable for remote debugger */
|
||||
LEON_REG.UART_Status_1 = 0;
|
||||
LEON_REG.UART_Status_2 = 0;
|
||||
#if (CONSOLE_USE_INTERRUPTS)
|
||||
console_initialize_interrupts();
|
||||
#endif
|
||||
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
rtems_device_driver console_open(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void * arg
|
||||
)
|
||||
{
|
||||
rtems_status_code sc;
|
||||
#if (CONSOLE_USE_INTERRUPTS)
|
||||
rtems_libio_open_close_args_t *args = arg;
|
||||
static const rtems_termios_callbacks intrCallbacks = {
|
||||
NULL, /* firstOpen */
|
||||
NULL, /* lastClose */
|
||||
NULL, /* pollRead */
|
||||
console_write_support, /* write */
|
||||
NULL, /* setAttributes */
|
||||
NULL, /* stopRemoteTx */
|
||||
NULL, /* startRemoteTx */
|
||||
0 /* outputUsesInterrupts */
|
||||
};
|
||||
#else
|
||||
static const rtems_termios_callbacks pollCallbacks = {
|
||||
NULL, /* firstOpen */
|
||||
NULL, /* lastClose */
|
||||
console_inbyte_nonblocking, /* pollRead */
|
||||
console_write_support, /* write */
|
||||
NULL, /* setAttributes */
|
||||
NULL, /* stopRemoteTx */
|
||||
NULL, /* startRemoteTx */
|
||||
0 /* outputUsesInterrupts */
|
||||
};
|
||||
#endif
|
||||
|
||||
assert( minor <= 1 );
|
||||
if ( minor > 2 )
|
||||
return RTEMS_INVALID_NUMBER;
|
||||
|
||||
#if (CONSOLE_USE_INTERRUPTS)
|
||||
sc = rtems_termios_open (major, minor, arg, &intrCallbacks);
|
||||
|
||||
console_termios_data[ minor ] = args->iop->data1;
|
||||
#else
|
||||
sc = rtems_termios_open (major, minor, arg, &pollCallbacks);
|
||||
#endif
|
||||
(void) sc; /* avoid set but not used warning */
|
||||
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
rtems_device_driver console_close(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void * arg
|
||||
)
|
||||
{
|
||||
return rtems_termios_close (arg);
|
||||
}
|
||||
|
||||
rtems_device_driver console_read(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void * arg
|
||||
)
|
||||
{
|
||||
return rtems_termios_read (arg);
|
||||
}
|
||||
|
||||
rtems_device_driver console_write(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void * arg
|
||||
)
|
||||
{
|
||||
return rtems_termios_write (arg);
|
||||
}
|
||||
|
||||
rtems_device_driver console_control(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void * arg
|
||||
)
|
||||
{
|
||||
return rtems_termios_ioctl (arg);
|
||||
}
|
||||
|
||||
/* putchar/getchar for printk */
|
||||
|
||||
static void bsp_out_char (char c)
|
||||
{
|
||||
console_outbyte_polled(0, c);
|
||||
}
|
||||
|
||||
BSP_output_char_function_type BSP_output_char = bsp_out_char;
|
||||
|
||||
static int bsp_in_char(void)
|
||||
{
|
||||
int tmp;
|
||||
|
||||
while ((tmp = console_inbyte_nonblocking(0)) < 0);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
BSP_polling_getchar_function_type BSP_poll_char = bsp_in_char;
|
||||
87
bsps/sparc/leon2/console/debugputs.c
Normal file
87
bsps/sparc/leon2/console/debugputs.c
Normal file
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
* @file
|
||||
* @ingroup sparc_leon2
|
||||
* @brief TTY driver for the serial ports on the LEON
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file contains the TTY driver for the serial ports on the LEON.
|
||||
*
|
||||
* This driver uses the termios pseudo driver.
|
||||
*
|
||||
* COPYRIGHT (c) 1989-1999.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <bsp.h>
|
||||
#include <rtems/libio.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
/*
|
||||
* Method is shared with console.c
|
||||
*/
|
||||
void console_outbyte_polled( int port, unsigned char ch );
|
||||
int console_inbyte_nonblocking( int port );
|
||||
|
||||
/*
|
||||
* console_outbyte_polled
|
||||
*
|
||||
* This routine transmits a character using polling.
|
||||
*/
|
||||
|
||||
void console_outbyte_polled(
|
||||
int port,
|
||||
unsigned char ch
|
||||
)
|
||||
{
|
||||
if ( port == 0 ) {
|
||||
while ( (LEON_REG.UART_Status_1 & LEON_REG_UART_STATUS_THE) == 0 );
|
||||
LEON_REG.UART_Channel_1 = (unsigned int) ch;
|
||||
return;
|
||||
}
|
||||
|
||||
while ( (LEON_REG.UART_Status_2 & LEON_REG_UART_STATUS_THE) == 0 );
|
||||
LEON_REG.UART_Channel_2 = (unsigned int) ch;
|
||||
}
|
||||
|
||||
/*
|
||||
* console_inbyte_nonblocking
|
||||
*
|
||||
* This routine polls for a character.
|
||||
*/
|
||||
|
||||
int console_inbyte_nonblocking( int port )
|
||||
{
|
||||
|
||||
switch (port) {
|
||||
|
||||
case 0:
|
||||
if (LEON_REG.UART_Status_1 & LEON_REG_UART_STATUS_ERR) {
|
||||
LEON_REG.UART_Status_1 = ~LEON_REG_UART_STATUS_ERR;
|
||||
}
|
||||
|
||||
if ((LEON_REG.UART_Status_1 & LEON_REG_UART_STATUS_DR) == 0)
|
||||
return -1;
|
||||
return (int) LEON_REG.UART_Channel_1;
|
||||
return 1;
|
||||
|
||||
case 1:
|
||||
if (LEON_REG.UART_Status_2 & LEON_REG_UART_STATUS_ERR) {
|
||||
LEON_REG.UART_Status_2 = ~LEON_REG_UART_STATUS_ERR;
|
||||
}
|
||||
|
||||
if ((LEON_REG.UART_Status_2 & LEON_REG_UART_STATUS_DR) == 0)
|
||||
return -1;
|
||||
return (int) LEON_REG.UART_Channel_2;
|
||||
|
||||
default:
|
||||
assert( 0 );
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
160
bsps/sparc/leon3/console/console.c
Normal file
160
bsps/sparc/leon3/console/console.c
Normal file
@@ -0,0 +1,160 @@
|
||||
/*
|
||||
* This file contains the TTY driver for the serial ports on the LEON.
|
||||
*
|
||||
* This driver uses the termios pseudo driver.
|
||||
*
|
||||
* COPYRIGHT (c) 1989-1998.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
*
|
||||
* Modified for LEON3 BSP.
|
||||
* COPYRIGHT (c) 2004.
|
||||
* Gaisler Research.
|
||||
*
|
||||
* 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 CONSOLE_USE_INTERRUPTS to enable APBUART interrupt handling instead
|
||||
* of polling mode.
|
||||
*
|
||||
* Note that it is not possible to use the interrupt mode of the driver
|
||||
* together with the "old" APBUART and -u to GRMON. However the new
|
||||
* APBUART core (from GRLIB 1.0.17-b2710) has the GRMON debug bit and can
|
||||
* handle interrupts.
|
||||
*
|
||||
* NOTE: This can be defined in the make/custom/leon3.cfg file.
|
||||
*/
|
||||
|
||||
#include <bsp.h>
|
||||
#include <bsp/fatal.h>
|
||||
#include <bsp/apbuart_termios.h>
|
||||
#include <rtems/console.h>
|
||||
#include <string.h>
|
||||
|
||||
/* The LEON3 BSP UART driver can rely on the Driver Manager if the
|
||||
* DrvMgr is initialized during startup. Otherwise the classic driver
|
||||
* must be used.
|
||||
*
|
||||
* The DrvMgr APBUART driver is located in the shared/uart directory
|
||||
*/
|
||||
#ifndef RTEMS_DRVMGR_STARTUP
|
||||
|
||||
int syscon_uart_index __attribute__((weak)) = 0;
|
||||
|
||||
/* body is in debugputs.c */
|
||||
static struct apbuart_context apbuarts[BSP_NUMBER_OF_TERMIOS_PORTS];
|
||||
static int uarts = 0;
|
||||
|
||||
static rtems_termios_device_context *leon3_console_get_context(int index)
|
||||
{
|
||||
struct apbuart_context *uart = &apbuarts[index];
|
||||
|
||||
rtems_termios_device_context_initialize(&uart->base, "APBUART");
|
||||
|
||||
return &uart->base;
|
||||
}
|
||||
|
||||
/* AMBA PP find routine. Extract AMBA PnP information into data structure. */
|
||||
static int find_matching_apbuart(struct ambapp_dev *dev, int index, void *arg)
|
||||
{
|
||||
struct ambapp_apb_info *apb = (struct ambapp_apb_info *)dev->devinfo;
|
||||
|
||||
/* Extract needed information of one APBUART */
|
||||
apbuarts[uarts].regs = (struct apbuart_regs *)apb->start;
|
||||
apbuarts[uarts].irq = apb->irq;
|
||||
/* Get APBUART core frequency, it is assumed that it is the same
|
||||
* as Bus frequency where the UART is situated
|
||||
*/
|
||||
apbuarts[uarts].freq_hz = ambapp_freq_get(&ambapp_plb, dev);
|
||||
uarts++;
|
||||
|
||||
if (uarts >= BSP_NUMBER_OF_TERMIOS_PORTS)
|
||||
return 1; /* Satisfied number of UARTs, stop search */
|
||||
else
|
||||
return 0; /* Continue searching for more UARTs */
|
||||
}
|
||||
|
||||
/* Find all UARTs */
|
||||
static void leon3_console_scan_uarts(void)
|
||||
{
|
||||
memset(apbuarts, 0, sizeof(apbuarts));
|
||||
|
||||
/* Find APBUART cores */
|
||||
ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_APB_SLVS), VENDOR_GAISLER,
|
||||
GAISLER_APBUART, find_matching_apbuart, NULL);
|
||||
}
|
||||
|
||||
rtems_device_driver console_initialize(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *arg
|
||||
)
|
||||
{
|
||||
const rtems_termios_device_handler *handler =
|
||||
#if CONSOLE_USE_INTERRUPTS
|
||||
&apbuart_handler_interrupt;
|
||||
#else
|
||||
&apbuart_handler_polled;
|
||||
#endif
|
||||
rtems_status_code status;
|
||||
int i;
|
||||
char console_name[16];
|
||||
|
||||
rtems_termios_initialize();
|
||||
|
||||
/* Find UARTs */
|
||||
leon3_console_scan_uarts();
|
||||
|
||||
/* Update syscon_uart_index to index used as /dev/console
|
||||
* Let user select System console by setting syscon_uart_index. If the
|
||||
* BSP is to provide the default UART (syscon_uart_index==0):
|
||||
* non-MP: APBUART[0] is system console
|
||||
* MP: LEON CPU index select UART
|
||||
*/
|
||||
if (syscon_uart_index == 0) {
|
||||
#if defined(RTEMS_MULTIPROCESSING)
|
||||
syscon_uart_index = LEON3_Cpu_Index;
|
||||
#else
|
||||
syscon_uart_index = 0;
|
||||
#endif
|
||||
} else {
|
||||
syscon_uart_index = syscon_uart_index - 1; /* User selected sys-console */
|
||||
}
|
||||
|
||||
/* Register Device Names
|
||||
*
|
||||
* 0 /dev/console - APBUART[USER-SELECTED, DEFAULT=APBUART[0]]
|
||||
* 1 /dev/console_a - APBUART[0] (by default not present because is console)
|
||||
* 2 /dev/console_b - APBUART[1]
|
||||
* ...
|
||||
*
|
||||
* On a MP system one should not open UARTs that other OS instances use.
|
||||
*/
|
||||
if (syscon_uart_index < uarts) {
|
||||
status = rtems_termios_device_install(
|
||||
CONSOLE_DEVICE_NAME,
|
||||
handler,
|
||||
NULL,
|
||||
leon3_console_get_context(syscon_uart_index)
|
||||
);
|
||||
if (status != RTEMS_SUCCESSFUL)
|
||||
bsp_fatal(LEON3_FATAL_CONSOLE_REGISTER_DEV);
|
||||
}
|
||||
strcpy(console_name,"/dev/console_a");
|
||||
for (i = 0; i < uarts; i++) {
|
||||
if (i == syscon_uart_index)
|
||||
continue; /* skip UART that is registered as /dev/console */
|
||||
console_name[13] = 'a' + i;
|
||||
rtems_termios_device_install(
|
||||
console_name,
|
||||
handler,
|
||||
NULL,
|
||||
leon3_console_get_context(i)
|
||||
);
|
||||
}
|
||||
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
#endif
|
||||
119
bsps/sparc/leon3/console/printk_support.c
Normal file
119
bsps/sparc/leon3/console/printk_support.c
Normal file
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* This file contains the TTY driver for the serial ports on the LEON.
|
||||
*
|
||||
* This driver uses the termios pseudo driver.
|
||||
*
|
||||
* COPYRIGHT (c) 1989-1999.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
*
|
||||
* Modified for LEON3 BSP.
|
||||
* COPYRIGHT (c) 2011.
|
||||
* Aeroflex Gaisler.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <bsp.h>
|
||||
#include <leon.h>
|
||||
#include <rtems/libio.h>
|
||||
#include <rtems/sysinit.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <bsp/apbuart.h>
|
||||
#include <bsp/apbuart_termios.h>
|
||||
|
||||
int leon3_debug_uart_index __attribute__((weak)) = 0;
|
||||
struct apbuart_regs *leon3_debug_uart = NULL;
|
||||
|
||||
/* Before UART driver has registered (or when no UART is available), calls to
|
||||
* printk that gets to bsp_out_char() will be filling data into the
|
||||
* pre_printk_dbgbuf[] buffer, hopefully the buffer can help debugging the
|
||||
* early BSP boot.. At least the last printk() will be caught.
|
||||
*/
|
||||
static char pre_printk_dbgbuf[32] = {0};
|
||||
static int pre_printk_pos = 0;
|
||||
|
||||
/* Initialize the BSP system debug console layer. It will scan AMBA Plu&Play
|
||||
* for a debug APBUART and enable RX/TX for that UART.
|
||||
*/
|
||||
static void bsp_debug_uart_init(void)
|
||||
{
|
||||
int i;
|
||||
struct ambapp_dev *adev;
|
||||
struct ambapp_apb_info *apb;
|
||||
|
||||
/* Update leon3_debug_uart_index to index used as debug console. Let user
|
||||
* select Debug console by setting leon3_debug_uart_index. If the BSP is to
|
||||
* provide the default UART (leon3_debug_uart_index==0):
|
||||
* non-MP: APBUART[0] is debug console
|
||||
* MP: LEON CPU index select UART
|
||||
*/
|
||||
if (leon3_debug_uart_index == 0) {
|
||||
#if defined(RTEMS_MULTIPROCESSING)
|
||||
leon3_debug_uart_index = LEON3_Cpu_Index;
|
||||
#else
|
||||
leon3_debug_uart_index = 0;
|
||||
#endif
|
||||
} else {
|
||||
leon3_debug_uart_index--; /* User selected dbg-console */
|
||||
}
|
||||
|
||||
/* Find APBUART core for System Debug Console */
|
||||
i = leon3_debug_uart_index;
|
||||
adev = (void *)ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_APB_SLVS),
|
||||
VENDOR_GAISLER, GAISLER_APBUART,
|
||||
ambapp_find_by_idx, (void *)&i);
|
||||
if (adev) {
|
||||
/* Found a matching debug console, initialize debug uart if present
|
||||
* for printk
|
||||
*/
|
||||
apb = (struct ambapp_apb_info *)adev->devinfo;
|
||||
leon3_debug_uart = (struct apbuart_regs *)apb->start;
|
||||
leon3_debug_uart->ctrl |= APBUART_CTRL_RE | APBUART_CTRL_TE;
|
||||
leon3_debug_uart->status = 0;
|
||||
}
|
||||
}
|
||||
|
||||
RTEMS_SYSINIT_ITEM(
|
||||
bsp_debug_uart_init,
|
||||
RTEMS_SYSINIT_BSP_START,
|
||||
RTEMS_SYSINIT_ORDER_FOURTH
|
||||
);
|
||||
|
||||
/* putchar/getchar for printk */
|
||||
static void bsp_out_char(char c)
|
||||
{
|
||||
if (leon3_debug_uart == NULL) {
|
||||
/* Local debug buffer when UART driver has not registered */
|
||||
pre_printk_dbgbuf[pre_printk_pos++] = c;
|
||||
pre_printk_pos = pre_printk_pos & (sizeof(pre_printk_dbgbuf)-1);
|
||||
return;
|
||||
}
|
||||
|
||||
apbuart_outbyte_polled(leon3_debug_uart, c, 1, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* To support printk
|
||||
*/
|
||||
|
||||
#include <rtems/bspIo.h>
|
||||
|
||||
BSP_output_char_function_type BSP_output_char = bsp_out_char;
|
||||
|
||||
static int bsp_in_char(void)
|
||||
{
|
||||
int tmp;
|
||||
|
||||
if (leon3_debug_uart == NULL)
|
||||
return EOF;
|
||||
|
||||
while ((tmp = apbuart_inbyte_nonblocking(leon3_debug_uart)) < 0)
|
||||
;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
BSP_polling_getchar_function_type BSP_poll_char = bsp_in_char;
|
||||
Reference in New Issue
Block a user