Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / compat / mach / mach_errno.c
blobdacfa5cdd2614102999ed49a4bec174d281cb593
1 /* $NetBSD: mach_errno.c,v 1.17 2007/12/08 18:36:13 dsl Exp $ */
3 /*-
4 * Copyright (c) 2002 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Emmanuel Dreyfus
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #include <sys/cdefs.h>
33 __KERNEL_RCSID(0, "$NetBSD: mach_errno.c,v 1.17 2007/12/08 18:36:13 dsl Exp $");
35 #include <sys/types.h>
36 #include <sys/systm.h>
37 #include <sys/null.h>
38 #include <sys/queue.h>
39 #include <sys/errno.h>
41 #include <compat/mach/mach_types.h>
42 #include <compat/mach/mach_message.h>
43 #include <compat/mach/mach_errno.h>
45 int native_to_mach_errno[] = {
46 MACH_KERN_SUCCESS, /* 0 */
47 MACH_KERN_PROTECTION_FAILURE, /* EPERM */
48 MACH_KERN_FAILURE, /* ENOENT */
49 MACH_KERN_FAILURE, /* ESRCH */
50 MACH_KERN_FAILURE, /* EINTR */
51 MACH_KERN_FAILURE, /* EIO */ /* 5 */
52 MACH_KERN_FAILURE, /* ENXIO */
53 MACH_KERN_FAILURE, /* E2BIG */
54 MACH_KERN_FAILURE, /* ENOEXEC */
55 MACH_KERN_FAILURE, /* EBADF */
56 MACH_KERN_FAILURE, /* ECHILD */ /* 10 */
57 MACH_KERN_FAILURE, /* EDEADLK */
58 MACH_KERN_NO_SPACE, /* ENOMEM */
59 MACH_KERN_FAILURE, /* EACCES */
60 MACH_KERN_INVALID_ADDRESS, /* EFAULT */
61 MACH_KERN_FAILURE, /* ENOTBLK */ /* 15 */
62 MACH_KERN_FAILURE, /* EBUSY */
63 MACH_KERN_FAILURE, /* EEXIST */
64 MACH_KERN_FAILURE, /* EXDEV */
65 MACH_KERN_FAILURE, /* ENODEV */
66 MACH_KERN_FAILURE, /* ENOTDIR */ /* 20 */
67 MACH_KERN_FAILURE, /* EISDIR */
68 MACH_KERN_INVALID_ARGUMENT, /* EINVAL */
69 MACH_KERN_FAILURE, /* ENFILE */
70 MACH_KERN_FAILURE, /* EMFILE */
71 MACH_KERN_FAILURE, /* ENOTTY */ /* 25 */
72 MACH_KERN_FAILURE, /* ETXTBSY */
73 MACH_KERN_FAILURE, /* EFBIG */
74 MACH_KERN_FAILURE, /* ENOSPC */
75 MACH_KERN_FAILURE, /* ESPIPE */
76 MACH_KERN_FAILURE, /* EROFS */ /* 30 */
77 MACH_KERN_FAILURE, /* EMLINK */
78 MACH_KERN_FAILURE, /* EPIPE */
79 MACH_KERN_FAILURE, /* EDOM */
80 MACH_KERN_FAILURE, /* ERANGE */
81 MACH_KERN_FAILURE, /* EAGAIN */ /* 35 */
82 MACH_KERN_FAILURE, /* EWOULDBLOCK */
83 MACH_KERN_FAILURE, /* EINPROGRESS */
84 MACH_KERN_FAILURE, /* EALREADY */
85 MACH_KERN_FAILURE, /* ENOTSOCK */
86 MACH_KERN_FAILURE, /* EDESTADDRREQ */ /* 40 */
87 MACH_KERN_FAILURE, /* EMSGSIZE */
88 MACH_KERN_FAILURE, /* EPROTOTYPE */
89 MACH_KERN_FAILURE, /* ENOPROTOOPT */
90 MACH_KERN_FAILURE, /* ESOCKTNOSUPPORT */
91 MACH_KERN_FAILURE, /* EOPNOTSUPP */ /* 45 */
92 MACH_KERN_FAILURE, /* EPFNOSUPPORT */
93 MACH_KERN_FAILURE, /* EAFNOSUPPORT */
94 MACH_KERN_FAILURE, /* EADDRINUSE */
95 MACH_KERN_FAILURE, /* EADDRNOTAVAIL */
96 MACH_KERN_FAILURE, /* ENETDOWN */ /* 50 */
97 MACH_KERN_FAILURE, /* ENETUNREACH */
98 MACH_KERN_FAILURE, /* ENETRESET */
99 MACH_KERN_FAILURE, /* ECONNABORTED */
100 MACH_KERN_FAILURE, /* ECONNRESET */
101 MACH_KERN_FAILURE, /* ENOBUFS */ /* 55 */
102 MACH_KERN_FAILURE, /* EISCONN */
103 MACH_KERN_FAILURE, /* ENOTCONN */
104 MACH_KERN_FAILURE, /* ESHUTDOWN */
105 MACH_KERN_FAILURE, /* ETOOMANYREFS */
106 MACH_KERN_FAILURE, /* ETIMEDOUT */ /* 60 */
107 MACH_KERN_FAILURE, /* ECONNREFUSED */
108 MACH_KERN_FAILURE, /* ELOOP */
109 MACH_KERN_FAILURE, /* ENAMETOOLONG */
110 MACH_KERN_FAILURE, /* EHOSTDOWN */
111 MACH_KERN_FAILURE, /* EHOSTUNREACH */ /* 65 */
112 MACH_KERN_FAILURE, /* ENOTEMPTY */
113 MACH_KERN_FAILURE, /* EPROCLIM */
114 MACH_KERN_FAILURE, /* EUSERS */
115 MACH_KERN_FAILURE, /* EDQUOT */
116 MACH_KERN_FAILURE, /* ESTALE */ /* 70 */
117 MACH_KERN_FAILURE, /* EREMOTE */
118 MACH_KERN_FAILURE, /* EBADRPC */
119 MACH_KERN_FAILURE, /* ERPCMISMATCH */
120 MACH_KERN_FAILURE, /* EPROGUNAVAIL */
121 MACH_KERN_FAILURE, /* EPROGMISMATCH */ /* 75 */
122 MACH_KERN_FAILURE, /* EPROCUNAVAIL */
123 MACH_KERN_FAILURE, /* ENOLCK */
124 MACH_KERN_FAILURE, /* ENOSYS */
125 MACH_KERN_FAILURE, /* EFTYPE */
126 MACH_KERN_FAILURE, /* EAUTH */ /* 80 */
127 MACH_KERN_FAILURE, /* ENEEDAUTH */
128 MACH_KERN_FAILURE, /* EIDRM */
129 MACH_KERN_FAILURE, /* ENOMSG */
130 MACH_KERN_FAILURE, /* EOVERFLOW */
131 MACH_KERN_FAILURE, /* EILSEQ */ /* 85 */
135 mach_msg_error(struct mach_trap_args *args, int error)
137 mach_msg_header_t *req = args->smsg;
138 mach_error_reply_t *rep = args->rmsg;
139 size_t *msglen = args->rsize;
141 *msglen = sizeof(*rep);
142 mach_set_header(rep, req, *msglen);
144 rep->rep_retval = native_to_mach_errno[error];
146 mach_set_trailer(rep, *msglen);
148 #ifdef DEBUG_MACH
149 if (error != 0)
150 printf("failure in kernel service %d (err %x, native %d)\n",
151 req->msgh_id, (int)rep->rep_retval, error);
152 #endif
153 return 0;
157 mach_iokit_error(struct mach_trap_args *args, int error)
159 mach_msg_header_t *req = args->smsg;
160 mach_error_reply_t *rep = args->rmsg;
161 size_t *msglen = args->rsize;
163 *msglen = sizeof(*rep);
164 mach_set_header(rep, req, *msglen);
166 rep->rep_retval = error;
168 #ifdef DEBUG_MACH
169 if (error != 0)
170 printf("failure in kernel service %d (Mach err %x)\n",
171 req->msgh_id, error);
172 #endif
173 mach_set_trailer(rep, *msglen);
175 return 0;