Changeset 2e8b5de in rtems


Ignore:
Timestamp:
Dec 5, 2018, 12:02:59 PM (7 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
7fe5922a
Parents:
5bb1f3b2
git-author:
Sebastian Huber <sebastian.huber@…> (12/05/18 12:02:59)
git-committer:
Sebastian Huber <sebastian.huber@…> (12/05/18 12:06:07)
Message:

bsp/leon2: Move printk() support

Avoid assert() in console_inbyte_nonblocking().

Do not poll forever in bsp_in_char(). This allows the caller to decide
what to do if no character is available.

This entangles some dependencies and fixes a spconfig02 test failure.

Location:
bsps/sparc/leon2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • bsps/sparc/leon2/console/console.c

    r5bb1f3b2 r2e8b5de  
    2121#include <rtems/console.h>
    2222#include <rtems/libio.h>
    23 #include <rtems/bspIo.h>
    2423#include <bsp.h>
    25 
    26 /*
    27  *  console_outbyte_polled
    28  *
    29  *  This routine transmits a character using polling.
    30  */
    31 void console_outbyte_polled(
    32   int           port,
    33   unsigned char ch
    34 );
    35 
    36 /* body is in debugputs.c */
    37 
    38 /*
    39  *  console_inbyte_nonblocking
    40  *
    41  *  This routine polls for a character.
    42  */
    43 
    44 int console_inbyte_nonblocking( int port );
    45 
    46 /* body is in debugputs.c */
    4724
    4825/*
     
    417394  return rtems_termios_ioctl (arg);
    418395}
    419 
    420 /* putchar/getchar for printk */
    421 
    422 static void bsp_out_char (char c)
    423 {
    424   console_outbyte_polled(0, c);
    425 }
    426 
    427 BSP_output_char_function_type BSP_output_char = bsp_out_char;
    428 
    429 static int bsp_in_char(void)
    430 {
    431   int tmp;
    432 
    433   while ((tmp = console_inbyte_nonblocking(0)) < 0);
    434   return tmp;
    435 }
    436 
    437 BSP_polling_getchar_function_type BSP_poll_char = bsp_in_char;
  • bsps/sparc/leon2/console/debugputs.c

    r5bb1f3b2 r2e8b5de  
    1919
    2020#include <bsp.h>
    21 #include <rtems/libio.h>
    22 #include <stdlib.h>
    23 #include <assert.h>
     21#include <rtems/bspIo.h>
    2422
    25 /*
    26  *  Method is shared with console.c
    27  */
    28 void console_outbyte_polled( int port, unsigned char ch );
    29 int console_inbyte_nonblocking( int port );
    30 
    31 /*
    32  *  console_outbyte_polled
    33  *
    34  *  This routine transmits a character using polling.
    35  */
    36 
    37 void console_outbyte_polled(
    38   int  port,
    39   unsigned char ch
    40 )
     23void console_outbyte_polled( int port, unsigned char ch )
    4124{
    4225  if ( port == 0 ) {
     
    5033}
    5134
    52 /*
    53  *  console_inbyte_nonblocking
    54  *
    55  *  This routine polls for a character.
    56  */
    57 
    5835int console_inbyte_nonblocking( int port )
    5936{
     37  if ( port == 0 ) {
     38    if (LEON_REG.UART_Status_1 & LEON_REG_UART_STATUS_ERR) {
     39      LEON_REG.UART_Status_1 = ~LEON_REG_UART_STATUS_ERR;
     40    }
    6041
    61   switch (port) {
    62 
    63     case 0:
    64       if (LEON_REG.UART_Status_1 & LEON_REG_UART_STATUS_ERR) {
    65         LEON_REG.UART_Status_1 = ~LEON_REG_UART_STATUS_ERR;
    66       }
    67 
    68       if ((LEON_REG.UART_Status_1 & LEON_REG_UART_STATUS_DR) == 0)
    69          return -1;
    70       return (int) LEON_REG.UART_Channel_1;
    71       return 1;
    72 
    73     case 1:
    74       if (LEON_REG.UART_Status_2 & LEON_REG_UART_STATUS_ERR) {
    75         LEON_REG.UART_Status_2 = ~LEON_REG_UART_STATUS_ERR;
    76       }
    77 
    78       if ((LEON_REG.UART_Status_2 & LEON_REG_UART_STATUS_DR) == 0)
    79          return -1;
    80       return (int) LEON_REG.UART_Channel_2;
    81 
    82     default:
    83       assert( 0 );
     42    if ((LEON_REG.UART_Status_1 & LEON_REG_UART_STATUS_DR) == 0)
     43       return -1;
     44    return (int) LEON_REG.UART_Channel_1;
    8445  }
    8546
    86   return -1;
     47  if (LEON_REG.UART_Status_2 & LEON_REG_UART_STATUS_ERR) {
     48    LEON_REG.UART_Status_2 = ~LEON_REG_UART_STATUS_ERR;
     49  }
     50
     51  if ((LEON_REG.UART_Status_2 & LEON_REG_UART_STATUS_DR) == 0)
     52     return -1;
     53  return (int) LEON_REG.UART_Channel_2;
    8754}
     55
     56static void bsp_out_char( char c )
     57{
     58  console_outbyte_polled( 0, c );
     59}
     60
     61BSP_output_char_function_type BSP_output_char = bsp_out_char;
     62
     63static int bsp_in_char( void )
     64{
     65  return console_inbyte_nonblocking( 0 );
     66}
     67
     68BSP_polling_getchar_function_type BSP_poll_char = bsp_in_char;
  • bsps/sparc/leon2/include/bsp.h

    r5bb1f3b2 r2e8b5de  
    214214#define GRETH_INFO_AVAIL              /* GRETH Ethernet driver */
    215215
     216void console_outbyte_polled( int port, unsigned char ch );
     217
     218int console_inbyte_nonblocking( int port );
     219
    216220#ifdef __cplusplus
    217221}
Note: See TracChangeset for help on using the changeset viewer.