|
| 1 | +/* |
| 2 | + * SPDX-License-Identifier: BSD-3-Clause |
| 3 | + * |
| 4 | + * Copyright © 2025 Keith Packard |
| 5 | + * |
| 6 | + * Redistribution and use in source and binary forms, with or without |
| 7 | + * modification, are permitted provided that the following conditions |
| 8 | + * are met: |
| 9 | + * |
| 10 | + * 1. Redistributions of source code must retain the above copyright |
| 11 | + * notice, this list of conditions and the following disclaimer. |
| 12 | + * |
| 13 | + * 2. Redistributions in binary form must reproduce the above |
| 14 | + * copyright notice, this list of conditions and the following |
| 15 | + * disclaimer in the documentation and/or other materials provided |
| 16 | + * with the distribution. |
| 17 | + * |
| 18 | + * 3. Neither the name of the copyright holder nor the names of its |
| 19 | + * contributors may be used to endorse or promote products derived |
| 20 | + * from this software without specific prior written permission. |
| 21 | + * |
| 22 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 23 | + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 24 | + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 25 | + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
| 26 | + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
| 27 | + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 28 | + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 29 | + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 30 | + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 31 | + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 32 | + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
| 33 | + * OF THE POSSIBILITY OF SUCH DAMAGE. |
| 34 | + */ |
| 35 | + |
| 36 | +#include <errno.h> |
| 37 | +#include "lm32_semihost.h" |
| 38 | + |
| 39 | +void |
| 40 | +lm32_errno(int err) |
| 41 | +{ |
| 42 | + switch (err) { |
| 43 | + case TARGET_NEWLIB_ERRNO_EPERM: errno = EPERM; break; |
| 44 | + case TARGET_NEWLIB_ERRNO_ENOENT: errno = ENOENT; break; |
| 45 | + case TARGET_NEWLIB_ERRNO_ESRCH: errno = ESRCH; break; |
| 46 | + case TARGET_NEWLIB_ERRNO_EINTR: errno = EINTR; break; |
| 47 | + case TARGET_NEWLIB_ERRNO_EIO: errno = EIO; break; |
| 48 | + case TARGET_NEWLIB_ERRNO_ENXIO: errno = ENXIO; break; |
| 49 | + case TARGET_NEWLIB_ERRNO_E2BIG: errno = E2BIG; break; |
| 50 | + case TARGET_NEWLIB_ERRNO_ENOEXEC: errno = ENOEXEC; break; |
| 51 | + case TARGET_NEWLIB_ERRNO_EBADF: errno = EBADF; break; |
| 52 | + case TARGET_NEWLIB_ERRNO_ECHILD: errno = ECHILD; break; |
| 53 | + case TARGET_NEWLIB_ERRNO_EAGAIN: errno = EAGAIN; break; |
| 54 | + case TARGET_NEWLIB_ERRNO_ENOMEM: errno = ENOMEM; break; |
| 55 | + case TARGET_NEWLIB_ERRNO_EACCES: errno = EACCES; break; |
| 56 | + case TARGET_NEWLIB_ERRNO_EFAULT: errno = EFAULT; break; |
| 57 | +// case TARGET_NEWLIB_ERRNO_ENOTBLK: errno = ENOTBLK; break; |
| 58 | + case TARGET_NEWLIB_ERRNO_EBUSY: errno = EBUSY; break; |
| 59 | + case TARGET_NEWLIB_ERRNO_EEXIST: errno = EEXIST; break; |
| 60 | + case TARGET_NEWLIB_ERRNO_EXDEV: errno = EXDEV; break; |
| 61 | + case TARGET_NEWLIB_ERRNO_ENODEV: errno = ENODEV; break; |
| 62 | + case TARGET_NEWLIB_ERRNO_ENOTDIR: errno = ENOTDIR; break; |
| 63 | + case TARGET_NEWLIB_ERRNO_EISDIR: errno = EISDIR; break; |
| 64 | + case TARGET_NEWLIB_ERRNO_EINVAL: errno = EINVAL; break; |
| 65 | + case TARGET_NEWLIB_ERRNO_ENFILE: errno = ENFILE; break; |
| 66 | + case TARGET_NEWLIB_ERRNO_EMFILE: errno = EMFILE; break; |
| 67 | + case TARGET_NEWLIB_ERRNO_ENOTTY: errno = ENOTTY; break; |
| 68 | + case TARGET_NEWLIB_ERRNO_ETXTBSY: errno = ETXTBSY; break; |
| 69 | + case TARGET_NEWLIB_ERRNO_EFBIG: errno = EFBIG; break; |
| 70 | + case TARGET_NEWLIB_ERRNO_ENOSPC: errno = ENOSPC; break; |
| 71 | + case TARGET_NEWLIB_ERRNO_ESPIPE: errno = ESPIPE; break; |
| 72 | + case TARGET_NEWLIB_ERRNO_EROFS: errno = EROFS; break; |
| 73 | + case TARGET_NEWLIB_ERRNO_EMLINK: errno = EMLINK; break; |
| 74 | + case TARGET_NEWLIB_ERRNO_EPIPE: errno = EPIPE; break; |
| 75 | + case TARGET_NEWLIB_ERRNO_EDOM: errno = EDOM; break; |
| 76 | + case TARGET_NEWLIB_ERRNO_ERANGE: errno = ERANGE; break; |
| 77 | + case TARGET_NEWLIB_ERRNO_ENOMSG: errno = ENOMSG; break; |
| 78 | + case TARGET_NEWLIB_ERRNO_EIDRM: errno = EIDRM; break; |
| 79 | +// case TARGET_NEWLIB_ERRNO_ECHRNG: errno = ECHRNG; break; |
| 80 | +// case TARGET_NEWLIB_ERRNO_EL2NSYNC: errno = EL2NSYNC; break; |
| 81 | +// case TARGET_NEWLIB_ERRNO_EL3HLT: errno = EL3HLT; break; |
| 82 | +// case TARGET_NEWLIB_ERRNO_EL3RST: errno = EL3RST; break; |
| 83 | +// case TARGET_NEWLIB_ERRNO_ELNRNG: errno = ELNRNG; break; |
| 84 | +// case TARGET_NEWLIB_ERRNO_EUNATCH: errno = EUNATCH; break; |
| 85 | +// case TARGET_NEWLIB_ERRNO_ENOCSI: errno = ENOCSI; break; |
| 86 | +// case TARGET_NEWLIB_ERRNO_EL2HLT: errno = EL2HLT; break; |
| 87 | + case TARGET_NEWLIB_ERRNO_EDEADLK: errno = EDEADLK; break; |
| 88 | + case TARGET_NEWLIB_ERRNO_ENOLCK: errno = ENOLCK; break; |
| 89 | +// case TARGET_NEWLIB_ERRNO_EBADE: errno = EBADE; break; |
| 90 | +// case TARGET_NEWLIB_ERRNO_EBADR: errno = EBADR; break; |
| 91 | +// case TARGET_NEWLIB_ERRNO_EXFULL: errno = EXFULL; break; |
| 92 | +// case TARGET_NEWLIB_ERRNO_ENOANO: errno = ENOANO; break; |
| 93 | +// case TARGET_NEWLIB_ERRNO_EBADRQC: errno = EBADRQC; break; |
| 94 | +// case TARGET_NEWLIB_ERRNO_EBADSLT: errno = EBADSLT; break; |
| 95 | +// case TARGET_NEWLIB_ERRNO_EDEADLOCK: errno = EDEADLOCK; break; |
| 96 | +// case TARGET_NEWLIB_ERRNO_EBFONT: errno = EBFONT; break; |
| 97 | + case TARGET_NEWLIB_ERRNO_ENOSTR: errno = ENOSTR; break; |
| 98 | + case TARGET_NEWLIB_ERRNO_ENODATA: errno = ENODATA; break; |
| 99 | + case TARGET_NEWLIB_ERRNO_ETIME: errno = ETIME; break; |
| 100 | + case TARGET_NEWLIB_ERRNO_ENOSR: errno = ENOSR; break; |
| 101 | +// case TARGET_NEWLIB_ERRNO_ENONET: errno = ENONET; break; |
| 102 | +// case TARGET_NEWLIB_ERRNO_ENOPKG: errno = ENOPKG; break; |
| 103 | +// case TARGET_NEWLIB_ERRNO_EREMOTE: errno = EREMOTE; break; |
| 104 | + case TARGET_NEWLIB_ERRNO_ENOLINK: errno = ENOLINK; break; |
| 105 | +// case TARGET_NEWLIB_ERRNO_EADV: errno = EADV; break; |
| 106 | +// case TARGET_NEWLIB_ERRNO_ESRMNT: errno = ESRMNT; break; |
| 107 | +// case TARGET_NEWLIB_ERRNO_ECOMM: errno = ECOMM; break; |
| 108 | + case TARGET_NEWLIB_ERRNO_EPROTO: errno = EPROTO; break; |
| 109 | + case TARGET_NEWLIB_ERRNO_EMULTIHOP: errno = EMULTIHOP; break; |
| 110 | +// case TARGET_NEWLIB_ERRNO_ELBIN: errno = ELBIN; break; |
| 111 | +// case TARGET_NEWLIB_ERRNO_EDOTDOT: errno = EDOTDOT; break; |
| 112 | + case TARGET_NEWLIB_ERRNO_EBADMSG: errno = EBADMSG; break; |
| 113 | +// case TARGET_NEWLIB_ERRNO_EFTYPE: errno = EFTYPE; break; |
| 114 | +// case TARGET_NEWLIB_ERRNO_ENOTUNIQ: errno = ENOTUNIQ; break; |
| 115 | +// case TARGET_NEWLIB_ERRNO_EBADFD: errno = EBADFD; break; |
| 116 | +// case TARGET_NEWLIB_ERRNO_EREMCHG: errno = EREMCHG; break; |
| 117 | +// case TARGET_NEWLIB_ERRNO_ELIBACC: errno = ELIBACC; break; |
| 118 | +// case TARGET_NEWLIB_ERRNO_ELIBBAD: errno = ELIBBAD; break; |
| 119 | +// case TARGET_NEWLIB_ERRNO_ELIBSCN: errno = ELIBSCN; break; |
| 120 | +// case TARGET_NEWLIB_ERRNO_ELIBMAX: errno = ELIBMAX; break; |
| 121 | +// case TARGET_NEWLIB_ERRNO_ELIBEXEC: errno = ELIBEXEC; break; |
| 122 | + case TARGET_NEWLIB_ERRNO_ENOSYS: errno = ENOSYS; break; |
| 123 | +// case TARGET_NEWLIB_ERRNO_ENMFILE: errno = ENMFILE; break; |
| 124 | + case TARGET_NEWLIB_ERRNO_ENOTEMPTY: errno = ENOTEMPTY; break; |
| 125 | + case TARGET_NEWLIB_ERRNO_ENAMETOOLONG: errno = ENAMETOOLONG; break; |
| 126 | + case TARGET_NEWLIB_ERRNO_ELOOP: errno = ELOOP; break; |
| 127 | + case TARGET_NEWLIB_ERRNO_EOPNOTSUPP: errno = EOPNOTSUPP; break; |
| 128 | +// case TARGET_NEWLIB_ERRNO_EPFNOSUPPORT: errno = EPFNOSUPPORT; break; |
| 129 | + case TARGET_NEWLIB_ERRNO_ECONNRESET: errno = ECONNRESET; break; |
| 130 | + case TARGET_NEWLIB_ERRNO_ENOBUFS: errno = ENOBUFS; break; |
| 131 | +// case TARGET_NEWLIB_ERRNO_EAFNOSUPPORT: errno = EAFNOSUPPORT; break; |
| 132 | + case TARGET_NEWLIB_ERRNO_EPROTOTYPE: errno = EPROTOTYPE; break; |
| 133 | + case TARGET_NEWLIB_ERRNO_ENOTSOCK: errno = ENOTSOCK; break; |
| 134 | + case TARGET_NEWLIB_ERRNO_ENOPROTOOPT: errno = ENOPROTOOPT; break; |
| 135 | +// case TARGET_NEWLIB_ERRNO_ESHUTDOWN: errno = ESHUTDOWN; break; |
| 136 | + case TARGET_NEWLIB_ERRNO_ECONNREFUSED: errno = ECONNREFUSED; break; |
| 137 | + case TARGET_NEWLIB_ERRNO_EADDRINUSE: errno = EADDRINUSE; break; |
| 138 | + case TARGET_NEWLIB_ERRNO_ECONNABORTED: errno = ECONNABORTED; break; |
| 139 | + case TARGET_NEWLIB_ERRNO_ENETUNREACH: errno = ENETUNREACH; break; |
| 140 | + case TARGET_NEWLIB_ERRNO_ENETDOWN: errno = ENETDOWN; break; |
| 141 | + case TARGET_NEWLIB_ERRNO_ETIMEDOUT: errno = ETIMEDOUT; break; |
| 142 | +// case TARGET_NEWLIB_ERRNO_EHOSTDOWN: errno = EHOSTDOWN; break; |
| 143 | + case TARGET_NEWLIB_ERRNO_EHOSTUNREACH: errno = EHOSTUNREACH; break; |
| 144 | + case TARGET_NEWLIB_ERRNO_EINPROGRESS: errno = EINPROGRESS; break; |
| 145 | + case TARGET_NEWLIB_ERRNO_EALREADY: errno = EALREADY; break; |
| 146 | + case TARGET_NEWLIB_ERRNO_EDESTADDRREQ: errno = EDESTADDRREQ; break; |
| 147 | + case TARGET_NEWLIB_ERRNO_EMSGSIZE: errno = EMSGSIZE; break; |
| 148 | + case TARGET_NEWLIB_ERRNO_EPROTONOSUPPORT: errno = EPROTONOSUPPORT; break; |
| 149 | +// case TARGET_NEWLIB_ERRNO_ESOCKTNOSUPPORT: errno = ESOCKTNOSUPPORT; break; |
| 150 | + case TARGET_NEWLIB_ERRNO_EADDRNOTAVAIL: errno = EADDRNOTAVAIL; break; |
| 151 | + case TARGET_NEWLIB_ERRNO_ENETRESET: errno = ENETRESET; break; |
| 152 | + case TARGET_NEWLIB_ERRNO_EISCONN: errno = EISCONN; break; |
| 153 | + case TARGET_NEWLIB_ERRNO_ENOTCONN: errno = ENOTCONN; break; |
| 154 | +// case TARGET_NEWLIB_ERRNO_ETOOMANYREFS: errno = ETOOMANYREFS; break; |
| 155 | +// case TARGET_NEWLIB_ERRNO_EPROCLIM: errno = EPROCLIM; break; |
| 156 | +// case TARGET_NEWLIB_ERRNO_EUSERS: errno = EUSERS; break; |
| 157 | + case TARGET_NEWLIB_ERRNO_EDQUOT: errno = EDQUOT; break; |
| 158 | + case TARGET_NEWLIB_ERRNO_ESTALE: errno = ESTALE; break; |
| 159 | + case TARGET_NEWLIB_ERRNO_ENOTSUP: errno = ENOTSUP; break; |
| 160 | +// case TARGET_NEWLIB_ERRNO_ENOMEDIUM: errno = ENOMEDIUM; break; |
| 161 | +// case TARGET_NEWLIB_ERRNO_ENOSHARE: errno = ENOSHARE; break; |
| 162 | +// case TARGET_NEWLIB_ERRNO_ECASECLASH: errno = ECASECLASH; break; |
| 163 | + case TARGET_NEWLIB_ERRNO_EILSEQ: errno = EILSEQ; break; |
| 164 | + case TARGET_NEWLIB_ERRNO_EOVERFLOW: errno = EOVERFLOW; break; |
| 165 | + case TARGET_NEWLIB_ERRNO_ECANCELED: errno = ECANCELED; break; |
| 166 | + case TARGET_NEWLIB_ERRNO_ENOTRECOVERABLE: errno = ENOTRECOVERABLE; break; |
| 167 | + case TARGET_NEWLIB_ERRNO_EOWNERDEAD: errno = EOWNERDEAD; break; |
| 168 | +// case TARGET_NEWLIB_ERRNO_ESTRPIPE: errno = ESTRPIPE; break; |
| 169 | +// case TARGET_NEWLIB_ERRNO_EHWPOISON: errno = EHWPOISON; break; |
| 170 | +// case TARGET_NEWLIB_ERRNO_EISNAM: errno = EISNAM; break; |
| 171 | +// case TARGET_NEWLIB_ERRNO_EKEYEXPIRED: errno = EKEYEXPIRED; break; |
| 172 | +// case TARGET_NEWLIB_ERRNO_EKEYREJECTED: errno = EKEYREJECTED; break; |
| 173 | +// case TARGET_NEWLIB_ERRNO_EKEYREVOKED: errno = EKEYREVOKED; break; |
| 174 | + default: break; |
| 175 | + } |
| 176 | +} |
0 commit comments