xref: /NextBSD/sys/sys/mach/error.h (revision 33da5adc555b3bc29986eeadca03829e4ad06b1e)
1 /*
2  * Copyright 1991-1998 by Open Software Foundation, Inc.
3  *              All Rights Reserved
4  *
5  * Permission to use, copy, modify, and distribute this software and
6  * its documentation for any purpose and without fee is hereby granted,
7  * provided that the above copyright notice appears in all copies and
8  * that both the copyright notice and this permission notice appear in
9  * supporting documentation.
10  *
11  * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
12  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
13  * FOR A PARTICULAR PURPOSE.
14  *
15  * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
16  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
17  * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
18  * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
19  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20  */
21 /*
22  * MkLinux
23  */
24 /* CMU_HIST */
25 /*
26  * Revision 2.4  91/05/14  16:51:24  mrt
27  * 	Correcting copyright
28  *
29  * Revision 2.3  91/02/05  17:31:48  mrt
30  * 	Changed to new Mach copyright
31  * 	[91/02/01  17:16:50  mrt]
32  *
33  * Revision 2.2  90/06/02  14:57:47  rpd
34  * 	Added err_mach_ipc for new IPC.
35  * 	[90/03/26  22:28:42  rpd]
36  *
37  * Revision 2.1  89/08/03  16:02:07  rwd
38  * Created.
39  *
40  * Revision 2.4  89/02/25  18:13:18  gm0w
41  * 	Changes for cleanup.
42  *
43  * Revision 2.3  89/02/07  00:51:57  mwyoung
44  * Relocated from sys/error.h
45  *
46  * Revision 2.2  88/10/18  00:37:31  mwyoung
47  * 	Added {system,sub and code}_emask
48  * 	[88/10/17  17:06:58  mrt]
49  *
50  *	Added {system,sub and code}_emask
51  *
52  *  12-May-88 Mary Thompson (mrt) at Carnegie Mellon
53  *	Changed mach_error_t from unsigned int to kern_return_t
54  *	which is a 32 bit integer regardless of machine type.
55  *      insigned int was incompatible with old usages of mach_error.
56  *
57  *  10-May-88 Douglas Orr (dorr) at Carnegie-Mellon University
58  *	Missing endif replaced
59  *
60  *   5-May-88 Mary Thompson (mrt) at Carnegie Mellon
61  *	Changed typedef of mach_error_t from long to unsigned int
62  *	to keep our Camelot users happy. Also moved the nonkernel
63  *	function declarations from here to mach_error.h.
64  *
65  *  10-Feb-88 Douglas Orr (dorr) at Carnegie-Mellon University
66  *	Created.
67  *
68  */
69 /* CMU_ENDHIST */
70 /*
71  * Mach Operating System
72  * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
73  * All Rights Reserved.
74  *
75  * Permission to use, copy, modify and distribute this software and its
76  * documentation is hereby granted, provided that both the copyright
77  * notice and this permission notice appear in all copies of the
78  * software, derivative works or modified versions, and any portions
79  * thereof, and that both notices appear in supporting documentation.
80  *
81  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
82  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
83  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
84  *
85  * Carnegie Mellon requests users of this software to return to
86  *
87  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
88  *  School of Computer Science
89  *  Carnegie Mellon University
90  *  Pittsburgh PA 15213-3890
91  *
92  * any improvements or extensions that they make and grant Carnegie Mellon
93  * the rights to redistribute these changes.
94  */
95 /*
96  */
97 /*
98  * File:	mach/error.h
99  * Purpose:
100  *	error module definitions
101  *
102  */
103 
104 #ifndef	ERROR_H_
105 #define ERROR_H_
106 #include <mach/kern_return.h>
107 
108 /*
109  *	error number layout as follows:
110  *
111  *	hi		 		       lo
112  *	| system(6) | subsystem(12) | code(14) |
113  */
114 
115 
116 #define	err_none		(mach_error_t)0
117 #define ERR_SUCCESS		(mach_error_t)0
118 #define	ERR_ROUTINE_NIL		(mach_error_fn_t)0
119 
120 
121 #define	err_system(x)		(((x)&0x3f)<<26)
122 #define err_sub(x)		(((x)&0xfff)<<14)
123 
124 #define err_get_system(err)	(((err)>>26)&0x3f)
125 #define err_get_sub(err)	(((err)>>14)&0xfff)
126 #define err_get_code(err)	((err)&0x3fff)
127 
128 #define system_emask		(err_system(0x3f))
129 #define sub_emask		(err_sub(0xfff))
130 #define code_emask		(0x3fff)
131 
132 
133 /*	major error systems	*/
134 #define	err_kern		err_system(0x0)		/* kernel */
135 #define	err_us			err_system(0x1)		/* user space library */
136 #define	err_server		err_system(0x2)		/* user space servers */
137 #define	err_ipc			err_system(0x3)		/* old ipc errors */
138 #define err_mach_ipc		err_system(0x4)		/* mach-ipc errors */
139 #define	err_dipc		err_system(0x7)		/* distributed ipc */
140 #define err_local		err_system(0x3e)	/* user defined errors */
141 #define	err_ipc_compat		err_system(0x3f)	/* (compatibility) mach-ipc errors */
142 
143 #define	err_max_system		0x3f
144 
145 
146 /*	unix errors get lumped into one subsystem  */
147 #define	unix_err(errno)		(err_kern|err_sub(3)|errno)
148 
149 typedef	kern_return_t	mach_error_t;
150 typedef mach_error_t	(* mach_error_fn_t)( void );
151 
152 #endif	/* ERROR_H_ */
153