diff options
author | Roland McGrath <roland@gnu.org> | 1995-02-18 01:27:10 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 1995-02-18 01:27:10 +0000 |
commit | 28f540f45bbacd939bfd07f213bcad2bf730b1bf (patch) | |
tree | 15f07c4c43d635959c6afee96bde71fb1b3614ee /mach/mach |
initial import
Diffstat (limited to 'mach/mach')
-rw-r--r-- | mach/mach/error.h | 140 | ||||
-rw-r--r-- | mach/mach/mach.h | 3 | ||||
-rw-r--r-- | mach/mach/mach_traps.h | 76 | ||||
-rw-r--r-- | mach/mach/mig_support.h | 68 |
4 files changed, 287 insertions, 0 deletions
diff --git a/mach/mach/error.h b/mach/mach/error.h new file mode 100644 index 0000000000..e75ccf3f66 --- /dev/null +++ b/mach/mach/error.h @@ -0,0 +1,140 @@ +/* err_hurd added by roland@gnu.ai.mit.edu for GNU Hurd. + * + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie Mellon + * the rights to redistribute these changes. + */ +/* + * HISTORY + * $Log$ + * Revision 1.1 1993/12/17 21:40:28 roland + * entered into RCS + * + * Revision 2.6 93/01/14 17:41:31 danner + * Standardized include symbol name. + * [92/06/10 pds] + * + * Revision 2.5 92/03/31 15:18:11 rpd + * Added err_bootstrap for bootstrap errors. + * [92/03/09 rpd] + * + * Revision 2.4 91/05/14 16:51:24 mrt + * Correcting copyright + * + * Revision 2.3 91/02/05 17:31:48 mrt + * Changed to new Mach copyright + * [91/02/01 17:16:50 mrt] + * + * Revision 2.2 90/06/02 14:57:47 rpd + * Added err_mach_ipc for new IPC. + * [90/03/26 22:28:42 rpd] + * + * Revision 2.1 89/08/03 16:02:07 rwd + * Created. + * + * Revision 2.4 89/02/25 18:13:18 gm0w + * Changes for cleanup. + * + * Revision 2.3 89/02/07 00:51:57 mwyoung + * Relocated from sys/error.h + * + * Revision 2.2 88/10/18 00:37:31 mwyoung + * Added {system,sub and code}_emask + * [88/10/17 17:06:58 mrt] + * + * Added {system,sub and code}_emask + * + * 12-May-88 Mary Thompson (mrt) at Carnegie Mellon + * Changed mach_error_t from unsigned int to kern_return_t + * which is a 32 bit integer regardless of machine type. + * insigned int was incompatible with old usages of mach_error. + * + * 10-May-88 Douglas Orr (dorr) at Carnegie-Mellon University + * Missing endif replaced + * + * 5-May-88 Mary Thompson (mrt) at Carnegie Mellon + * Changed typedef of mach_error_t from long to unsigned int + * to keep our Camelot users happy. Also moved the nonkernel + * function declarations from here to mach_error.h. + * + * 10-Feb-88 Douglas Orr (dorr) at Carnegie-Mellon University + * Created. + * + */ +/* + * File: mach/error.h + * Purpose: + * error module definitions + * + */ + +#ifndef _MACH_ERROR_H_ +#define _MACH_ERROR_H_ +#include <mach/kern_return.h> + +/* + * error number layout as follows: + * + * hi lo + * | system(6) | subsystem(12) | code(14) | + */ + + +#define err_none (mach_error_t)0 +#define ERR_SUCCESS (mach_error_t)0 +#define ERR_ROUTINE_NIL (mach_error_fn_t)0 + + +#define err_system(x) (((x)&0x3f)<<26) +#define err_sub(x) (((x)&0xfff)<<14) + +#define err_get_system(err) (((err)>>26)&0x3f) +#define err_get_sub(err) (((err)>>14)&0xfff) +#define err_get_code(err) ((err)&0x3fff) + +#define system_emask (err_system(0x3f)) +#define sub_emask (err_sub(0xfff)) +#define code_emask (0x3fff) + + +/* major error systems */ +#define err_kern err_system(0x0) /* kernel */ +#define err_us err_system(0x1) /* user space library */ +#define err_server err_system(0x2) /* user space servers */ +#define err_ipc err_system(0x3) /* old ipc errors */ +#define err_mach_ipc err_system(0x4) /* mach-ipc errors */ +#define err_bootstrap err_system(0x5) /* bootstrap errors */ +#define err_hurd err_system(0x10) /* GNU Hurd server errors */ +#define err_local err_system(0x3e) /* user defined errors */ +#define err_ipc_compat err_system(0x3f) /* (compatibility) mach-ipc errors */ + +#define err_max_system 0x3f + + +/* unix errors get lumped into one subsystem */ +#define unix_err(errno) (err_kern|err_sub(3)|errno) + +typedef kern_return_t mach_error_t; +typedef mach_error_t (* mach_error_fn_t)(); + +#endif /* _MACH_ERROR_H_ */ diff --git a/mach/mach/mach.h b/mach/mach/mach.h new file mode 100644 index 0000000000..826e7172a7 --- /dev/null +++ b/mach/mach/mach.h @@ -0,0 +1,3 @@ +/* Some old programs may expect to find <mach.h> in <mach/mach.h>. */ + +#include <mach.h> diff --git a/mach/mach/mach_traps.h b/mach/mach/mach_traps.h new file mode 100644 index 0000000000..e741e16996 --- /dev/null +++ b/mach/mach/mach_traps.h @@ -0,0 +1,76 @@ +/* Copyright (C) 1994 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +/* Declare the few Mach system calls (except mach_msg, in <mach/message.h>). + This does not include the kernel RPC shortcut calls (in <mach-shortcuts.h>). + + This file omits the MACH_IPC_COMPAT functions. */ + +#ifndef _MACH_MACH_TRAPS_H + +#define _MACH_MACH_TRAPS_H_ 1 + +#include <mach/port.h> + + +/* Create and return a new receive right. */ +extern mach_port_t mach_reply_port (void); +extern mach_port_t __mach_reply_port (void); + +/* Return the thread control port for the calling thread. */ +extern mach_port_t mach_thread_self (void); +extern mach_port_t __mach_thread_self (void); + +/* Return the task control port for the calling task. + The parens are needed to protect against the macro in <mach_init.h>. */ +extern mach_port_t (mach_task_self) (void); +extern mach_port_t (__mach_task_self) (void); + +/* Return the host information port for the host of the calling task. */ +extern mach_port_t mach_host_self (void); +extern mach_port_t __mach_host_self (void); + +/* Attempt to context switch the current thread off the processor. Returns + true if there are other threads that can be run and false if not. */ +extern boolean_t swtch (void); +extern boolean_t __swtch (void); + +/* Attempt to context switch the current thread off the processor. Lower + the thread's priority as much as possible. The thread's priority will + be restored when it runs again. PRIORITY is currently unused. Return + true if there are other threads that can be run and false if not. */ +extern boolean_t swtch_pri (int priority); +extern boolean_t __swtch_pri (int priority); + +/* Attempt to context switch the current thread of the rpocessor. Try + to run NEW_THREAD next, ignoring normal scheduling policies. The + OPTION value comes from <mach/thread_switch.h>. If OPTION is + SWITCH_OPTION_WAIT, then block the current thread for TIME + milliseconds. If OPTION is SWITCH_OPTION_DEPRESS, then block for + TIME milliseconds and depress the thread's priority as done by + swtch_pri. If OPTION is SWITCH_OPTION_NONE, ignore TIME. */ +kern_return_t thread_switch (mach_port_t new_thread, int option, int time); +kern_return_t __thread_switch (mach_port_t new_thread, int option, int time); + +/* Block the current thread until the kernel (or device) event + identified by EVENT occurs. */ +kern_return_t evc_wait (unsigned int event); +kern_return_t __evc_wait (unsigned int event); + + +#endif /* mach/mach_traps.h */ diff --git a/mach/mach/mig_support.h b/mach/mach/mig_support.h new file mode 100644 index 0000000000..0f8c983c87 --- /dev/null +++ b/mach/mach/mig_support.h @@ -0,0 +1,68 @@ +/* Copyright (C) 1993, 1994 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +/* Useful declarations and support functions for MiG-generated stubs. */ + +#ifndef _MACH_MIG_SUPPORT_H + +#define _MACH_MIG_SUPPORT_H 1 + +#include <mach/std_types.h> +#include <mach/message.h> +#include <sys/types.h> +#include <string.h> + +/* MiG initialization. */ +extern void __mig_init (void *__first); +extern void mig_init (void *__first); + +/* Shorthand functions for vm_allocate and vm_deallocate on + mach_task_self () (and with ANYWHERE=1). */ +extern void __mig_allocate (vm_address_t *__addr_p, vm_size_t __size); +extern void mig_allocate (vm_address_t *__addr_p, vm_size_t __size); +extern void __mig_deallocate (vm_address_t __addr, vm_size_t __size); +extern void mig_deallocate (vm_address_t __addr, vm_size_t __size); + +/* Reply-port management support functions. */ +extern void __mig_dealloc_reply_port (mach_port_t); +extern void mig_dealloc_reply_port (mach_port_t); +extern mach_port_t __mig_get_reply_port (void); +extern mach_port_t mig_get_reply_port (void); +extern void __mig_put_reply_port (mach_port_t); +extern void mig_put_reply_port (mach_port_t); + +extern void __mig_reply_setup (const mach_msg_header_t *__request, + mach_msg_header_t *__reply); +extern void mig_reply_setup (const mach_msg_header_t *__request, + mach_msg_header_t *__reply); + +/* Idiocy support function. */ +extern __inline vm_size_t +__mig_strncpy (char *__dst, const char *__src, vm_size_t __len) +{ + return __stpncpy (__dst, __src, __len) - __dst; +} +extern __inline vm_size_t +mig_strncpy (char *__dst, const char *__src, vm_size_t __len) +{ + return __mig_strncpy (__dst, __src, __len); +} + + + +#endif /* mach/mig_support.h */ |