[d40da79b] | 1 | /* |
---|
| 2 | * IMFS Device Node Handlers |
---|
| 3 | * |
---|
| 4 | * This file contains the set of handlers used to map operations on |
---|
| 5 | * IMFS device nodes onto calls to the RTEMS Classic API IO Manager. |
---|
| 6 | * |
---|
| 7 | * COPYRIGHT (c) 1989-2008. |
---|
| 8 | * On-Line Applications Research Corporation (OAR). |
---|
| 9 | * |
---|
| 10 | * The license and distribution terms for this file may be |
---|
| 11 | * found in the file LICENSE in this distribution or at |
---|
| 12 | * http://www.rtems.com/license/LICENSE. |
---|
| 13 | */ |
---|
| 14 | |
---|
| 15 | #if HAVE_CONFIG_H |
---|
| 16 | #include "config.h" |
---|
| 17 | #endif |
---|
| 18 | |
---|
| 19 | #include <errno.h> |
---|
| 20 | |
---|
[78f4d6d7] | 21 | #include <rtems.h> |
---|
| 22 | #include <rtems/libio.h> |
---|
[326d83f] | 23 | #include <rtems/devfs.h> |
---|
[d40da79b] | 24 | |
---|
[78f4d6d7] | 25 | static const int status_code_to_errno [RTEMS_STATUS_CODES_LAST + 1] = { |
---|
| 26 | [RTEMS_SUCCESSFUL] = 0, |
---|
| 27 | [RTEMS_TASK_EXITTED] = EIO, |
---|
| 28 | [RTEMS_MP_NOT_CONFIGURED] = EIO, |
---|
| 29 | [RTEMS_INVALID_NAME] = EINVAL, |
---|
| 30 | [RTEMS_INVALID_ID] = EIO, |
---|
| 31 | [RTEMS_TOO_MANY] = EIO, |
---|
| 32 | [RTEMS_TIMEOUT] = ETIMEDOUT, |
---|
| 33 | [RTEMS_OBJECT_WAS_DELETED] = EIO, |
---|
| 34 | [RTEMS_INVALID_SIZE] = EIO, |
---|
| 35 | [RTEMS_INVALID_ADDRESS] = EIO, |
---|
| 36 | [RTEMS_INVALID_NUMBER] = EBADF, |
---|
| 37 | [RTEMS_NOT_DEFINED] = EIO, |
---|
| 38 | [RTEMS_RESOURCE_IN_USE] = EBUSY, |
---|
| 39 | [RTEMS_UNSATISFIED] = ENODEV, |
---|
| 40 | [RTEMS_INCORRECT_STATE] = EIO, |
---|
| 41 | [RTEMS_ALREADY_SUSPENDED] = EIO, |
---|
| 42 | [RTEMS_ILLEGAL_ON_SELF] = EIO, |
---|
| 43 | [RTEMS_ILLEGAL_ON_REMOTE_OBJECT] = EIO, |
---|
| 44 | [RTEMS_CALLED_FROM_ISR] = EIO, |
---|
| 45 | [RTEMS_INVALID_PRIORITY] = EIO, |
---|
[78d1190] | 46 | [RTEMS_INVALID_CLOCK] = EINVAL, |
---|
| 47 | [RTEMS_INVALID_NODE] = EINVAL, |
---|
| 48 | [RTEMS_NOT_CONFIGURED] = ENOSYS, |
---|
[78f4d6d7] | 49 | [RTEMS_NOT_OWNER_OF_RESOURCE] = EPERM, |
---|
| 50 | [RTEMS_NOT_IMPLEMENTED] = ENOSYS, |
---|
| 51 | [RTEMS_INTERNAL_ERROR] = EIO, |
---|
| 52 | [RTEMS_NO_MEMORY] = ENOMEM, |
---|
| 53 | [RTEMS_IO_ERROR] = EIO, |
---|
| 54 | [RTEMS_PROXY_BLOCKING] = EIO |
---|
[d40da79b] | 55 | }; |
---|
| 56 | |
---|
[78f4d6d7] | 57 | int rtems_deviceio_errno(rtems_status_code sc) |
---|
[d40da79b] | 58 | { |
---|
[78f4d6d7] | 59 | if (sc == RTEMS_SUCCESSFUL) { |
---|
| 60 | return 0; |
---|
| 61 | } else { |
---|
| 62 | int eno = EINVAL; |
---|
[d40da79b] | 63 | |
---|
[78f4d6d7] | 64 | if ((unsigned) sc <= RTEMS_STATUS_CODES_LAST) { |
---|
| 65 | eno = status_code_to_errno [sc]; |
---|
[d40da79b] | 66 | } |
---|
| 67 | |
---|
[78f4d6d7] | 68 | errno = eno; |
---|
[d40da79b] | 69 | |
---|
[78f4d6d7] | 70 | return -1; |
---|
| 71 | } |
---|
| 72 | } |
---|