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 <rtems/deviceio.h> |
---|
20 | |
---|
21 | #include <errno.h> |
---|
22 | |
---|
23 | static const int status_code_to_errno [RTEMS_STATUS_CODES_LAST + 1] = { |
---|
24 | [RTEMS_SUCCESSFUL] = 0, |
---|
25 | [RTEMS_TASK_EXITTED] = EIO, |
---|
26 | [RTEMS_MP_NOT_CONFIGURED] = EIO, |
---|
27 | [RTEMS_INVALID_NAME] = EINVAL, |
---|
28 | [RTEMS_INVALID_ID] = EIO, |
---|
29 | [RTEMS_TOO_MANY] = EIO, |
---|
30 | [RTEMS_TIMEOUT] = ETIMEDOUT, |
---|
31 | [RTEMS_OBJECT_WAS_DELETED] = EIO, |
---|
32 | [RTEMS_INVALID_SIZE] = EIO, |
---|
33 | [RTEMS_INVALID_ADDRESS] = EIO, |
---|
34 | [RTEMS_INVALID_NUMBER] = EBADF, |
---|
35 | [RTEMS_NOT_DEFINED] = EIO, |
---|
36 | [RTEMS_RESOURCE_IN_USE] = EBUSY, |
---|
37 | [RTEMS_UNSATISFIED] = ENODEV, |
---|
38 | [RTEMS_INCORRECT_STATE] = EIO, |
---|
39 | [RTEMS_ALREADY_SUSPENDED] = EIO, |
---|
40 | [RTEMS_ILLEGAL_ON_SELF] = EIO, |
---|
41 | [RTEMS_ILLEGAL_ON_REMOTE_OBJECT] = EIO, |
---|
42 | [RTEMS_CALLED_FROM_ISR] = EIO, |
---|
43 | [RTEMS_INVALID_PRIORITY] = EIO, |
---|
44 | [RTEMS_INVALID_CLOCK] = EINVAL, |
---|
45 | [RTEMS_INVALID_NODE] = EINVAL, |
---|
46 | [RTEMS_NOT_CONFIGURED] = ENOSYS, |
---|
47 | [RTEMS_NOT_OWNER_OF_RESOURCE] = EPERM, |
---|
48 | [RTEMS_NOT_IMPLEMENTED] = ENOSYS, |
---|
49 | [RTEMS_INTERNAL_ERROR] = EIO, |
---|
50 | [RTEMS_NO_MEMORY] = ENOMEM, |
---|
51 | [RTEMS_IO_ERROR] = EIO, |
---|
52 | [RTEMS_PROXY_BLOCKING] = EIO |
---|
53 | }; |
---|
54 | |
---|
55 | int rtems_deviceio_errno(rtems_status_code sc) |
---|
56 | { |
---|
57 | if (sc == RTEMS_SUCCESSFUL) { |
---|
58 | return 0; |
---|
59 | } else { |
---|
60 | int eno = EINVAL; |
---|
61 | |
---|
62 | if ((unsigned) sc <= RTEMS_STATUS_CODES_LAST) { |
---|
63 | eno = status_code_to_errno [sc]; |
---|
64 | } |
---|
65 | |
---|
66 | errno = eno; |
---|
67 | |
---|
68 | return -1; |
---|
69 | } |
---|
70 | } |
---|