Changeset 6c58b6f in rtems


Ignore:
Timestamp:
Oct 15, 1996, 9:39:15 PM (25 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
fe6ef776
Parents:
39cafa5
Message:

updated to format of 3.6.0 console drivers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/i386/i386ex/console/console.c

    r39cafa5 r6c58b6f  
    11/*
    2  *  This file contains the Force CPU386 console IO package.
     2 *  This file contains the i386ex console IO package.
    33 *
    44 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
     
    1515#define F386_INIT
    1616
     17#include <bsp.h>
     18#include <rtems/libio.h>
     19 
    1720#include <stdlib.h>
    18 #include <stdio.h>   /* to be removed */
    19 
    20 #include <rtems.h>
    21 #include "console.h"
    22 #include "bsp.h"
     21
    2322#include "../startup/80386ex.h"
    2423
     
    4140
    4241   inport_byte( RBR0, ignored );
    43 
    44 /*  inport_byte( RBR0, ignored );
    45  *  inport_byte( RBR0, ignored );
    46  *  inport_byte( RBR0, ignored );
    47  *  inport_byte( RBR0, ignored );
    48  */
    4942
    5043}
     
    6457  rtems_device_major_number  major,
    6558  rtems_device_minor_number  minor,
    66   void                      *arg,
    67   rtems_id                   self,
    68   rtems_unsigned32          *status
    69 )
    70 {
    71    /*
    72     *  flush the console now and at exit.  Just in case.
    73     */
    74 
    75    console_cleanup();
    76 
    77    atexit( console_cleanup );
     59  void                      *arg
     60)
     61{
     62  rtems_status_code status;
     63
     64  /*
     65   *  flush the console now and at exit.  Just in case.
     66   */
     67
     68  console_cleanup();
     69
     70  status = rtems_io_register_name(
     71    "/dev/console",
     72    major,
     73    (rtems_device_minor_number) 0
     74  );
     75 
     76  if (status != RTEMS_SUCCESSFUL)
     77    rtems_fatal_error_occurred(status);
     78 
     79  atexit( console_cleanup );
     80
     81  return RTEMS_SUCCESSFUL;
    7882}
    7983
     
    174178
    175179/*
    176  * __read  -- read bytes from the serial port. Ignore fd, since
    177  *            we only have stdin.
    178  */
    179 
    180 int __read(
    181   int fd,
    182   char *buf,
    183   int nbytes
    184 )
    185 {
    186   int i = 0;
    187 
    188   for (i = 0; i < nbytes; i++) {
    189     *(buf + i) = inbyte();
    190     if ((*(buf + i) == '\n') || (*(buf + i) == '\r')) {
    191       (*(buf + i++)) = '\n';
    192       (*(buf + i)) = 0;
     180 *  Open entry point
     181 */
     182 
     183rtems_device_driver console_open(
     184  rtems_device_major_number major,
     185  rtems_device_minor_number minor,
     186  void                    * arg
     187)
     188{
     189  return RTEMS_SUCCESSFUL;
     190}
     191 
     192/*
     193 *  Close entry point
     194 */
     195 
     196rtems_device_driver console_close(
     197  rtems_device_major_number major,
     198  rtems_device_minor_number minor,
     199  void                    * arg
     200)
     201{
     202  return RTEMS_SUCCESSFUL;
     203}
     204 
     205/*
     206 * read bytes from the serial port. We only have stdin.
     207 */
     208 
     209rtems_device_driver console_read(
     210  rtems_device_major_number major,
     211  rtems_device_minor_number minor,
     212  void                    * arg
     213)
     214{
     215  rtems_libio_rw_args_t *rw_args;
     216  char *buffer;
     217  int maximum;
     218  int count = 0;
     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    buffer[ count ] = inbyte();
     227    if (buffer[ count ] == '\n' || buffer[ count ] == '\r') {
     228      buffer[ count++ ]  = '\n';
     229      buffer[ count ]  = 0;
    193230      break;
    194231    }
    195232  }
    196   return (i);
    197 }
    198 
    199 /*
    200  * __write -- write bytes to the serial port. Ignore fd, since
    201  *            stdout and stderr are the same. Since we have no filesystem,
    202  *            open will only return an error.
    203  */
    204 
    205 int __write(
    206   int fd,
    207   char *buf,
    208   int nbytes
    209 )
    210 {
    211   int i;
    212 
    213   for (i = 0; i < nbytes; i++) {
    214     if (*(buf + i) == '\n') {
    215       outbyte ('\r');
     233 
     234  rw_args->bytes_moved = count;
     235  return (count >= 0) ? RTEMS_SUCCESSFUL : RTEMS_UNSATISFIED;
     236}
     237
     238/*
     239 * write bytes to the serial port. Stdout and stderr are the same.
     240 */
     241 
     242rtems_device_driver console_write(
     243  rtems_device_major_number major,
     244  rtems_device_minor_number minor,
     245  void                    * arg
     246)
     247{
     248  int count;
     249  int maximum;
     250  rtems_libio_rw_args_t *rw_args;
     251  char *buffer;
     252 
     253  rw_args = (rtems_libio_rw_args_t *) arg;
     254 
     255  buffer = rw_args->buffer;
     256  maximum = rw_args->count;
     257 
     258  for (count = 0; count < maximum; count++) {
     259    if ( buffer[ count ] == '\n') {
     260      outbyte('\r');
    216261    }
    217     outbyte (*(buf + i));
    218   }
    219   return (nbytes);
    220 }
     262    outbyte( buffer[ count ] );
     263  }
     264 
     265  rw_args->bytes_moved = maximum;
     266  return 0;
     267}
     268 
     269/*
     270 *  IO Control entry point
     271 */
     272 
     273rtems_device_driver console_control(
     274  rtems_device_major_number major,
     275  rtems_device_minor_number minor,
     276  void                    * arg
     277)
     278{
     279  return RTEMS_SUCCESSFUL;
     280}
Note: See TracChangeset for help on using the changeset viewer.