forked from Imagelibrary/rtems
Simplify and unify BSP_output_char
The BSP_output_char should output a char and not mingle with high level processing, e.g. '\n' to '\r\n' translation. Move this translation to rtems_putc(). Remove it from all the BSP_output_char implementations. Close #3122.
This commit is contained in:
@@ -150,10 +150,6 @@ static void output_char(char c)
|
||||
{
|
||||
rtems_termios_device_context *ctx = console_device_table[0].context;
|
||||
|
||||
if (c == '\n') {
|
||||
ns16550_polled_putchar( ctx, '\r' );
|
||||
}
|
||||
|
||||
ns16550_polled_putchar( ctx, c );
|
||||
}
|
||||
|
||||
|
||||
@@ -20,10 +20,6 @@
|
||||
|
||||
static void atsam_debug_console_out(char c)
|
||||
{
|
||||
if (c == '\n') {
|
||||
DBG_PutChar('\r');
|
||||
}
|
||||
|
||||
DBG_PutChar((uint8_t) c);
|
||||
}
|
||||
|
||||
|
||||
@@ -136,9 +136,6 @@ static void uart_write_polled( char c )
|
||||
|
||||
static void _BSP_put_char( char c ) {
|
||||
uart_write_polled( c );
|
||||
if (c == '\n') {
|
||||
uart_write_polled('\r');
|
||||
}
|
||||
}
|
||||
|
||||
static int _BSP_get_char(void)
|
||||
|
||||
@@ -461,9 +461,6 @@ static void imx_uart_poll_write_char(int minor, char c)
|
||||
static void _BSP_output_char(char c)
|
||||
{
|
||||
poll_write(c);
|
||||
if (c == '\n') {
|
||||
poll_write('\r');
|
||||
}
|
||||
}
|
||||
|
||||
BSP_output_char_function_type BSP_output_char = _BSP_output_char;
|
||||
|
||||
@@ -61,15 +61,7 @@ static void imx_uart_write_polled(rtems_termios_device_context *base, char c)
|
||||
|
||||
static void imx_output_char(char c)
|
||||
{
|
||||
imx_uart_context *ctx;
|
||||
|
||||
ctx = imx_uart_console;
|
||||
|
||||
if (c == '\n') {
|
||||
imx_uart_write_polled(&ctx->base, '\r');
|
||||
}
|
||||
|
||||
imx_uart_write_polled(&ctx->base, c);
|
||||
imx_uart_write_polled(&imx_uart_console->base, c);
|
||||
}
|
||||
|
||||
static void imx_uart_init_context(
|
||||
|
||||
@@ -70,9 +70,6 @@ static void output_char(char c)
|
||||
const console_fns *con =
|
||||
Console_Configuration_Ports [Console_Port_Minor].pDeviceFns;
|
||||
|
||||
if (c == '\n') {
|
||||
con->deviceWritePolled((int) Console_Port_Minor, '\r');
|
||||
}
|
||||
con->deviceWritePolled((int) Console_Port_Minor, c);
|
||||
}
|
||||
|
||||
|
||||
@@ -60,9 +60,6 @@ static void output_char(char c)
|
||||
const console_fns *con =
|
||||
Console_Configuration_Ports [Console_Port_Minor].pDeviceFns;
|
||||
|
||||
if (c == '\n') {
|
||||
con->deviceWritePolled((int) Console_Port_Minor, '\r');
|
||||
}
|
||||
con->deviceWritePolled((int) Console_Port_Minor, c);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,10 +37,6 @@ static arm_pl050_context pl050_context = {
|
||||
|
||||
static void output_char(char c)
|
||||
{
|
||||
if (c == '\n') {
|
||||
arm_pl011_write_polled(&pl011_context.base, '\r');
|
||||
}
|
||||
|
||||
arm_pl011_write_polled(&pl011_context.base, c);
|
||||
}
|
||||
|
||||
|
||||
@@ -250,9 +250,6 @@ static int uart_set_attributes(int minor, const struct termios *t)
|
||||
static void _BSP_put_char( char c )
|
||||
{
|
||||
uart_write_polled(0, c);
|
||||
if (c == '\n') {
|
||||
uart_write_polled(0, '\r');
|
||||
}
|
||||
}
|
||||
|
||||
BSP_output_char_function_type BSP_output_char = _BSP_put_char;
|
||||
|
||||
@@ -294,7 +294,6 @@ void
|
||||
BSP_output_char_via_serial(int val)
|
||||
{
|
||||
BSP_uart_polled_write(BSPConsolePort, val);
|
||||
if (val == '\n') BSP_uart_polled_write(BSPConsolePort,'\r');
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -230,9 +230,6 @@ int uart_poll_read(int minor)
|
||||
*/
|
||||
static void _BSP_put_char( char c ) {
|
||||
uart_write_polled(0, c);
|
||||
if (c == '\n') {
|
||||
uart_write_polled(0, '\r');
|
||||
}
|
||||
}
|
||||
|
||||
BSP_output_char_function_type BSP_output_char = _BSP_put_char;
|
||||
|
||||
@@ -100,10 +100,7 @@ static void output_char(char c)
|
||||
{
|
||||
const console_fns *con =
|
||||
Console_Configuration_Ports [Console_Port_Minor].pDeviceFns;
|
||||
|
||||
if (c == '\n') {
|
||||
con->deviceWritePolled((int) Console_Port_Minor, '\r');
|
||||
}
|
||||
|
||||
con->deviceWritePolled((int) Console_Port_Minor, c);
|
||||
}
|
||||
|
||||
|
||||
@@ -65,10 +65,6 @@ static void tms570_debug_console_putc(char ch)
|
||||
*/
|
||||
static void tms570_debug_console_out(char c)
|
||||
{
|
||||
if ( c == '\n' ) {
|
||||
tms570_debug_console_putc('\r');
|
||||
}
|
||||
|
||||
tms570_debug_console_putc(c);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,10 +24,6 @@ static void zynq_debug_console_out(char c)
|
||||
rtems_termios_device_context *base =
|
||||
&zynq_uart_instances[BSP_CONSOLE_MINOR].base;
|
||||
|
||||
if (c == '\n') {
|
||||
zynq_uart_write_polled(base, '\r');
|
||||
}
|
||||
|
||||
zynq_uart_write_polled(base, c);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,11 +44,6 @@ void BSP_outch(char ch)
|
||||
console_tbl *port = Console_Port_Tbl[BSPPrintkPort];
|
||||
if (port->pDeviceFns && port->pDeviceFns->deviceWritePolled) {
|
||||
port->pDeviceFns->deviceWritePolled( BSPPrintkPort, ch );
|
||||
/*
|
||||
* No termios so expand the LF to LF/CR.
|
||||
*/
|
||||
if ( ch == '\n')
|
||||
port->pDeviceFns->deviceWritePolled( BSPPrintkPort, '\r' );
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -397,7 +397,6 @@ void
|
||||
BSP_output_char_via_serial(char val)
|
||||
{
|
||||
BSP_uart_polled_write(BSPConsolePort, val);
|
||||
if (val == '\n') BSP_uart_polled_write(BSPConsolePort,'\r');
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -29,8 +29,6 @@ static void _BSP_null_char( char c )
|
||||
{
|
||||
rtems_interrupt_level level;
|
||||
|
||||
if (c == '\n')
|
||||
_BSP_null_char('\r');
|
||||
rtems_interrupt_disable(level);
|
||||
while ( (MCF5282_UART_USR(CONSOLE_PORT) & MCF5282_UART_USR_TXRDY) == 0 )
|
||||
continue;
|
||||
|
||||
@@ -77,8 +77,6 @@ _BSP_null_char( char c )
|
||||
{
|
||||
int level;
|
||||
|
||||
if (c == '\n')
|
||||
_BSP_null_char('\r');
|
||||
rtems_interrupt_disable(level);
|
||||
while (!((MCF548X_PSC_SR(CONSOLE_PORT) & MCF548X_PSC_SR_TXRDY)))
|
||||
continue;
|
||||
|
||||
@@ -22,9 +22,6 @@ static void _BSP_null_char(char c)
|
||||
{
|
||||
rtems_interrupt_level level=UART0_IRQ_LEVEL;
|
||||
|
||||
if (c == '\n')
|
||||
_BSP_null_char('\r');
|
||||
|
||||
rtems_interrupt_disable(level);
|
||||
while ((MCF_UART_USR(CONSOLE_PORT) & MCF_UART_USR_TXRDY) == 0)
|
||||
continue;
|
||||
|
||||
@@ -30,8 +30,6 @@ _BSP_null_char( char c )
|
||||
{
|
||||
int level;
|
||||
|
||||
if (c == '\n')
|
||||
_BSP_null_char('\r');
|
||||
rtems_interrupt_disable(level);
|
||||
while ( (MCF5235_UART_USR(CONSOLE_PORT) & MCF5235_UART_USR_TXRDY) == 0 )
|
||||
continue;
|
||||
|
||||
@@ -30,8 +30,6 @@ static void _BSP_null_char(char c)
|
||||
{
|
||||
int level;
|
||||
|
||||
if (c == '\n')
|
||||
_BSP_null_char('\r');
|
||||
rtems_interrupt_disable(level);
|
||||
while ((MCF_UART_USR(CONSOLE_PORT) & MCF_UART_USR_TXRDY) == 0)
|
||||
continue;
|
||||
|
||||
@@ -1426,8 +1426,6 @@ void _BSP_output_char(char c)
|
||||
printk_minor = PRINTK_MINOR;
|
||||
|
||||
_167Bug_pollWrite(printk_minor, &c, 1);
|
||||
if ( c == '\n' )
|
||||
_167Bug_pollWrite(printk_minor, &cr_char, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -41,8 +41,6 @@ _BSP_null_char( char c )
|
||||
{
|
||||
int level;
|
||||
|
||||
if (c == '\n')
|
||||
_BSP_null_char('\r');
|
||||
rtems_interrupt_disable(level);
|
||||
while ( (MCF5282_UART_USR(CONSOLE_PORT) & MCF5282_UART_USR_TXRDY) == 0 )
|
||||
continue;
|
||||
|
||||
@@ -73,9 +73,6 @@ int console_inbyte_nonblocking(
|
||||
static void csb250_output_char(char c)
|
||||
{
|
||||
console_outbyte_polled( 0, c );
|
||||
if (c == '\n') {
|
||||
console_outbyte_polled( 0, '\r' );
|
||||
}
|
||||
}
|
||||
|
||||
static int csb250_get_char(void)
|
||||
|
||||
@@ -47,9 +47,6 @@ static void output_char(char c)
|
||||
const console_fns *con =
|
||||
Console_Configuration_Ports [Console_Port_Minor].pDeviceFns;
|
||||
|
||||
if (c == '\n') {
|
||||
con->deviceWritePolled((int) Console_Port_Minor, '\r');
|
||||
}
|
||||
con->deviceWritePolled((int) Console_Port_Minor, c);
|
||||
}
|
||||
|
||||
|
||||
@@ -637,9 +637,6 @@ static void A_BSP_output_char(
|
||||
#define PRINTK_WRITE mpc5200_uart_pollWrite
|
||||
|
||||
PRINTK_WRITE(PRINTK_MINOR, &c, 1 );
|
||||
|
||||
if( c == '\n' )
|
||||
PRINTK_WRITE( PRINTK_MINOR, &cr, 1 );
|
||||
}
|
||||
|
||||
static int A_BSP_get_char(void)
|
||||
|
||||
@@ -99,10 +99,6 @@ static void gen83xx_output_char(char c)
|
||||
{
|
||||
rtems_termios_device_context *ctx = console_device_table[0].context;
|
||||
|
||||
if (c == '\n') {
|
||||
ns16550_polled_putchar(ctx, '\r');
|
||||
}
|
||||
|
||||
ns16550_polled_putchar(ctx, c);
|
||||
}
|
||||
|
||||
|
||||
@@ -150,8 +150,6 @@ DirectUARTWrite(const char c)
|
||||
volatile uint8_t* up = (uint8_t*)(BSP_UART_IOBASE_COM1);
|
||||
while ((up[LSR] & THRE) == 0) { ; }
|
||||
up[THR] = c;
|
||||
if (c=='\n')
|
||||
DirectUARTWrite('\r');
|
||||
}
|
||||
|
||||
/* We will provide our own printk output function as it may get used early */
|
||||
|
||||
@@ -37,10 +37,6 @@ static void console_generic_char_out(char c)
|
||||
const console_generic_callbacks *cb =
|
||||
console_generic_info_table [minor].callbacks;
|
||||
|
||||
if (c == '\n') {
|
||||
(*cb->poll_write)(minor, '\r');
|
||||
}
|
||||
|
||||
(*cb->poll_write)(minor, c);
|
||||
}
|
||||
|
||||
|
||||
@@ -193,8 +193,6 @@ static rtems_status_code do_poll_write(
|
||||
|
||||
static void _BSP_output_char( char c )
|
||||
{
|
||||
char cr = '\r';
|
||||
|
||||
/*
|
||||
* Can't rely on console_initialize having been called before this function
|
||||
* is used, so it may fail unless output is done through EPPC-Bug.
|
||||
@@ -202,9 +200,6 @@ static void _BSP_output_char( char c )
|
||||
#define PRINTK_WRITE m8xx_uart_pollWrite
|
||||
|
||||
PRINTK_WRITE( PRINTK_MINOR, &c, 1 );
|
||||
if( c == '\n' )
|
||||
PRINTK_WRITE( PRINTK_MINOR, &cr, 1 );
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -183,10 +183,6 @@ static void output_char(char c)
|
||||
{
|
||||
rtems_termios_device_context *ctx = console_device_table[0].context;
|
||||
|
||||
if (c == '\n') {
|
||||
ns16550_polled_putchar(ctx, '\r');
|
||||
}
|
||||
|
||||
ns16550_polled_putchar(ctx, c);
|
||||
}
|
||||
|
||||
|
||||
@@ -426,8 +426,6 @@ void debug_putc(const u_char c)
|
||||
void
|
||||
debug_putc_onlcr(const char c)
|
||||
{
|
||||
if ('\n'==c)
|
||||
debug_putc('\r');
|
||||
debug_putc(c);
|
||||
}
|
||||
|
||||
@@ -525,7 +523,7 @@ void my_puts(const u_char *s)
|
||||
char c;
|
||||
|
||||
while ( ( c = *s++ ) != '\0' ) {
|
||||
debug_putc_onlcr((const char)c);
|
||||
rtems_putc(c);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -417,7 +417,6 @@ void
|
||||
BSP_output_char_via_serial(const char val)
|
||||
{
|
||||
BSP_uart_polled_write(BSPConsolePort, val);
|
||||
if (val == '\n') BSP_uart_polled_write(BSPConsolePort,'\r');
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -123,15 +123,6 @@ rtems_device_driver console_initialize(
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
static void t32_output_char(char c)
|
||||
{
|
||||
if (c == '\n') {
|
||||
t32_console_write_char_polled('\r');
|
||||
}
|
||||
|
||||
t32_console_write_char_polled(c);
|
||||
}
|
||||
|
||||
BSP_output_char_function_type BSP_output_char = t32_output_char;
|
||||
BSP_output_char_function_type BSP_output_char = t32_console_write_char_polled;
|
||||
|
||||
BSP_polling_getchar_function_type BSP_poll_char = NULL;
|
||||
|
||||
@@ -846,14 +846,10 @@ int BSP_output_chan = CONS_CHN_NONE; /* channel used for printk operation */
|
||||
static void console_debug_putc_onlcr(const char c)
|
||||
{
|
||||
rtems_interrupt_level irq_level;
|
||||
static char cr_chr = '\r';
|
||||
|
||||
if (BSP_output_chan != CONS_CHN_NONE) {
|
||||
rtems_interrupt_disable(irq_level);
|
||||
|
||||
if (c == '\n') {
|
||||
sccPollWrite (BSP_output_chan,&cr_chr,1);
|
||||
}
|
||||
sccPollWrite (BSP_output_chan,&c,1);
|
||||
rtems_interrupt_enable(irq_level);
|
||||
}
|
||||
|
||||
@@ -411,9 +411,6 @@ unsigned long Console_Configuration_Count =
|
||||
|
||||
static void outputChar(char ch)
|
||||
{
|
||||
if (ch == '\n') {
|
||||
xlite_write_char_polled( 0, '\r' );
|
||||
}
|
||||
xlite_write_char_polled( 0, ch );
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ ssize_t __bsp_memory_write(int minor, const char* buf, size_t len)
|
||||
const char* const last = buf+len;
|
||||
while (buf < last)
|
||||
{
|
||||
BSP_output_char(*buf++);
|
||||
rtems_putc(*buf++);
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ ssize_t __bsp_memory_write(int minor, const char* buf, size_t len)
|
||||
const char* const last = buf+len;
|
||||
while (buf < last)
|
||||
{
|
||||
BSP_output_char(*buf++);
|
||||
rtems_putc(*buf++);
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
@@ -23,10 +23,6 @@ static void output_char(char c)
|
||||
Console_Port_Tbl[minor] : &Console_Configuration_Ports[minor];
|
||||
const console_fns *cf = ct->pDeviceFns;
|
||||
|
||||
if (c == '\n') {
|
||||
(*cf->deviceWritePolled)(minor, '\r');
|
||||
}
|
||||
|
||||
(*cf->deviceWritePolled)(minor, c);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,10 +35,6 @@ static void uart_output_raw(char c)
|
||||
|
||||
static void uart_output(char c)
|
||||
{
|
||||
if (c == '\n') {
|
||||
uart_output_raw('\r');
|
||||
}
|
||||
|
||||
uart_output_raw(c);
|
||||
}
|
||||
|
||||
|
||||
@@ -211,8 +211,6 @@ static int dbgu_poll_read(int minor)
|
||||
*/
|
||||
static void _BSP_put_char( char c ) {
|
||||
dbgu_write_polled(0, c);
|
||||
if ( c == '\n' )
|
||||
dbgu_write_polled(0, '\r');
|
||||
}
|
||||
|
||||
BSP_output_char_function_type BSP_output_char = _BSP_put_char;
|
||||
|
||||
@@ -659,9 +659,6 @@ static void mpc55xx_esci_output_char( char c)
|
||||
mpc55xx_esci_driver_entry *e = &mpc55xx_esci_driver_table [MPC55XX_ESCI_CONSOLE_MINOR];
|
||||
|
||||
mpc55xx_esci_interrupts_disable( e);
|
||||
if (c == '\n') {
|
||||
mpc55xx_esci_write_char( e, '\r');
|
||||
}
|
||||
mpc55xx_esci_write_char( e, c);
|
||||
mpc55xx_esci_interrupts_enable( e);
|
||||
}
|
||||
|
||||
@@ -55,6 +55,9 @@ typedef int (*BSP_polling_getchar_function_type) (void);
|
||||
/**
|
||||
* This variable points to the BSP provided method to output a
|
||||
* character for the purposes of debug output.
|
||||
*
|
||||
* It must output only the specific character. It must not perform character
|
||||
* translations, e.g. "\n" to "\r\n".
|
||||
*/
|
||||
extern BSP_output_char_function_type BSP_output_char;
|
||||
|
||||
@@ -94,7 +97,8 @@ extern int vprintk(const char *fmt, va_list ap);
|
||||
/**
|
||||
* @brief Kernel Print
|
||||
*
|
||||
* This method allows the user to perform a debug printk().
|
||||
* This method allows the user to perform a debug printk(). It performs a
|
||||
* character translation from "\n" to "\r\n".
|
||||
*
|
||||
* @param[in] fmt is a printf()-style format string
|
||||
*
|
||||
@@ -116,7 +120,8 @@ extern int putk(const char *s);
|
||||
/**
|
||||
* @brief Kernel Put Character
|
||||
*
|
||||
* This method allows the user to perform a debug putc().
|
||||
* This method allows the user to perform a debug putc(). It performs a
|
||||
* character translation from "\n" to "\r\n".
|
||||
*
|
||||
* @param[in] c is the character to print
|
||||
*/
|
||||
|
||||
@@ -29,7 +29,7 @@ int putk(const char *s)
|
||||
int len_out = 0;
|
||||
|
||||
for (p=s ; *p ; p++, len_out++ )
|
||||
BSP_output_char(*p);
|
||||
BSP_output_char('\n');
|
||||
rtems_putc(*p);
|
||||
rtems_putc('\n');
|
||||
return len_out + 1;
|
||||
}
|
||||
|
||||
@@ -85,9 +85,6 @@ void termios_printk_outputchar
|
||||
/*
|
||||
* send character to debug serial port
|
||||
*/
|
||||
if (c == '\n') {
|
||||
termios_printk_tty->device.write(termios_printk_tty->minor,&cr,1);
|
||||
}
|
||||
termios_printk_tty->device.write(termios_printk_tty->minor,&c,1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user