Changeset 35b8f48a in rtems


Ignore:
Timestamp:
Dec 6, 2013, 6:21:20 PM (6 years ago)
Author:
Daniel Ramirez <javamonn@…>
Branches:
4.11, master
Children:
78c84df
Parents:
a77c3719
git-author:
Daniel Ramirez <javamonn@…> (12/06/13 18:21:20)
git-committer:
Joel Sherrill <joel.sherrill@…> (01/08/14 21:24:09)
Message:

libcsupport: Refactor rtems_deviceio_errno

Renames rtems_deviceio_errno to rtems_status_code_to_errno and
integrates it into the Classic API Status Handler. This function
can now be called by including status.h

Location:
cpukit
Files:
1 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libcsupport/Makefile.am

    ra77c3719 r35b8f48a  
    137137    src/sup_fs_node_type.c \
    138138    src/sup_fs_deviceio.c \
    139     src/sup_fs_deviceerrno.c \
    140139    src/clonenode.c \
    141140    src/freenode.c \
  • cpukit/libcsupport/include/rtems/deviceio.h

    ra77c3719 r35b8f48a  
    4040 * IMFS device nodes onto calls to the RTEMS Classic API IO Manager.
    4141 */
    42 int rtems_deviceio_errno( rtems_status_code status );
    43 
    4442int rtems_deviceio_open(
    4543  rtems_libio_t *iop,
  • cpukit/libcsupport/src/sup_fs_deviceio.c

    ra77c3719 r35b8f48a  
    77
    88/*
    9  *  COPYRIGHT (c) 1989-2012.
     9 *  COPYRIGHT (c) 1989-2013.
    1010 *  On-Line Applications Research Corporation (OAR).
    1111 *
     
    2020
    2121#include <rtems/deviceio.h>
     22#include <rtems/rtems/status.h>
    2223
    2324int rtems_deviceio_open(
     
    3940  status = rtems_io_open( major, minor, &args );
    4041
    41   return rtems_deviceio_errno( status );
     42  return rtems_status_code_to_errno( status );
    4243}
    4344
     
    5758  status = rtems_io_close( major, minor, &args );
    5859
    59   return rtems_deviceio_errno( status );
     60  return rtems_status_code_to_errno( status );
    6061}
    6162
     
    8485    return (ssize_t) args.bytes_moved;
    8586  } else {
    86     return rtems_deviceio_errno( status );
     87    return rtems_status_code_to_errno( status );
    8788  }
    8889}
     
    112113    return (ssize_t) args.bytes_moved;
    113114  } else {
    114     return rtems_deviceio_errno( status );
     115    return rtems_status_code_to_errno( status );
    115116  }
    116117}
     
    135136    return args.ioctl_return;
    136137  } else {
    137     return rtems_deviceio_errno(status);
     138    return rtems_status_code_to_errno(status);
    138139  }
    139140}
  • cpukit/rtems/include/rtems/rtems/status.h

    ra77c3719 r35b8f48a  
    218218}
    219219
     220/**
     221 *  @brief RTEMS Status Code to Errno Mapping Function
     222 *
     223 *  This function recieves an RTEMS status code and returns an
     224 *  errno error code. The retval values show the mappings between
     225 *  rtems_status_codes and errno error codes.
     226 *
     227 *  @retval 0 RTEMS_SUCCESSFUL
     228 *  @retval EIO RTEMS_TASK_EXITED, RTEMS_MP_NOT_CONFIGURED, RTEMS_INVALID_ID,
     229 *   RTEMS_TOO_MANY, RTEMS_OBJECT_WAS_DELETED, RTEMS_INVALID_SIZE,
     230 *   RTEMS_INVALID_ADDRESS, RTEMS_NOT_DEFINED, RTEMS_INCORRECT_STATE,
     231 *   RTEMS_ILLEGAL_ON_SELF, RTEMS_ILLEGAL_ON_REMOTE_OBJECT,
     232 *   RTEMS_CALLED_FROM_ISR, RTEMS_INVALID_PRIORITY, RTEMS_INTERNAL_ERROR,
     233 *   RTEMS_IO_ERROR, RTEMS_PROXY_BLOCKING
     234 *  @retval EINVAL RTEMS_INVALID_NAME, RTEMS_INVALID_CLOCK, RTEMS_INVALID_NODE
     235 *  @retval ETIMEDOUT RTEMS_TIMEOUT
     236 *  @retval EBADF RTEMS_INVALID_NUMBER
     237 *  @retval EBUSY RTEMS_RESOURCE_IN_USE
     238 *  @retval ENODEV RTEMS_UNSATISFIED
     239 *  @retval ENOSYS RTEMS_NOT_IMPLEMENTED, RTEMS_NOT_CONFIGURED
     240 *  @retval ENOMEM RTEMS_NO_MEMORY
     241 */
     242int rtems_status_code_to_errno(rtems_status_code sc);
     243
    220244/**@}*/
    221245
  • cpukit/rtems/src/status.c

    ra77c3719 r35b8f48a  
    22 *  @file
    33 *
    4  *  @brief Status Object Name Errors to Status Array
     4 *  @brief Status Mapping Arrays
    55 *  @ingroup ClassicStatus
    66 */
    77
    8 /*  COPYRIGHT (c) 1989-2008.
     8/*  COPYRIGHT (c) 1989-2013.
    99 *  On-Line Applications Research Corporation (OAR).
    1010 *
     
    1515
    1616#include <rtems/rtems/statusimpl.h>
     17#include <errno.h>
    1718
    1819const rtems_status_code _Status_Object_name_errors_to_status[] = {
     
    2829  RTEMS_INVALID_NODE
    2930};
     31
     32static const int status_code_to_errno [RTEMS_STATUS_CODES_LAST + 1] = {
     33  [RTEMS_SUCCESSFUL]               = 0,
     34  [RTEMS_TASK_EXITTED]             = EIO,
     35  [RTEMS_MP_NOT_CONFIGURED]        = EIO,
     36  [RTEMS_INVALID_NAME]             = EINVAL,
     37  [RTEMS_INVALID_ID]               = EIO,
     38  [RTEMS_TOO_MANY]                 = EIO,
     39  [RTEMS_TIMEOUT]                  = ETIMEDOUT,
     40  [RTEMS_OBJECT_WAS_DELETED]       = EIO,
     41  [RTEMS_INVALID_SIZE]             = EIO,
     42  [RTEMS_INVALID_ADDRESS]          = EIO,
     43  [RTEMS_INVALID_NUMBER]           = EBADF,
     44  [RTEMS_NOT_DEFINED]              = EIO,
     45  [RTEMS_RESOURCE_IN_USE]          = EBUSY,
     46  [RTEMS_UNSATISFIED]              = ENODEV,
     47  [RTEMS_INCORRECT_STATE]          = EIO,
     48  [RTEMS_ALREADY_SUSPENDED]        = EIO,
     49  [RTEMS_ILLEGAL_ON_SELF]          = EIO,
     50  [RTEMS_ILLEGAL_ON_REMOTE_OBJECT] = EIO,
     51  [RTEMS_CALLED_FROM_ISR]          = EIO,
     52  [RTEMS_INVALID_PRIORITY]         = EIO,
     53  [RTEMS_INVALID_CLOCK]            = EINVAL,
     54  [RTEMS_INVALID_NODE]             = EINVAL,
     55  [RTEMS_NOT_CONFIGURED]           = ENOSYS,
     56  [RTEMS_NOT_OWNER_OF_RESOURCE]    = EPERM,
     57  [RTEMS_NOT_IMPLEMENTED]          = ENOSYS,
     58  [RTEMS_INTERNAL_ERROR]           = EIO,
     59  [RTEMS_NO_MEMORY]                = ENOMEM,
     60  [RTEMS_IO_ERROR]                 = EIO,
     61  [RTEMS_PROXY_BLOCKING]           = EIO
     62};
     63
     64int rtems_status_code_to_errno(rtems_status_code sc)
     65{
     66  if (sc == RTEMS_SUCCESSFUL) {
     67    return 0;
     68  } else {
     69    int eno = EINVAL;
     70
     71    if ((unsigned) sc <= RTEMS_STATUS_CODES_LAST) {
     72      eno = status_code_to_errno [sc];
     73    }
     74
     75    errno = eno;
     76
     77    return -1;
     78  }
     79}
Note: See TracChangeset for help on using the changeset viewer.