]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/l4sys/lib/src/errtostr.c
Inital import
[l4.git] / l4 / pkg / l4sys / lib / src / errtostr.c
1 /*
2  * (c) 2008-2009 Technische Universität Dresden
3  * This file is part of TUD:OS and distributed under the terms of the
4  * GNU General Public License 2.
5  * Please see the COPYING-GPL-2 file for details.
6  *
7  * As a special exception, you may use this file as part of a free software
8  * library without restriction.  Specifically, if other files instantiate
9  * templates or use macros or inline functions from this file, or you compile
10  * this file and link it with other files to produce an executable, this
11  * file does not by itself cause the resulting executable to be covered by
12  * the GNU General Public License.  This exception does not however
13  * invalidate any other reasons why the executable file might be covered by
14  * the GNU General Public License.
15  */
16
17 #include <l4/sys/err.h>
18 #include <l4/sys/ipc.h>
19
20 char const *l4sys_errtostr(long err);
21
22 static char const *const _l4sys_errortab[L4_ERRNOMAX] = {
23     [L4_EOK]           = "OK",
24     [L4_EPERM]         = "Operation not permitted",
25     [L4_ENOENT]        = "No such object found",
26     [L4_EIO]           = "I/O error",
27     [L4_EAGAIN]        = "Try again",
28     [L4_ENOMEM]        = "Insufficient memory",
29     [L4_EACCESS]       = "Access not permitted",
30     [L4_EEXIST]        = "Object exists",
31     [L4_ENODEV]        = "No such device",
32     [L4_EINVAL]        = "Invalid argument",
33     [L4_ERANGE]        = "Argument out of range",
34     [L4_ENAMETOOLONG]  = "Name too long",
35     [L4_ENOSYS]        = "Invalid request",
36     [L4_EBADPROTO]     = "Invalid protocol",
37     [L4_EADDRNOTAVAIL] = "Address not available"
38 };
39
40 static char const *const _l4sys_ipc_errortab[L4_EIPC_HI - L4_EIPC_LO] = {
41     [0]                = "OK",
42     [L4_IPC_SETIMEOUT]     = "Send timeout",
43     [L4_IPC_RETIMEOUT]     = "Receive timeout",
44     [L4_IPC_ENOT_EXISTENT] = "Void capability invoked",
45     [L4_IPC_SECANCELED]    = "Send operation canceled",
46     [L4_IPC_RECANCELED]    = "Receive operation canceled",
47     [L4_IPC_SEMSGCUT]      = "Overflow during send operation",
48     [L4_IPC_REMSGCUT]      = "Overflow during receive operation",
49     [L4_IPC_SESNDPFTO]     = "Send page-fault timeout (send phase)",
50     [L4_IPC_RESNDPFTO]     = "Send page-fault timeout (receive phase)",
51     [L4_IPC_SERCVPFTO]     = "Receive page-fault timeout (send phase)",
52     [L4_IPC_RERCVPFTO]     = "Receive page-fault timeout (receive phase)",
53     [L4_IPC_SEABORTED]     = "Send operation aborted",
54     [L4_IPC_REABORTED]     = "Receive operation aborted",
55     [L4_IPC_SEMAPFAILED]   = "Map operation failed (send phase)",
56     [L4_IPC_REMAPFAILED]   = "Map operation failed (receive phase)"
57 };
58
59 char const *l4sys_errtostr(long err)
60 {
61   err = -err;
62   if (err >= 0 && err < L4_ERRNOMAX)
63     return _l4sys_errortab[err];
64   else if (err >= L4_EIPC_LO && err < L4_EIPC_HI)
65     return _l4sys_ipc_errortab[err-L4_EIPC_LO];
66   else
67     return "bad, unknown runtime error";
68 }