Changeset b96bd98 in rtems


Ignore:
Timestamp:
Mar 3, 2009, 12:20:30 PM (11 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, master
Children:
eb7ee96
Parents:
f0f8e4d
Message:

2009-03-02 Joel Sherrill <joel.sherrill@…>

  • Makefile.am, console/console.c: Use shared polled console framework.
Location:
c/src/lib/libbsp/nios2/nios2_iss
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/nios2/nios2_iss/ChangeLog

    rf0f8e4d rb96bd98  
     12009-03-02      Joel Sherrill <joel.sherrill@oarcorp.com>
     2
     3        * Makefile.am, console/console.c: Use shared polled console framework.
     4
    152009-03-02      Joel Sherrill <joel.sherrill@oarcorp.com>
    26
  • c/src/lib/libbsp/nios2/nios2_iss/Makefile.am

    rf0f8e4d rb96bd98  
    4040libbsp_a_SOURCES += clock/clock.c ../../../shared/clockdrv_shell.h
    4141# console
    42 libbsp_a_SOURCES += console/console.c
     42libbsp_a_SOURCES += console/console.c ../../shared/console-polled.c
    4343# timer
    4444libbsp_a_SOURCES += timer/timer.c
  • c/src/lib/libbsp/nios2/nios2_iss/console/console.c

    rf0f8e4d rb96bd98  
    2222
    2323/* #define JTAG_UART_REGS ((altera_avalon_jtag_uart_regs*)NIOS2_IO_BASE(JTAG_UART_BASE)) */
    24 
    25 #if 0
    26 #define XOFFchar              0x13
    27 #define XONchar               0x11
    28 #endif
    29 
    30 /*  console_initialize
    31  *
    32  *  This routine initializes the console IO driver.
    33  *
    34  *  Input parameters: NONE
    35  *
    36  *  Output parameters:  NONE
    37  *
    38  *  Return values:
    39  */
    40 
    41 rtems_device_driver console_initialize(
    42   rtems_device_major_number  major,
    43   rtems_device_minor_number  minor,
    44   void                      *arg
    45 )
    46 {
    47   rtems_status_code status;
    48 
    49   status = rtems_io_register_name(
    50     "/dev/console",
    51     major,
    52     (rtems_device_minor_number) 0
    53   );
    54 
    55   if (status != RTEMS_SUCCESSFUL)
    56     rtems_fatal_error_occurred(status);
    57 
    58   return RTEMS_SUCCESSFUL;
    59 }
    6024
    6125/*  is_character_ready
     
    8953}
    9054
    91 /*  inbyte
    92  *
     55/*
    9356 *  This routine reads a character from the SOURCE.
    9457 *
     
    10164 */
    10265
    103 char inbyte( void )
     66int console_inbyte_nonblocking(
     67  int port
     68)
    10469{
    105     /*
    106      *  Wait until a character is available.
    107      */
    108     char ch;
    109     while(!is_character_ready(&ch));
     70  char ch;
     71  /*
     72   *  Wait until a character is available.
     73   */
     74
     75  if (is_character_ready(&ch))
    11076    return ch;
     77  return -1;
    11178}
    11279
    113 /*  outbyte
    114  *
     80/*
    11581 *  This routine transmits a character out the SOURCE.  It may support
    11682 *  XON/XOFF flow control.
     
    12288 */
    12389
    124 void outbyte(
     90void console_outbyte_polled(
     91  int  port,
    12592  char ch
    12693)
    12794{
    12895  altera_avalon_jtag_uart_regs *ajur = NIOS2_IO_BASE(JTAG_UART_BASE);
    129   /*
    130    *  Carriage Return/New line translation.
    131    */
    132 
    133   if ( ch == '\n' )
    134     outbyte( '\r' );
    135 
    13696  /*
    13797   *  Wait for the transmitter to be ready.
     
    146106
    147107/*
    148  *  Open entry point
    149  */
     108 *  *  To support printk
     109 *   */
    150110
    151 rtems_device_driver console_open(
    152   rtems_device_major_number major,
    153   rtems_device_minor_number minor,
    154   void                    * arg
    155 )
    156 {
    157   return RTEMS_SUCCESSFUL;
    158 }
     111#include <rtems/bspIo.h>
    159112
    160 /*
    161  *  Close entry point
    162  */
    163113
    164 rtems_device_driver console_close(
    165   rtems_device_major_number major,
    166   rtems_device_minor_number minor,
    167   void                    * arg
    168 )
    169 {
    170   return RTEMS_SUCCESSFUL;
    171 }
     114ISS_output_char(char c) { console_outbyte_polled( 0, c ); }
    172115
    173 /*
    174  * read bytes from the serial port. We only have stdin.
    175  */
     116BSP_output_char_function_type           BSP_output_char = ISS_output_char;
     117BSP_polling_getchar_function_type       BSP_poll_char = NULL;
    176118
    177 rtems_device_driver console_read(
    178   rtems_device_major_number major,
    179   rtems_device_minor_number minor,
    180   void                    * arg
    181 )
    182 {
    183   rtems_libio_rw_args_t *rw_args;
    184   char *buffer;
    185   int maximum;
    186   int count = 0;
    187 
    188   rw_args = (rtems_libio_rw_args_t *) arg;
    189 
    190   buffer = rw_args->buffer;
    191   maximum = rw_args->count;
    192 
    193   for (count = 0; count < maximum; count++) {
    194     buffer[ count ] = inbyte();
    195     if (buffer[ count ] == '\n' || buffer[ count ] == '\r') {
    196       buffer[ count++ ]  = '\n';
    197       break;
    198     }
    199   }
    200 
    201   rw_args->bytes_moved = count;
    202   return (count >= 0) ? RTEMS_SUCCESSFUL : RTEMS_UNSATISFIED;
    203 }
    204 
    205 /*
    206  * write bytes to the serial port. Stdout and stderr are the same.
    207  */
    208 
    209 rtems_device_driver console_write(
    210   rtems_device_major_number major,
    211   rtems_device_minor_number minor,
    212   void                    * arg
    213 )
    214 {
    215   int count;
    216   int maximum;
    217   rtems_libio_rw_args_t *rw_args;
    218   char *buffer;
    219 
    220   rw_args = (rtems_libio_rw_args_t *) arg;
    221 
    222   buffer = rw_args->buffer;
    223   maximum = rw_args->count;
    224 
    225   for (count = 0; count < maximum; count++) {
    226     if ( buffer[ count ] == '\n') {
    227       outbyte('\r');
    228     }
    229     outbyte( buffer[ count ] );
    230   }
    231 
    232   rw_args->bytes_moved = maximum;
    233   return 0;
    234 }
    235 
    236 /*
    237  *  IO Control entry point
    238  */
    239 
    240 rtems_device_driver console_control(
    241   rtems_device_major_number major,
    242   rtems_device_minor_number minor,
    243   void                    * arg
    244 )
    245 {
    246   return RTEMS_SUCCESSFUL;
    247 }
Note: See TracChangeset for help on using the changeset viewer.