diff options
Diffstat (limited to 'boot-proxy-exc')
121 files changed, 35774 insertions, 0 deletions
diff --git a/boot-proxy-exc/CVS/Entries b/boot-proxy-exc/CVS/Entries new file mode 100644 index 00000000..52df2bda --- /dev/null +++ b/boot-proxy-exc/CVS/Entries @@ -0,0 +1,26 @@ +/boot_script.h/1.10/Wed May 29 02:42:34 2002//Tzhengda-soc2008-virt-branch +/frank1.ld/1.1/Thu Jul 18 04:29:29 1996//Tzhengda-soc2008-virt-branch +/frankemul.ld/1.1/Thu Jul 18 04:29:30 1996//Tzhengda-soc2008-virt-branch +/mach-crt0.c/1.3/Fri Sep 22 18:14:11 1995//Tzhengda-soc2008-virt-branch +/sigvec.S/1.3/Mon May 22 15:49:14 1995//Tzhengda-soc2008-virt-branch +/syscall.S/1.6/Sat Sep 23 06:30:10 1995//Tzhengda-soc2008-virt-branch +/ux.c/1.3/Mon Apr 29 03:54:24 1996//Tzhengda-soc2008-virt-branch +/ux.h/1.2/Wed Feb 14 18:09:19 1996//Tzhengda-soc2008-virt-branch +/Makefile/1.56.14.1/Sun Apr 5 19:36:59 2009//Tzhengda-soc2008-virt-branch +/boot_script.c/1.15.14.1/Sun Apr 5 22:00:26 2009//Tzhengda-soc2008-virt-branch +/exc_impl.c/1.1.2.1/Sun Apr 5 18:55:11 2009//Tzhengda-soc2008-virt-branch +/list.c/1.1.2.1/Sun Apr 5 18:55:11 2009//Tzhengda-soc2008-virt-branch +/list.h/1.1.2.1/Sun Apr 5 18:55:11 2009//Tzhengda-soc2008-virt-branch +/mach_host_impl.c/1.1.2.1/Sun Apr 5 18:55:11 2009//Tzhengda-soc2008-virt-branch +/mach_impl.c/1.1.2.1/Sun Apr 5 19:31:21 2009//Tzhengda-soc2008-virt-branch +/mach_port_impl.c/1.1.2.1/Sun Apr 5 18:55:11 2009//Tzhengda-soc2008-virt-branch +/mach_proxy.c/1.1.2.1/Sun Apr 5 18:55:11 2009//Tzhengda-soc2008-virt-branch +/mach_proxy.h/1.1.2.1/Sun Apr 5 18:55:11 2009//Tzhengda-soc2008-virt-branch +/ourmach.defs/1.1.2.1/Sun Apr 5 19:51:14 2009//Tzhengda-soc2008-virt-branch +/ourmach_host.defs/1.1.2.1/Sun Apr 5 19:59:02 2009//Tzhengda-soc2008-virt-branch +/ourmach_port.defs/1.1.2.1/Sun Apr 5 18:55:11 2009//Tzhengda-soc2008-virt-branch +/userland-boot.c/1.4.14.2/Sat Apr 18 12:48:03 2009//Tzhengda-soc2008-virt-branch +/util.h/1.1.2.2/Mon Apr 6 19:41:15 2009//Tzhengda-soc2008-virt-branch +/ChangeLog/1.46.12.5/Sun Apr 19 18:04:59 2009//Tzhengda-soc2008-virt-branch +/boot.c/1.109.12.5/Sun Apr 19 18:02:37 2009//Tzhengda-soc2008-virt-branch +D diff --git a/boot-proxy-exc/CVS/Repository b/boot-proxy-exc/CVS/Repository new file mode 100644 index 00000000..038eab09 --- /dev/null +++ b/boot-proxy-exc/CVS/Repository @@ -0,0 +1 @@ +hurd/boot diff --git a/boot-proxy-exc/CVS/Root b/boot-proxy-exc/CVS/Root new file mode 100644 index 00000000..a10aa66d --- /dev/null +++ b/boot-proxy-exc/CVS/Root @@ -0,0 +1 @@ +:ext:zhengda@cvs.savannah.gnu.org:/sources/hurd diff --git a/boot-proxy-exc/CVS/Tag b/boot-proxy-exc/CVS/Tag new file mode 100644 index 00000000..7e454c6d --- /dev/null +++ b/boot-proxy-exc/CVS/Tag @@ -0,0 +1 @@ +Tzhengda-soc2008-virt-branch diff --git a/boot-proxy-exc/ChangeLog b/boot-proxy-exc/ChangeLog new file mode 100644 index 00000000..39dc9f7a --- /dev/null +++ b/boot-proxy-exc/ChangeLog @@ -0,0 +1,998 @@ +2009-04-19 Zheng Da <zhengda1936@gmail.com> + + * boot.c (init_kernel_task): Create a pseudo kernel task. + (main): Create the port bucket, initialize the kernel task and fork a + thread after the arguments of boot are parsed. + +2009-04-19 Zheng Da <zhengda1936@gmail.com> + + * boot.c (thread_portclass): Removed variable. + (is_user): Added variable. + (options): Add option 'u'. + (parse_opt): Handle option 'u'. + (logfile): Added variabled. + (main): Handle the cases differently when the user is root. + (do_bootstrap_privileged_ports): Likewise. + (bootstrap_compat): Likewise. + (do_mach_notify_no_senders): Likewise. + (ds_device_open): If the user is root, open the kernel device + directly. + + * userland-boot.c (boot_script_task_create): Create the pseudo task + port if it's the normal user. + (boot_script_free_task): Deallocate the task port if it's root. + +2009-04-05 Zheng Da <zhengda1936@gmail.com> + + * Makefile (SRCS): Add list.c, mach_proxy.c. + (COMMON-OBJS): Add ourmach_hostServer.o, ourmachServer.o, + ourmach_portServer.o, excServer.o. + (OBJS): Add mach_host_impl.o, mach_impl.o, mach_port_impl.o, + exc_impl.o, list.o, mach_proxy.o. + (LCLHDRS): Add util.h. + (HURDLIBS): Add ports. + + * boot.c: Include hurd/ports.h, util.h, mach_proxy.h. + (port_bucket): New variable. + (task_portclass): Likewise. + (thread_portclass): Likewise. + (privileged_host_port): Removed variable. + (master_device_port): Likewise. + (pseudo_privileged_host_port): New variable. + (request_server): Call mach_host_server() and mach_server(). + (mach_proxy_demuxer): New function. + (mach_proxy_thread): Likewise. + (options): Add option -p. + (pager_file): New variable. + (parse_opt): Handle option -p. + (init_kernel_task): New function. + (main): Create port bucket, port class, new thread; + get default memory manager; get the pseudo privileged host port; + set 'host-port' with the pseudo privileged host port. + (do_bootstrap_privileged_ports): Return the pseudo privileged host port. + (bootstrap_compat): Use the pseudo privileged host port. + (ds_device_open): Return D_NO_SUCH_DEVICE if the device isn't specified. + (do_mach_notify_no_senders): Call ports_do_mach_notify_no_senders(); + check the pseudo privileged host port. + + * boot_script.c (add_arg): Convert 'cmd->args' to 'void *' pointer first. + (sym_enter): Convert 'symtab' to 'void *' pointer first. + (boot_script_parse_line): Convert 'cmds' to to 'void *' pointer first; + Convert 'cmd->exec_funcs' to to 'void *' pointer first. + + * exc_impl.c: New file. Implement the server-side RPCs of exc. + + * list.c: New file. Implement a double linked list. + + * list.h: New file. Define a double linked list. + + * mach_host_impl.c: New file. Implement the server-side RPCs of mach_host. + + * mach_impl.c: New file. Implement the server-side RPCs of mach. + + * mach_port_impl.c: New file. Implement the server-side RPCs of mach_port. + + * mach_proxy.c: New file. + + * mach_proxy.h: New file. + + * ourmach.defs: New file. A modified mach/mach.defs. + + * ourmach_host.defs: New file. A modified mach/mach_host.defs. + + * ourmach_port.defs: New file. A modified mach/mach_port.defs. + + * userland-boot.c: Include mach_proxy.h and util.h. + (boot_script_task_create): Create a pseudo task port. + (boot_script_free_task): Don't deallocate the task port. + + * util.h: New file. + +2008-09-21 Zheng Da <zhengda1936@gmail.com> + + * boot.c (options): Change the long option and the description of + its argument. + +2008-08-28 Zheng Da <zhengda1936@gmail.com> + + * boot.c: Add '-m' option. + (dev_map): New structure. + (dev_map_head): New variable. + (add_dev_map): New function. + (lookup_dev): New function. + (parse_opt): Handle the '-m' option. + (ds_device_open): Open the device from the device file. + +2006-03-15 Thomas Schwinge <tschwinge@gnu.org> + + * boot.c (boot_script_exec_cmd): Fix invalid lvalues. + +2003-01-04 Roland McGrath <roland@frob.com> + + * boot_script.c (boot_script_parse_line): Copy the file name into + malloc'd storage. + (add_arg): New arg TEXTLEN. Store malloc'd copy of TEXT. + (boot_script_parse_line): Update callers. + +2002-06-13 Roland McGrath <roland@frob.com> + + * boot.c (ds_device_write): int -> size_t in store_write call. + (ds_device_write_inband): Likewise. + +2002-06-08 Roland McGrath <roland@frob.com> + + * boot.c (S_io_identity): Use ino_t for FILENO. + +2002-05-31 Roland McGrath <roland@frob.com> + + * boot.c: Don't include "exec_S.h". + + * boot.c (boot_script_exec_cmd): Fix typos: + {I386,ALPHA}_THREAD_STATE -> {i386,ALPHA}_THREAD_STATE_COUNT + +2002-05-28 Roland McGrath <roland@frob.com> + + * boot_script.c (boot_script_set_variable): Values int -> integer_t. + (boot_script_define_function): Likewise. + (boot_script_parse_line): Likewise. + (struct sym, struct arg): Likewise. + (boot_script_exec): Likewise. + (builtin_symbols): Likewise. + * boot.c (main): Likewise. + * boot_script.h: Update decls. + + * boot.c (boot_script_exec_cmd) + [I386_THREAD_STATE]: Conditionalize i386 thread setup code on this. + [ALPHA_THREAD_STATE]: Add Alpha thread setup code. + (set_mach_stack_args): Obsolete function removed. + + * boot.c (load_image): u_int -> vm_address_t + (ds_xxx_device_get_status, ds_xxx_device_set_status): u_int -> size_t + (S_io_restrict_auth, S_io_reauthenticate): Likewise. + (ds_device_write, ds_device_read_inband): Likewise. + (ds_device_get_status): Likewise. + (ds_device_set_status): Likewise. + (boot_script_exec_cmd): Likewise. + (ds_device_read, ds_device_write_inband): Likewise. + (ds_xxx_device_set_filter): Likewise. + (ds_device_set_filter): Likewise. + +2002-05-13 Marcus Brinkmann <marcus@gnu.org> + + * boot.c: Include <version.h> + (argp_program_version): New variable. + +2002-03-23 James A. Morrison <ja2morri@uwaterloo.ca> + + * boot.c (main): Use error, not perror and exit. + +2001-10-07 Neal H Walfield <neal@cs.uml.edu> + + * boot.c (main): Set the boot script variables based on + the KERNEL_COMMAND_LINE value. + +2001-08-23 Roland McGrath <roland@frob.com> + + * boot.c (kernel_command_line): New variable. + (options): Add --kernel-command-line/-K. + (parse_opt): Parse it, set kernel_command_line. + (main): If unset, default it to "argv[0] bootstrap_args bootdevice". + Set ${kernel-command-line} boot script variable to kernel_command_line. + +2001-08-17 Neal H Walfield <neal@cs.uml.edu> + + * userland-boot.c (boot_script_task_create): Suspend the newly + created task as the protocol requires. + (boot_script_insert_right): Fix the error message. + +2001-08-17 Roland McGrath <roland@frob.com> + + * userland-boot.c (boot_script_insert_right): Take new result + parameter for send right name in target task. + (boot_script_insert_task_port): New function. + + * boot_script.h: Update those two decls. + (VAL_TASK): New macro. + * boot_script.c (VAL_SYM, VAL_FUNC): Increase these constants. + (builtin_symbols): Use VAL_TASK for "task-create". + (boot_script_exec): Update caller of boot_script_insert_right. + Treat VAL_TASK like VAL_PORT, but call boot_script_insert_task_port. + + * boot_script.h: size_t -> unsigned int + * boot_script.c: Don't #include <string.h>. + +2001-08-16 Roland McGrath <roland@frob.com> + + * userland-boot.c (boot_script_insert_right): New function. + * boot_script.h: Declare it. + * boot_script.c (boot_script_exec): Use that instead of + mach_port_insert_right. + + * boot_script.h: Protect from multiple inclusion. + (safe_gets): Remove decl. + + * boot_script.h (boot_script_exec_cmd): Change TASK arg type to task_t. + * userland-boot.c: Likewise. + + * boot_script.h (struct cmd): Change `task' member type to `task_t'. + (boot_script_task_create, boot_script_task_resume, + boot_script_prompt_task_resume, boot_script_free_task): Declare new + functions that callers must define. + * userland-boot.c: Define those. + * boot_script.c (create_task, resume_task, prompt_resume_task): Use + those instead of direct Mach calls. + (free_cmd): Likewise. + (read_file): Function removed. + (builtin_symbols): Remove the "read-file" element. + + * boot_script.h (boot_script_malloc, boot_script_free): Declare new + functions that callers must define. + * boot_script.c: All uses of malloc/free changed to use those instead. + * userland-boot.c: New file. Defines them using malloc/free. + * Makefile (SRCS, OBJS): Add it. + * boot.c (boot_script_malloc, boot_script_free): Old cruft functions + removed. + + * boot_script.c (boot_script_parse_line): Take new first argument HOOK. + Store it in CMD->hook. + (main): Update caller. + (boot_script_exec): Pass CMD->hook as 1st arg to boot_script_exec_cmd. + (boot_script_exec_cmd): Take new first argument HOOK. + * boot.c (boot_script_exec_cmd): Likewise. + * boot_script.h (struct cmd): New member `void *hook'. + Update decls for HOOK arguments added. + +2001-02-25 Roland McGrath <roland@frob.com> + + * Makefile (ourdevice.defs): Loosen up regexp since some whitespace in + the file changed. + +2000-12-21 Marcus Brinkmann <marcus@gnu.org> + + * boot.c (main): If malloc or realloc fails, print diagnostic + message and exit. + (queue_read): Change return type from void to kern_return_t. + If malloc fails, return D_NO_MEMORY, otherwise D_SUCCESS (to simplify + code flow, malloc before acquiring the queuelock). + (ds_device_read): New variable err (local to the block in which it is + used). If queue_read fails, pass through error. + (ds_device_read_inband): Likewise. + (S_io_read): Likewise. + Reported by Igor Khavkine <i_khavki@alcor.concordia.ca>. + +2000-03-17 Roland McGrath <roland@baalperazim.frob.com> + + * boot.c (S_io_reauthenticate): Check mach_port_insert_right result + with assert_perror. + +2000-03-17 Thomas Bushnell, BSG <tb@mit.edu> + + * boot.c (S_io_reauthenticate): Don't use MACH_MSG_TYPE_MAKE_SEND + in Hurd RPC. + +2000-02-28 Roland McGrath <roland@baalperazim.frob.com> + + * boot.c (ds_device_get_status): Accept *STATUSLEN greater than needed. + +1999-09-13 Roland McGrath <roland@baalperazim.frob.com> + + * boot.c: Reverted changes related to io_map_segment. + +1999-09-07 Thomas Bushnell, BSG <tb@mit.edu> + + * boot.c (S_io_map_segment): New function. + +1999-07-11 Roland McGrath <roland@baalperazim.frob.com> + + * boot.c (ds_device_read, S_io_read): Fix sloppy bugs in last change. + +1999-07-06 Thomas Bushnell, BSG <tb@mit.edu> + + * boot.c (load_image): Use mmap instead of vm_allocate, when + allocating in mach_task_self (). + (boot_script_exec_cmd): Likewise. + (set_mach_stack_args): Likewise. + (read_reply): Likewise. + (S_io_read): Likewise. + +1999-07-10 Roland McGrath <roland@baalperazim.frob.com> + + * boot.c: Add #include <sys/mman.h> for munmap decl. + +Mon Jul 5 20:04:06 1999 Thomas Bushnell, BSG <tb@mit.edu> + + * boot.c (load_image): Fix typo in cast. Reported by Yamashita + TAKAO <jargon@lares.dti.ne.jp>. + +1999-07-03 Thomas Bushnell, BSG <tb@mit.edu> + + * boot.c (load_image): Use munmap instead of vm_deallocate when + it's from our own task. + (boot_script_read_file): Likewise. + (boot_script_exec_cmd): Likewise. + (set_mach_stack_args): Likewise. + (ds_device_read_inband): Likewise. + +1999-03-20 Roland McGrath <roland@baalperazim.frob.com> + + * boot.c (S_term_get_peername): New function. + +1999-03-14 Roland McGrath <roland@baalperazim.frob.com> + + * boot.c: Fix typo in last change. + +1999-03-10 Roland McGrath <roland@baalperazim.frob.com> + + * boot.c (main): Only use real device name if root_store is for an + enforced single run starting at the beginning of the device. + +1999-03-09 Roland McGrath <roland@baalperazim.frob.com> + + * boot.c (main): Add newline to error msg. + Patch by Marcus Brinkmann <Marcus.Brinkmann@ruhr-uni-bochum.de>. + +1999-02-16 Roland McGrath <roland@baalperazim.frob.com> + + * boot.c (S_io_revoke): Add reply, replyPoly args. + +Tue Feb 16 05:06:12 1999 Thomas Bushnell, BSG <tb@mit.edu> + + * boot.c (S_io_revoke): New (unsupported) routine. + +1998-12-26 Roland McGrath <roland@baalperazim.frob.com> + + * boot.c (isig): New variable. + (init_termstate): If it's set, set ISIG flag in c_lflag. + (options): New option -I/--isig. + (parse_opt): Make -I set `isig'. + (boot_script_exec_cmd): Print out args as well as file name. + +1998-09-04 Roland McGrath <roland@baalperazim.frob.com> + + * boot_script.c: Include <string.h> instead of declaring memset here. + Include <stdlib.h> instead of declaring malloc, free here. + +1997-07-08 Miles Bader <miles@gnu.ai.mit.edu> + + * boot_script.c (prompt_resume_task): Pass more than a single + character buffer to safe_gets. + +Mon Jul 7 16:25:49 1997 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu> + + * boot.c: Include <fcntl.h> instead of <fcntlbits.h>. Suggested + by Marcus G. Daniels (marcus@cathcart.sysc.pdx.edu). + +1997-06-20 Miles Bader <miles@gnu.ai.mit.edu> + + * boot.c (bootscript): Made global. + (parse_opt): New function. + (options, doc, args_doc): New variables. + (bootscript_args): Now an array. + (ds_device_open, ds_device_close, ds_device_write, + ds_device_write_inband, ds_device_read, ds_device_read_inband, + ds_device_get_status, ds_device_set_status, ds_device_map, + ds_xxx_device_set_filter, ds_xxx_device_get_status, + ds_xxx_device_set_status, ds_device_set_filter): + Handle "pseudo-root" device. + (pseudo_root, root_store): New variables. + (main): Use argp to parse args, and implement the pseudo-root device. + Include <argp.h> & <hurd/store.h> + * Makefile (HURDLIBS): Include libstore & libshouldbeinlibc. + +Thu Apr 10 11:53:57 1997 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu> + + * boot.c: Don't include varargs.h. + (set_mach_stack_args): Use stdarg instead of vararg. + +Mon Mar 17 13:12:45 1997 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu> + + * boot_script.c (boot_script_parse_line): Don't print gratuitous + output noise. + +Thu Sep 12 16:28:47 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu> + + * Makefile (HURDLIBS): New variable. + (boot): Delete special depedencies. + +Tue Aug 13 16:57:22 1996 Miles Bader <miles@gnu.ai.mit.edu> + + * Makefile (device.defs): Rule removed. + (ourdevice.defs): Fix rule to work with Makeconf-generated device.defs. + +Tue Aug 13 15:09:45 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu> + + * Makefile (ourdevice.defs): Depend on local device.defs. + (device.defs): New rule. + +Mon Aug 12 11:11:08 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu> + + * Makefile (ourdevice.defs): Find device.defs under + install_includedir now. + + * Makefile (all): No longer build uxboot by default. + +Thu Aug 1 14:38:38 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu> + + * boot_script.h (safe_gets): Declare second parm as type `int'. + * boot.c (safe_gets): Likewise. + +Sun Jul 7 21:10:08 1996 Michael I. Bushnell, p/BSG <mib@gnu.ai.mit.edu> + + * boot.c (S_io_reauthenticate): Don't use unsafe MOVE_SEND in + auth_server_authenticate. + +Fri May 10 16:11:49 1996 Miles Bader <miles@gnu.ai.mit.edu> + + * boot.c (S_io_identity): Typo. + +Fri May 10 09:18:53 1996 Michael I. Bushnell, p/BSG <mib@gnu.ai.mit.edu> + + * boot.c (S_io_identity): New function. + +Thu May 9 18:57:34 1996 Michael I. Bushnell, p/BSG <mib@gnu.ai.mit.edu> + + * boot.c (S_io_select): No longer has TAG parm. + + * boot.c (S_io_reauthenticate): Use new interface. + +Sun Apr 28 22:50:38 1996 Miles Bader <miles@gnu.ai.mit.edu> + + * boot.c (main): Use select instead of SIGIO. + +Mon Apr 15 12:57:29 1996 Michael I. Bushnell, p/BSG <mib@gnu.ai.mit.edu> + + * Makefile (uxboot): Permit errors because people might not have + the a.out-mach3 target installed, and that's OK for many users. + + * Makefile (uxboot.0): Find frank1.ld in #(srcdir). + + * boot_script.h (safe_gets): Add decl. + * boot_script.c: Include <stdio.h>. + +Wed Apr 3 18:54:22 1996 Miles Bader <miles@gnu.ai.mit.edu> + + * ux.c (printf): Add %d. + +Wed Mar 27 11:30:29 1996 Miles Bader <miles@gnu.ai.mit.edu> + + * boot.c [notanymore] (S_tioctl_tiocgeta, S_tioctl_tiocseta, + S_tioctl_tiocsetaf, term_modes, term_ccs, term_speeds): + Functions & variables removed. + * Makefile (COMMON-OBJS): Remove tcattr.o. + (SRCS): Remove tcattr.c. + +Thu Mar 14 10:10:20 1996 Roland McGrath <roland@charlie-brown.gnu.ai.mit.edu> + + * Makefile (boot): Depend on libthreads.so, nothing wrong with shared + libs. + (uxboot.0, uxboot.1): Use automatic vars in cmds instead of gratuitous + redundancy. + (LDFLAGS-uxboot.0): Remove useless indirection through variable. + +Wed Feb 14 16:50:05 1996 Miles Bader <miles@gnu.ai.mit.edu> + + * boot.c [!UX] + (orig_tty_state): New variable. + (init_termstate, restore_termstate): New hurd versions of these funcs. + * ux.c (init_termstate, restore_termstate, term_sgb, localbits): + Moved here from boot.c + +Tue Feb 13 18:49:26 1996 Miles Bader <miles@gnu.ai.mit.edu> + + * boot.c (load_image, boot_script_read_file, main): Use O_RDONLY, + not 0 (kind of ironic, this...). + (load_image): Give the filename with the error message (and a newline). + + * ux.h (O_RDONLY, O_WRONLY, O_RDWR): New macros. + + * ux.c, ux.h: New files. + * boot.c: Move all the ux-specific grot into ux.c & ux.h. + If UX is defined, include "ux.h", else define hurdish stuff. + (main): Use get_privileged_ports instead of task_by_pid. + (load_image, boot_script_read_file, main, do_mach_notify_no_senders, + do_mach_notify_dead_name): Use host_exit instead of uxexit. + (boot_script_read_file): Use host_stat instead of uxstat. + (init_termstate, S_tioctl_tiocseta): Use sg_flags fld in struct sgttyb. + + * Makefile (all): Depend on `boot' and `uxboot'. + (COMMON-OBJS, UX-OBJS): New macros. + (OBJS): Inherit most names from $(COMMON-OBJS). + (LCLHDRS): Add ux.h. + (LDFLAGS): Use target-specific value. + (uxboot.0-LDFLAGS): New macro (with contents from old LDFLAGS). + (uxboot.o, uxboot.0): New targets. + (uxboot): Target renamed from boot.a. + +Sun Dec 10 18:05:14 1995 Miles Bader <miles@gnu.ai.mit.edu> + + * boot.c (read_reply): Don't call clear_should_read(), just do + things ourselves. + (should_read_lock): Variable deleted. + (service_sigio): Function deleted. + (main): Use read_reply to service SIGIO again, not service_sigio. + + * boot.c (service_sigio): New function, replacing set_should_read. + Calls read_reply() itself too. + (unlock_readlock): New function. + (ds_device_read, ds_device_read_inband, S_io_read): Call + unlock_readlock instead of directly unlocking READLOCK. + (request_server, main): Don't call read_reply() anymore. + + * boot.c (should_read): New variable. + (main): SIGIO uses set_should_read instead of read_reply. + Call read_reply() after sigpause() returns. + (read_reply): Call clear_should_read(), and don't do anything if + SHOULD_READ wasn't set. + (set_should_read): New function. + (clear_should_read): New function. + (request_server): Call read_reply() before returning. + +Sat Dec 9 19:01:10 1995 Miles Bader <miles@gnu.ai.mit.edu> + + * boot.c (S_io_read, ds_device_read_inband, ds_device_read): Don't + block SIGIO. + (main): Don't trap SIGMSG & SIGEMSG. + +Mon Dec 4 23:54:18 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu> + + * boot.c (main): Request no-senders notification on + pseudo_master_device_port. + Deallocate our send right to it when we no longer need it. + (do_mach_notify_no_senders): Exit only when both pseudo_console and + pseudo_master_device_port have no senders. + (ds_device_read_inband): Unlock readlock properly. + +Thu Nov 30 15:58:47 1995 Michael I. Bushnell, p/BSG <mib@gnu.ai.mit.edu> + + * boot.c (readlock): New variable. + (read_reply): Check FIONREAD before dequeueing QR so that we don't + abandon requests. Lock READLOCK around FIONREAD/read pair. + (ds_device_read): Lock READLOCK around FIONREAD/read pair. + (ds_device_read_inband): Likewise. + (S_io_read): Likewise. + +Nov 22 16:25:01 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu> + + * boot.c (request_server): Don't call exec_server. + (S_exec_*): Functions removed. + (boot_script_task_port): Variable removed. + (boot_script_task_*, boot_script_port_*): Functions removed. + +Tue Nov 14 12:07:24 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu> + + * Makefile (OBJS): Remove execServer.o. + +Thu Sep 28 14:47:46 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu> + + * boot_script.c (read_file): Pass CMD->path for file name. + (CHECK_CMDLINE_LEN): Update ARGV pointers after reallocating the line + buffer. + +Wed Sep 27 14:01:03 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu> + + * boot.c (struct uxstat): New type. + (uxfstat): Renamed from fstat; use struct uxstat * for arg. + (boot_script_read_file): Use those. + Return the memory object port, not zero. + + * boot.c (fstat): New syscall function. + + * boot_script.c (read_file): New function. + (builtin_symbols): Add $(read-file) builtin. + * boot_script.h (boot_script_read_file): Declare it. + * boot.c (close): New syscall function. + (defpager): New variable. + (main): Set it up. + (boot_script_read_file): New function. + (useropen_dir): New variable. + (useropen): New function. + (load_image): Call it instead of open. + (main): Grok -D arg to set useropen_dir. + +Sat Sep 23 00:53:51 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu> + + * syscall.S: Restore entry SP before return. + + * boot.c (main): Use static const for constant strings. + On boot script error, write script line with error msg. + + * boot_script.c (boot_script_parse_line): Ignore line beginning + with #. + + * boot.c (S_io_pathconf): New function. + + * Makefile (LDFLAGS): Add -static. + +Fri Sep 22 14:14:23 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu> + + * mach-crt0.c (__data_start): New variable. + +Tue Aug 29 10:41:29 1995 Michael I. Bushnell, p/BSG <mib@duality.gnu.ai.mit.edu> + + * boot.c (mig_dealloc_reply_port): Remove __ from call to + mach_port_mod_refs. + (main): Look for -d in bootstrap_args, not (nonexistent) + boot_args. Remove `const' keyword from decl of MSG. + + * boot.c (sigblock, sigsetmask): New functions. + (sigmask): New macro. + (ds_device_read): Block SIGIO around critical section. + (ds_device_read_inband): Likewise. + (S_io_read): Likewise. + +Mon Aug 28 17:16:48 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu> + + * boot_script.h, boot_script.c: Updated by Shantanu Goel, to + accept action keywords only inside $(...) and only variable values + inside ${...}. + * boot.c: Updated for changes in boot_script.h protocol by + Shantanu Goel. + (main): Use boot_script_set_variable instead of magic variables. + Under -d, pause between parsing bootscript and executing it. + +Wed Aug 23 16:08:04 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu> + + New script-driven boot mechanism, mostly implemented by Shantanu Goel. + * Makefile (SRCS): Add boot_script.c. + (OBJS): Add boot_script.o. + (LCLHDRS): New variable. + (HURDLIBS): Variable removed. + (boot): Depend on ../libthreads/libthreads.a. + * boot_script.c, boot_script.h: New files. + * boot.c (boot_like_kernel, boot_like_cmudef, boot_like_hurd): + Variables removed. + (main): Don't interpret switches. Instead of servers, take + command line argument of boot script file name. Read the file and + use boot_script functions to parse and execute its directives. + (boot_script_*): New variables and functions for boot_script callbacks. + +Sun Jul 30 23:50:53 1995 Michael I. Bushnell, p/BSG <mib@geech.gnu.ai.mit.edu> + + * Makefile: DISTFILES -> DIST_FILES. + +Sat Jul 8 11:37:32 1995 Miles Bader <miles@churchy.gnu.ai.mit.edu> + + * boot.c (free_reply_ports, free_reply_ports_lock): New variables. + (__mig_get_reply_port, __mig_put_reply_port, __mig_dealloc_reply_port, + mig_get_reply_port, mig_put_reply_port, mig_dealloc_reply_port): + Provide better versions of these routines that won't leak reply ports. + +Fri Jul 7 15:55:18 1995 Miles Bader <miles@churchy.gnu.ai.mit.edu> + + * mach-crt0.c: New file, from mach4-i386/libmach/standalone. + * boot.c (mach_init_routine): New variable, wanted by mach-crt0.o. + (__mig_get_reply_port, __mig_dealloc_reply_port, __mig_put_reply_port): + New functions, to avoid using hurdish versions. + * Makefile (OBJS): Add mach-crt0.o. + (SRCS): Add mach-crt0.c. + (LDFLAGS): Add -nostartfiles (as we now use mach-crt0.o). + +Thu Jul 6 15:30:18 1995 Michael I Bushnell <mib@duality.gnu.ai.mit.edu> + + * Makefile (boot.1, boot.a): Use $(LD) and $(OBJCOPY) instead of + explicit names. + + * boot.c: Include <mach/mig_support.h>. + (S_io_reauthenticate): Cast first arg to mig_deallocate. + (load_image): Cast second arg to read. + * tcattr.c: Undo last change; add private decl of ioctl. + + * boot.c (bootdevice): Initialize to hard-coded `sd0a' instead of + DEFAULT_BOOTDEVICE. + + * Makefile (all): Depend on boot.a too. + + * Makefile: Removed dependencies that are now automatically + generated. + +Wed May 31 10:02:11 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu> + + * Makefile (DISTFILES): New variable; include frank1.ld and + frankemul.ld. + (CPPFLAGS): Variable removed. + (LDFLAGS): Append -T frank1.ld. + (boot.1, boot.a): New targets. + + * syscall.S: Omit .globl decl for errno; it caused some as + complaint. + +Mon May 22 11:48:58 1995 Michael I Bushnell <mib@duality.gnu.ai.mit.edu> + + * sigvec.S: Remove copyright notice. + +Wed May 17 13:10:27 1995 Miles Bader <miles@churchy.gnu.ai.mit.edu> + + * boot.c (load_image): Make sure we actually allocate enough + memory to read into, including the offset into the buffer at which + the segment is read. + + * sigvec.S (sigreturn, _sigreturn, sigvec): Remove the explicit + underscore prefixes from these names, now that we're using elf. + Instead we use the various macros from <i386/asm.h>. Also, return + errors correctly. [Also added a copyright notice] + +Sat May 13 03:37:24 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu> + + * boot.c (load_image): Fixed alignment calculation in ELF segment + loading. + + * syscall.S: Include i386/asm.h and use ENTRY and EXT macros, + instead of explicit _s. + +Fri May 12 18:36:39 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu> + + * boot.c (load_image): Grok ELF executables as well as a.out. + (main): Load multiple servers. Suspend all but the first. + The first gets an extra arg, its name for the task port of the + second. + +Wed Apr 12 09:18:50 1995 Miles Bader <miles@churchy.gnu.ai.mit.edu> + + * Makefile: Don't try and install boot in /usr/local/bin. + +Wed Apr 5 17:25:19 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu> + + * boot.c: Don't include <errno.h>. Define `errno' variable. + * Makefile (SRCS): Add syscall.S. + (OBJS): Add syscall.o. + * syscall.S: Check for errors. + +Thu Jan 19 01:21:24 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu> + + * boot.c (S_io_select): Updated to new io_select protocol. + +Fri Dec 9 01:23:22 1994 Roland McGrath <roland@churchy.gnu.ai.mit.edu> + + * boot.c: Use mach_msg_type_number_t in place of unsigned int and + int. + +Fri Nov 11 14:05:43 1994 Michael I Bushnell <mib@churchy.gnu.ai.mit.edu> + + * boot.c (main): Always set `f' flag (signifying "fake" because we + aren't a real native bootstrap). + +Thu Nov 3 17:26:37 1994 Michael I Bushnell <mib@geech.gnu.ai.mit.edu> + + * Makefile (boot.o): Depend on bootstrap_S.h. + +Fri Oct 28 17:08:12 1994 Roland McGrath <roland@churchy.gnu.ai.mit.edu> + + * boot.c (main): Create the thread before setting it up. + (bootstrap_compat): Make a send right for psuedo_master_device_port. + (main): Explicitly clear NEWTASK's bootstrap port for boot_like_kernel. + (main): Format strings for port names for boot_like_kernel. + +Fri Oct 28 15:26:48 1994 Michael I Bushnell <mib@churchy.gnu.ai.mit.edu> + + * boot.c (boot_like_kernel, boot_like_cmudef, boot_like_hurd): New + global vars. + (set_mach_stack_args): New function. + (main): If the -k flag is given, set BOOT_LIKE_KERNEL. + If the -p flag is given, set BOOT_LIKE_CMUDEF. If neither is + given, set BOOT_LIKE_HURD. + Only set a bootstrap port if BOOT_LIKE_CMUDEF or BOOT_LIKE_HURD. + If BOOT_LIKE_KERNEL or BOOT_LIKE_CMUDEF, set up the stack the + Mach way using set_mach_stack_args. + (request_server): Declare and call bootstrap_server. + (do_bootstrap_priveleged_ports, bootstrap_compat): New functions. + * Makefile (OBJS): Require bootstrapServer.o. + * bootstrap.defs: New file. + +Tue Aug 30 11:41:33 1994 Michael I Bushnell <mib@geech.gnu.ai.mit.edu> + + * boot.c (S_io_reauthenticate): Use new authentication protocol. + +Mon Aug 22 13:43:32 1994 Michael I Bushnell <mib@geech.gnu.ai.mit.edu> + + * boot.c: Include <cthreads.h>. + (main): Run msg_thread fork; don't call + mach_msg_server_timeout here. Use sigpause instead of getpid. + (msg_thread): New function. + (queuelock): New variable. + (queue_read): Acquire queuelock. + (read_reply): Acquire queuelock. + * Makefile (HURDLIBS): New var to get threads. + +Thu Aug 18 18:04:36 1994 Michael I Bushnell <mib@geech.gnu.ai.mit.edu> + + * boot.c (restore_termstate): New function. + (do_mach_notify_no_senders): Call restore_termstate before exiting. + + * boot.c (main): New var `usagemsg'; print it if args are wrong. + Allow flags and disk device to be given on command line. + New var `bootfile'. + (bootdevice, bootstrap_args): New vars. + (load_image): Exit nicely if the startup file can't be found. + (S_exec_startup): Use `bootdevice' instead of hardcoded name. + Use `bootstrap_args' instead of hardcoded "-x". + (main): Only do `pausing' hack if -d was provided. + + * Makefile (CPPFLAGS): Define DEFAULT_BOOTDEVICE. + + * Makefile (/usr/local/bin/boot): Depend on boot. + + * boot.c (S_termctty_open_terminal): New "function". + (S_io_select): Added `rettype' arg. + +Sat Jul 23 02:58:05 1994 Roland McGrath <roland@churchy.gnu.ai.mit.edu> + + * Makefile (io-MIGSFLAGS): Renamed from ioMIGSFLAGS. + +Fri Jul 22 15:10:45 1994 Michael I Bushnell <mib@geech.gnu.ai.mit.edu> + + * boot.c (request_server): Remove S_ from io_server and + term_server. + +Thu Jul 21 19:00:36 1994 Michael I Bushnell <mib@geech.gnu.ai.mit.edu> + + * Makefile: Rewritten to use new scheme. + * boot.c: Include io_reply_U.h and device_reply_U.h instead + of io_repl.h and device_reply.h. + +Wed Jul 20 13:19:45 1994 Michael I Bushnell <mib@geech.gnu.ai.mit.edu> + + * boot.c: Comment out bits relating to tioctl interface. + * Makefile: Likewise. + +Tue Jul 19 12:41:46 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * Makefile (boot): Don't use variable $(link) anymore. + +Tue Jul 5 14:19:36 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * Makefile (SRCS): New variable. + +Sun Jul 3 17:20:07 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * tcattr.c: New file. + * boot.c (S_tioctl_tiocgeta): Call tcgetattr. + (S_tioctl_tiocseta): Call tcsetattr. + * Makefile (OBJS): Add tcattr.o. + (DIST_FILES): Add tcattr.c. + +Fri Jul 1 11:16:27 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * boot.c (init_termstate): Enter raw mode here. + +Fri Jun 24 14:27:56 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * boot.c (S_term_open_ctty): Renamed from term_become_ctty. + Deleted SIGPT arg. Add msg type arg for NEWTTY. + +Fri Jun 17 13:46:07 1994 Michael I Bushnell (mib@geech.gnu.ai.mit.edu) + + * boot.c (request_server): Remove S_ prefix from exec_server + and notify_server. + +Fri Jun 17 00:12:16 1994 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * Makefile (boot.o): Depend on term_S.h. + +Tue Jun 14 01:28:10 1994 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * boot.c (request_server): Add S_ prefix to demuxer functions. + +Wed Jun 8 18:02:19 1994 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * boot.c (S_tioctl_tiocseta): Turn off ECHO. + (S_io_select): Implement. + +Tue Jun 7 04:33:42 1994 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * Makefile (tioctlServer.o): Depend on ../hurd/ioctl_types.h. + +Mon Jun 6 20:33:39 1994 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * boot.c (authserver): New variable. + (S_io_reauthenticate): Do auth_server_authenticate and throw away + the returned info. + (S_exec_init): Set authserver to the passed port. + +Sat Jun 4 02:32:03 1994 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * boot.c: Include term_S.h and tioctl_S.h. + (S_term_getctty): New function. + (S_term_*): Stub functions. + (request_server): Use S_term_server. + + * Makefile (termServer.c term_S.h): New rule. + (OBJS): Add termServer.o. + + * boot.c (S_exec_setexecdata, S_exec_exec): Fix prototypes. + +Tue May 17 18:44:29 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * boot.c (ds_device_write): DATA arg is char *; don't dereference + it in call to write. + +Mon May 16 14:34:15 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * boot.c (fsname): New variable. + (main): Set fsname to argv[1]. + (S_exec_startup): Include fsname in child's argv[0]. + + * boot.c (init_termstate): Add forward declaration. + (struct sigvec): Make SV_HANDLER member void (*)(). + (sigvec): Add declaration to avoid warning. + +Tue May 10 18:14:39 1994 Michael I Bushnell (mib@geech.gnu.ai.mit.edu) + + * boot.c (tioctl_tiocseta, tioctl_tiocsetw, tioctl_tiocsetf, + tioctl_tiocgeta, init_termstate): New functions. + (term_modes, term_ccs, term_speeds, term_sgb, localbits): Nev + vars. + Also added new bits from ioctl.h. + (main): Call init_termstate. + (request_server): Call tioctl_server. + * Makefile (tioctlServer.c tioctl_S.h): New targets. + (OBJS): Include tioctlServer.o. + (boot.o): Depend on tioctl_S.h + +Fri May 6 13:56:58 1994 Michael I Bushnell (mib@geech.gnu.ai.mit.edu) + + * boot.c (main): Restore braindamage of yesterday relating to + signals; that is, restore declaration of VEC and calls to sigvec. + * Makefile (DIST_FILES): Add sigvec.S. + +Thu May 5 13:16:42 1994 Michael I Bushnell (mib@geech.gnu.ai.mit.edu) + + * Makefile (device_replyUser.c): Mention that this build + device_reply.h as well. + (boot.o): Add dependency on device_reply.h and io_repl.h. + + * boot.c: Include <stdlib.h> for malloc and free prototypes. + Include <string.h> for bcopy and bzero prototypes. + Include <stdio.h> for sprintf prototype. + Include "device_reply.h" for its prototypes. + Include "io_reply.h" for its prototypes. + Declare return type for all the server functions that were lacking + such. + (sigpause): Declare type of MASK. + (ioctl): Declare third arg to be generic pointer, not char *. + (request_server): Declare MiG functions we call. + (load_image): Delete unused variable STACKADDR. + (main): Comment out declaration of VEC. + Comment out calls to sigvec. + Cast STARTPC in call to __mach_setup_thread. + Delete unused variable TIMEOUT. + (read_reply): Cast BUF correctly in call to ds_device_read_reply. + (S_exec_startup): Delete unused variable DTABLE. + (ds_device_write): Double cast arg to write to avoid warning. + (S_io_read): Order args to vm_allocate properly; cast DATA arg. + Check *datalen properly for unsigned type. + + * boot.c: Renamed _exit to uxexit to avoid library name clash. + (do_mach_notify_dead_name, do_mach_notify_no_senders): + Call uxexit instead of _exit. + + * boot.c (S_io_async, S_io_get_icky_async_id, S_io_map_cntl): + Expect new type arg for returned port. + (S_io_prenotify, S_io_postnotify): START and END args are now + vm_offset_t. + + * boot.c: Change error_t to kern_return_t because error_t + is now unsigned and conflicts with MiG's use of kern_return_t. + + * Makefile (io_S.h, ioServer.c): Punt mungio hack; use + -DREPLY_PORTS. + * boot.c: Changed all io server stubs to expect reply ports. + + * mungio: removed file. + * Makefile (DIST_FILES): Removed mungio. + + * boot.c (load_image): Only read from the image file the actual + amount being read, not that amount rounded to the nearest page. + Otherwise, the first bit of the BSS will not be zero, but will be + whatever is in the front of the symbol section of the a.out. + +Thu May 5 07:43:06 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Makefile: Change uses of $(headers) to $(includedir). + +Mon May 2 16:47:49 1994 Michael I Bushnell (mib@geech.gnu.ai.mit.edu) + + * boot.c (S_io_readable): Implement io_readable fully. + +Fri Apr 1 17:55:38 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Makefile (OBJS): Remove boot_machdep.o. diff --git a/boot-proxy-exc/Makefile b/boot-proxy-exc/Makefile new file mode 100644 index 00000000..33c475fb --- /dev/null +++ b/boot-proxy-exc/Makefile @@ -0,0 +1,56 @@ +# Copyright (C) 1993,94,95,96,97,2001 Free Software Foundation, Inc. +# This file is part of the GNU Hurd. +# +# The GNU Hurd is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# The GNU Hurd 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with the GNU Hurd; see the file COPYING. If not, write to +# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + +dir := boot +makemode := utility + +SRCS = mach-crt0.c boot.c ux.c sigvec.S syscall.S \ + boot_script.c userland-boot.c list.c mach_proxy.c +COMMON-OBJS = notifyServer.o ourdeviceServer.o \ + ioServer.o io_replyUser.o device_replyUser.o \ + termServer.o bootstrapServer.o boot_script.o userland-boot.o \ + ourmach_hostServer.o ourmachServer.o ourmach_portServer.o excServer.o +OBJS = boot.o mach_host_impl.o mach_impl.o mach_port_impl.o \ + exc_impl.o list.o mach_proxy.o $(COMMON-OBJS) +UX-OBJS = mach-crt0.o uxboot.o sigvec.o syscall.o ux.o $(COMMON-OBJS) +LCLHDRS = boot_script.h ux.h util.h +target = boot +io-MIGSFLAGS=-DREPLY_PORTS +DIST_FILES=frank1.ld frankemul.ld +HURDLIBS=store shouldbeinlibc threads ports + +include ../Makeconf + +#install: /usr/local/bin/uxboot +# +#/usr/local/bin/uxboot: uxboot +# cp $< $@ + +all: boot # uxboot + +ourdevice.defs: device.defs + $(CPP) $(CPPFLAGS) -x c $< | sed -e '/out[ ]*device[ ]*:[ ]*device_t/s/device_t/mach_port_send_t/' > $@ + +uxboot.o: boot.c + $(COMPILE.c) -DUX $< -o $@ + +uxboot.0: $(UX-OBJS) ../libthreads/libthreads.a + $(LINK.o) -o $@ -static -nostartfiles -Wl,-T -Wl,$(srcdir)/frank1.ld $^ +uxboot.1: frankemul.ld uxboot.0 + $(LD) -o $@ -T $^ +uxboot: uxboot.1 + -$(OBJCOPY) -S --remove-section=.comment -O a.out-mach3 $< $@ diff --git a/boot-proxy-exc/backup/ourmach.defs b/boot-proxy-exc/backup/ourmach.defs new file mode 100644 index 00000000..67d8475e --- /dev/null +++ b/boot-proxy-exc/backup/ourmach.defs @@ -0,0 +1,770 @@ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University. + * Copyright (c) 1993,1994 The University of Utah and + * the Computer Systems Laboratory (CSL). + * 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, THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF + * THIS SOFTWARE IN ITS "AS IS" CONDITION, AND DISCLAIM 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. + */ +/* + * Matchmaker definitions file for Mach kernel interface. + */ + +#ifdef MACH_KERNEL +simport <kern/compat_xxx_defs.h>; /* for obsolete routines */ +#endif /* MACH_KERNEL */ + +subsystem +#if KERNEL_USER + KernelUser +#endif /* KERNEL_USER */ +#if KERNEL_SERVER + KernelServer +#endif /* KERNEL_SERVER */ + mach 2000; + +serverprefix S_; + +#ifdef KERNEL_USER +userprefix r_; +#endif /* KERNEL_USER */ + +#include <mach/std_types.defs> +#include <mach/mach_types.defs> + +skip; /* old port_allocate */ +skip; /* old port_deallocate */ +skip; /* old port_enable */ +skip; /* old port_disable */ +skip; /* old port_select */ +skip; /* old port_set_backlog */ +skip; /* old port_status */ + +/* + * Create a new task with an empty set of IPC rights, + * and having an address space constructed from the + * target task (or empty, if inherit_memory is FALSE). + */ +routine task_create( + target_task : task_t; + inherit_memory : boolean_t; + out child_task : mach_port_send_t); + +/* + * Destroy the target task, causing all of its threads + * to be destroyed, all of its IPC rights to be deallocated, + * and all of its address space to be deallocated. + */ +routine task_terminate( + target_task : task_t); + +/* + * Get user-level handler entry points for all + * emulated system calls. + */ +routine task_get_emulation_vector( + task : task_t; + out vector_start : int; + out emulation_vector: emulation_vector_t); + +/* + * Establish user-level handlers for the specified + * system calls. Non-emulated system calls are specified + * with emulation_vector[i] == EML_ROUTINE_NULL. + */ +routine task_set_emulation_vector( + task : task_t; + vector_start : int; + emulation_vector: emulation_vector_t); + +/* + * Returns the set of threads belonging to the target task. + */ +routine task_threads( + target_task : task_t; + out thread_list : thread_array_t = + array[] of mach_port_send_t, + dealloc); + +/* + * Returns information about the target task. + */ +routine task_info( + target_task : task_t; + flavor : int; + out task_info_out : task_info_t, CountInOut); + + +skip; /* old task_status */ +skip; /* old task_set_notify */ +skip; /* old thread_create */ + +/* + * Destroy the target thread. + */ +routine thread_terminate( + target_thread : thread_t); + +/* + * Return the selected state information for the target + * thread. If the thread is currently executing, the results + * may be stale. [Flavor THREAD_STATE_FLAVOR_LIST provides a + * list of valid flavors for the target thread.] + */ +routine thread_get_state( + target_thread : thread_t; + flavor : int; + out old_state : thread_state_t, CountInOut); + +/* + * Set the selected state information for the target thread. + * If the thread is currently executing, the state change + * may be ill-defined. + */ +routine thread_set_state( + target_thread : thread_t; + flavor : int; + new_state : thread_state_t); + +/* + * Returns information about the target thread. + */ +routine thread_info( + target_thread : thread_t; + flavor : int; + out thread_info_out : thread_info_t, CountInOut); + +skip; /* old thread_mutate */ + +/* + * Allocate zero-filled memory in the address space + * of the target task, either at the specified address, + * or wherever space can be found (if anywhere is TRUE), + * of the specified size. The address at which the + * allocation actually took place is returned. + */ +#ifdef EMULATOR +skip; /* the emulator redefines vm_allocate using vm_map */ +#else /* EMULATOR */ +routine vm_allocate( + target_task : vm_task_t; + inout address : vm_address_t; + size : vm_size_t; + anywhere : boolean_t); +#endif /* EMULATOR */ + +skip; /* old vm_allocate_with_pager */ + +/* + * Deallocate the specified range from the virtual + * address space of the target task. + */ +routine vm_deallocate( + target_task : vm_task_t; + address : vm_address_t; + size : vm_size_t); + +/* + * Set the current or maximum protection attribute + * for the specified range of the virtual address + * space of the target task. The current protection + * limits the memory access rights of threads within + * the task; the maximum protection limits the accesses + * that may be given in the current protection. + * Protections are specified as a set of {read, write, execute} + * *permissions*. + */ +routine vm_protect( + target_task : vm_task_t; + address : vm_address_t; + size : vm_size_t; + set_maximum : boolean_t; + new_protection : vm_prot_t); + +/* + * Set the inheritance attribute for the specified range + * of the virtual address space of the target task. + * The inheritance value is one of {none, copy, share}, and + * specifies how the child address space should acquire + * this memory at the time of a task_create call. + */ +routine vm_inherit( + target_task : vm_task_t; + address : vm_address_t; + size : vm_size_t; + new_inheritance : vm_inherit_t); + +/* + * Returns the contents of the specified range of the + * virtual address space of the target task. [The + * range must be aligned on a virtual page boundary, + * and must be a multiple of pages in extent. The + * protection on the specified range must permit reading.] + */ +routine vm_read( + target_task : vm_task_t; + address : vm_address_t; + size : vm_size_t; + out data : pointer_t, dealloc); + +/* + * Writes the contents of the specified range of the + * virtual address space of the target task. [The + * range must be aligned on a virtual page boundary, + * and must be a multiple of pages in extent. The + * protection on the specified range must permit writing.] + */ +routine vm_write( + target_task : vm_task_t; + address : vm_address_t; + data : pointer_t); + +/* + * Copy the contents of the source range of the virtual + * address space of the target task to the destination + * range in that same address space. [Both of the + * ranges must be aligned on a virtual page boundary, + * and must be multiples of pages in extent. The + * protection on the source range must permit reading, + * and the protection on the destination range must + * permit writing.] + */ +routine vm_copy( + target_task : vm_task_t; + source_address : vm_address_t; + size : vm_size_t; + dest_address : vm_address_t); + +/* + * Returns information about the contents of the virtual + * address space of the target task at the specified + * address. The returned protection, inheritance, sharing + * and memory object values apply to the entire range described + * by the address range returned; the memory object offset + * corresponds to the beginning of the address range. + * [If the specified address is not allocated, the next + * highest address range is described. If no addresses beyond + * the one specified are allocated, the call returns KERN_NO_SPACE.] + */ +routine vm_region( + target_task : vm_task_t; + inout address : vm_address_t; + out size : vm_size_t; + out protection : vm_prot_t; + out max_protection : vm_prot_t; + out inheritance : vm_inherit_t; + out is_shared : boolean_t; + /* avoid out-translation of the argument */ + out object_name : memory_object_name_t = + MACH_MSG_TYPE_COPY_SEND + ctype: mach_port_t; + out offset : vm_offset_t); + +/* + * Return virtual memory statistics for the host + * on which the target task resides. [Note that the + * statistics are not specific to the target task.] + */ +routine vm_statistics( + target_task : vm_task_t; + out vm_stats : vm_statistics_data_t); + +skip; /* old task_by_u*x_pid */ +skip; /* old vm_pageable */ + +/* + * Stash a handful of ports for the target task; child + * tasks inherit this stash at task_create time. + */ +routine mach_ports_register( + target_task : task_t; + init_port_set : mach_port_array_t = + ^array[] of mach_port_t); + +/* + * Retrieve the stashed ports for the target task. + */ +routine mach_ports_lookup( + target_task : task_t; + out init_port_set : mach_port_array_t = + ^array[] of mach_port_t); + +skip; /* old u*x_pid */ +skip; /* old netipc_listen */ +skip; /* old netipc_ignore */ + +/* + * Provide the data contents of a range of the given memory + * object, with the access restriction specified. [Only + * whole virtual pages of data can be accepted; partial pages + * will be discarded. Data should be provided on request, but + * may be provided in advance as desired. When data already + * held by this kernel is provided again, the new data is ignored. + * The access restriction is the subset of {read, write, execute} + * which are prohibited. The kernel may not provide any data (or + * protection) consistency among pages with different virtual page + * alignments within the same object.] + */ +simpleroutine memory_object_data_provided( + memory_control : memory_object_control_t; + offset : vm_offset_t; + data : pointer_t; + lock_value : vm_prot_t); + +/* + * Indicate that a range of the given temporary memory object does + * not exist, and that the backing memory object should be used + * instead (or zero-fill memory be used, if no backing object exists). + * [This call is intended for use only by the default memory manager. + * It should not be used to indicate a real error -- + * memory_object_data_error should be used for that purpose.] + */ +simpleroutine memory_object_data_unavailable( + memory_control : memory_object_control_t; + offset : vm_offset_t; + size : vm_size_t); + +/* + * Retrieves the attributes currently associated with + * a memory object. + */ +routine memory_object_get_attributes( + memory_control : memory_object_control_t; + out object_ready : boolean_t; + out may_cache : boolean_t; + out copy_strategy : memory_object_copy_strategy_t); + +/* + * Sets the default memory manager, the port to which + * newly-created temporary memory objects are delivered. + * [See (memory_object_default)memory_object_create.] + * The old memory manager port is returned. + */ +routine vm_set_default_memory_manager( + host_priv : host_priv_t; + inout default_manager : mach_port_copy_send_t); + +skip; /* old pager_flush_request */ + +/* + * Control use of the data associated with the given + * memory object. For each page in the given range, + * perform the following operations, in order: + * 1) restrict access to the page (disallow + * forms specified by "prot"); + * 2) write back modifications (if "should_return" + * is RETURN_DIRTY and the page is dirty, or + * "should_return" is RETURN_ALL and the page + * is either dirty or precious); and, + * 3) flush the cached copy (if "should_flush" + * is asserted). + * The set of pages is defined by a starting offset + * ("offset") and size ("size"). Only pages with the + * same page alignment as the starting offset are + * considered. + * + * A single acknowledgement is sent (to the "reply_to" + * port) when these actions are complete. + * + * There are two versions of this routine because IPC distinguishes + * between booleans and integers (a 2-valued integer is NOT a + * boolean). The new routine is backwards compatible at the C + * language interface. + */ +simpleroutine xxx_memory_object_lock_request( + memory_control : memory_object_control_t; + offset : vm_offset_t; + size : vm_size_t; + should_clean : boolean_t; + should_flush : boolean_t; + lock_value : vm_prot_t; + reply_to : mach_port_t = + MACH_MSG_TYPE_MAKE_SEND_ONCE|polymorphic); + + +simpleroutine memory_object_lock_request( + memory_control : memory_object_control_t; + offset : vm_offset_t; + size : vm_size_t; + should_return : memory_object_return_t; + should_flush : boolean_t; + lock_value : vm_prot_t; + reply_to : mach_port_t = + MACH_MSG_TYPE_MAKE_SEND_ONCE|polymorphic); + +/* obsolete */ +routine xxx_task_get_emulation_vector( + task : task_t; + out vector_start : int; + out emulation_vector: xxx_emulation_vector_t, IsLong); + +/* obsolete */ +routine xxx_task_set_emulation_vector( + task : task_t; + vector_start : int; + emulation_vector: xxx_emulation_vector_t, IsLong); + +/* + * Returns information about the host on which the + * target object resides. [This object may be + * a task, thread, or memory_object_control port.] + */ +routine xxx_host_info( + target_task : mach_port_t; + out info : machine_info_data_t); + +/* + * Returns information about a particular processor on + * the host on which the target task resides. + */ +routine xxx_slot_info( + target_task : task_t; + slot : int; + out info : machine_slot_data_t); + +/* + * Performs control operations (currently only + * turning off or on) on a particular processor on + * the host on which the target task resides. + */ +routine xxx_cpu_control( + target_task : task_t; + cpu : int; + running : boolean_t); + +skip; /* old thread_statistics */ +skip; /* old task_statistics */ +skip; /* old netport_init */ +skip; /* old netport_enter */ +skip; /* old netport_remove */ +skip; /* old thread_set_priority */ + +/* + * Increment the suspend count for the target task. + * No threads within a task may run when the suspend + * count for that task is non-zero. + */ +routine task_suspend( + target_task : task_t); + +/* + * Decrement the suspend count for the target task, + * if the count is currently non-zero. If the resulting + * suspend count is zero, then threads within the task + * that also have non-zero suspend counts may execute. + */ +routine task_resume( + target_task : task_t); + +/* + * Returns the current value of the selected special port + * associated with the target task. + */ +routine task_get_special_port( + task : task_t; + which_port : int; + out special_port : mach_port_send_t); + +/* + * Set one of the special ports associated with the + * target task. + */ +routine task_set_special_port( + task : task_t; + which_port : int; + special_port : mach_port_t); + +/* obsolete */ +routine xxx_task_info( + target_task : task_t; + flavor : int; + out task_info_out : task_info_t, IsLong); + + +/* + * Create a new thread within the target task, returning + * the port representing that new thread. The + * initial execution state of the thread is undefined. + */ +routine thread_create( + parent_task : task_t; + out child_thread : mach_port_send_t); + +/* + * Increment the suspend count for the target thread. + * Once this call has completed, the thread will not + * execute any further user or meta- instructions. + * Once suspended, a thread may not execute again until + * its suspend count is zero, and the suspend count + * for its task is also zero. + */ +routine thread_suspend( + target_thread : thread_t); + +/* + * Decrement the suspend count for the target thread, + * if that count is not already zero. + */ +routine thread_resume( + target_thread : thread_t); + +/* + * Cause any user or meta- instructions currently being + * executed by the target thread to be aborted. [Meta- + * instructions consist of the basic traps for IPC + * (e.g., msg_send, msg_receive) and self-identification + * (e.g., task_self, thread_self, thread_reply). Calls + * described by MiG interfaces are not meta-instructions + * themselves.] + */ +routine thread_abort( + target_thread : thread_t); + +/* obsolete */ +routine xxx_thread_get_state( + target_thread : thread_t; + flavor : int; + out old_state : thread_state_t, IsLong); + +/* obsolete */ +routine xxx_thread_set_state( + target_thread : thread_t; + flavor : int; + new_state : thread_state_t, IsLong); + +/* + * Returns the current value of the selected special port + * associated with the target thread. + */ +routine thread_get_special_port( + thread : thread_t; + which_port : int; + out special_port : mach_port_t); + +/* + * Set one of the special ports associated with the + * target thread. + */ +routine thread_set_special_port( + thread : thread_t; + which_port : int; + special_port : mach_port_t); + +/* obsolete */ +routine xxx_thread_info( + target_thread : thread_t; + flavor : int; + out thread_info_out : thread_info_t, IsLong); + +/* + * Establish a user-level handler for the specified + * system call. + */ +routine task_set_emulation( + target_port : task_t; + routine_entry_pt: vm_address_t; + routine_number : int); + +/* + * Establish restart pc for interrupted atomic sequences. + * This reuses the message number for the old task_get_io_port. + * See task_info.h for description of flavors. + * + */ +routine task_ras_control( + target_task : task_t; + basepc : vm_address_t; + boundspc : vm_address_t; + flavor : int); + + + +skip; /* old host_ipc_statistics */ +skip; /* old port_names */ +skip; /* old port_type */ +skip; /* old port_rename */ +skip; /* old port_allocate */ +skip; /* old port_deallocate */ +skip; /* old port_set_backlog */ +skip; /* old port_status */ +skip; /* old port_set_allocate */ +skip; /* old port_set_deallocate */ +skip; /* old port_set_add */ +skip; /* old port_set_remove */ +skip; /* old port_set_status */ +skip; /* old port_insert_send */ +skip; /* old port_extract_send */ +skip; /* old port_insert_receive */ +skip; /* old port_extract_receive */ + +/* + * Map a user-defined memory object into the virtual address + * space of the target task. If desired (anywhere is TRUE), + * the kernel will find a suitable address range of the + * specified size; else, the specific address will be allocated. + * + * The beginning address of the range will be aligned on a virtual + * page boundary, be at or beyond the address specified, and + * meet the mask requirements (bits turned on in the mask must not + * be turned on in the result); the size of the range, in bytes, + * will be rounded up to an integral number of virtual pages. + * + * The memory in the resulting range will be associated with the + * specified memory object, with the beginning of the memory range + * referring to the specified offset into the memory object. + * + * The mapping will take the current and maximum protections and + * the inheritance attributes specified; see the vm_protect and + * vm_inherit calls for a description of these attributes. + * + * If desired (copy is TRUE), the memory range will be filled + * with a copy of the data from the memory object; this copy will + * be private to this mapping in this target task. Otherwise, + * the memory in this mapping will be shared with other mappings + * of the same memory object at the same offset (in this task or + * in other tasks). [The Mach kernel only enforces shared memory + * consistency among mappings on one host with similar page alignments. + * The user-defined memory manager for this object is responsible + * for further consistency.] + */ +#ifdef EMULATOR +routine htg_vm_map( + target_task : vm_task_t; + ureplyport reply_port : mach_port_make_send_once_t; + inout address : vm_address_t; + size : vm_size_t; + mask : vm_address_t; + anywhere : boolean_t; + memory_object : memory_object_t; + offset : vm_offset_t; + copy : boolean_t; + cur_protection : vm_prot_t; + max_protection : vm_prot_t; + inheritance : vm_inherit_t); +#else /* EMULATOR */ +routine vm_map( + target_task : vm_task_t; + inout address : vm_address_t; + size : vm_size_t; + mask : vm_address_t; + anywhere : boolean_t; + memory_object : memory_object_t; + offset : vm_offset_t; + copy : boolean_t; + cur_protection : vm_prot_t; + max_protection : vm_prot_t; + inheritance : vm_inherit_t); +#endif /* EMULATOR */ + +/* + * Indicate that a range of the specified memory object cannot + * be provided at this time. [Threads waiting for memory pages + * specified by this call will experience a memory exception. + * Only threads waiting at the time of the call are affected.] + */ +simpleroutine memory_object_data_error( + memory_control : memory_object_control_t; + offset : vm_offset_t; + size : vm_size_t; + error_value : kern_return_t); + +/* + * Make decisions regarding the use of the specified + * memory object. + */ +simpleroutine memory_object_set_attributes( + memory_control : memory_object_control_t; + object_ready : boolean_t; + may_cache : boolean_t; + copy_strategy : memory_object_copy_strategy_t); + +/* + */ +simpleroutine memory_object_destroy( + memory_control : memory_object_control_t; + reason : kern_return_t); + +/* + * Provide the data contents of a range of the given memory + * object, with the access restriction specified, optional + * precious attribute, and reply message. [Only + * whole virtual pages of data can be accepted; partial pages + * will be discarded. Data should be provided on request, but + * may be provided in advance as desired. When data already + * held by this kernel is provided again, the new data is ignored. + * The access restriction is the subset of {read, write, execute} + * which are prohibited. The kernel may not provide any data (or + * protection) consistency among pages with different virtual page + * alignments within the same object. The precious value controls + * how the kernel treats the data. If it is FALSE, the kernel treats + * its copy as a temporary and may throw it away if it hasn't been + * changed. If the precious value is TRUE, the kernel treats its + * copy as a data repository and promises to return it to the manager; + * the manager may tell the kernel to throw it away instead by flushing + * and not cleaning the data -- see memory_object_lock_request. The + * reply_to port is for a compeletion message; it will be + * memory_object_supply_completed.] + */ + +simpleroutine memory_object_data_supply( + memory_control : memory_object_control_t; + offset : vm_offset_t; + data : pointer_t, Dealloc[]; + lock_value : vm_prot_t; + precious : boolean_t; + reply_to : mach_port_t = + MACH_MSG_TYPE_MAKE_SEND_ONCE|polymorphic); + +simpleroutine memory_object_ready( + memory_control : memory_object_control_t; + may_cache : boolean_t; + copy_strategy : memory_object_copy_strategy_t); + +simpleroutine memory_object_change_attributes( + memory_control : memory_object_control_t; + may_cache : boolean_t; + copy_strategy : memory_object_copy_strategy_t; + reply_to : mach_port_t = + MACH_MSG_TYPE_MAKE_SEND_ONCE|polymorphic); + +skip; /* old host_callout_statistics_reset */ +skip; /* old port_set_select */ +skip; /* old port_set_backup */ + +/* + * Set/Get special properties of memory associated + * to some virtual address range, such as cachability, + * migrability, replicability. Machine-dependent. + */ +routine vm_machine_attribute( + target_task : vm_task_t; + address : vm_address_t; + size : vm_size_t; + attribute : vm_machine_attribute_t; + inout value : vm_machine_attribute_val_t); + +skip; /* old host_fpa_counters_reset */ + +/* + * There is no more room in this interface for additional calls. + */ diff --git a/boot-proxy-exc/backup/ourmach_host.defs b/boot-proxy-exc/backup/ourmach_host.defs new file mode 100644 index 00000000..0e7e367e --- /dev/null +++ b/boot-proxy-exc/backup/ourmach_host.defs @@ -0,0 +1,381 @@ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989 Carnegie Mellon University. + * Copyright (c) 1993,1994 The University of Utah and + * the Computer Systems Laboratory (CSL). + * 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, THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF + * THIS SOFTWARE IN ITS "AS IS" CONDITION, AND DISCLAIM 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. + */ +/* + * File: mach/mach_host.defs + * + * Abstract: + * Mach host operations support. Includes processor allocation and + * control. + */ + +#ifdef MACH_KERNEL +simport <kern/compat_xxx_defs.h>; /* for obsolete routines */ +#endif + +subsystem +#if KERNEL_SERVER + KernelServer +#endif + mach_host 2600; + +serverprefix S_; + +/* + * Basic types + */ + +#include <mach/std_types.defs> +#include <mach/mach_types.defs> + +/* + * Get list of processors on this host. + */ + +routine host_processors( + host_priv : host_priv_t; + out processor_list : processor_array_t); + +/* obsolete */ +routine yyy_host_info( + host : host_t; + flavor : int; + out host_info_out : host_info_t, IsLong); + + +/* obsolete */ +routine yyy_processor_info( + processor : processor_t; + flavor : int; + out host : host_t; + out processor_info_out: processor_info_t, IsLong); + +/* + * Start processor. + */ + +routine processor_start( + processor : processor_t); + +/* + * Exit processor -- may not be restartable. + */ + +routine processor_exit( + processor : processor_t); + +/* obsolete */ +routine yyy_processor_control( + processor : processor_t; + processor_cmd : processor_info_t, IsLong); + +/* + * Get default processor set for host. + */ +routine processor_set_default( + host : host_t; + out default_set : processor_set_name_t); + +/* + * Get rights to default processor set for host. + * Replaced by host_processor_set_priv. + */ +routine xxx_processor_set_default_priv( + host : host_priv_t; + out default_set : processor_set_t); + +/* + * Create new processor set. Returns real port for manipulations, + * and name port for obtaining information. + */ +routine processor_set_create( + host : host_t; + out new_set : processor_set_t; + out new_name : processor_set_name_t); + +/* + * Destroy processor set. + */ +routine processor_set_destroy( + set : processor_set_t); + +/* obsolete */ +routine yyy_processor_set_info( + set_name : processor_set_name_t; + flavor : int; + out host : host_t; + out info_out : processor_set_info_t, IsLong); + +/* + * Assign processor to processor set. + */ +routine processor_assign( + processor : processor_t; + new_set : processor_set_t; + wait : boolean_t); + +/* + * Get current assignment for processor. + */ + +routine processor_get_assignment( + processor : processor_t; + out assigned_set : processor_set_name_t); + +/* + * Assign thread to processor set. + */ +routine thread_assign( + thread : thread_t; + new_set : processor_set_t); + +/* + * Assign thread to default set. + */ +routine thread_assign_default( + thread : thread_t); + +/* + * Get current assignment for thread. + */ +routine thread_get_assignment( + thread : thread_t; + out assigned_set : processor_set_name_t); + +/* + * Assign task to processor set. + */ +routine task_assign( + task : task_t; + new_set : processor_set_t; + assign_threads : boolean_t); +/* + * Assign task to default set. + */ +routine task_assign_default( + task : task_t; + assign_threads : boolean_t); + +/* + * Get current assignment for task. + */ +routine task_get_assignment( + task : task_t; + out assigned_set : processor_set_name_t); + +/* + * Get string describing current kernel version. + */ +routine host_kernel_version( + host : host_t; + out kernel_version : kernel_version_t); + +/* + * Set priority for thread. + */ +routine thread_priority( + thread : thread_t; + priority : int; + set_max : boolean_t); + +/* + * Set max priority for thread. + */ +routine thread_max_priority( + thread : thread_t; + processor_set : processor_set_t; + max_priority : int); + +/* + * Set task priority. + */ +routine task_priority( + task : task_t; + priority : int; + change_threads : boolean_t); + +/* + * Set max priority for processor_set. + */ +routine processor_set_max_priority( + processor_set : processor_set_t; + max_priority : int; + change_threads : boolean_t); + +/* + * Set policy for thread + */ +routine thread_policy( + thread : thread_t; + policy : int; + data : int); + +/* + * Enable policy for processor set + */ +routine processor_set_policy_enable( + processor_set : processor_set_t; + policy : int); + +/* + * Disable policy for processor set + */ +routine processor_set_policy_disable( + processor_set : processor_set_t; + policy : int; + change_threads : boolean_t); +/* + * List all tasks in processor set. + */ +routine processor_set_tasks( + processor_set : processor_set_t; + out task_list : task_array_t); + +/* + * List all threads in processor set. + */ +routine processor_set_threads( + processor_set : processor_set_t; + out thread_list : thread_array_t); + +/* + * List all processor sets on host. + */ +routine host_processor_sets( + host : host_t; + out processor_sets : processor_set_name_array_t); + +/* + * Get control port for a processor set. + */ +routine host_processor_set_priv( + host_priv : host_priv_t; + set_name : processor_set_name_t; + out set : mach_port_send_t); + +routine thread_depress_abort( + thread : thread_t); + +/* + * Set the time on this host. + * Only available to privileged users. + */ +routine host_set_time( + host_priv : host_priv_t; + new_time : time_value_t); + +/* + * Arrange for the time on this host to be gradually changed + * by an adjustment value, and return the old value. + * Only available to privileged users. + */ +routine host_adjust_time( + host_priv : host_priv_t; + in new_adjustment : time_value_t; + out old_adjustment : time_value_t); + +/* + * Get the time on this host. + * Available to all. + */ +routine host_get_time( + host : host_t; + out current_time : time_value_t); + +/* + * Reboot this host. + * Only available to privileged users. + */ +routine host_reboot( + host_priv : host_priv_t; + options : int); + +/* + * Specify that the range of the virtual address space + * of the target task must not cause page faults for + * the indicated accesses. + * + * [ To unwire the pages, specify VM_PROT_NONE. ] + */ +routine vm_wire( + host_priv : host_priv_t; + task : vm_task_t; + address : vm_address_t; + size : vm_size_t; + access : vm_prot_t); + +/* + * Specify that the target thread must always be able + * to run and to allocate memory. + */ +routine thread_wire( + host_priv : host_priv_t; + thread : thread_t; + wired : boolean_t); + +/* + * Return information about this host. + */ + +routine host_info( + host : host_t; + flavor : int; + out host_info_out : host_info_t, CountInOut); + + +/* + * Return information about this processor. + */ +routine processor_info( + processor : processor_t; + flavor : int; + out host : host_t; + out processor_info_out: processor_info_t, CountInOut); + +/* + * Get information about processor set. + */ +routine processor_set_info( + set_name : processor_set_name_t; + flavor : int; + out host : host_t; + out info_out : processor_set_info_t, CountInOut); + +/* + * Do something machine-dependent to processor. + */ +routine processor_control( + processor : processor_t; + processor_cmd : processor_info_t); + +/* + * Get boot configuration information from kernel. + */ +routine host_get_boot_info( + host_priv : host_priv_t; + out boot_info : kernel_boot_info_t); diff --git a/boot-proxy-exc/backup/ourmach_port.defs b/boot-proxy-exc/backup/ourmach_port.defs new file mode 100644 index 00000000..4f131bb2 --- /dev/null +++ b/boot-proxy-exc/backup/ourmach_port.defs @@ -0,0 +1,349 @@ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989 Carnegie Mellon University. + * Copyright (c) 1993,1994 The University of Utah and + * the Computer Systems Laboratory (CSL). + * 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, THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF + * THIS SOFTWARE IN ITS "AS IS" CONDITION, AND DISCLAIM 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. + */ +/* + * File: mach/mach_port.defs + * Author: Rich Draves + * + * Copyright (c) 1989 Richard P. Draves, Jr. + * + * Exported kernel calls. + */ + +subsystem +#if KERNEL_SERVER + KernelServer +#endif + mach_port 3200; + +#include <mach/std_types.defs> +#include <mach/mach_types.defs> + +/* + * Returns the set of port and port set names + * to which the target task has access, along with + * the type (set or port) for each name. + */ + +routine mach_port_names( + task : ipc_space_t; + out names : mach_port_name_array_t = + ^array[] of mach_port_name_t + ctype: mach_port_array_t, + dealloc; + out types : mach_port_type_array_t = + ^array[] of mach_port_type_t, + dealloc); + +/* + * Returns the type (set or port) for the port name + * within the target task. Also indicates whether + * there is a dead-name request for the name. + */ + +routine mach_port_type( + task : ipc_space_t; + name : mach_port_name_t; + out ptype : mach_port_type_t); + +/* + * Changes the name by which a port (or port set) is known to + * the target task. The new name can't be in use. The + * old name becomes available for recycling. + */ + +routine mach_port_rename( + task : ipc_space_t; + old_name : mach_port_name_t; + new_name : mach_port_name_t); + +/* + * Allocates the specified kind of object, with the given name. + * The right must be one of + * MACH_PORT_RIGHT_RECEIVE + * MACH_PORT_RIGHT_PORT_SET + * MACH_PORT_RIGHT_DEAD_NAME + * New port sets are empty. New ports don't have any + * send/send-once rights or queued messages. The make-send + * count is zero and their queue limit is MACH_PORT_QLIMIT_DEFAULT. + * New sets, ports, and dead names have one user reference. + */ + +routine mach_port_allocate_name( + task : ipc_space_t; + right : mach_port_right_t; + name : mach_port_name_t); + +/* + * Allocates the specified kind of object. + * The right must be one of + * MACH_PORT_RIGHT_RECEIVE + * MACH_PORT_RIGHT_PORT_SET + * MACH_PORT_RIGHT_DEAD_NAME + * Like port_allocate_name, but the kernel picks a name. + * It can use any name not associated with a right. + */ + +routine mach_port_allocate( + task : ipc_space_t; + right : mach_port_right_t; + out name : mach_port_name_t); + +/* + * Destroys all rights associated with the name and makes it + * available for recycling immediately. The name can be a + * port (possibly with multiple user refs), a port set, or + * a dead name (again, with multiple user refs). + */ + +routine mach_port_destroy( + task : ipc_space_t; + name : mach_port_name_t); + +/* + * Releases one send/send-once/dead-name user ref. + * Just like mach_port_mod_refs -1, but deduces the + * correct type of right. This allows a user task + * to release a ref for a port without worrying + * about whether the port has died or not. + */ + +routine mach_port_deallocate( + task : ipc_space_t; + name : mach_port_name_t); + +/* + * A port set always has one user ref. + * A send-once right always has one user ref. + * A dead name always has one or more user refs. + * A send right always has one or more user refs. + * A receive right always has one user ref. + * The right must be one of + * MACH_PORT_RIGHT_RECEIVE + * MACH_PORT_RIGHT_PORT_SET + * MACH_PORT_RIGHT_DEAD_NAME + * MACH_PORT_RIGHT_SEND + * MACH_PORT_RIGHT_SEND_ONCE + */ + +routine mach_port_get_refs( + task : ipc_space_t; + name : mach_port_name_t; + right : mach_port_right_t; + out refs : mach_port_urefs_t); + +/* + * The delta is a signed change to the task's + * user ref count for the right. Only dead names + * and send rights can have a positive delta. + * The resulting user ref count can't be negative. + * If it is zero, the right is deallocated. + * If the name isn't a composite right, it becomes + * available for recycling. The right must be one of + * MACH_PORT_RIGHT_RECEIVE + * MACH_PORT_RIGHT_PORT_SET + * MACH_PORT_RIGHT_DEAD_NAME + * MACH_PORT_RIGHT_SEND + * MACH_PORT_RIGHT_SEND_ONCE + */ + +routine mach_port_mod_refs( + task : ipc_space_t; + name : mach_port_name_t; + right : mach_port_right_t; + delta : mach_port_delta_t); + +/* + * Temporary compatibility call. + */ + +routine old_mach_port_get_receive_status( + task : ipc_space_t; + name : mach_port_name_t; + out status : old_mach_port_status_t); + +/* + * Only valid for receive rights. + * Sets the queue-limit for the port. + * The limit must be + * 1 <= qlimit <= MACH_PORT_QLIMIT_MAX + */ + +routine mach_port_set_qlimit( + task : ipc_space_t; + name : mach_port_name_t; + qlimit : mach_port_msgcount_t); + +/* + * Only valid for receive rights. + * Sets the make-send count for the port. + */ + +routine mach_port_set_mscount( + task : ipc_space_t; + name : mach_port_name_t; + mscount : mach_port_mscount_t); + +/* + * Only valid for port sets. Returns a list of + * the members. + */ + +routine mach_port_get_set_status( + task : ipc_space_t; + name : mach_port_name_t; + out members : mach_port_name_array_t = + ^array[] of mach_port_name_t + ctype: mach_port_array_t, + dealloc); + +/* + * Puts the member port (the task must have receive rights) + * into the after port set. (Or removes it from any port set + * if after is MACH_PORT_NULL.) If the port is already in + * a set, does an atomic move. + */ + +routine mach_port_move_member( + task : ipc_space_t; + member : mach_port_name_t; + after : mach_port_name_t); + +/* + * Requests a notification from the kernel. The request + * must supply the send-once right which is used for + * the notification. If a send-once right was previously + * registered, it is returned. The msg_id must be one of + * MACH_NOTIFY_PORT_DESTROYED (receive rights) + * MACH_NOTIFY_DEAD_NAME (send/receive/send-once rights) + * MACH_NOTIFY_NO_SENDERS (receive rights) + * + * The sync value specifies whether a notification should + * get sent immediately, if appropriate. The exact meaning + * depends on the notification: + * MACH_NOTIFY_PORT_DESTROYED: must be zero. + * MACH_NOTIFY_DEAD_NAME: if non-zero, then name can be dead, + * and the notification gets sent immediately. + * If zero, then name can't be dead. + * MACH_NOTIFY_NO_SENDERS: the notification gets sent + * immediately if the current mscount is greater + * than or equal to the sync value and there are no + * extant send rights. + */ + +routine mach_port_request_notification( + task : ipc_space_t; + name : mach_port_name_t; + id : mach_msg_id_t; + sync : mach_port_mscount_t; + notify : mach_port_send_once_t; + out previous : mach_port_send_once_t); + +/* + * Inserts the specified rights into the target task, + * using the specified name. If inserting send/receive + * rights and the task already has send/receive rights + * for the port, then the names must agree. In any case, + * the task gains a user ref for the port. + */ + +routine mach_port_insert_right( + task : ipc_space_t; + name : mach_port_name_t; + poly : mach_port_poly_t); + +/* + * Returns the specified right for the named port + * in the target task, extracting that right from + * the target task. The target task loses a user + * ref and the name may be available for recycling. + * msgt_name must be one of + * MACH_MSG_TYPE_MOVE_RECEIVE + * MACH_MSG_TYPE_COPY_SEND + * MACH_MSG_TYPE_MAKE_SEND + * MACH_MSG_TYPE_MOVE_SEND + * MACH_MSG_TYPE_MAKE_SEND_ONCE + * MACH_MSG_TYPE_MOVE_SEND_ONCE + */ + +routine mach_port_extract_right( + task : ipc_space_t; + name : mach_port_name_t; + msgt_name : mach_msg_type_name_t; + out poly : mach_port_poly_t); + +/* + * The task must have receive rights for the named port. + * Returns a status structure (see mach/port.h). + */ + +routine mach_port_get_receive_status( + task : ipc_space_t; + name : mach_port_name_t; + out status : mach_port_status_t); + +/* + * Only valid for receive rights. + * Sets the sequence number for the port. + */ + +routine mach_port_set_seqno( + task : ipc_space_t; + name : mach_port_name_t; + seqno : mach_port_seqno_t); + +#ifdef MIGRATING_THREADS +/* + * Only valid for receive rights. + * Set the user-mode entry info for RPCs coming through this port. + * Do this BEFORE attaching an ActPool to this port, + * unless you can be sure no RPCs will be coming through it yet. + */ + +routine mach_port_set_rpcinfo( + task : ipc_space_t; + name : mach_port_name_t; + rpc_info : thread_info_t); /* XXX */ + +/* + * Only valid for receive rights. + * Create a new activation for migrating RPC, and attach it to the port's ActPool. + * Create an ActPool for the port if it doesn't already have one. + * Supply a stack and receive memory buffer. + */ + +routine mach_port_create_act( + task : task_t; + name : mach_port_name_t; + user_stack : vm_offset_t; + user_rbuf : vm_offset_t; + user_rbuf_size : vm_size_t; + out new_act : thread_t); + +#endif /* MIGRATING_THREADS */ + diff --git a/boot-proxy-exc/boot b/boot-proxy-exc/boot Binary files differnew file mode 100755 index 00000000..046e7a02 --- /dev/null +++ b/boot-proxy-exc/boot diff --git a/boot-proxy-exc/boot.c b/boot-proxy-exc/boot.c new file mode 100644 index 00000000..83b69c08 --- /dev/null +++ b/boot-proxy-exc/boot.c @@ -0,0 +1,2150 @@ +/* Load a task using the single server, and then run it + as if we were the kernel. + Copyright (C) 1993,94,95,96,97,98,99,2000,01,02,2006 + Free Software Foundation, Inc. + +This file is part of the GNU Hurd. + +The GNU Hurd is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +The GNU Hurd 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with the GNU Hurd; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/* Written by Michael I. Bushnell. */ + +#include <mach.h> +#include <mach/notify.h> +#include <device/device.h> +#include <a.out.h> +#include <mach/message.h> +#include <mach/mig_errors.h> +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <cthreads.h> +#include <fcntl.h> +#include <elf.h> +#include <mach/mig_support.h> +#include <mach/default_pager.h> +#include <argp.h> +#include <hurd/store.h> +#include <hurd/ports.h> +#include <sys/mman.h> +#include <version.h> + +#include "notify_S.h" +#include "ourdevice_S.h" +#include "io_S.h" +#include "device_reply_U.h" +#include "io_reply_U.h" +#include "term_S.h" +#include "bootstrap_S.h" +/* #include "tioctl_S.h" */ +#include "util.h" +#include "boot_script.h" +#include "mach_proxy.h" + +#include <hurd/auth.h> + +#ifdef UX +#undef STORE /* We can't use libstore when under UX. */ +#else +#define STORE +#endif + +#ifdef UX + +#include "ux.h" + +#else /* !UX */ + +#include <unistd.h> +#include <fcntl.h> +#include <signal.h> +#include <sys/ioctl.h> +#include <sys/stat.h> +#include <termios.h> +#include <error.h> +#include <hurd.h> +#include <assert.h> + +static struct termios orig_tty_state; +static int isig; +static char *kernel_command_line; + +struct port_bucket *port_bucket; +struct port_class *task_portclass; +struct port_class *exc_portclass; +struct port_class *priv_host_portclass; +struct port_class *other_portclass; + +void destroy_priv_host (void *pi); + +static void +init_termstate () +{ + struct termios tty_state; + + if (tcgetattr (0, &tty_state) < 0) + error (10, errno, "tcgetattr"); + + orig_tty_state = tty_state; + cfmakeraw (&tty_state); + if (isig) + tty_state.c_lflag |= ISIG; + + if (tcsetattr (0, 0, &tty_state) < 0) + error (11, errno, "tcsetattr"); +} + +static void +restore_termstate () +{ + tcsetattr (0, 0, &orig_tty_state); +} + +#define host_fstat fstat +typedef struct stat host_stat_t; +#define host_exit exit + +#endif /* UX */ + +mach_port_t privileged_host_port, master_device_port, defpager; +mach_port_t pseudo_master_device_port; +mach_port_t receive_set; +mach_port_t pseudo_console, pseudo_root; +auth_t authserver; + +struct port_info *pseudo_priv_host_pi; + +struct store *root_store; + +spin_lock_t queuelock = SPIN_LOCK_INITIALIZER; +spin_lock_t readlock = SPIN_LOCK_INITIALIZER; + +mach_port_t php_child_name, psmdp_child_name, taskname; + +task_t child_task; +mach_port_t bootport; + +int console_mscount; + +vm_address_t fs_stack_base; +vm_size_t fs_stack_size; + +void init_termstate (); +void restore_termstate (); + +char *fsname; + +char bootstrap_args[100] = "-"; +char *bootdevice = 0; +char *bootscript = 0; + +boolean_t is_user = 0; + + +void safe_gets (char *buf, int buf_len) +{ + fgets (buf, buf_len, stdin); +} + +char *useropen_dir; + +int +useropen (const char *name, int flags, int mode) +{ + if (useropen_dir) + { + static int dlen; + if (!dlen) dlen = strlen (useropen_dir); + { + int len = strlen (name); + char try[dlen + 1 + len + 1]; + int fd; + memcpy (try, useropen_dir, dlen); + try[dlen] = '/'; + memcpy (&try[dlen + 1], name, len + 1); + fd = open (try, flags, mode); + if (fd >= 0) + return fd; + } + } + return open (name, flags, mode); +} + +int +request_server (mach_msg_header_t *inp, + mach_msg_header_t *outp) +{ + extern int io_server (mach_msg_header_t *, mach_msg_header_t *); + extern int device_server (mach_msg_header_t *, mach_msg_header_t *); + extern int notify_server (mach_msg_header_t *, mach_msg_header_t *); + extern int term_server (mach_msg_header_t *, mach_msg_header_t *); +/* extern int tioctl_server (mach_msg_header_t *, mach_msg_header_t *); */ + extern int bootstrap_server (mach_msg_header_t *, mach_msg_header_t *); + extern boolean_t mach_host_server (mach_msg_header_t *InHeadP, + mach_msg_header_t *OutHeadP); + extern boolean_t mach_server (mach_msg_header_t *InHeadP, + mach_msg_header_t *OutHeadP); + extern void bootstrap_compat (); + +#if 0 + if (inp->msgh_local_port == bootport && boot_like_cmudef) + { + if (inp->msgh_id == 999999) + { + bootstrap_compat (inp, outp); + return 1; + } + else + return bootstrap_server (inp, outp); + } + else +#endif + return (io_server (inp, outp) + || device_server (inp, outp) + || notify_server (inp, outp) + || term_server (inp, outp) + /* || tioctl_server (inp, outp) */); +} + +int +mach_proxy_demuxer (mach_msg_header_t *inp, + mach_msg_header_t *outp) +{ + extern boolean_t mach_server + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP); + extern boolean_t mach_host_server + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP); + extern boolean_t mach_port_server + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP); + extern boolean_t exc_server + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP); + extern int notify_server (mach_msg_header_t *, mach_msg_header_t *); + return (mach_server (inp, outp) + || mach_host_server (inp, outp) + || mach_port_server (inp, outp) + || notify_server (inp, outp) + || exc_server (inp, outp)); +} + +void +mach_proxy_thread () +{ + ports_manage_port_operations_multithread (port_bucket, + mach_proxy_demuxer, + 30 * 1000, 0, 0); +} + +vm_address_t +load_image (task_t t, + char *file) +{ + int fd; + union + { + struct exec a; + Elf32_Ehdr e; + } hdr; + char msg[] = ": cannot open bootstrap file\n"; + + fd = useropen (file, O_RDONLY, 0); + + if (fd == -1) + { + write (2, file, strlen (file)); + write (2, msg, sizeof msg - 1); + task_terminate (t); + host_exit (1); + } + + read (fd, &hdr, sizeof hdr); + if (*(Elf32_Word *) hdr.e.e_ident == *(Elf32_Word *) "\177ELF") + { + Elf32_Phdr phdrs[hdr.e.e_phnum], *ph; + lseek (fd, hdr.e.e_phoff, SEEK_SET); + read (fd, phdrs, sizeof phdrs); + for (ph = phdrs; ph < &phdrs[sizeof phdrs/sizeof phdrs[0]]; ++ph) + if (ph->p_type == PT_LOAD) + { + vm_address_t buf; + vm_size_t offs = ph->p_offset & (ph->p_align - 1); + vm_size_t bufsz = round_page (ph->p_filesz + offs); + + buf = (vm_address_t) mmap (0, bufsz, + PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); + + lseek (fd, ph->p_offset, SEEK_SET); + read (fd, (void *)(buf + offs), ph->p_filesz); + + ph->p_memsz = ((ph->p_vaddr + ph->p_memsz + ph->p_align - 1) + & ~(ph->p_align - 1)); + ph->p_vaddr &= ~(ph->p_align - 1); + ph->p_memsz -= ph->p_vaddr; + + vm_allocate (t, (vm_address_t*)&ph->p_vaddr, ph->p_memsz, 0); + vm_write (t, ph->p_vaddr, buf, bufsz); + munmap ((caddr_t) buf, bufsz); + vm_protect (t, ph->p_vaddr, ph->p_memsz, 0, + ((ph->p_flags & PF_R) ? VM_PROT_READ : 0) | + ((ph->p_flags & PF_W) ? VM_PROT_WRITE : 0) | + ((ph->p_flags & PF_X) ? VM_PROT_EXECUTE : 0)); + } + return hdr.e.e_entry; + } + else + { + /* a.out */ + int magic = N_MAGIC (hdr.a); + int headercruft; + vm_address_t base = 0x10000; + int rndamount, amount; + vm_address_t bsspagestart, bssstart; + char *buf; + + headercruft = sizeof (struct exec) * (magic == ZMAGIC); + + amount = headercruft + hdr.a.a_text + hdr.a.a_data; + rndamount = round_page (amount); + buf = mmap (0, rndamount, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); + lseek (fd, sizeof hdr.a - headercruft, SEEK_SET); + read (fd, buf, amount); + vm_allocate (t, &base, rndamount, 0); + vm_write (t, base, (vm_address_t) buf, rndamount); + if (magic != OMAGIC) + vm_protect (t, base, trunc_page (headercruft + hdr.a.a_text), + 0, VM_PROT_READ | VM_PROT_EXECUTE); + munmap ((caddr_t) buf, rndamount); + + bssstart = base + hdr.a.a_text + hdr.a.a_data + headercruft; + bsspagestart = round_page (bssstart); + vm_allocate (t, &bsspagestart, + hdr.a.a_bss - (bsspagestart - bssstart), 0); + + return hdr.a.a_entry; + } +} + + +void read_reply (); +void msg_thread (); + +/* Callbacks for boot_script.c; see boot_script.h. */ + +mach_port_t +boot_script_read_file (const char *filename) +{ + static const char msg[] = ": cannot open\n"; + int fd = useropen (filename, O_RDONLY, 0); + host_stat_t st; + error_t err; + mach_port_t memobj; + vm_address_t region; + + write (2, filename, strlen (filename)); + if (fd < 0) + { + write (2, msg, sizeof msg - 1); + host_exit (1); + } + else + write (2, msg + sizeof msg - 2, 1); + + host_fstat (fd, &st); + + err = default_pager_object_create (defpager, &memobj, + round_page (st.st_size)); + if (err) + { + static const char msg[] = "cannot create default-pager object\n"; + write (2, msg, sizeof msg - 1); + host_exit (1); + } + + region = 0; + vm_map (mach_task_self (), ®ion, round_page (st.st_size), + 0, 1, memobj, 0, 0, VM_PROT_ALL, VM_PROT_ALL, VM_INHERIT_NONE); + read (fd, (char *) region, st.st_size); + munmap ((caddr_t) region, round_page (st.st_size)); + + close (fd); + return memobj; +} + +int +boot_script_exec_cmd (void *hook, + mach_port_t task, char *path, int argc, + char **argv, char *strings, int stringlen) +{ + char *args, *p; + int arg_len, i; + size_t reg_size; + void *arg_pos; + vm_offset_t stack_start, stack_end; + vm_address_t startpc, str_start; + thread_t thread; + + write (2, path, strlen (path)); + for (i = 1; i < argc; ++i) + { + write (2, " ", 1); + write (2, argv[i], strlen (argv[i])); + } + write (2, "\r\n", 2); + + startpc = load_image (task, path); + arg_len = stringlen + (argc + 2) * sizeof (char *) + sizeof (integer_t); + arg_len += 5 * sizeof (int); + stack_end = VM_MAX_ADDRESS; + stack_start = VM_MAX_ADDRESS - 16 * 1024 * 1024; + vm_allocate (task, &stack_start, stack_end - stack_start, FALSE); + arg_pos = (void *) ((stack_end - arg_len) & ~(sizeof (natural_t) - 1)); + args = mmap (0, stack_end - trunc_page ((vm_offset_t) arg_pos), + PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); + str_start = ((vm_address_t) arg_pos + + (argc + 2) * sizeof (char *) + sizeof (integer_t)); + p = args + ((vm_address_t) arg_pos & (vm_page_size - 1)); + *(int *) p = argc; + p = (void *) p + sizeof (int); + for (i = 0; i < argc; i++) + { + *(char **) p = argv[i] - strings + (char *) str_start; + p = (void *) p + sizeof (char *); + } + *(char **) p = 0; + p = (void *) p + sizeof (char *); + *(char **) p = 0; + p = (void *) p + sizeof (char *); + memcpy (p, strings, stringlen); + bzero (args, (vm_offset_t) arg_pos & (vm_page_size - 1)); + vm_write (task, trunc_page ((vm_offset_t) arg_pos), (vm_address_t) args, + stack_end - trunc_page ((vm_offset_t) arg_pos)); + munmap ((caddr_t) args, + stack_end - trunc_page ((vm_offset_t) arg_pos)); + + thread_create (task, &thread); +#ifdef i386_THREAD_STATE_COUNT + { + struct i386_thread_state regs; + reg_size = i386_THREAD_STATE_COUNT; + thread_get_state (thread, i386_THREAD_STATE, + (thread_state_t) ®s, ®_size); + regs.eip = (int) startpc; + regs.uesp = (int) arg_pos; + thread_set_state (thread, i386_THREAD_STATE, + (thread_state_t) ®s, reg_size); + } +#elif defined(ALPHA_THREAD_STATE_COUNT) + { + struct alpha_thread_state regs; + reg_size = ALPHA_THREAD_STATE_COUNT; + thread_get_state (thread, ALPHA_THREAD_STATE, + (thread_state_t) ®s, ®_size); + regs.r30 = (natural_t) arg_pos; + regs.pc = (natural_t) startpc; + thread_set_state (thread, ALPHA_THREAD_STATE, + (thread_state_t) ®s, reg_size); + } +#else +# error needs to be ported +#endif + + thread_resume (thread); + mach_port_deallocate (mach_task_self (), thread); + return 0; +} + +const char *argp_program_version = STANDARD_HURD_VERSION (boot); + +static struct argp_option options[] = +{ + { "boot-root", 'D', "DIR", 0, + "Root of a directory tree in which to find files specified in BOOT-SCRIPT" }, + { "single-user", 's', 0, 0, + "Boot in single user mode" }, + { "kernel-command-line", 'c', "COMMAND LINE", 0, + "Simulated multiboot command line to supply" }, + { "pause" , 'd', 0, 0, + "Pause for user confirmation at various times during booting" }, + { "isig", 'I', 0, 0, + "Do not disable terminal signals, so you can suspend and interrupt boot."}, + { "device-map", 'm', "DEBICENAME=DEVICEFILE", 0, + "Map the device in subhurd to the device in the main Hurd."}, + { "defpager", 'p', "PAGER TRANSLATOR", 0, + "Specify the default pager for subhurd."}, + { "user", 'u', 0, 0, "For normal user."}, + { 0 } +}; +static char args_doc[] = "BOOT-SCRIPT"; +static char doc[] = "Boot a second hurd"; + +struct dev_map +{ + char *name; + mach_port_t port; + struct dev_map *next; +}; + +static struct dev_map *dev_map_head; + +static struct dev_map *add_dev_map (char *dev_name, char *dev_file) +{ + struct dev_map *map = (struct dev_map *) malloc (sizeof (*map)); + + assert (map); + map->name = dev_name; + map->port = file_name_lookup (dev_file, 0, 0); + if (map->port == MACH_PORT_NULL) + error (1, errno, "file_name_lookup: %s", dev_file); + map->next = dev_map_head; + dev_map_head = map; + return map; +} + +static struct dev_map *lookup_dev (char *dev_name) +{ + struct dev_map *map; + + for (map = dev_map_head; map; map = map->next) + { + if (strcmp (map->name, dev_name) == 0) + return map; + } + return NULL; +} + +char *pager_file; + +static error_t +parse_opt (int key, char *arg, struct argp_state *state) +{ + char *dev_file; + + switch (key) + { + size_t len; + + case 'c': kernel_command_line = arg; break; + + case 'D': useropen_dir = arg; break; + + case 'I': isig = 1; break; + + case 's': case 'd': + len = strlen (bootstrap_args); + if (len >= sizeof bootstrap_args - 1) + argp_error (state, "Too many bootstrap args"); + bootstrap_args[len++] = key; + bootstrap_args[len] = '\0'; + break; + + case 'm': + dev_file = strchr (arg, '='); + if (dev_file == NULL) + return ARGP_ERR_UNKNOWN; + *dev_file = 0; + add_dev_map (arg, dev_file+1); + break; + + case 'p': + pager_file = arg; + break; + + case 'u': + is_user = 1; + break; + + case ARGP_KEY_ARG: + if (state->arg_num == 0) + bootscript = arg; + else + return ARGP_ERR_UNKNOWN; + break; + + case ARGP_KEY_INIT: + state->child_inputs[0] = state->input; break; + + default: + return ARGP_ERR_UNKNOWN; + } + return 0; +} + +static void +sigint (int signo) +{ + int kill_task (struct task_info *task_pi) + { + task_terminate (task_pi->task_port); + return 0; + } + + info ("receives an INT"); + foreach_task (kill_task); + exit (0); +} + +void +init_signal () +{ + struct sigaction sa; + sa.sa_handler = sigint; + sa.sa_flags = 0; /* No SA_RESTART! */ + sigemptyset(&sa.sa_mask); + if (sigaction (SIGINT, &sa, NULL)) + error (2, errno, "cannot set SIGHUP handler"); +} + +void +init_kernel_task () +{ + error_t err; + task_t pseudo_task; + task_t pseudo_kernel_task; + process_t real_kernel_task_proc; + process_t proc; + extern int create_pseudo_task (task_t real_task, task_t *ret_pseudo_task); + + err = task_create (mach_task_self (), 0, &pseudo_kernel_task); + if (err) + error (4, err, "cannot create the pseudo kernel task."); + + err = proc_task2proc (getproc (), pseudo_kernel_task, &proc); + if (err) + error (4, err, "cannot get the proc port for the pseudo kernel task."); + + err = task_set_bootstrap_port (pseudo_kernel_task, proc); + if (err) + error (4, err, "cannot set the pseudo kernel task's bootstrap port"); + + err = proc_pid2proc (getproc (), 2, &real_kernel_task_proc); + if (err) + error (4, err, "cannot get the kernel task's proc port"); + + vm_address_t kargv, kenvp; + err = proc_get_arg_locations (real_kernel_task_proc, &kargv, &kenvp); + if (err) + error (4, err, "cannot get the kernel task's argument"); + proc_set_arg_locations (proc, kargv, kenvp); + create_pseudo_task (pseudo_kernel_task, &pseudo_task); + // TODO the pseudo kernel task has to been destroyed after subhurd exits. +} + +FILE *logfile; + +int +main (int argc, char **argv, char **envp) +{ + error_t err; + mach_port_t foo; + char *buf = 0; + int i, len; + char *root_store_name; + const struct argp_child kids[] = { { &store_argp }, { 0 }}; + struct argp argp = { options, parse_opt, args_doc, doc, kids }; + struct store_argp_params store_argp_params = { 0 }; + mach_port_t subhurd_privileged_host_port = MACH_PORT_NULL; + + LOG_START (); + + argp_parse (&argp, argc, argv, 0, 0, &store_argp_params); + err = store_parsed_name (store_argp_params.result, &root_store_name); + if (err) + error (2, err, "store_parsed_name"); + + err = store_parsed_open (store_argp_params.result, 0, &root_store); + if (err) + error (4, err, "%s", root_store_name); + + init_signal (); + if (!is_user) + { + get_privileged_ports (&privileged_host_port, &master_device_port); + defpager = MACH_PORT_NULL; + err = vm_set_default_memory_manager (privileged_host_port, &defpager); + if (err) + error (4, err, "vm_set_default_memory_manager"); + subhurd_privileged_host_port = privileged_host_port; + } + else + { + port_bucket = ports_create_bucket (); + task_portclass = ports_create_class (clean_pseudo_task, 0); + priv_host_portclass = ports_create_class (destroy_priv_host, 0); + exc_portclass = ports_create_class (0, 0); + other_portclass = ports_create_class (0, 0); + init_kernel_task (); + cthread_detach (cthread_fork ((cthread_fn_t) mach_proxy_thread, + (any_t) 0)); + { + mach_port_t priv_host; + get_privileged_ports (&priv_host, NULL); + defpager = MACH_PORT_NULL; + err = vm_set_default_memory_manager (priv_host, &defpager); + if (err) + error (4, err, "vm_set_default_memory_manager"); + mach_port_deallocate (mach_task_self (), priv_host); + } +// if (pager_file == NULL) +// error (4, 0, "The default pager must be specified for subhurd."); +// defpager = file_name_lookup (pager_file, O_EXEC, 0); +// if (defpager == MACH_PORT_NULL) +// error (4, errno, "file_name_look: %s", pager_file); + + /* Initialize the pseudo privileged host port. */ + err = ports_create_port (priv_host_portclass, port_bucket, + sizeof (struct port_info), + &pseudo_priv_host_pi); + if (err) + error (4, err, "fail to create the pseudo privileged host port"); + subhurd_privileged_host_port = ports_get_send_right (pseudo_priv_host_pi); + ports_port_deref (pseudo_priv_host_pi); + } + + strcat (bootstrap_args, "f"); + + mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_PORT_SET, + &receive_set); + + if (root_store->class == &store_device_class && root_store->name + && (root_store->flags & STORE_ENFORCED) + && root_store->num_runs == 1 && root_store->runs[0].start == 0) + /* Let known device nodes pass through directly. */ + bootdevice = root_store->name; + else + /* Pass a magic value that we can use to do I/O to ROOT_STORE. */ + { + bootdevice = "pseudo-root"; + mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_RECEIVE, + &pseudo_root); + mach_port_move_member (mach_task_self (), pseudo_root, receive_set); + } + + /* Initialize the pseudo master device port. */ + mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_RECEIVE, + &pseudo_master_device_port); + mach_port_insert_right (mach_task_self (), + pseudo_master_device_port, + pseudo_master_device_port, + MACH_MSG_TYPE_MAKE_SEND); + mach_port_move_member (mach_task_self (), pseudo_master_device_port, + receive_set); + mach_port_request_notification (mach_task_self (), pseudo_master_device_port, + MACH_NOTIFY_NO_SENDERS, 1, + pseudo_master_device_port, + MACH_MSG_TYPE_MAKE_SEND_ONCE, &foo); + if (foo != MACH_PORT_NULL) + mach_port_deallocate (mach_task_self (), foo); + + /* Initialize the pseudo console port. */ + mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_RECEIVE, + &pseudo_console); + mach_port_move_member (mach_task_self (), pseudo_console, receive_set); + mach_port_request_notification (mach_task_self (), pseudo_console, + MACH_NOTIFY_NO_SENDERS, 1, pseudo_console, + MACH_MSG_TYPE_MAKE_SEND_ONCE, &foo); + if (foo != MACH_PORT_NULL) + mach_port_deallocate (mach_task_self (), foo); + + if (kernel_command_line == 0) + asprintf (&kernel_command_line, "%s %s root=%s", + argv[0], bootstrap_args, bootdevice); + + /* Initialize boot script variables. */ + if (boot_script_set_variable ("host-port", VAL_PORT, + (int) subhurd_privileged_host_port) + || boot_script_set_variable ("device-port", VAL_PORT, + (integer_t) pseudo_master_device_port) + || boot_script_set_variable ("kernel-command-line", VAL_STR, + (integer_t) kernel_command_line) + || boot_script_set_variable ("root-device", + VAL_STR, (integer_t) bootdevice) + || boot_script_set_variable ("boot-args", + VAL_STR, (integer_t) bootstrap_args)) + { + static const char msg[] = "error setting variable"; + + write (2, msg, strlen (msg)); + host_exit (1); + } + + /* Turn each `FOO=BAR' word in the command line into a boot script + variable ${FOO} with value BAR. */ + { + int len = strlen (kernel_command_line) + 1; + char *s = memcpy (alloca (len), kernel_command_line, len); + char *word; + + while ((word = strsep (&s, " \t")) != 0) + { + char *eq = strchr (word, '='); + if (eq == 0) + continue; + *eq++ = '\0'; + err = boot_script_set_variable (word, VAL_STR, (integer_t) eq); + if (err) + { + char *msg; + asprintf (&msg, "cannot set boot-script variable %s: %s\n", + word, boot_script_error_string (err)); + assert (msg); + write (2, msg, strlen (msg)); + free (msg); + host_exit (1); + } + } + } + + /* Parse the boot script. */ + { + char *p, *line; + static const char filemsg[] = "Can't open boot script\n"; + static const char memmsg[] = "Not enough memory\n"; + int amt, fd, err; + + fd = open (bootscript, O_RDONLY, 0); + if (fd < 0) + { + write (2, filemsg, sizeof (filemsg)); + host_exit (1); + } + p = buf = malloc (500); + if (!buf) + { + write (2, memmsg, sizeof (memmsg)); + host_exit (1); + } + len = 500; + amt = 0; + while (1) + { + i = read (fd, p, len - (p - buf)); + if (i <= 0) + break; + p += i; + amt += i; + if (p == buf + len) + { + char *newbuf; + + len += 500; + newbuf = realloc (buf, len); + if (!newbuf) + { + write (2, memmsg, sizeof (memmsg)); + host_exit (1); + } + p = newbuf + (p - buf); + buf = newbuf; + } + } + line = p = buf; + while (1) + { + while (p < buf + amt && *p != '\n') + p++; + *p = '\0'; + err = boot_script_parse_line (0, line); + if (err) + { + char *str; + int i; + + str = boot_script_error_string (err); + i = strlen (str); + write (2, str, i); + write (2, " in `", 5); + write (2, line, strlen (line)); + write (2, "'\n", 2); + host_exit (1); + } + if (p == buf + amt) + break; + line = ++p; + } + } + + if (index (bootstrap_args, 'd')) + { + static const char msg[] = "Pausing. . ."; + char c; + write (2, msg, sizeof (msg) - 1); + read (0, &c, 1); + } + + init_termstate (); + + /* The boot script has now been parsed into internal data structures. + Now execute its directives. */ + { + int err; + + err = boot_script_exec (); + if (err) + { + char *str = boot_script_error_string (err); + int i = strlen (str); + + write (2, str, i); + host_exit (1); + } + free (buf); + } + + mach_port_deallocate (mach_task_self (), pseudo_master_device_port); + if (is_user) + mach_port_deallocate (mach_task_self (), subhurd_privileged_host_port); + + cthread_detach (cthread_fork ((cthread_fn_t) msg_thread, (any_t) 0)); + + for (;;) + { + fd_set rmask; + FD_ZERO (&rmask); + FD_SET (0, &rmask); + if (select (1, &rmask, 0, 0, 0) == 1) + read_reply (); + else /* We hosed */ + error (5, errno, "select"); + } + + LOG_END (); +/* mach_msg_server (request_server, __vm_page_size * 2, receive_set); */ +} + +void +msg_thread() +{ + while (1) + mach_msg_server (request_server, 0, receive_set); +} + + +enum read_type +{ + DEV_READ, + DEV_READI, + IO_READ, +}; +struct qr +{ + enum read_type type; + mach_port_t reply_port; + mach_msg_type_name_t reply_type; + int amount; + struct qr *next; +}; +struct qr *qrhead, *qrtail; + +/* Queue a read for later reply. */ +kern_return_t +queue_read (enum read_type type, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + int amount) +{ + struct qr *qr; + + qr = malloc (sizeof (struct qr)); + if (!qr) + return D_NO_MEMORY; + + spin_lock (&queuelock); + + qr->type = type; + qr->reply_port = reply_port; + qr->reply_type = reply_type; + qr->amount = amount; + qr->next = 0; + if (qrtail) + qrtail->next = qr; + else + qrhead = qrtail = qr; + + spin_unlock (&queuelock); + return D_SUCCESS; +} + +/* TRUE if there's data available on stdin, which should be used to satisfy + console read requests. */ +static int should_read = 0; + +/* Reply to a queued read. */ +void +read_reply () +{ + int avail; + struct qr *qr; + char * buf; + int amtread; + + /* By forcing SHOULD_READ to true before trying the lock, we ensure that + either we get the lock ourselves or that whoever currently holds the + lock will service this read when he unlocks it. */ + should_read = 1; + if (! spin_try_lock (&readlock)) + return; + + /* Since we're commited to servicing the read, no one else need do so. */ + should_read = 0; + + ioctl (0, FIONREAD, &avail); + if (!avail) + { + spin_unlock (&readlock); + return; + } + + spin_lock (&queuelock); + + if (!qrhead) + { + spin_unlock (&queuelock); + spin_unlock (&readlock); + return; + } + + qr = qrhead; + qrhead = qr->next; + if (qr == qrtail) + qrtail = 0; + + spin_unlock (&queuelock); + + if (qr->type == DEV_READ) + buf = mmap (0, qr->amount, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); + else + buf = alloca (qr->amount); + amtread = read (0, buf, qr->amount); + + spin_unlock (&readlock); + + switch (qr->type) + { + case DEV_READ: + if (amtread >= 0) + ds_device_read_reply (qr->reply_port, qr->reply_type, 0, + (io_buf_ptr_t) buf, amtread); + else + ds_device_read_reply (qr->reply_port, qr->reply_type, errno, 0, 0); + break; + + case DEV_READI: + if (amtread >= 0) + ds_device_read_reply_inband (qr->reply_port, qr->reply_type, 0, + buf, amtread); + else + ds_device_read_reply_inband (qr->reply_port, qr->reply_type, errno, + 0, 0); + break; + + case IO_READ: + if (amtread >= 0) + io_read_reply (qr->reply_port, qr->reply_type, 0, + buf, amtread); + else + io_read_reply (qr->reply_port, qr->reply_type, errno, 0, 0); + break; + } + + free (qr); +} + +/* Unlock READLOCK, and also service any new read requests that it was + blocking. */ +static void +unlock_readlock () +{ + spin_unlock (&readlock); + while (should_read) + read_reply (); +} + +/* + * Handle bootstrap requests. + */ +/* These two functions from .../mk/bootstrap/default_pager.c. */ + +kern_return_t +do_bootstrap_privileged_ports(bootstrap, hostp, devicep) + mach_port_t bootstrap; + mach_port_t *hostp, *devicep; +{ + if (is_user) + /* I cannot use ports_get_right() here, + * because the port will be copied to the client. */ + *hostp = pseudo_priv_host_pi->port_right; + else + *hostp = privileged_host_port; + *devicep = pseudo_master_device_port; + return KERN_SUCCESS; +} + +void +bootstrap_compat(in, out) + mach_msg_header_t *in, *out; +{ + mig_reply_header_t *reply = (mig_reply_header_t *) out; + mach_msg_return_t mr; + + struct imsg { + mach_msg_header_t hdr; + mach_msg_type_t port_desc_1; + mach_port_t port_1; + mach_msg_type_t port_desc_2; + mach_port_t port_2; + } imsg; + + /* + * Send back the host and device ports. + */ + + imsg.hdr.msgh_bits = MACH_MSGH_BITS_COMPLEX | + MACH_MSGH_BITS(MACH_MSGH_BITS_REMOTE(in->msgh_bits), 0); + /* msgh_size doesn't need to be initialized */ + imsg.hdr.msgh_remote_port = in->msgh_remote_port; + imsg.hdr.msgh_local_port = MACH_PORT_NULL; + /* msgh_seqno doesn't need to be initialized */ + imsg.hdr.msgh_id = in->msgh_id + 100; /* this is a reply msg */ + + imsg.port_desc_1.msgt_name = MACH_MSG_TYPE_COPY_SEND; + imsg.port_desc_1.msgt_size = (sizeof(mach_port_t) * 8); + imsg.port_desc_1.msgt_number = 1; + imsg.port_desc_1.msgt_inline = TRUE; + imsg.port_desc_1.msgt_longform = FALSE; + imsg.port_desc_1.msgt_deallocate = FALSE; + imsg.port_desc_1.msgt_unused = 0; + + if (is_user) + imsg.port_1 = pseudo_priv_host_pi->port_right; + else + imsg.port_1 = privileged_host_port; + + imsg.port_desc_2 = imsg.port_desc_1; + + imsg.port_desc_2.msgt_name = MACH_MSG_TYPE_MAKE_SEND; + imsg.port_2 = pseudo_master_device_port; + + /* + * Send the reply message. + * (mach_msg_server can not do this, because the reply + * is not in standard format.) + */ + + mr = mach_msg(&imsg.hdr, MACH_SEND_MSG, + sizeof imsg, 0, MACH_PORT_NULL, + MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (mr != MACH_MSG_SUCCESS) + (void) mach_port_deallocate(mach_task_self (), + imsg.hdr.msgh_remote_port); + + /* + * Tell mach_msg_server to do nothing. + */ + + reply->RetCode = MIG_NO_REPLY; +} + +/* Implementation of device interface */ + +kern_return_t +ds_device_open (mach_port_t master_port, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + dev_mode_t mode, + dev_name_t name, + mach_port_t *device, + mach_msg_type_name_t *devicetype) +{ + struct dev_map *map; + + if (master_port != pseudo_master_device_port) + return D_INVALID_OPERATION; + + debug ("open %s", name); + if (!strcmp (name, "console")) + { +#if 0 + mach_port_insert_right (mach_task_self (), pseudo_console, + pseudo_console, MACH_MSG_TYPE_MAKE_SEND); + console_send_rights++; +#endif + console_mscount++; + *device = pseudo_console; + *devicetype = MACH_MSG_TYPE_MAKE_SEND; + return 0; + } + else if (strcmp (name, "pseudo-root") == 0) + /* Magic root device. */ + { + *device = pseudo_root; + *devicetype = MACH_MSG_TYPE_MAKE_SEND; + return 0; + } + + map = lookup_dev (name); + if (map) + { + error_t err; + *devicetype = MACH_MSG_TYPE_MOVE_SEND; + err = device_open (map->port, mode, "", device); + return err; + } + + if (is_user) + return D_NO_SUCH_DEVICE; + else + { + *devicetype = MACH_MSG_TYPE_MOVE_SEND; + return device_open (master_device_port, mode, name, device); + } +} + +kern_return_t +ds_device_close (device_t device) +{ + if (device != pseudo_console && device != pseudo_root) + return D_NO_SUCH_DEVICE; + return 0; +} + +kern_return_t +ds_device_write (device_t device, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + dev_mode_t mode, + recnum_t recnum, + io_buf_ptr_t data, + size_t datalen, + int *bytes_written) +{ + if (device == pseudo_console) + { +#if 0 + if (console_send_rights) + { + mach_port_mod_refs (mach_task_self (), pseudo_console, + MACH_PORT_TYPE_SEND, -console_send_rights); + console_send_rights = 0; + } +#endif + + *bytes_written = write (1, data, datalen); + + return (*bytes_written == -1 ? D_IO_ERROR : D_SUCCESS); + } + else if (device == pseudo_root) + { + size_t wrote; + if (store_write (root_store, recnum, data, datalen, &wrote) != 0) + return D_IO_ERROR; + *bytes_written = wrote; + return D_SUCCESS; + } + else + return D_NO_SUCH_DEVICE; +} + +kern_return_t +ds_device_write_inband (device_t device, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + dev_mode_t mode, + recnum_t recnum, + io_buf_ptr_inband_t data, + size_t datalen, + int *bytes_written) +{ + if (device == pseudo_console) + { +#if 0 + if (console_send_rights) + { + mach_port_mod_refs (mach_task_self (), pseudo_console, + MACH_PORT_TYPE_SEND, -console_send_rights); + console_send_rights = 0; + } +#endif + + *bytes_written = write (1, data, datalen); + + return (*bytes_written == -1 ? D_IO_ERROR : D_SUCCESS); + } + else if (device == pseudo_root) + { + size_t wrote; + if (store_write (root_store, recnum, data, datalen, &wrote) != 0) + return D_IO_ERROR; + *bytes_written = wrote; + return D_SUCCESS; + } + else + return D_NO_SUCH_DEVICE; +} + +kern_return_t +ds_device_read (device_t device, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + dev_mode_t mode, + recnum_t recnum, + int bytes_wanted, + io_buf_ptr_t *data, + size_t *datalen) +{ + if (device == pseudo_console) + { + int avail; + +#if 0 + if (console_send_rights) + { + mach_port_mod_refs (mach_task_self (), pseudo_console, + MACH_PORT_TYPE_SEND, -console_send_rights); + console_send_rights = 0; + } +#endif + + spin_lock (&readlock); + ioctl (0, FIONREAD, &avail); + if (avail) + { + *data = mmap (0, bytes_wanted, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); + *datalen = read (0, *data, bytes_wanted); + unlock_readlock (); + return (*datalen == -1 ? D_IO_ERROR : D_SUCCESS); + } + else + { + kern_return_t err; + + unlock_readlock (); + err = queue_read (DEV_READ, reply_port, reply_type, bytes_wanted); + if (err) + return err; + return MIG_NO_REPLY; + } + } + else if (device == pseudo_root) + { + *datalen = 0; + return + (store_read (root_store, recnum, bytes_wanted, (void **)data, datalen) == 0 + ? D_SUCCESS + : D_IO_ERROR); + } + else + return D_NO_SUCH_DEVICE; +} + +kern_return_t +ds_device_read_inband (device_t device, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + dev_mode_t mode, + recnum_t recnum, + int bytes_wanted, + io_buf_ptr_inband_t data, + size_t *datalen) +{ + if (device == pseudo_console) + { + int avail; + +#if 0 + if (console_send_rights) + { + mach_port_mod_refs (mach_task_self (), pseudo_console, + MACH_PORT_TYPE_SEND, -console_send_rights); + console_send_rights = 0; + } +#endif + + spin_lock (&readlock); + ioctl (0, FIONREAD, &avail); + if (avail) + { + *datalen = read (0, data, bytes_wanted); + unlock_readlock (); + return (*datalen == -1 ? D_IO_ERROR : D_SUCCESS); + } + else + { + kern_return_t err; + + unlock_readlock (); + err = queue_read (DEV_READI, reply_port, reply_type, bytes_wanted); + if (err) + return err; + return MIG_NO_REPLY; + } + } + else if (device == pseudo_root) + { + error_t err; + void *returned = data; + + *datalen = bytes_wanted; + err = + store_read (root_store, recnum, bytes_wanted, (void **)&returned, datalen); + + if (! err) + { + if (returned != data) + { + bcopy (returned, (void *)data, *datalen); + munmap ((caddr_t) returned, *datalen); + } + return D_SUCCESS; + } + else + return D_IO_ERROR; + } + else + return D_NO_SUCH_DEVICE; +} + +kern_return_t +ds_xxx_device_set_status (device_t device, + dev_flavor_t flavor, + dev_status_t status, + size_t statu_cnt) +{ + if (device != pseudo_console) + return D_NO_SUCH_DEVICE; + return D_INVALID_OPERATION; +} + +kern_return_t +ds_xxx_device_get_status (device_t device, + dev_flavor_t flavor, + dev_status_t status, + size_t *statuscnt) +{ + if (device != pseudo_console && device != pseudo_root) + return D_NO_SUCH_DEVICE; + return D_INVALID_OPERATION; +} + +kern_return_t +ds_xxx_device_set_filter (device_t device, + mach_port_t rec, + int pri, + filter_array_t filt, + size_t len) +{ + if (device != pseudo_console && device != pseudo_root) + return D_NO_SUCH_DEVICE; + return D_INVALID_OPERATION; +} + +kern_return_t +ds_device_map (device_t device, + vm_prot_t prot, + vm_offset_t offset, + vm_size_t size, + memory_object_t *pager, + int unmap) +{ + if (device != pseudo_console && device != pseudo_root) + return D_NO_SUCH_DEVICE; + return D_INVALID_OPERATION; +} + +kern_return_t +ds_device_set_status (device_t device, + dev_flavor_t flavor, + dev_status_t status, + size_t statuslen) +{ + if (device != pseudo_console && device != pseudo_root) + return D_NO_SUCH_DEVICE; + return D_INVALID_OPERATION; +} + +kern_return_t +ds_device_get_status (device_t device, + dev_flavor_t flavor, + dev_status_t status, + size_t *statuslen) +{ + if (device == pseudo_console) + return D_INVALID_OPERATION; + else if (device == pseudo_root) + if (flavor == DEV_GET_SIZE) + if (*statuslen < DEV_GET_SIZE_COUNT) + return D_INVALID_SIZE; + else + { + status[DEV_GET_SIZE_DEVICE_SIZE] = root_store->size; + status[DEV_GET_SIZE_RECORD_SIZE] = root_store->block_size; + *statuslen = DEV_GET_SIZE_COUNT; + return D_SUCCESS; + } + else + return D_INVALID_OPERATION; + else + return D_NO_SUCH_DEVICE; +} + +kern_return_t +ds_device_set_filter (device_t device, + mach_port_t receive_port, + int priority, + filter_array_t filter, + size_t filterlen) +{ + if (device != pseudo_console && device != pseudo_root) + return D_NO_SUCH_DEVICE; + return D_INVALID_OPERATION; +} + + +/* Implementation of notify interface */ +kern_return_t +do_mach_notify_port_deleted (mach_port_t notify, + mach_port_t name) +{ + return EOPNOTSUPP; +} + +kern_return_t +do_mach_notify_msg_accepted (mach_port_t notify, + mach_port_t name) +{ + return EOPNOTSUPP; +} + +kern_return_t +do_mach_notify_port_destroyed (mach_port_t notify, + mach_port_t port) +{ + return EOPNOTSUPP; +} + +boolean_t pseudo_priv_host_destroyed = FALSE; + +void +destroy_priv_host (void *pi) +{ + pseudo_priv_host_destroyed = TRUE; + info ("pseudo privileged host port is destroyed"); +} + +kern_return_t +do_mach_notify_no_senders (mach_port_t notify, + mach_port_mscount_t mscount) +{ + static int no_console; + mach_port_t foo; + error_t err = EOPNOTSUPP; + + if (notify == pseudo_master_device_port) + { + info ("pseudo master device port has no senders"); + /* for the root */ + if (no_console && !is_user) + goto bye; + /* for the normal user */ + if (no_console && is_user && pseudo_priv_host_destroyed) + goto bye; + pseudo_master_device_port = MACH_PORT_NULL; + return 0; + } + if (pseudo_priv_host_pi->port_right == notify && is_user) + { + if (no_console && pseudo_master_device_port == MACH_PORT_NULL) + goto bye; + pseudo_priv_host_destroyed = TRUE; + return 0; + } + if (notify == pseudo_console) + { + info ("pseudo console has no senders"); + if ( + /* for the root */ + (mscount == console_mscount && + pseudo_master_device_port == MACH_PORT_NULL && + !is_user) || + /* for the normal user */ + (mscount == console_mscount && + pseudo_master_device_port == MACH_PORT_NULL && + pseudo_priv_host_destroyed && + is_user)) + { + bye: + restore_termstate (); + write (2, "bye\n", 4); + host_exit (0); + } + else + { + no_console = (mscount == console_mscount); + info ("no console: %d", no_console); + + mach_port_request_notification (mach_task_self (), pseudo_console, + MACH_NOTIFY_NO_SENDERS, + console_mscount == mscount + ? mscount + 1 + : console_mscount, + pseudo_console, + MACH_MSG_TYPE_MAKE_SEND_ONCE, &foo); + if (foo != MACH_PORT_NULL) + mach_port_deallocate (mach_task_self (), foo); + } + } + + err = ports_do_mach_notify_no_senders (notify, mscount); + + return err; +} + +kern_return_t +do_mach_notify_send_once (mach_port_t notify) +{ + return EOPNOTSUPP; +} + +kern_return_t +do_mach_notify_dead_name (mach_port_t notify, + mach_port_t name) +{ +#if 0 + if (name == child_task && notify == bootport) + host_exit (0); +#endif + return EOPNOTSUPP; +} + + +/* Implementation of the Hurd I/O interface, which + we support for the console port only. */ + +kern_return_t +S_io_write (mach_port_t object, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + char *data, + mach_msg_type_number_t datalen, + off_t offset, + mach_msg_type_number_t *amtwritten) +{ + if (object != pseudo_console) + return EOPNOTSUPP; + +#if 0 + if (console_send_rights) + { + mach_port_mod_refs (mach_task_self (), pseudo_console, + MACH_PORT_TYPE_SEND, -console_send_rights); + console_send_rights = 0; + } +#endif + + *amtwritten = write (1, data, datalen); + return *amtwritten == -1 ? errno : 0; +} + +kern_return_t +S_io_read (mach_port_t object, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + char **data, + mach_msg_type_number_t *datalen, + off_t offset, + mach_msg_type_number_t amount) +{ + mach_msg_type_number_t avail; + + if (object != pseudo_console) + return EOPNOTSUPP; + +#if 0 + if (console_send_rights) + { + mach_port_mod_refs (mach_task_self (), pseudo_console, + MACH_PORT_TYPE_SEND, -console_send_rights); + console_send_rights = 0; + } +#endif + + spin_lock (&readlock); + ioctl (0, FIONREAD, &avail); + if (avail) + { + if (amount > *datalen) + *data = mmap (0, amount, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); + *datalen = read (0, *data, amount); + unlock_readlock (); + return *datalen == -1 ? errno : 0; + } + else + { + kern_return_t err; + unlock_readlock (); + err = queue_read (IO_READ, reply_port, reply_type, amount); + if (err) + return err; + return MIG_NO_REPLY; + } +} + +kern_return_t +S_io_seek (mach_port_t object, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + off_t offset, + int whence, + off_t *newp) +{ + return object == pseudo_console ? ESPIPE : EOPNOTSUPP; +} + +kern_return_t +S_io_readable (mach_port_t object, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + mach_msg_type_number_t *amt) +{ + if (object != pseudo_console) + return EOPNOTSUPP; + ioctl (0, FIONREAD, amt); + return 0; +} + +kern_return_t +S_io_set_all_openmodes (mach_port_t object, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + int bits) +{ + return EOPNOTSUPP; +} + +kern_return_t +S_io_get_openmodes (mach_port_t object, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + int *modes) +{ + *modes = O_READ | O_WRITE; + return object == pseudo_console ? 0 : EOPNOTSUPP; +} + +kern_return_t +S_io_set_some_openmodes (mach_port_t object, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + int bits) +{ + return EOPNOTSUPP; +} + +kern_return_t +S_io_clear_some_openmodes (mach_port_t object, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + int bits) +{ + return EOPNOTSUPP; +} + +kern_return_t +S_io_async (mach_port_t object, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + mach_port_t notify, + mach_port_t *id, + mach_msg_type_name_t *idtype) +{ + return EOPNOTSUPP; +} + +kern_return_t +S_io_mod_owner (mach_port_t object, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + pid_t owner) +{ + return EOPNOTSUPP; +} + +kern_return_t +S_io_get_owner (mach_port_t object, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + pid_t *owner) +{ + return EOPNOTSUPP; +} + +kern_return_t +S_io_get_icky_async_id (mach_port_t object, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + mach_port_t *id, + mach_msg_type_name_t *idtype) +{ + return EOPNOTSUPP; +} + +kern_return_t +S_io_select (mach_port_t object, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + int *type) +{ + fd_set r, w, x; + int n; + + if (object != pseudo_console) + return EOPNOTSUPP; + + FD_ZERO (&r); + FD_ZERO (&w); + FD_ZERO (&x); + FD_SET (0, &r); + FD_SET (0, &w); + FD_SET (0, &x); + + n = select (1, + (*type & SELECT_READ) ? &r : 0, + (*type & SELECT_WRITE) ? &w : 0, + (*type & SELECT_URG) ? &x : 0, + 0); + if (n < 0) + return errno; + + if (! FD_ISSET (0, &r)) + *type &= ~SELECT_READ; + if (! FD_ISSET (0, &w)) + *type &= ~SELECT_WRITE; + if (! FD_ISSET (0, &x)) + *type &= ~SELECT_URG; + + return 0; +} + +kern_return_t +S_io_stat (mach_port_t object, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + struct stat *st) +{ + if (object != pseudo_console) + return EOPNOTSUPP; + + bzero (st, sizeof (struct stat)); + st->st_blksize = 1024; + return 0; +} + +kern_return_t +S_io_reauthenticate (mach_port_t object, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + mach_port_t rend) +{ + uid_t *gu, *au; + gid_t *gg, *ag; + size_t gulen = 0, aulen = 0, gglen = 0, aglen = 0; + error_t err; + + err = mach_port_insert_right (mach_task_self (), object, object, + MACH_MSG_TYPE_MAKE_SEND); + assert_perror (err); + + if (! auth_server_authenticate (authserver, + rend, MACH_MSG_TYPE_COPY_SEND, + object, MACH_MSG_TYPE_COPY_SEND, + &gu, &gulen, + &au, &aulen, + &gg, &gglen, + &ag, &aglen)) + { + mig_deallocate ((vm_address_t) gu, gulen * sizeof *gu); + mig_deallocate ((vm_address_t) au, aulen * sizeof *gu); + mig_deallocate ((vm_address_t) gg, gglen * sizeof *gu); + mig_deallocate ((vm_address_t) au, aulen * sizeof *gu); + } + mach_port_deallocate (mach_task_self (), rend); + mach_port_deallocate (mach_task_self (), object); + + return 0; +} + +kern_return_t +S_io_restrict_auth (mach_port_t object, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + mach_port_t *newobject, + mach_msg_type_name_t *newobjtype, + uid_t *uids, + size_t nuids, + uid_t *gids, + size_t ngids) +{ + if (object != pseudo_console) + return EOPNOTSUPP; + *newobject = pseudo_console; + *newobjtype = MACH_MSG_TYPE_MAKE_SEND; + console_mscount++; + return 0; +} + +kern_return_t +S_io_duplicate (mach_port_t object, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + mach_port_t *newobj, + mach_msg_type_name_t *newobjtype) +{ + if (object != pseudo_console) + return EOPNOTSUPP; + *newobj = pseudo_console; + *newobjtype = MACH_MSG_TYPE_MAKE_SEND; + console_mscount++; + return 0; +} + +kern_return_t +S_io_server_version (mach_port_t object, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + char *name, + int *maj, + int *min, + int *edit) +{ + return EOPNOTSUPP; +} + +kern_return_t +S_io_map (mach_port_t obj, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + mach_port_t *rd, + mach_msg_type_name_t *rdtype, + mach_port_t *wr, + mach_msg_type_name_t *wrtype) +{ + return EOPNOTSUPP; +} + +kern_return_t +S_io_map_cntl (mach_port_t obj, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + mach_port_t *mem, + mach_msg_type_name_t *memtype) +{ + return EOPNOTSUPP; +} + +kern_return_t +S_io_get_conch (mach_port_t obj, + mach_port_t reply_port, + mach_msg_type_name_t reply_type) +{ + return EOPNOTSUPP; +} + +kern_return_t +S_io_release_conch (mach_port_t obj, + mach_port_t reply_port, + mach_msg_type_name_t reply_type) +{ + return EOPNOTSUPP; +} + +kern_return_t +S_io_eofnotify (mach_port_t obj, + mach_port_t reply_port, + mach_msg_type_name_t reply_type) + +{ + return EOPNOTSUPP; +} + +kern_return_t +S_io_prenotify (mach_port_t obj, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + vm_offset_t start, + vm_offset_t end) +{ + return EOPNOTSUPP; +} + +kern_return_t +S_io_postnotify (mach_port_t obj, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + vm_offset_t start, + vm_offset_t end) +{ + return EOPNOTSUPP; +} + +kern_return_t +S_io_readsleep (mach_port_t obj, + mach_port_t reply_port, + mach_msg_type_name_t reply_type) +{ + return EOPNOTSUPP; +} + +kern_return_t +S_io_readnotify (mach_port_t obj, + mach_port_t reply_port, + mach_msg_type_name_t reply_type) +{ + return EOPNOTSUPP; +} + + +kern_return_t +S_io_sigio (mach_port_t obj, + mach_port_t reply_port, + mach_msg_type_name_t reply_type) +{ + return EOPNOTSUPP; +} + + +kern_return_t +S_io_pathconf (mach_port_t obj, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + int name, int *value) +{ + return EOPNOTSUPP; +} + +kern_return_t +S_io_identity (mach_port_t obj, + mach_port_t reply, + mach_msg_type_name_t replytype, + mach_port_t *id, + mach_msg_type_name_t *idtype, + mach_port_t *fsid, + mach_msg_type_name_t *fsidtype, + ino_t *fileno) +{ + return EOPNOTSUPP; +} + +kern_return_t +S_io_revoke (mach_port_t obj, + mach_port_t reply, mach_msg_type_name_t replyPoly) +{ + return EOPNOTSUPP; +} + + + +/* Implementation of the Hurd terminal driver interface, which we only + support on the console device. */ + +kern_return_t +S_termctty_open_terminal (mach_port_t object, + int flags, + mach_port_t *result, + mach_msg_type_name_t *restype) +{ + return EOPNOTSUPP; +} + +kern_return_t +S_term_getctty (mach_port_t object, + mach_port_t *cttyid, mach_msg_type_name_t *cttyPoly) +{ + static mach_port_t id = MACH_PORT_NULL; + + if (object != pseudo_console) + return EOPNOTSUPP; + + if (id == MACH_PORT_NULL) + mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_DEAD_NAME, &id); + + *cttyid = id; + *cttyPoly = MACH_MSG_TYPE_COPY_SEND; + return 0; +} + + +kern_return_t S_term_open_ctty +( + io_t terminal, + pid_t pid, + pid_t pgrp, + mach_port_t *newtty, + mach_msg_type_name_t *newttytype +) +{ return EOPNOTSUPP; } + +kern_return_t S_term_set_nodename +( + io_t terminal, + string_t name +) +{ return EOPNOTSUPP; } + +kern_return_t S_term_get_nodename +( + io_t terminal, + string_t name +) +{ return EOPNOTSUPP; } + +kern_return_t S_term_get_peername +( + io_t terminal, + string_t name +) +{ return EOPNOTSUPP; } + +kern_return_t S_term_set_filenode +( + io_t terminal, + file_t filenode +) +{ return EOPNOTSUPP; } + +kern_return_t S_term_get_bottom_type +( + io_t terminal, + int *ttype +) +{ return EOPNOTSUPP; } + +kern_return_t S_term_on_machdev +( + io_t terminal, + mach_port_t machdev +) +{ return EOPNOTSUPP; } + +kern_return_t S_term_on_hurddev +( + io_t terminal, + io_t hurddev +) +{ return EOPNOTSUPP; } + +kern_return_t S_term_on_pty +( + io_t terminal, + io_t *ptymaster +) +{ return EOPNOTSUPP; } diff --git a/boot-proxy-exc/boot.c~ b/boot-proxy-exc/boot.c~ new file mode 100644 index 00000000..e7ce0f96 --- /dev/null +++ b/boot-proxy-exc/boot.c~ @@ -0,0 +1,2149 @@ +/* Load a task using the single server, and then run it + as if we were the kernel. + Copyright (C) 1993,94,95,96,97,98,99,2000,01,02,2006 + Free Software Foundation, Inc. + +This file is part of the GNU Hurd. + +The GNU Hurd is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +The GNU Hurd 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with the GNU Hurd; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/* Written by Michael I. Bushnell. */ + +#include <mach.h> +#include <mach/notify.h> +#include <device/device.h> +#include <a.out.h> +#include <mach/message.h> +#include <mach/mig_errors.h> +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <cthreads.h> +#include <fcntl.h> +#include <elf.h> +#include <mach/mig_support.h> +#include <mach/default_pager.h> +#include <argp.h> +#include <hurd/store.h> +#include <hurd/ports.h> +#include <sys/mman.h> +#include <version.h> + +#include "notify_S.h" +#include "ourdevice_S.h" +#include "io_S.h" +#include "device_reply_U.h" +#include "io_reply_U.h" +#include "term_S.h" +#include "bootstrap_S.h" +/* #include "tioctl_S.h" */ +#include "util.h" +#include "boot_script.h" +#include "mach_proxy.h" + +#include <hurd/auth.h> + +#ifdef UX +#undef STORE /* We can't use libstore when under UX. */ +#else +#define STORE +#endif + +#ifdef UX + +#include "ux.h" + +#else /* !UX */ + +#include <unistd.h> +#include <fcntl.h> +#include <signal.h> +#include <sys/ioctl.h> +#include <sys/stat.h> +#include <termios.h> +#include <error.h> +#include <hurd.h> +#include <assert.h> + +static struct termios orig_tty_state; +static int isig; +static char *kernel_command_line; + +struct port_bucket *port_bucket; +struct port_class *task_portclass; +struct port_class *exc_portclass; +struct port_class *priv_host_portclass; +struct port_class *other_portclass; + +void destroy_priv_host (void *pi); + +static void +init_termstate () +{ + struct termios tty_state; + + if (tcgetattr (0, &tty_state) < 0) + error (10, errno, "tcgetattr"); + + orig_tty_state = tty_state; + cfmakeraw (&tty_state); + if (isig) + tty_state.c_lflag |= ISIG; + + if (tcsetattr (0, 0, &tty_state) < 0) + error (11, errno, "tcsetattr"); +} + +static void +restore_termstate () +{ + tcsetattr (0, 0, &orig_tty_state); +} + +#define host_fstat fstat +typedef struct stat host_stat_t; +#define host_exit exit + +#endif /* UX */ + +mach_port_t privileged_host_port, master_device_port, defpager; +mach_port_t pseudo_master_device_port; +mach_port_t receive_set; +mach_port_t pseudo_console, pseudo_root; +auth_t authserver; + +struct port_info *pseudo_priv_host_pi; + +struct store *root_store; + +spin_lock_t queuelock = SPIN_LOCK_INITIALIZER; +spin_lock_t readlock = SPIN_LOCK_INITIALIZER; + +mach_port_t php_child_name, psmdp_child_name, taskname; + +task_t child_task; +mach_port_t bootport; + +int console_mscount; + +vm_address_t fs_stack_base; +vm_size_t fs_stack_size; + +void init_termstate (); +void restore_termstate (); + +char *fsname; + +char bootstrap_args[100] = "-"; +char *bootdevice = 0; +char *bootscript = 0; + +boolean_t is_user = 0; + + +void safe_gets (char *buf, int buf_len) +{ + fgets (buf, buf_len, stdin); +} + +char *useropen_dir; + +int +useropen (const char *name, int flags, int mode) +{ + if (useropen_dir) + { + static int dlen; + if (!dlen) dlen = strlen (useropen_dir); + { + int len = strlen (name); + char try[dlen + 1 + len + 1]; + int fd; + memcpy (try, useropen_dir, dlen); + try[dlen] = '/'; + memcpy (&try[dlen + 1], name, len + 1); + fd = open (try, flags, mode); + if (fd >= 0) + return fd; + } + } + return open (name, flags, mode); +} + +int +request_server (mach_msg_header_t *inp, + mach_msg_header_t *outp) +{ + extern int io_server (mach_msg_header_t *, mach_msg_header_t *); + extern int device_server (mach_msg_header_t *, mach_msg_header_t *); + extern int notify_server (mach_msg_header_t *, mach_msg_header_t *); + extern int term_server (mach_msg_header_t *, mach_msg_header_t *); +/* extern int tioctl_server (mach_msg_header_t *, mach_msg_header_t *); */ + extern int bootstrap_server (mach_msg_header_t *, mach_msg_header_t *); + extern boolean_t mach_host_server (mach_msg_header_t *InHeadP, + mach_msg_header_t *OutHeadP); + extern boolean_t mach_server (mach_msg_header_t *InHeadP, + mach_msg_header_t *OutHeadP); + extern void bootstrap_compat (); + +#if 0 + if (inp->msgh_local_port == bootport && boot_like_cmudef) + { + if (inp->msgh_id == 999999) + { + bootstrap_compat (inp, outp); + return 1; + } + else + return bootstrap_server (inp, outp); + } + else +#endif + return (io_server (inp, outp) + || device_server (inp, outp) + || notify_server (inp, outp) + || term_server (inp, outp) + /* || tioctl_server (inp, outp) */); +} + +int +mach_proxy_demuxer (mach_msg_header_t *inp, + mach_msg_header_t *outp) +{ + extern boolean_t mach_server + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP); + extern boolean_t mach_host_server + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP); + extern boolean_t mach_port_server + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP); + extern boolean_t exc_server + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP); + extern int notify_server (mach_msg_header_t *, mach_msg_header_t *); + return (mach_server (inp, outp) + || mach_host_server (inp, outp) + || mach_port_server (inp, outp) + || notify_server (inp, outp) + || exc_server (inp, outp)); +} + +void +mach_proxy_thread () +{ + ports_manage_port_operations_multithread (port_bucket, + mach_proxy_demuxer, + 30 * 1000, 0, 0); +} + +vm_address_t +load_image (task_t t, + char *file) +{ + int fd; + union + { + struct exec a; + Elf32_Ehdr e; + } hdr; + char msg[] = ": cannot open bootstrap file\n"; + + fd = useropen (file, O_RDONLY, 0); + + if (fd == -1) + { + write (2, file, strlen (file)); + write (2, msg, sizeof msg - 1); + task_terminate (t); + host_exit (1); + } + + read (fd, &hdr, sizeof hdr); + if (*(Elf32_Word *) hdr.e.e_ident == *(Elf32_Word *) "\177ELF") + { + Elf32_Phdr phdrs[hdr.e.e_phnum], *ph; + lseek (fd, hdr.e.e_phoff, SEEK_SET); + read (fd, phdrs, sizeof phdrs); + for (ph = phdrs; ph < &phdrs[sizeof phdrs/sizeof phdrs[0]]; ++ph) + if (ph->p_type == PT_LOAD) + { + vm_address_t buf; + vm_size_t offs = ph->p_offset & (ph->p_align - 1); + vm_size_t bufsz = round_page (ph->p_filesz + offs); + + buf = (vm_address_t) mmap (0, bufsz, + PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); + + lseek (fd, ph->p_offset, SEEK_SET); + read (fd, (void *)(buf + offs), ph->p_filesz); + + ph->p_memsz = ((ph->p_vaddr + ph->p_memsz + ph->p_align - 1) + & ~(ph->p_align - 1)); + ph->p_vaddr &= ~(ph->p_align - 1); + ph->p_memsz -= ph->p_vaddr; + + vm_allocate (t, (vm_address_t*)&ph->p_vaddr, ph->p_memsz, 0); + vm_write (t, ph->p_vaddr, buf, bufsz); + munmap ((caddr_t) buf, bufsz); + vm_protect (t, ph->p_vaddr, ph->p_memsz, 0, + ((ph->p_flags & PF_R) ? VM_PROT_READ : 0) | + ((ph->p_flags & PF_W) ? VM_PROT_WRITE : 0) | + ((ph->p_flags & PF_X) ? VM_PROT_EXECUTE : 0)); + } + return hdr.e.e_entry; + } + else + { + /* a.out */ + int magic = N_MAGIC (hdr.a); + int headercruft; + vm_address_t base = 0x10000; + int rndamount, amount; + vm_address_t bsspagestart, bssstart; + char *buf; + + headercruft = sizeof (struct exec) * (magic == ZMAGIC); + + amount = headercruft + hdr.a.a_text + hdr.a.a_data; + rndamount = round_page (amount); + buf = mmap (0, rndamount, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); + lseek (fd, sizeof hdr.a - headercruft, SEEK_SET); + read (fd, buf, amount); + vm_allocate (t, &base, rndamount, 0); + vm_write (t, base, (vm_address_t) buf, rndamount); + if (magic != OMAGIC) + vm_protect (t, base, trunc_page (headercruft + hdr.a.a_text), + 0, VM_PROT_READ | VM_PROT_EXECUTE); + munmap ((caddr_t) buf, rndamount); + + bssstart = base + hdr.a.a_text + hdr.a.a_data + headercruft; + bsspagestart = round_page (bssstart); + vm_allocate (t, &bsspagestart, + hdr.a.a_bss - (bsspagestart - bssstart), 0); + + return hdr.a.a_entry; + } +} + + +void read_reply (); +void msg_thread (); + +/* Callbacks for boot_script.c; see boot_script.h. */ + +mach_port_t +boot_script_read_file (const char *filename) +{ + static const char msg[] = ": cannot open\n"; + int fd = useropen (filename, O_RDONLY, 0); + host_stat_t st; + error_t err; + mach_port_t memobj; + vm_address_t region; + + write (2, filename, strlen (filename)); + if (fd < 0) + { + write (2, msg, sizeof msg - 1); + host_exit (1); + } + else + write (2, msg + sizeof msg - 2, 1); + + host_fstat (fd, &st); + + err = default_pager_object_create (defpager, &memobj, + round_page (st.st_size)); + if (err) + { + static const char msg[] = "cannot create default-pager object\n"; + write (2, msg, sizeof msg - 1); + host_exit (1); + } + + region = 0; + vm_map (mach_task_self (), ®ion, round_page (st.st_size), + 0, 1, memobj, 0, 0, VM_PROT_ALL, VM_PROT_ALL, VM_INHERIT_NONE); + read (fd, (char *) region, st.st_size); + munmap ((caddr_t) region, round_page (st.st_size)); + + close (fd); + return memobj; +} + +int +boot_script_exec_cmd (void *hook, + mach_port_t task, char *path, int argc, + char **argv, char *strings, int stringlen) +{ + char *args, *p; + int arg_len, i; + size_t reg_size; + void *arg_pos; + vm_offset_t stack_start, stack_end; + vm_address_t startpc, str_start; + thread_t thread; + + write (2, path, strlen (path)); + for (i = 1; i < argc; ++i) + { + write (2, " ", 1); + write (2, argv[i], strlen (argv[i])); + } + write (2, "\r\n", 2); + + startpc = load_image (task, path); + arg_len = stringlen + (argc + 2) * sizeof (char *) + sizeof (integer_t); + arg_len += 5 * sizeof (int); + stack_end = VM_MAX_ADDRESS; + stack_start = VM_MAX_ADDRESS - 16 * 1024 * 1024; + vm_allocate (task, &stack_start, stack_end - stack_start, FALSE); + arg_pos = (void *) ((stack_end - arg_len) & ~(sizeof (natural_t) - 1)); + args = mmap (0, stack_end - trunc_page ((vm_offset_t) arg_pos), + PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); + str_start = ((vm_address_t) arg_pos + + (argc + 2) * sizeof (char *) + sizeof (integer_t)); + p = args + ((vm_address_t) arg_pos & (vm_page_size - 1)); + *(int *) p = argc; + p = (void *) p + sizeof (int); + for (i = 0; i < argc; i++) + { + *(char **) p = argv[i] - strings + (char *) str_start; + p = (void *) p + sizeof (char *); + } + *(char **) p = 0; + p = (void *) p + sizeof (char *); + *(char **) p = 0; + p = (void *) p + sizeof (char *); + memcpy (p, strings, stringlen); + bzero (args, (vm_offset_t) arg_pos & (vm_page_size - 1)); + vm_write (task, trunc_page ((vm_offset_t) arg_pos), (vm_address_t) args, + stack_end - trunc_page ((vm_offset_t) arg_pos)); + munmap ((caddr_t) args, + stack_end - trunc_page ((vm_offset_t) arg_pos)); + + thread_create (task, &thread); +#ifdef i386_THREAD_STATE_COUNT + { + struct i386_thread_state regs; + reg_size = i386_THREAD_STATE_COUNT; + thread_get_state (thread, i386_THREAD_STATE, + (thread_state_t) ®s, ®_size); + regs.eip = (int) startpc; + regs.uesp = (int) arg_pos; + thread_set_state (thread, i386_THREAD_STATE, + (thread_state_t) ®s, reg_size); + } +#elif defined(ALPHA_THREAD_STATE_COUNT) + { + struct alpha_thread_state regs; + reg_size = ALPHA_THREAD_STATE_COUNT; + thread_get_state (thread, ALPHA_THREAD_STATE, + (thread_state_t) ®s, ®_size); + regs.r30 = (natural_t) arg_pos; + regs.pc = (natural_t) startpc; + thread_set_state (thread, ALPHA_THREAD_STATE, + (thread_state_t) ®s, reg_size); + } +#else +# error needs to be ported +#endif + + thread_resume (thread); + mach_port_deallocate (mach_task_self (), thread); + return 0; +} + +const char *argp_program_version = STANDARD_HURD_VERSION (boot); + +static struct argp_option options[] = +{ + { "boot-root", 'D', "DIR", 0, + "Root of a directory tree in which to find files specified in BOOT-SCRIPT" }, + { "single-user", 's', 0, 0, + "Boot in single user mode" }, + { "kernel-command-line", 'c', "COMMAND LINE", 0, + "Simulated multiboot command line to supply" }, + { "pause" , 'd', 0, 0, + "Pause for user confirmation at various times during booting" }, + { "isig", 'I', 0, 0, + "Do not disable terminal signals, so you can suspend and interrupt boot."}, + { "device-map", 'm', "DEBICENAME=DEVICEFILE", 0, + "Map the device in subhurd to the device in the main Hurd."}, + { "defpager", 'p', "PAGER TRANSLATOR", 0, + "Specify the default pager for subhurd."}, + { "user", 'u', 0, 0, "For normal user."}, + { 0 } +}; +static char args_doc[] = "BOOT-SCRIPT"; +static char doc[] = "Boot a second hurd"; + +struct dev_map +{ + char *name; + mach_port_t port; + struct dev_map *next; +}; + +static struct dev_map *dev_map_head; + +static struct dev_map *add_dev_map (char *dev_name, char *dev_file) +{ + struct dev_map *map = (struct dev_map *) malloc (sizeof (*map)); + + assert (map); + map->name = dev_name; + map->port = file_name_lookup (dev_file, 0, 0); + if (map->port == MACH_PORT_NULL) + error (1, errno, "file_name_lookup: %s", dev_file); + map->next = dev_map_head; + dev_map_head = map; + return map; +} + +static struct dev_map *lookup_dev (char *dev_name) +{ + struct dev_map *map; + + for (map = dev_map_head; map; map = map->next) + { + if (strcmp (map->name, dev_name) == 0) + return map; + } + return NULL; +} + +char *pager_file; + +static error_t +parse_opt (int key, char *arg, struct argp_state *state) +{ + char *dev_file; + + switch (key) + { + size_t len; + + case 'c': kernel_command_line = arg; break; + + case 'D': useropen_dir = arg; break; + + case 'I': isig = 1; break; + + case 's': case 'd': + len = strlen (bootstrap_args); + if (len >= sizeof bootstrap_args - 1) + argp_error (state, "Too many bootstrap args"); + bootstrap_args[len++] = key; + bootstrap_args[len] = '\0'; + break; + + case 'm': + dev_file = strchr (arg, '='); + if (dev_file == NULL) + return ARGP_ERR_UNKNOWN; + *dev_file = 0; + add_dev_map (arg, dev_file+1); + break; + + case 'p': + pager_file = arg; + break; + + case 'u': + is_user = 1; + break; + + case ARGP_KEY_ARG: + if (state->arg_num == 0) + bootscript = arg; + else + return ARGP_ERR_UNKNOWN; + break; + + case ARGP_KEY_INIT: + state->child_inputs[0] = state->input; break; + + default: + return ARGP_ERR_UNKNOWN; + } + return 0; +} + +static void +sigint (int signo) +{ + int kill_task (struct task_info *task_pi) + { + task_terminate (task_pi->task_port); + return 0; + } + + info ("receives an INT"); + foreach_task (kill_task); + exit (0); +} + +void +init_signal () +{ + struct sigaction sa; + sa.sa_handler = sigint; + sa.sa_flags = 0; /* No SA_RESTART! */ + sigemptyset(&sa.sa_mask); + if (sigaction (SIGINT, &sa, NULL)) + error (2, errno, "cannot set SIGHUP handler"); +} + +void +init_kernel_task () +{ + error_t err; + task_t pseudo_task; + task_t pseudo_kernel_task; + process_t real_kernel_task_proc; + process_t proc; + extern int create_pseudo_task (task_t real_task, task_t *ret_pseudo_task); + + err = task_create (mach_task_self (), 0, &pseudo_kernel_task); + if (err) + error (4, err, "cannot create the pseudo kernel task."); + + err = proc_task2proc (getproc (), pseudo_kernel_task, &proc); + if (err) + error (4, err, "cannot get the proc port for the pseudo kernel task."); + + err = task_set_bootstrap_port (pseudo_kernel_task, proc); + if (err) + error (4, err, "cannot set the pseudo kernel task's bootstrap port"); + + err = proc_pid2proc (getproc (), 2, &real_kernel_task_proc); + if (err) + error (4, err, "cannot get the kernel task's proc port"); + + vm_address_t kargv, kenvp; + err = proc_get_arg_locations (real_kernel_task_proc, &kargv, &kenvp); + if (err) + error (4, err, "cannot get the kernel task's argument"); + proc_set_arg_locations (proc, kargv, kenvp); + create_pseudo_task (pseudo_kernel_task, &pseudo_task); + // TODO the pseudo kernel task has to been destroyed after subhurd exits. +} + +FILE *logfile; + +int +main (int argc, char **argv, char **envp) +{ + error_t err; + mach_port_t foo; + char *buf = 0; + int i, len; + char *root_store_name; + const struct argp_child kids[] = { { &store_argp }, { 0 }}; + struct argp argp = { options, parse_opt, args_doc, doc, kids }; + struct store_argp_params store_argp_params = { 0 }; + mach_port_t subhurd_privileged_host_port = MACH_PORT_NULL; + + LOG_START (); + + argp_parse (&argp, argc, argv, 0, 0, &store_argp_params); + err = store_parsed_name (store_argp_params.result, &root_store_name); + if (err) + error (2, err, "store_parsed_name"); + + err = store_parsed_open (store_argp_params.result, 0, &root_store); + if (err) + error (4, err, "%s", root_store_name); + + init_signal (); + if (!is_user) + { + get_privileged_ports (&privileged_host_port, &master_device_port); + defpager = MACH_PORT_NULL; + err = vm_set_default_memory_manager (privileged_host_port, &defpager); + if (err) + error (4, err, "vm_set_default_memory_manager"); + subhurd_privileged_host_port = privileged_host_port; + } + else + { + port_bucket = ports_create_bucket (); + task_portclass = ports_create_class (clean_pseudo_task, 0); + priv_host_portclass = ports_create_class (destroy_priv_host, 0); + other_portclass = ports_create_class (0, 0); + init_kernel_task (); + cthread_detach (cthread_fork ((cthread_fn_t) mach_proxy_thread, + (any_t) 0)); + { + mach_port_t priv_host; + get_privileged_ports (&priv_host, NULL); + defpager = MACH_PORT_NULL; + err = vm_set_default_memory_manager (priv_host, &defpager); + if (err) + error (4, err, "vm_set_default_memory_manager"); + mach_port_deallocate (mach_task_self (), priv_host); + } +// if (pager_file == NULL) +// error (4, 0, "The default pager must be specified for subhurd."); +// defpager = file_name_lookup (pager_file, O_EXEC, 0); +// if (defpager == MACH_PORT_NULL) +// error (4, errno, "file_name_look: %s", pager_file); + + /* Initialize the pseudo privileged host port. */ + err = ports_create_port (priv_host_portclass, port_bucket, + sizeof (struct port_info), + &pseudo_priv_host_pi); + if (err) + error (4, err, "fail to create the pseudo privileged host port"); + subhurd_privileged_host_port = ports_get_send_right (pseudo_priv_host_pi); + ports_port_deref (pseudo_priv_host_pi); + } + + strcat (bootstrap_args, "f"); + + mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_PORT_SET, + &receive_set); + + if (root_store->class == &store_device_class && root_store->name + && (root_store->flags & STORE_ENFORCED) + && root_store->num_runs == 1 && root_store->runs[0].start == 0) + /* Let known device nodes pass through directly. */ + bootdevice = root_store->name; + else + /* Pass a magic value that we can use to do I/O to ROOT_STORE. */ + { + bootdevice = "pseudo-root"; + mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_RECEIVE, + &pseudo_root); + mach_port_move_member (mach_task_self (), pseudo_root, receive_set); + } + + /* Initialize the pseudo master device port. */ + mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_RECEIVE, + &pseudo_master_device_port); + mach_port_insert_right (mach_task_self (), + pseudo_master_device_port, + pseudo_master_device_port, + MACH_MSG_TYPE_MAKE_SEND); + mach_port_move_member (mach_task_self (), pseudo_master_device_port, + receive_set); + mach_port_request_notification (mach_task_self (), pseudo_master_device_port, + MACH_NOTIFY_NO_SENDERS, 1, + pseudo_master_device_port, + MACH_MSG_TYPE_MAKE_SEND_ONCE, &foo); + if (foo != MACH_PORT_NULL) + mach_port_deallocate (mach_task_self (), foo); + + /* Initialize the pseudo console port. */ + mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_RECEIVE, + &pseudo_console); + mach_port_move_member (mach_task_self (), pseudo_console, receive_set); + mach_port_request_notification (mach_task_self (), pseudo_console, + MACH_NOTIFY_NO_SENDERS, 1, pseudo_console, + MACH_MSG_TYPE_MAKE_SEND_ONCE, &foo); + if (foo != MACH_PORT_NULL) + mach_port_deallocate (mach_task_self (), foo); + + if (kernel_command_line == 0) + asprintf (&kernel_command_line, "%s %s root=%s", + argv[0], bootstrap_args, bootdevice); + + /* Initialize boot script variables. */ + if (boot_script_set_variable ("host-port", VAL_PORT, + (int) subhurd_privileged_host_port) + || boot_script_set_variable ("device-port", VAL_PORT, + (integer_t) pseudo_master_device_port) + || boot_script_set_variable ("kernel-command-line", VAL_STR, + (integer_t) kernel_command_line) + || boot_script_set_variable ("root-device", + VAL_STR, (integer_t) bootdevice) + || boot_script_set_variable ("boot-args", + VAL_STR, (integer_t) bootstrap_args)) + { + static const char msg[] = "error setting variable"; + + write (2, msg, strlen (msg)); + host_exit (1); + } + + /* Turn each `FOO=BAR' word in the command line into a boot script + variable ${FOO} with value BAR. */ + { + int len = strlen (kernel_command_line) + 1; + char *s = memcpy (alloca (len), kernel_command_line, len); + char *word; + + while ((word = strsep (&s, " \t")) != 0) + { + char *eq = strchr (word, '='); + if (eq == 0) + continue; + *eq++ = '\0'; + err = boot_script_set_variable (word, VAL_STR, (integer_t) eq); + if (err) + { + char *msg; + asprintf (&msg, "cannot set boot-script variable %s: %s\n", + word, boot_script_error_string (err)); + assert (msg); + write (2, msg, strlen (msg)); + free (msg); + host_exit (1); + } + } + } + + /* Parse the boot script. */ + { + char *p, *line; + static const char filemsg[] = "Can't open boot script\n"; + static const char memmsg[] = "Not enough memory\n"; + int amt, fd, err; + + fd = open (bootscript, O_RDONLY, 0); + if (fd < 0) + { + write (2, filemsg, sizeof (filemsg)); + host_exit (1); + } + p = buf = malloc (500); + if (!buf) + { + write (2, memmsg, sizeof (memmsg)); + host_exit (1); + } + len = 500; + amt = 0; + while (1) + { + i = read (fd, p, len - (p - buf)); + if (i <= 0) + break; + p += i; + amt += i; + if (p == buf + len) + { + char *newbuf; + + len += 500; + newbuf = realloc (buf, len); + if (!newbuf) + { + write (2, memmsg, sizeof (memmsg)); + host_exit (1); + } + p = newbuf + (p - buf); + buf = newbuf; + } + } + line = p = buf; + while (1) + { + while (p < buf + amt && *p != '\n') + p++; + *p = '\0'; + err = boot_script_parse_line (0, line); + if (err) + { + char *str; + int i; + + str = boot_script_error_string (err); + i = strlen (str); + write (2, str, i); + write (2, " in `", 5); + write (2, line, strlen (line)); + write (2, "'\n", 2); + host_exit (1); + } + if (p == buf + amt) + break; + line = ++p; + } + } + + if (index (bootstrap_args, 'd')) + { + static const char msg[] = "Pausing. . ."; + char c; + write (2, msg, sizeof (msg) - 1); + read (0, &c, 1); + } + + init_termstate (); + + /* The boot script has now been parsed into internal data structures. + Now execute its directives. */ + { + int err; + + err = boot_script_exec (); + if (err) + { + char *str = boot_script_error_string (err); + int i = strlen (str); + + write (2, str, i); + host_exit (1); + } + free (buf); + } + + mach_port_deallocate (mach_task_self (), pseudo_master_device_port); + if (is_user) + mach_port_deallocate (mach_task_self (), subhurd_privileged_host_port); + + cthread_detach (cthread_fork ((cthread_fn_t) msg_thread, (any_t) 0)); + + for (;;) + { + fd_set rmask; + FD_ZERO (&rmask); + FD_SET (0, &rmask); + if (select (1, &rmask, 0, 0, 0) == 1) + read_reply (); + else /* We hosed */ + error (5, errno, "select"); + } + + LOG_END (); +/* mach_msg_server (request_server, __vm_page_size * 2, receive_set); */ +} + +void +msg_thread() +{ + while (1) + mach_msg_server (request_server, 0, receive_set); +} + + +enum read_type +{ + DEV_READ, + DEV_READI, + IO_READ, +}; +struct qr +{ + enum read_type type; + mach_port_t reply_port; + mach_msg_type_name_t reply_type; + int amount; + struct qr *next; +}; +struct qr *qrhead, *qrtail; + +/* Queue a read for later reply. */ +kern_return_t +queue_read (enum read_type type, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + int amount) +{ + struct qr *qr; + + qr = malloc (sizeof (struct qr)); + if (!qr) + return D_NO_MEMORY; + + spin_lock (&queuelock); + + qr->type = type; + qr->reply_port = reply_port; + qr->reply_type = reply_type; + qr->amount = amount; + qr->next = 0; + if (qrtail) + qrtail->next = qr; + else + qrhead = qrtail = qr; + + spin_unlock (&queuelock); + return D_SUCCESS; +} + +/* TRUE if there's data available on stdin, which should be used to satisfy + console read requests. */ +static int should_read = 0; + +/* Reply to a queued read. */ +void +read_reply () +{ + int avail; + struct qr *qr; + char * buf; + int amtread; + + /* By forcing SHOULD_READ to true before trying the lock, we ensure that + either we get the lock ourselves or that whoever currently holds the + lock will service this read when he unlocks it. */ + should_read = 1; + if (! spin_try_lock (&readlock)) + return; + + /* Since we're commited to servicing the read, no one else need do so. */ + should_read = 0; + + ioctl (0, FIONREAD, &avail); + if (!avail) + { + spin_unlock (&readlock); + return; + } + + spin_lock (&queuelock); + + if (!qrhead) + { + spin_unlock (&queuelock); + spin_unlock (&readlock); + return; + } + + qr = qrhead; + qrhead = qr->next; + if (qr == qrtail) + qrtail = 0; + + spin_unlock (&queuelock); + + if (qr->type == DEV_READ) + buf = mmap (0, qr->amount, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); + else + buf = alloca (qr->amount); + amtread = read (0, buf, qr->amount); + + spin_unlock (&readlock); + + switch (qr->type) + { + case DEV_READ: + if (amtread >= 0) + ds_device_read_reply (qr->reply_port, qr->reply_type, 0, + (io_buf_ptr_t) buf, amtread); + else + ds_device_read_reply (qr->reply_port, qr->reply_type, errno, 0, 0); + break; + + case DEV_READI: + if (amtread >= 0) + ds_device_read_reply_inband (qr->reply_port, qr->reply_type, 0, + buf, amtread); + else + ds_device_read_reply_inband (qr->reply_port, qr->reply_type, errno, + 0, 0); + break; + + case IO_READ: + if (amtread >= 0) + io_read_reply (qr->reply_port, qr->reply_type, 0, + buf, amtread); + else + io_read_reply (qr->reply_port, qr->reply_type, errno, 0, 0); + break; + } + + free (qr); +} + +/* Unlock READLOCK, and also service any new read requests that it was + blocking. */ +static void +unlock_readlock () +{ + spin_unlock (&readlock); + while (should_read) + read_reply (); +} + +/* + * Handle bootstrap requests. + */ +/* These two functions from .../mk/bootstrap/default_pager.c. */ + +kern_return_t +do_bootstrap_privileged_ports(bootstrap, hostp, devicep) + mach_port_t bootstrap; + mach_port_t *hostp, *devicep; +{ + if (is_user) + /* I cannot use ports_get_right() here, + * because the port will be copied to the client. */ + *hostp = pseudo_priv_host_pi->port_right; + else + *hostp = privileged_host_port; + *devicep = pseudo_master_device_port; + return KERN_SUCCESS; +} + +void +bootstrap_compat(in, out) + mach_msg_header_t *in, *out; +{ + mig_reply_header_t *reply = (mig_reply_header_t *) out; + mach_msg_return_t mr; + + struct imsg { + mach_msg_header_t hdr; + mach_msg_type_t port_desc_1; + mach_port_t port_1; + mach_msg_type_t port_desc_2; + mach_port_t port_2; + } imsg; + + /* + * Send back the host and device ports. + */ + + imsg.hdr.msgh_bits = MACH_MSGH_BITS_COMPLEX | + MACH_MSGH_BITS(MACH_MSGH_BITS_REMOTE(in->msgh_bits), 0); + /* msgh_size doesn't need to be initialized */ + imsg.hdr.msgh_remote_port = in->msgh_remote_port; + imsg.hdr.msgh_local_port = MACH_PORT_NULL; + /* msgh_seqno doesn't need to be initialized */ + imsg.hdr.msgh_id = in->msgh_id + 100; /* this is a reply msg */ + + imsg.port_desc_1.msgt_name = MACH_MSG_TYPE_COPY_SEND; + imsg.port_desc_1.msgt_size = (sizeof(mach_port_t) * 8); + imsg.port_desc_1.msgt_number = 1; + imsg.port_desc_1.msgt_inline = TRUE; + imsg.port_desc_1.msgt_longform = FALSE; + imsg.port_desc_1.msgt_deallocate = FALSE; + imsg.port_desc_1.msgt_unused = 0; + + if (is_user) + imsg.port_1 = pseudo_priv_host_pi->port_right; + else + imsg.port_1 = privileged_host_port; + + imsg.port_desc_2 = imsg.port_desc_1; + + imsg.port_desc_2.msgt_name = MACH_MSG_TYPE_MAKE_SEND; + imsg.port_2 = pseudo_master_device_port; + + /* + * Send the reply message. + * (mach_msg_server can not do this, because the reply + * is not in standard format.) + */ + + mr = mach_msg(&imsg.hdr, MACH_SEND_MSG, + sizeof imsg, 0, MACH_PORT_NULL, + MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (mr != MACH_MSG_SUCCESS) + (void) mach_port_deallocate(mach_task_self (), + imsg.hdr.msgh_remote_port); + + /* + * Tell mach_msg_server to do nothing. + */ + + reply->RetCode = MIG_NO_REPLY; +} + +/* Implementation of device interface */ + +kern_return_t +ds_device_open (mach_port_t master_port, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + dev_mode_t mode, + dev_name_t name, + mach_port_t *device, + mach_msg_type_name_t *devicetype) +{ + struct dev_map *map; + + if (master_port != pseudo_master_device_port) + return D_INVALID_OPERATION; + + debug ("open %s", name); + if (!strcmp (name, "console")) + { +#if 0 + mach_port_insert_right (mach_task_self (), pseudo_console, + pseudo_console, MACH_MSG_TYPE_MAKE_SEND); + console_send_rights++; +#endif + console_mscount++; + *device = pseudo_console; + *devicetype = MACH_MSG_TYPE_MAKE_SEND; + return 0; + } + else if (strcmp (name, "pseudo-root") == 0) + /* Magic root device. */ + { + *device = pseudo_root; + *devicetype = MACH_MSG_TYPE_MAKE_SEND; + return 0; + } + + map = lookup_dev (name); + if (map) + { + error_t err; + *devicetype = MACH_MSG_TYPE_MOVE_SEND; + err = device_open (map->port, mode, "", device); + return err; + } + + if (is_user) + return D_NO_SUCH_DEVICE; + else + { + *devicetype = MACH_MSG_TYPE_MOVE_SEND; + return device_open (master_device_port, mode, name, device); + } +} + +kern_return_t +ds_device_close (device_t device) +{ + if (device != pseudo_console && device != pseudo_root) + return D_NO_SUCH_DEVICE; + return 0; +} + +kern_return_t +ds_device_write (device_t device, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + dev_mode_t mode, + recnum_t recnum, + io_buf_ptr_t data, + size_t datalen, + int *bytes_written) +{ + if (device == pseudo_console) + { +#if 0 + if (console_send_rights) + { + mach_port_mod_refs (mach_task_self (), pseudo_console, + MACH_PORT_TYPE_SEND, -console_send_rights); + console_send_rights = 0; + } +#endif + + *bytes_written = write (1, data, datalen); + + return (*bytes_written == -1 ? D_IO_ERROR : D_SUCCESS); + } + else if (device == pseudo_root) + { + size_t wrote; + if (store_write (root_store, recnum, data, datalen, &wrote) != 0) + return D_IO_ERROR; + *bytes_written = wrote; + return D_SUCCESS; + } + else + return D_NO_SUCH_DEVICE; +} + +kern_return_t +ds_device_write_inband (device_t device, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + dev_mode_t mode, + recnum_t recnum, + io_buf_ptr_inband_t data, + size_t datalen, + int *bytes_written) +{ + if (device == pseudo_console) + { +#if 0 + if (console_send_rights) + { + mach_port_mod_refs (mach_task_self (), pseudo_console, + MACH_PORT_TYPE_SEND, -console_send_rights); + console_send_rights = 0; + } +#endif + + *bytes_written = write (1, data, datalen); + + return (*bytes_written == -1 ? D_IO_ERROR : D_SUCCESS); + } + else if (device == pseudo_root) + { + size_t wrote; + if (store_write (root_store, recnum, data, datalen, &wrote) != 0) + return D_IO_ERROR; + *bytes_written = wrote; + return D_SUCCESS; + } + else + return D_NO_SUCH_DEVICE; +} + +kern_return_t +ds_device_read (device_t device, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + dev_mode_t mode, + recnum_t recnum, + int bytes_wanted, + io_buf_ptr_t *data, + size_t *datalen) +{ + if (device == pseudo_console) + { + int avail; + +#if 0 + if (console_send_rights) + { + mach_port_mod_refs (mach_task_self (), pseudo_console, + MACH_PORT_TYPE_SEND, -console_send_rights); + console_send_rights = 0; + } +#endif + + spin_lock (&readlock); + ioctl (0, FIONREAD, &avail); + if (avail) + { + *data = mmap (0, bytes_wanted, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); + *datalen = read (0, *data, bytes_wanted); + unlock_readlock (); + return (*datalen == -1 ? D_IO_ERROR : D_SUCCESS); + } + else + { + kern_return_t err; + + unlock_readlock (); + err = queue_read (DEV_READ, reply_port, reply_type, bytes_wanted); + if (err) + return err; + return MIG_NO_REPLY; + } + } + else if (device == pseudo_root) + { + *datalen = 0; + return + (store_read (root_store, recnum, bytes_wanted, (void **)data, datalen) == 0 + ? D_SUCCESS + : D_IO_ERROR); + } + else + return D_NO_SUCH_DEVICE; +} + +kern_return_t +ds_device_read_inband (device_t device, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + dev_mode_t mode, + recnum_t recnum, + int bytes_wanted, + io_buf_ptr_inband_t data, + size_t *datalen) +{ + if (device == pseudo_console) + { + int avail; + +#if 0 + if (console_send_rights) + { + mach_port_mod_refs (mach_task_self (), pseudo_console, + MACH_PORT_TYPE_SEND, -console_send_rights); + console_send_rights = 0; + } +#endif + + spin_lock (&readlock); + ioctl (0, FIONREAD, &avail); + if (avail) + { + *datalen = read (0, data, bytes_wanted); + unlock_readlock (); + return (*datalen == -1 ? D_IO_ERROR : D_SUCCESS); + } + else + { + kern_return_t err; + + unlock_readlock (); + err = queue_read (DEV_READI, reply_port, reply_type, bytes_wanted); + if (err) + return err; + return MIG_NO_REPLY; + } + } + else if (device == pseudo_root) + { + error_t err; + void *returned = data; + + *datalen = bytes_wanted; + err = + store_read (root_store, recnum, bytes_wanted, (void **)&returned, datalen); + + if (! err) + { + if (returned != data) + { + bcopy (returned, (void *)data, *datalen); + munmap ((caddr_t) returned, *datalen); + } + return D_SUCCESS; + } + else + return D_IO_ERROR; + } + else + return D_NO_SUCH_DEVICE; +} + +kern_return_t +ds_xxx_device_set_status (device_t device, + dev_flavor_t flavor, + dev_status_t status, + size_t statu_cnt) +{ + if (device != pseudo_console) + return D_NO_SUCH_DEVICE; + return D_INVALID_OPERATION; +} + +kern_return_t +ds_xxx_device_get_status (device_t device, + dev_flavor_t flavor, + dev_status_t status, + size_t *statuscnt) +{ + if (device != pseudo_console && device != pseudo_root) + return D_NO_SUCH_DEVICE; + return D_INVALID_OPERATION; +} + +kern_return_t +ds_xxx_device_set_filter (device_t device, + mach_port_t rec, + int pri, + filter_array_t filt, + size_t len) +{ + if (device != pseudo_console && device != pseudo_root) + return D_NO_SUCH_DEVICE; + return D_INVALID_OPERATION; +} + +kern_return_t +ds_device_map (device_t device, + vm_prot_t prot, + vm_offset_t offset, + vm_size_t size, + memory_object_t *pager, + int unmap) +{ + if (device != pseudo_console && device != pseudo_root) + return D_NO_SUCH_DEVICE; + return D_INVALID_OPERATION; +} + +kern_return_t +ds_device_set_status (device_t device, + dev_flavor_t flavor, + dev_status_t status, + size_t statuslen) +{ + if (device != pseudo_console && device != pseudo_root) + return D_NO_SUCH_DEVICE; + return D_INVALID_OPERATION; +} + +kern_return_t +ds_device_get_status (device_t device, + dev_flavor_t flavor, + dev_status_t status, + size_t *statuslen) +{ + if (device == pseudo_console) + return D_INVALID_OPERATION; + else if (device == pseudo_root) + if (flavor == DEV_GET_SIZE) + if (*statuslen < DEV_GET_SIZE_COUNT) + return D_INVALID_SIZE; + else + { + status[DEV_GET_SIZE_DEVICE_SIZE] = root_store->size; + status[DEV_GET_SIZE_RECORD_SIZE] = root_store->block_size; + *statuslen = DEV_GET_SIZE_COUNT; + return D_SUCCESS; + } + else + return D_INVALID_OPERATION; + else + return D_NO_SUCH_DEVICE; +} + +kern_return_t +ds_device_set_filter (device_t device, + mach_port_t receive_port, + int priority, + filter_array_t filter, + size_t filterlen) +{ + if (device != pseudo_console && device != pseudo_root) + return D_NO_SUCH_DEVICE; + return D_INVALID_OPERATION; +} + + +/* Implementation of notify interface */ +kern_return_t +do_mach_notify_port_deleted (mach_port_t notify, + mach_port_t name) +{ + return EOPNOTSUPP; +} + +kern_return_t +do_mach_notify_msg_accepted (mach_port_t notify, + mach_port_t name) +{ + return EOPNOTSUPP; +} + +kern_return_t +do_mach_notify_port_destroyed (mach_port_t notify, + mach_port_t port) +{ + return EOPNOTSUPP; +} + +boolean_t pseudo_priv_host_destroyed = FALSE; + +void +destroy_priv_host (void *pi) +{ + pseudo_priv_host_destroyed = TRUE; + info ("pseudo privileged host port is destroyed"); +} + +kern_return_t +do_mach_notify_no_senders (mach_port_t notify, + mach_port_mscount_t mscount) +{ + static int no_console; + mach_port_t foo; + error_t err = EOPNOTSUPP; + + if (notify == pseudo_master_device_port) + { + info ("pseudo master device port has no senders"); + /* for the root */ + if (no_console && !is_user) + goto bye; + /* for the normal user */ + if (no_console && is_user && pseudo_priv_host_destroyed) + goto bye; + pseudo_master_device_port = MACH_PORT_NULL; + return 0; + } + if (pseudo_priv_host_pi->port_right == notify && is_user) + { + if (no_console && pseudo_master_device_port == MACH_PORT_NULL) + goto bye; + pseudo_priv_host_destroyed = TRUE; + return 0; + } + if (notify == pseudo_console) + { + info ("pseudo console has no senders"); + if ( + /* for the root */ + (mscount == console_mscount && + pseudo_master_device_port == MACH_PORT_NULL && + !is_user) || + /* for the normal user */ + (mscount == console_mscount && + pseudo_master_device_port == MACH_PORT_NULL && + pseudo_priv_host_destroyed && + is_user)) + { + bye: + restore_termstate (); + write (2, "bye\n", 4); + host_exit (0); + } + else + { + no_console = (mscount == console_mscount); + info ("no console: %d", no_console); + + mach_port_request_notification (mach_task_self (), pseudo_console, + MACH_NOTIFY_NO_SENDERS, + console_mscount == mscount + ? mscount + 1 + : console_mscount, + pseudo_console, + MACH_MSG_TYPE_MAKE_SEND_ONCE, &foo); + if (foo != MACH_PORT_NULL) + mach_port_deallocate (mach_task_self (), foo); + } + } + + err = ports_do_mach_notify_no_senders (notify, mscount); + + return err; +} + +kern_return_t +do_mach_notify_send_once (mach_port_t notify) +{ + return EOPNOTSUPP; +} + +kern_return_t +do_mach_notify_dead_name (mach_port_t notify, + mach_port_t name) +{ +#if 0 + if (name == child_task && notify == bootport) + host_exit (0); +#endif + return EOPNOTSUPP; +} + + +/* Implementation of the Hurd I/O interface, which + we support for the console port only. */ + +kern_return_t +S_io_write (mach_port_t object, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + char *data, + mach_msg_type_number_t datalen, + off_t offset, + mach_msg_type_number_t *amtwritten) +{ + if (object != pseudo_console) + return EOPNOTSUPP; + +#if 0 + if (console_send_rights) + { + mach_port_mod_refs (mach_task_self (), pseudo_console, + MACH_PORT_TYPE_SEND, -console_send_rights); + console_send_rights = 0; + } +#endif + + *amtwritten = write (1, data, datalen); + return *amtwritten == -1 ? errno : 0; +} + +kern_return_t +S_io_read (mach_port_t object, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + char **data, + mach_msg_type_number_t *datalen, + off_t offset, + mach_msg_type_number_t amount) +{ + mach_msg_type_number_t avail; + + if (object != pseudo_console) + return EOPNOTSUPP; + +#if 0 + if (console_send_rights) + { + mach_port_mod_refs (mach_task_self (), pseudo_console, + MACH_PORT_TYPE_SEND, -console_send_rights); + console_send_rights = 0; + } +#endif + + spin_lock (&readlock); + ioctl (0, FIONREAD, &avail); + if (avail) + { + if (amount > *datalen) + *data = mmap (0, amount, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); + *datalen = read (0, *data, amount); + unlock_readlock (); + return *datalen == -1 ? errno : 0; + } + else + { + kern_return_t err; + unlock_readlock (); + err = queue_read (IO_READ, reply_port, reply_type, amount); + if (err) + return err; + return MIG_NO_REPLY; + } +} + +kern_return_t +S_io_seek (mach_port_t object, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + off_t offset, + int whence, + off_t *newp) +{ + return object == pseudo_console ? ESPIPE : EOPNOTSUPP; +} + +kern_return_t +S_io_readable (mach_port_t object, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + mach_msg_type_number_t *amt) +{ + if (object != pseudo_console) + return EOPNOTSUPP; + ioctl (0, FIONREAD, amt); + return 0; +} + +kern_return_t +S_io_set_all_openmodes (mach_port_t object, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + int bits) +{ + return EOPNOTSUPP; +} + +kern_return_t +S_io_get_openmodes (mach_port_t object, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + int *modes) +{ + *modes = O_READ | O_WRITE; + return object == pseudo_console ? 0 : EOPNOTSUPP; +} + +kern_return_t +S_io_set_some_openmodes (mach_port_t object, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + int bits) +{ + return EOPNOTSUPP; +} + +kern_return_t +S_io_clear_some_openmodes (mach_port_t object, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + int bits) +{ + return EOPNOTSUPP; +} + +kern_return_t +S_io_async (mach_port_t object, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + mach_port_t notify, + mach_port_t *id, + mach_msg_type_name_t *idtype) +{ + return EOPNOTSUPP; +} + +kern_return_t +S_io_mod_owner (mach_port_t object, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + pid_t owner) +{ + return EOPNOTSUPP; +} + +kern_return_t +S_io_get_owner (mach_port_t object, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + pid_t *owner) +{ + return EOPNOTSUPP; +} + +kern_return_t +S_io_get_icky_async_id (mach_port_t object, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + mach_port_t *id, + mach_msg_type_name_t *idtype) +{ + return EOPNOTSUPP; +} + +kern_return_t +S_io_select (mach_port_t object, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + int *type) +{ + fd_set r, w, x; + int n; + + if (object != pseudo_console) + return EOPNOTSUPP; + + FD_ZERO (&r); + FD_ZERO (&w); + FD_ZERO (&x); + FD_SET (0, &r); + FD_SET (0, &w); + FD_SET (0, &x); + + n = select (1, + (*type & SELECT_READ) ? &r : 0, + (*type & SELECT_WRITE) ? &w : 0, + (*type & SELECT_URG) ? &x : 0, + 0); + if (n < 0) + return errno; + + if (! FD_ISSET (0, &r)) + *type &= ~SELECT_READ; + if (! FD_ISSET (0, &w)) + *type &= ~SELECT_WRITE; + if (! FD_ISSET (0, &x)) + *type &= ~SELECT_URG; + + return 0; +} + +kern_return_t +S_io_stat (mach_port_t object, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + struct stat *st) +{ + if (object != pseudo_console) + return EOPNOTSUPP; + + bzero (st, sizeof (struct stat)); + st->st_blksize = 1024; + return 0; +} + +kern_return_t +S_io_reauthenticate (mach_port_t object, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + mach_port_t rend) +{ + uid_t *gu, *au; + gid_t *gg, *ag; + size_t gulen = 0, aulen = 0, gglen = 0, aglen = 0; + error_t err; + + err = mach_port_insert_right (mach_task_self (), object, object, + MACH_MSG_TYPE_MAKE_SEND); + assert_perror (err); + + if (! auth_server_authenticate (authserver, + rend, MACH_MSG_TYPE_COPY_SEND, + object, MACH_MSG_TYPE_COPY_SEND, + &gu, &gulen, + &au, &aulen, + &gg, &gglen, + &ag, &aglen)) + { + mig_deallocate ((vm_address_t) gu, gulen * sizeof *gu); + mig_deallocate ((vm_address_t) au, aulen * sizeof *gu); + mig_deallocate ((vm_address_t) gg, gglen * sizeof *gu); + mig_deallocate ((vm_address_t) au, aulen * sizeof *gu); + } + mach_port_deallocate (mach_task_self (), rend); + mach_port_deallocate (mach_task_self (), object); + + return 0; +} + +kern_return_t +S_io_restrict_auth (mach_port_t object, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + mach_port_t *newobject, + mach_msg_type_name_t *newobjtype, + uid_t *uids, + size_t nuids, + uid_t *gids, + size_t ngids) +{ + if (object != pseudo_console) + return EOPNOTSUPP; + *newobject = pseudo_console; + *newobjtype = MACH_MSG_TYPE_MAKE_SEND; + console_mscount++; + return 0; +} + +kern_return_t +S_io_duplicate (mach_port_t object, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + mach_port_t *newobj, + mach_msg_type_name_t *newobjtype) +{ + if (object != pseudo_console) + return EOPNOTSUPP; + *newobj = pseudo_console; + *newobjtype = MACH_MSG_TYPE_MAKE_SEND; + console_mscount++; + return 0; +} + +kern_return_t +S_io_server_version (mach_port_t object, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + char *name, + int *maj, + int *min, + int *edit) +{ + return EOPNOTSUPP; +} + +kern_return_t +S_io_map (mach_port_t obj, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + mach_port_t *rd, + mach_msg_type_name_t *rdtype, + mach_port_t *wr, + mach_msg_type_name_t *wrtype) +{ + return EOPNOTSUPP; +} + +kern_return_t +S_io_map_cntl (mach_port_t obj, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + mach_port_t *mem, + mach_msg_type_name_t *memtype) +{ + return EOPNOTSUPP; +} + +kern_return_t +S_io_get_conch (mach_port_t obj, + mach_port_t reply_port, + mach_msg_type_name_t reply_type) +{ + return EOPNOTSUPP; +} + +kern_return_t +S_io_release_conch (mach_port_t obj, + mach_port_t reply_port, + mach_msg_type_name_t reply_type) +{ + return EOPNOTSUPP; +} + +kern_return_t +S_io_eofnotify (mach_port_t obj, + mach_port_t reply_port, + mach_msg_type_name_t reply_type) + +{ + return EOPNOTSUPP; +} + +kern_return_t +S_io_prenotify (mach_port_t obj, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + vm_offset_t start, + vm_offset_t end) +{ + return EOPNOTSUPP; +} + +kern_return_t +S_io_postnotify (mach_port_t obj, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + vm_offset_t start, + vm_offset_t end) +{ + return EOPNOTSUPP; +} + +kern_return_t +S_io_readsleep (mach_port_t obj, + mach_port_t reply_port, + mach_msg_type_name_t reply_type) +{ + return EOPNOTSUPP; +} + +kern_return_t +S_io_readnotify (mach_port_t obj, + mach_port_t reply_port, + mach_msg_type_name_t reply_type) +{ + return EOPNOTSUPP; +} + + +kern_return_t +S_io_sigio (mach_port_t obj, + mach_port_t reply_port, + mach_msg_type_name_t reply_type) +{ + return EOPNOTSUPP; +} + + +kern_return_t +S_io_pathconf (mach_port_t obj, + mach_port_t reply_port, + mach_msg_type_name_t reply_type, + int name, int *value) +{ + return EOPNOTSUPP; +} + +kern_return_t +S_io_identity (mach_port_t obj, + mach_port_t reply, + mach_msg_type_name_t replytype, + mach_port_t *id, + mach_msg_type_name_t *idtype, + mach_port_t *fsid, + mach_msg_type_name_t *fsidtype, + ino_t *fileno) +{ + return EOPNOTSUPP; +} + +kern_return_t +S_io_revoke (mach_port_t obj, + mach_port_t reply, mach_msg_type_name_t replyPoly) +{ + return EOPNOTSUPP; +} + + + +/* Implementation of the Hurd terminal driver interface, which we only + support on the console device. */ + +kern_return_t +S_termctty_open_terminal (mach_port_t object, + int flags, + mach_port_t *result, + mach_msg_type_name_t *restype) +{ + return EOPNOTSUPP; +} + +kern_return_t +S_term_getctty (mach_port_t object, + mach_port_t *cttyid, mach_msg_type_name_t *cttyPoly) +{ + static mach_port_t id = MACH_PORT_NULL; + + if (object != pseudo_console) + return EOPNOTSUPP; + + if (id == MACH_PORT_NULL) + mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_DEAD_NAME, &id); + + *cttyid = id; + *cttyPoly = MACH_MSG_TYPE_COPY_SEND; + return 0; +} + + +kern_return_t S_term_open_ctty +( + io_t terminal, + pid_t pid, + pid_t pgrp, + mach_port_t *newtty, + mach_msg_type_name_t *newttytype +) +{ return EOPNOTSUPP; } + +kern_return_t S_term_set_nodename +( + io_t terminal, + string_t name +) +{ return EOPNOTSUPP; } + +kern_return_t S_term_get_nodename +( + io_t terminal, + string_t name +) +{ return EOPNOTSUPP; } + +kern_return_t S_term_get_peername +( + io_t terminal, + string_t name +) +{ return EOPNOTSUPP; } + +kern_return_t S_term_set_filenode +( + io_t terminal, + file_t filenode +) +{ return EOPNOTSUPP; } + +kern_return_t S_term_get_bottom_type +( + io_t terminal, + int *ttype +) +{ return EOPNOTSUPP; } + +kern_return_t S_term_on_machdev +( + io_t terminal, + mach_port_t machdev +) +{ return EOPNOTSUPP; } + +kern_return_t S_term_on_hurddev +( + io_t terminal, + io_t hurddev +) +{ return EOPNOTSUPP; } + +kern_return_t S_term_on_pty +( + io_t terminal, + io_t *ptymaster +) +{ return EOPNOTSUPP; } diff --git a/boot-proxy-exc/boot.d b/boot-proxy-exc/boot.d new file mode 100644 index 00000000..97598985 --- /dev/null +++ b/boot-proxy-exc/boot.d @@ -0,0 +1,100 @@ +boot.o boot_pic.o boot_p.o boot.d: boot.c /usr/include/mach.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/include/gnu/stubs-pthread.h /usr/local/include/mach/mach_types.h \ + /usr/local/include/mach/host_info.h /usr/local/include/mach/machine.h \ + /usr/local/include/mach/machine/vm_types.h \ + /usr/local/include/mach/boolean.h \ + /usr/local/include/mach/machine/boolean.h \ + /usr/local/include/mach/memory_object.h /usr/local/include/mach/port.h \ + /usr/local/include/mach/pc_sample.h \ + /usr/local/include/mach/processor_info.h \ + /usr/local/include/mach/task_info.h \ + /usr/local/include/mach/time_value.h \ + /usr/local/include/mach/task_special_ports.h \ + /usr/local/include/mach/thread_info.h /usr/local/include/mach/policy.h \ + /usr/local/include/mach/thread_special_ports.h \ + /usr/local/include/mach/thread_status.h \ + /usr/local/include/mach/machine/thread_status.h \ + /usr/local/include/mach/machine/fp_reg.h \ + /usr/local/include/mach/vm_attributes.h \ + /usr/local/include/mach/vm_inherit.h /usr/local/include/mach/vm_prot.h \ + /usr/local/include/mach/vm_statistics.h \ + /usr/local/include/mach/std_types.h \ + /usr/local/include/mach/kern_return.h \ + /usr/local/include/mach/machine/kern_return.h /usr/include/mach_init.h \ + /usr/include/mach/mach_traps.h /usr/local/include/mach/message.h \ + /usr/include/mach/mach_interface.h /usr/include/mach/mach_port.h \ + /usr/include/mach/mach_host.h /usr/include/mach-shortcuts.h \ + /usr/include/stdio.h /usr/local/include/mach/notify.h \ + /usr/include/device/device.h /usr/local/include/device/device_types.h \ + /usr/local/include/device/net_status.h /usr/local/include/device/bpf.h \ + /usr/include/sys/types.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/time.h \ + /usr/lib/gcc/i486-gnu/4.2.4/include/stddef.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/bits/byteswap.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/pthread/pthreadtypes.h /usr/include/xlocale.h \ + /usr/include/bits/pthread.h /usr/include/bits/thread-attr.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/mutex-attr.h /usr/include/bits/mutex.h \ + /usr/include/bits/spin-lock.h /usr/include/bits/condition-attr.h \ + /usr/include/bits/condition.h /usr/include/bits/rwlock-attr.h \ + /usr/include/bits/rwlock.h /usr/include/bits/barrier-attr.h \ + /usr/include/bits/barrier.h /usr/include/bits/thread-specific.h \ + /usr/include/bits/once.h /usr/include/a.out.h \ + /usr/local/include/mach/mig_errors.h /usr/include/stdlib.h \ + /usr/include/bits/waitflags.h /usr/include/bits/waitstatus.h \ + /usr/include/alloca.h /usr/include/string.h /usr/include/bits/string.h \ + /usr/include/bits/string2.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/lib/gcc/i486-gnu/4.2.4/include/stdarg.h \ + /usr/include/bits/stdio-lock.h /usr/include/bits/libc-lock.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/bits/stdio.h ../include/cthreads.h \ + ../include/../libthreads/cthreads.h \ + /usr/local/include/mach/machine/vm_param.h /usr/include/machine-sp.h \ + /usr/include/spin-lock.h /usr/include/lock-intern.h \ + /usr/include/machine-lock.h /usr/include/setjmp.h \ + /usr/include/bits/setjmp.h /usr/include/fcntl.h \ + /usr/include/bits/fcntl.h /usr/include/sys/stat.h \ + /usr/include/bits/stat.h /usr/include/elf.h /usr/include/stdint.h \ + /usr/include/bits/wchar.h /usr/include/mach/mig_support.h \ + /usr/include/mach/default_pager.h \ + /usr/local/include/mach/default_pager_types.h /usr/include/argp.h \ + /usr/include/ctype.h /usr/include/getopt.h \ + /usr/lib/gcc/i486-gnu/4.2.4/include/limits.h \ + /usr/lib/gcc/i486-gnu/4.2.4/include/syslimits.h /usr/include/limits.h \ + /usr/include/bits/posix1_lim.h /usr/include/bits/local_lim.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/xopen_lim.h \ + /usr/include/errno.h /usr/include/bits/errno.h ../hurd/store.h \ + ../hurd/../libstore/store.h ../hurd/hurd_types.h ../hurd/ports.h \ + ../hurd/../libports/ports.h /usr/include/hurd.h \ + /usr/include/hurd/auth.h /usr/include/sys/statfs.h \ + /usr/include/bits/statfs.h /usr/include/sys/resource.h \ + /usr/include/bits/resource.h /usr/include/sys/utsname.h \ + /usr/include/bits/utsname.h /usr/include/hurd/process.h \ + /usr/include/hurd/fs.h /usr/include/hurd/io.h /usr/include/hurd/port.h \ + /usr/include/hurd/userlink.h /usr/include/hurd/signal.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/sys/ucontext.h /usr/include/bits/sigthread.h \ + /usr/include/hurd/msg.h /usr/include/hurd/threadvar.h ../hurd/ihash.h \ + ../hurd/../libihash/ihash.h /usr/include/sys/mman.h \ + /usr/include/bits/mman.h ../version.h notify_S.h ourdevice_S.h io_S.h \ + device_reply_U.h io_reply_U.h term_S.h bootstrap_S.h util.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/arpa/inet.h \ + /usr/include/netinet/in.h /usr/include/bits/in.h \ + /usr/include/netinet/ip.h /usr/include/syslog.h \ + /usr/include/sys/syslog.h /usr/include/bits/syslog-path.h boot_script.h \ + mach_proxy.h list.h /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/environments.h /usr/include/bits/confname.h \ + /usr/include/sys/ioctl.h /usr/include/bits/ioctls.h \ + /usr/include/bits/ioctl-types.h /usr/include/sys/ttydefaults.h \ + /usr/include/termios.h /usr/include/bits/termios.h /usr/include/error.h \ + /usr/include/assert.h diff --git a/boot-proxy-exc/boot.o b/boot-proxy-exc/boot.o Binary files differnew file mode 100644 index 00000000..47f26ba3 --- /dev/null +++ b/boot-proxy-exc/boot.o diff --git a/boot-proxy-exc/boot.prof_d b/boot-proxy-exc/boot.prof_d new file mode 100644 index 00000000..50416b09 --- /dev/null +++ b/boot-proxy-exc/boot.prof_d @@ -0,0 +1 @@ +boot.prof: boot_p.o mach_host_impl_p.o mach_impl_p.o mach_port_impl_p.o exc_impl_p.o list_p.o mach_proxy_p.o notifyServer_p.o ourdeviceServer_p.o ioServer_p.o io_replyUser_p.o device_replyUser_p.o termServer_p.o bootstrapServer_p.o boot_script_p.o userland-boot_p.o ourmach_hostServer_p.o ourmachServer_p.o ourmach_portServer_p.o excServer_p.o ../libstore/libstore_p.a ../libshouldbeinlibc/libshouldbeinlibc_p.a ../libthreads/libthreads_p.a ../libports/libports_p.a diff --git a/boot-proxy-exc/boot_script.c b/boot-proxy-exc/boot_script.c new file mode 100644 index 00000000..f95cc5c4 --- /dev/null +++ b/boot-proxy-exc/boot_script.c @@ -0,0 +1,791 @@ +/* Boot script parser for Mach. */ + +/* Written by Shantanu Goel (goel@cs.columbia.edu). */ + +#include <mach/mach_types.h> +#if !KERNEL || OSKIT_MACH +#include <string.h> +#endif +#include "boot_script.h" + + +/* This structure describes a symbol. */ +struct sym +{ + /* Symbol name. */ + const char *name; + + /* Type of value returned by function. */ + int type; + + /* Symbol value. */ + integer_t val; + + /* For function symbols; type of value returned by function. */ + int ret_type; + + /* For function symbols; if set, execute function at the time + of command execution, not during parsing. A function with + this field set must also have `no_arg' set. Also, the function's + `val' argument will always be NULL. */ + int run_on_exec; +}; + +/* Additional values symbols can take. + These are only used internally. */ +#define VAL_SYM 10 /* symbol table entry */ +#define VAL_FUNC 11 /* function pointer */ + +/* This structure describes an argument. */ +struct arg +{ + /* Argument text copied verbatim. 0 if none. */ + char *text; + + /* Type of value assigned. 0 if none. */ + int type; + + /* Argument value. */ + integer_t val; +}; + +/* List of commands. */ +static struct cmd **cmds = 0; + +/* Amount allocated for `cmds'. */ +static int cmds_alloc = 0; + +/* Next available slot in `cmds'. */ +static int cmds_index = 0; + +/* Symbol table. */ +static struct sym **symtab = 0; + +/* Amount allocated for `symtab'. */ +static int symtab_alloc = 0; + +/* Next available slot in `symtab'. */ +static int symtab_index = 0; + +/* Create a task and suspend it. */ +static int +create_task (struct cmd *cmd, int *val) +{ + int err = boot_script_task_create (cmd); + *val = (int) cmd->task; + return err; +} + +/* Resume a task. */ +static int +resume_task (struct cmd *cmd, int *val) +{ + return boot_script_task_resume (cmd); +} + +/* Resume a task when the user hits return. */ +static int +prompt_resume_task (struct cmd *cmd, int *val) +{ + return boot_script_prompt_task_resume (cmd); +} + +/* List of builtin symbols. */ +static struct sym builtin_symbols[] = +{ + { "task-create", VAL_FUNC, (integer_t) create_task, VAL_TASK, 0 }, + { "task-resume", VAL_FUNC, (integer_t) resume_task, VAL_NONE, 1 }, + { "prompt-task-resume", + VAL_FUNC, (integer_t) prompt_resume_task, VAL_NONE, 1 }, +}; +#define NUM_BUILTIN (sizeof (builtin_symbols) / sizeof (builtin_symbols[0])) + +/* Free CMD and all storage associated with it. + If ABORTING is set, terminate the task associated with CMD, + otherwise just deallocate the send right. */ +static void +free_cmd (struct cmd *cmd, int aborting) +{ + if (cmd->task) + boot_script_free_task (cmd->task, aborting); + if (cmd->args) + { + int i; + for (i = 0; i < cmd->args_index; i++) + boot_script_free (cmd->args[i], sizeof *cmd->args[i]); + boot_script_free (cmd->args, sizeof cmd->args[0] * cmd->args_alloc); + } + if (cmd->exec_funcs) + boot_script_free (cmd->exec_funcs, + sizeof cmd->exec_funcs[0] * cmd->exec_funcs_alloc); + boot_script_free (cmd, sizeof *cmd); +} + +/* Free all storage allocated by the parser. + If ABORTING is set, terminate all tasks. */ +static void +cleanup (int aborting) +{ + int i; + + for (i = 0; i < cmds_index; i++) + free_cmd (cmds[i], aborting); + boot_script_free (cmds, sizeof cmds[0] * cmds_alloc); + cmds = 0; + cmds_index = cmds_alloc = 0; + + for (i = 0; i < symtab_index; i++) + boot_script_free (symtab[i], sizeof *symtab[i]); + boot_script_free (symtab, sizeof symtab[0] * symtab_alloc); + symtab = 0; + symtab_index = symtab_alloc = 0; +} + +/* Add PTR to the list of pointers PTR_LIST, which + currently has ALLOC amount of space allocated to it, and + whose next available slot is INDEX. If more space + needs to to allocated, INCR is the amount by which + to increase it. Return 0 on success, non-zero otherwise. */ +static int +add_list (void *ptr, void ***ptr_list, int *alloc, int *index, int incr) +{ + if (*index == *alloc) + { + void **p; + + *alloc += incr; + p = boot_script_malloc (*alloc * sizeof (void *)); + if (! p) + { + *alloc -= incr; + return 1; + } + if (*ptr_list) + { + memcpy (p, *ptr_list, *index * sizeof (void *)); + boot_script_free (*ptr_list, (*alloc - incr) * sizeof (void *)); + } + *ptr_list = p; + } + *(*ptr_list + *index) = ptr; + *index += 1; + return 0; +} + +/* Create an argument with TEXT, value type TYPE, and value VAL. + Add the argument to the argument list of CMD. */ +static struct arg * +add_arg (struct cmd *cmd, const char *text, int textlen, int type, int val) +{ + struct arg *arg; + + arg = boot_script_malloc (sizeof (struct arg) + textlen); + if (arg) + { + arg->text = text == 0 ? 0 : memcpy (arg + 1, text, textlen); + arg->type = type; + arg->val = val; + if (add_list (arg, (void ***) (void *)&cmd->args, + &cmd->args_alloc, &cmd->args_index, 5)) + { + boot_script_free (arg, sizeof *arg); + return 0; + } + } + return arg; +} + +/* Search for the symbol NAME in the symbol table. */ +static struct sym * +sym_lookup (const char *name) +{ + int i; + + for (i = 0; i < symtab_index; i++) + if (! strcmp (name, symtab[i]->name)) + return symtab[i]; + return 0; +} + +/* Create an entry for symbol NAME in the symbol table. */ +static struct sym * +sym_enter (const char *name) +{ + struct sym *sym; + + sym = boot_script_malloc (sizeof (struct sym)); + if (sym) + { + memset (sym, 0, sizeof (struct sym)); + sym->name = name; + if (add_list (sym, (void ***) (void *)&symtab, &symtab_alloc, &symtab_index, 20)) + { + boot_script_free (sym, sizeof *sym); + return 0; + } + } + return sym; +} + +/* Parse the command line CMDLINE. */ +int +boot_script_parse_line (void *hook, char *cmdline) +{ + char *p, *q; + int error; + struct cmd *cmd; + struct arg *arg; + + /* Extract command name. Ignore line if it lacks a command. */ + for (p = cmdline; *p == ' ' || *p == '\t'; p++) + ; + if (*p == '#') + /* Ignore comment line. */ + return 0; + +#if 0 + if (*p && *p != ' ' && *p != '\t' && *p != '\n') + { + printf ("(bootstrap): %s\n", cmdline); + } +#endif + + for (q = p; *q && *q != ' ' && *q != '\t' && *q != '\n'; q++) + ; + if (p == q) + return 0; + + *q++ = '\0'; + + /* Allocate a command structure. */ + cmd = boot_script_malloc (sizeof (struct cmd) + (q - p)); + if (! cmd) + return BOOT_SCRIPT_NOMEM; + memset (cmd, 0, sizeof (struct cmd)); + cmd->hook = hook; + cmd->path = memcpy (cmd + 1, p, q - p); + p = q; + + for (arg = 0;;) + { + if (! arg) + { + /* Skip whitespace. */ + while (*p == ' ' || *p == '\t') + p++; + + /* End of command line. */ + if (! *p || *p == '\n') + { + /* Add command to list. */ + if (add_list (cmd, (void ***) (void *) &cmds, + &cmds_alloc, &cmds_index, 10)) + { + error = BOOT_SCRIPT_NOMEM; + goto bad; + } + return 0; + } + } + + /* Look for a symbol. */ + if (arg || (*p == '$' && (*(p + 1) == '{' || *(p + 1) == '('))) + { + char end_char = (*(p + 1) == '{') ? '}' : ')'; + struct sym *sym = 0; + + for (p += 2;;) + { + char c; + int i, type; + integer_t val; + struct sym *s; + + /* Parse symbol name. */ + for (q = p; *q && *q != '\n' && *q != end_char && *q != '='; q++) + ; + if (p == q || ! *q || *q == '\n' + || (end_char == '}' && *q != '}')) + { + error = BOOT_SCRIPT_SYNTAX_ERROR; + goto bad; + } + c = *q; + *q = '\0'; + + /* See if this is a builtin symbol. */ + for (i = 0; i < NUM_BUILTIN; i++) + if (! strcmp (p, builtin_symbols[i].name)) + break; + + if (i < NUM_BUILTIN) + s = &builtin_symbols[i]; + else + { + /* Look up symbol in symbol table. + If no entry exists, create one. */ + s = sym_lookup (p); + if (! s) + { + s = sym_enter (p); + if (! s) + { + error = BOOT_SCRIPT_NOMEM; + goto bad; + } + } + } + + /* Only values are allowed in ${...} constructs. */ + if (end_char == '}' && s->type == VAL_FUNC) + return BOOT_SCRIPT_INVALID_SYM; + + /* Check that assignment is valid. */ + if (c == '=' && s->type == VAL_FUNC) + { + error = BOOT_SCRIPT_INVALID_ASG; + goto bad; + } + + /* For function symbols, execute the function. */ + if (s->type == VAL_FUNC) + { + if (! s->run_on_exec) + { + (error + = ((*((int (*) (struct cmd *, integer_t *)) s->val)) + (cmd, &val))); + if (error) + goto bad; + type = s->ret_type; + } + else + { + if (add_list (s, (void ***) (void *) &cmd->exec_funcs, + &cmd->exec_funcs_alloc, + &cmd->exec_funcs_index, 5)) + { + error = BOOT_SCRIPT_NOMEM; + goto bad; + } + type = VAL_NONE; + goto out; + } + } + else if (s->type == VAL_NONE) + { + type = VAL_SYM; + val = (integer_t) s; + } + else + { + type = s->type; + val = s->val; + } + + if (sym) + { + sym->type = type; + sym->val = val; + } + else if (arg) + { + arg->type = type; + arg->val = val; + } + + out: + p = q + 1; + if (c == end_char) + { + /* Create an argument if necessary. + We create an argument if the symbol appears + in the expression by itself. + + NOTE: This is temporary till the boot filesystem + servers support arguments. When that happens, + symbol values will only be printed if they're + associated with an argument. */ + if (! arg && end_char == '}') + { + if (! add_arg (cmd, 0, 0, type, val)) + { + error = BOOT_SCRIPT_NOMEM; + goto bad; + } + } + arg = 0; + break; + } + if (s->type != VAL_FUNC) + sym = s; + } + } + else + { + char c; + + /* Command argument; just copy the text. */ + for (q = p;; q++) + { + if (! *q || *q == ' ' || *q == '\t' || *q == '\n') + break; + if (*q == '$' && *(q + 1) == '{') + break; + } + c = *q; + *q = '\0'; + + /* Add argument to list. */ + arg = add_arg (cmd, p, q + 1 - p, VAL_NONE, 0); + if (! arg) + { + error = BOOT_SCRIPT_NOMEM; + goto bad; + } + if (c == '$') + p = q; + else + { + if (c) + p = q + 1; + else + p = q; + arg = 0; + } + } + } + + + bad: + free_cmd (cmd, 1); + cleanup (1); + return error; +} + +/* Ensure that the command line buffer can accommodate LEN bytes of space. */ +#define CHECK_CMDLINE_LEN(len) \ +{ \ + if (cmdline_alloc - cmdline_index < len) \ + { \ + char *ptr; \ + int alloc, i; \ + alloc = cmdline_alloc + len - (cmdline_alloc - cmdline_index) + 100; \ + ptr = boot_script_malloc (alloc); \ + if (! ptr) \ + { \ + error = BOOT_SCRIPT_NOMEM; \ + goto done; \ + } \ + memcpy (ptr, cmdline, cmdline_index); \ + for (i = 0; i < argc; ++i) \ + argv[i] = ptr + (argv[i] - cmdline); \ + boot_script_free (cmdline, cmdline_alloc); \ + cmdline = ptr; \ + cmdline_alloc = alloc; \ + } \ +} + +/* Execute commands previously parsed. */ +int +boot_script_exec () +{ + int cmd_index; + + for (cmd_index = 0; cmd_index < cmds_index; cmd_index++) + { + char **argv, *cmdline; + int i, argc, cmdline_alloc; + int cmdline_index, error, arg_index; + struct cmd *cmd = cmds[cmd_index]; + + /* Skip command if it doesn't have an associated task. */ + if (cmd->task == 0) + continue; + + /* Allocate a command line and copy command name. */ + cmdline_index = strlen (cmd->path) + 1; + cmdline_alloc = cmdline_index + 100; + cmdline = boot_script_malloc (cmdline_alloc); + if (! cmdline) + { + cleanup (1); + return BOOT_SCRIPT_NOMEM; + } + memcpy (cmdline, cmd->path, cmdline_index); + + /* Allocate argument vector. */ + argv = boot_script_malloc (sizeof (char *) * (cmd->args_index + 2)); + if (! argv) + { + boot_script_free (cmdline, cmdline_alloc); + cleanup (1); + return BOOT_SCRIPT_NOMEM; + } + argv[0] = cmdline; + argc = 1; + + /* Build arguments. */ + for (arg_index = 0; arg_index < cmd->args_index; arg_index++) + { + struct arg *arg = cmd->args[arg_index]; + + /* Copy argument text. */ + if (arg->text) + { + int len = strlen (arg->text); + + if (arg->type == VAL_NONE) + len++; + CHECK_CMDLINE_LEN (len); + memcpy (cmdline + cmdline_index, arg->text, len); + argv[argc++] = &cmdline[cmdline_index]; + cmdline_index += len; + } + + /* Add value of any symbol associated with this argument. */ + if (arg->type != VAL_NONE) + { + char *p, buf[50]; + int len; + mach_port_t name; + + if (arg->type == VAL_SYM) + { + struct sym *sym = (struct sym *) arg->val; + + /* Resolve symbol value. */ + while (sym->type == VAL_SYM) + sym = (struct sym *) sym->val; + if (sym->type == VAL_NONE) + { + error = BOOT_SCRIPT_UNDEF_SYM; + goto done; + } + arg->type = sym->type; + arg->val = sym->val; + } + + /* Print argument value. */ + switch (arg->type) + { + case VAL_STR: + p = (char *) arg->val; + len = strlen (p); + break; + + case VAL_TASK: + case VAL_PORT: + if (arg->type == VAL_TASK) + /* Insert send right to task port. */ + error = boot_script_insert_task_port + (cmd, (task_t) arg->val, &name); + else + /* Insert send right. */ + error = boot_script_insert_right (cmd, + (mach_port_t) arg->val, + &name); + if (error) + goto done; + + i = name; + p = buf + sizeof (buf); + len = 0; + do + { + *--p = i % 10 + '0'; + len++; + } + while (i /= 10); + break; + + default: + error = BOOT_SCRIPT_BAD_TYPE; + goto done; + } + len++; + CHECK_CMDLINE_LEN (len); + memcpy (cmdline + cmdline_index, p, len - 1); + *(cmdline + cmdline_index + len - 1) = '\0'; + if (! arg->text) + argv[argc++] = &cmdline[cmdline_index]; + cmdline_index += len; + } + } + + /* Terminate argument vector. */ + argv[argc] = 0; + + /* Execute the command. */ + if (boot_script_exec_cmd (cmd->hook, cmd->task, cmd->path, + argc, argv, cmdline, cmdline_index)) + { + error = BOOT_SCRIPT_EXEC_ERROR; + goto done; + } + + error = 0; + + done: + boot_script_free (cmdline, cmdline_alloc); + boot_script_free (argv, sizeof (char *) * (cmd->args_index + 2)); + if (error) + { + cleanup (1); + return error; + } + } + + for (cmd_index = 0; cmd_index < cmds_index; cmd_index++) + { + int i; + struct cmd *cmd = cmds[cmd_index]; + + /* Execute functions that want to be run on exec. */ + for (i = 0; i < cmd->exec_funcs_index; i++) + { + struct sym *sym = cmd->exec_funcs[i]; + int error = ((*((int (*) (struct cmd *, integer_t *)) sym->val)) + (cmd, 0)); + if (error) + { + cleanup (1); + return error; + } + } + } + + cleanup (0); + return 0; +} + +/* Create an entry for the variable NAME with TYPE and value VAL, + in the symbol table. */ +int +boot_script_set_variable (const char *name, int type, integer_t val) +{ + struct sym *sym = sym_enter (name); + + if (sym) + { + sym->type = type; + sym->val = val; + } + return sym ? 0 : 1; +} + + +/* Define the function NAME, which will return type RET_TYPE. */ +int +boot_script_define_function (const char *name, int ret_type, + int (*func) (const struct cmd *cmd, + integer_t *val)) +{ + struct sym *sym = sym_enter (name); + + if (sym) + { + sym->type = VAL_FUNC; + sym->val = (integer_t) func; + sym->ret_type = ret_type; + sym->run_on_exec = ret_type == VAL_NONE; + } + return sym ? 0 : 1; +} + + +/* Return a string describing ERR. */ +char * +boot_script_error_string (int err) +{ + switch (err) + { + case BOOT_SCRIPT_NOMEM: + return "no memory"; + + case BOOT_SCRIPT_SYNTAX_ERROR: + return "syntax error"; + + case BOOT_SCRIPT_INVALID_ASG: + return "invalid variable in assignment"; + + case BOOT_SCRIPT_MACH_ERROR: + return "mach error"; + + case BOOT_SCRIPT_UNDEF_SYM: + return "undefined symbol"; + + case BOOT_SCRIPT_EXEC_ERROR: + return "exec error"; + + case BOOT_SCRIPT_INVALID_SYM: + return "invalid variable in expression"; + + case BOOT_SCRIPT_BAD_TYPE: + return "invalid value type"; + } + return 0; +} + +#ifdef BOOT_SCRIPT_TEST +#include <stdio.h> + +int +boot_script_exec_cmd (void *hook, + mach_port_t task, char *path, int argc, + char **argv, char *strings, int stringlen) +{ + int i; + + printf ("port = %d: ", (int) task); + for (i = 0; i < argc; i++) + printf ("%s ", argv[i]); + printf ("\n"); + return 0; +} + +void +main (int argc, char **argv) +{ + char buf[500], *p; + int len; + FILE *fp; + mach_port_t host_port, device_port; + + if (argc < 2) + { + fprintf (stderr, "Usage: %s <script>\n", argv[0]); + exit (1); + } + fp = fopen (argv[1], "r"); + if (! fp) + { + fprintf (stderr, "Can't open %s\n", argv[1]); + exit (1); + } + host_port = 1; + device_port = 2; + boot_script_set_variable ("host-port", VAL_PORT, (int) host_port); + boot_script_set_variable ("device-port", VAL_PORT, (int) device_port); + boot_script_set_variable ("root-device", VAL_STR, (int) "hd0a"); + boot_script_set_variable ("boot-args", VAL_STR, (int) "-ad"); + p = buf; + len = sizeof (buf); + while (fgets (p, len, fp)) + { + int i, err; + + i = strlen (p) + 1; + err = boot_script_parse_line (0, p); + if (err) + { + fprintf (stderr, "error %s\n", boot_script_error_string (err)); + exit (1); + } + p += i; + len -= i; + } + boot_script_exec (); + exit (0); +} +#endif /* BOOT_SCRIPT_TEST */ diff --git a/boot-proxy-exc/boot_script.d b/boot-proxy-exc/boot_script.d new file mode 100644 index 00000000..2722b522 --- /dev/null +++ b/boot-proxy-exc/boot_script.d @@ -0,0 +1,30 @@ +boot_script.o boot_script_pic.o boot_script_p.o boot_script.d: boot_script.c /usr/local/include/mach/mach_types.h \ + /usr/local/include/mach/host_info.h /usr/local/include/mach/machine.h \ + /usr/local/include/mach/machine/vm_types.h \ + /usr/local/include/mach/boolean.h \ + /usr/local/include/mach/machine/boolean.h \ + /usr/local/include/mach/memory_object.h /usr/local/include/mach/port.h \ + /usr/local/include/mach/pc_sample.h \ + /usr/local/include/mach/processor_info.h \ + /usr/local/include/mach/task_info.h \ + /usr/local/include/mach/time_value.h \ + /usr/local/include/mach/task_special_ports.h \ + /usr/local/include/mach/thread_info.h /usr/local/include/mach/policy.h \ + /usr/local/include/mach/thread_special_ports.h \ + /usr/local/include/mach/thread_status.h \ + /usr/local/include/mach/machine/thread_status.h \ + /usr/local/include/mach/machine/fp_reg.h \ + /usr/local/include/mach/vm_attributes.h \ + /usr/local/include/mach/vm_inherit.h /usr/local/include/mach/vm_prot.h \ + /usr/local/include/mach/vm_statistics.h \ + /usr/local/include/mach/std_types.h \ + /usr/local/include/mach/kern_return.h \ + /usr/local/include/mach/machine/kern_return.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h /usr/include/gnu/stubs-pthread.h \ + /usr/lib/gcc/i486-gnu/4.2.4/include/stddef.h /usr/include/xlocale.h \ + /usr/include/bits/string.h /usr/include/bits/string2.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/bits/byteswap.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/stdlib.h boot_script.h diff --git a/boot-proxy-exc/boot_script.h b/boot-proxy-exc/boot_script.h new file mode 100644 index 00000000..62458693 --- /dev/null +++ b/boot-proxy-exc/boot_script.h @@ -0,0 +1,116 @@ +/* Definitions for boot script parser for Mach. */ + +#ifndef _boot_script_h +#define _boot_script_h + +/* Written by Shantanu Goel (goel@cs.columbia.edu). */ + +/* Error codes returned by boot_script_parse_line() + and boot_script_exec_cmd(). */ +#define BOOT_SCRIPT_NOMEM 1 +#define BOOT_SCRIPT_SYNTAX_ERROR 2 +#define BOOT_SCRIPT_INVALID_ASG 3 +#define BOOT_SCRIPT_MACH_ERROR 4 +#define BOOT_SCRIPT_UNDEF_SYM 5 +#define BOOT_SCRIPT_EXEC_ERROR 6 +#define BOOT_SCRIPT_INVALID_SYM 7 +#define BOOT_SCRIPT_BAD_TYPE 8 + +/* Legal values for argument `type' to function + boot_script_set_variable and boot_script_define_function. */ +#define VAL_NONE 0 /* none -- function runs at exec time */ +#define VAL_STR 1 /* string */ +#define VAL_PORT 2 /* port */ +#define VAL_TASK 3 /* task port */ + +/* This structure describes a command. */ +struct cmd +{ + /* Cookie passed in to boot_script_parse_line. */ + void *hook; + + /* Path of executable. */ + char *path; + + /* Task port. */ + task_t task; + + /* Argument list. */ + struct arg **args; + + /* Amount allocated for `args'. */ + int args_alloc; + + /* Next available slot in `args'. */ + int args_index; + + /* List of functions that want to be run on command execution. */ + struct sym **exec_funcs; + + /* Amount allocated for `exec_funcs'. */ + int exec_funcs_alloc; + + /* Next available slot in `exec_funcs'. */ + int exec_funcs_index; +}; + + +/* The user must define these functions, we work like malloc and free. */ +void *boot_script_malloc (unsigned int); +void boot_script_free (void *, unsigned int); + +/* The user must define this function. Load the image of the + executable specified by PATH in TASK. Create a thread + in TASK and point it at the executable's entry point. Initialize + TASK's stack with argument vector ARGV of length ARGC whose + strings are STRINGS. STRINGS has length STRINGLEN. + Return 0 for success, non-zero otherwise. */ +int boot_script_exec_cmd (void *hook, + task_t task, char *path, int argc, + char **argv, char *strings, int stringlen); + +/* The user must define this function. Load the contents of FILE + into a fresh anonymous memory object and return the memory object port. */ +mach_port_t boot_script_read_file (const char *file); + +/* The user must define this functions to perform the corresponding + Mach task manipulations. */ +int boot_script_task_create (struct cmd *); /* task_create + task_suspend */ +int boot_script_task_resume (struct cmd *); +int boot_script_prompt_task_resume (struct cmd *); +int boot_script_insert_right (struct cmd *, mach_port_t, mach_port_t *namep); +int boot_script_insert_task_port (struct cmd *, task_t, mach_port_t *namep); + +/* The user must define this function to clean up the `task_t' + returned by boot_script_task_create. */ +void boot_script_free_task (task_t task, int aborting); + + +/* Parse the command line LINE. This causes the command line to be + converted into an internal format. Returns 0 for success, non-zero + otherwise. + + NOTE: The parser writes into the line so it must not be a string constant. + It is also the responsibility of the caller not to deallocate the line + across calls to the parser. */ +int boot_script_parse_line (void *hook, char *cmdline); + +/* Execute the command lines prevously parsed. + Returns 0 for success, non-zero otherwise. */ +int boot_script_exec (void); + +/* Create an entry in the symbol table for variable NAME, + whose type is TYPE and value is VAL. Returns 0 on success, + non-zero otherwise. */ +int boot_script_set_variable (const char *name, int type, integer_t val); + +/* Define the function NAME, which will return type RET_TYPE. */ +int boot_script_define_function (const char *name, int ret_type, + int (*func) (const struct cmd *cmd, + integer_t *val)); + +/* Returns a string describing the error ERR. */ +char *boot_script_error_string (int err); + + +#endif /* _boot_script_h */ diff --git a/boot-proxy-exc/boot_script.o b/boot-proxy-exc/boot_script.o Binary files differnew file mode 100644 index 00000000..6d629e2c --- /dev/null +++ b/boot-proxy-exc/boot_script.o diff --git a/boot-proxy-exc/bootstrap.defs b/boot-proxy-exc/bootstrap.defs new file mode 100644 index 00000000..ad4bac91 --- /dev/null +++ b/boot-proxy-exc/bootstrap.defs @@ -0,0 +1 @@ +#include <mach/bootstrap.defs> diff --git a/boot-proxy-exc/bootstrap.sdefs.d b/boot-proxy-exc/bootstrap.sdefs.d new file mode 100644 index 00000000..f812a8c4 --- /dev/null +++ b/boot-proxy-exc/bootstrap.sdefs.d @@ -0,0 +1,3 @@ +bootstrapServer.c bootstrap_S.h: bootstrap.defs /usr/local/include/mach/bootstrap.defs \ + /usr/local/include/mach/std_types.defs \ + /usr/local/include/mach/machine/machine_types.defs diff --git a/boot-proxy-exc/bootstrapServer.c b/boot-proxy-exc/bootstrapServer.c new file mode 100644 index 00000000..2aa817be --- /dev/null +++ b/boot-proxy-exc/bootstrapServer.c @@ -0,0 +1,154 @@ +/* Module bootstrap */ + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE 1 +#endif + +#define EXPORT_BOOLEAN +#include <mach/boolean.h> +#include <mach/kern_return.h> +#include <mach/message.h> +#include <mach/mig_errors.h> +#include <mach/mig_support.h> + +#ifndef mig_internal +#define mig_internal static +#endif + +#ifndef mig_external +#define mig_external +#endif + +#ifndef TypeCheck +#define TypeCheck 1 +#endif + +#ifndef UseExternRCSId +#define UseExternRCSId 1 +#endif + +#define BAD_TYPECHECK(type, check) ({\ + union { mach_msg_type_t t; unsigned32_t w; } _t, _c;\ + _t.t = *(type); _c.t = *(check); _t.w != _c.w; }) +#define msgh_request_port msgh_local_port +#define MACH_MSGH_BITS_REQUEST(bits) MACH_MSGH_BITS_LOCAL(bits) +#define msgh_reply_port msgh_remote_port +#define MACH_MSGH_BITS_REPLY(bits) MACH_MSGH_BITS_REMOTE(bits) + +#include <mach/std_types.h> + +/* Routine bootstrap_privileged_ports */ +mig_internal void _Xbootstrap_privileged_ports + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t priv_hostType; + mach_port_t priv_host; + mach_msg_type_t priv_deviceType; + mach_port_t priv_device; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t do_bootstrap_privileged_ports + (mach_port_t bootstrap, mach_port_t *priv_host, mach_port_t *priv_device); + + auto const mach_msg_type_t priv_hostType = { + /* msgt_name = */ 19, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t priv_deviceType = { + /* msgt_name = */ 19, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = do_bootstrap_privileged_ports(In0P->Head.msgh_request_port, &OutP->priv_host, &OutP->priv_device); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; + OutP->Head.msgh_size = 48; + + OutP->priv_hostType = priv_hostType; + + OutP->priv_deviceType = priv_deviceType; +} + +static mig_routine_t bootstrap_server_routines[] = { + 0, + _Xbootstrap_privileged_ports, +}; + +mig_external boolean_t bootstrap_server + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + register mach_msg_header_t *InP = InHeadP; + register mig_reply_header_t *OutP = (mig_reply_header_t *) OutHeadP; + + auto const mach_msg_type_t RetCodeType = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + register mig_routine_t routine; + + OutP->Head.msgh_bits = MACH_MSGH_BITS(MACH_MSGH_BITS_REPLY(InP->msgh_bits), 0); + OutP->Head.msgh_size = sizeof *OutP; + OutP->Head.msgh_remote_port = InP->msgh_reply_port; + OutP->Head.msgh_local_port = MACH_PORT_NULL; + OutP->Head.msgh_seqno = 0; + OutP->Head.msgh_id = InP->msgh_id + 100; + + OutP->RetCodeType = RetCodeType; + + if ((InP->msgh_id > 1000000) || (InP->msgh_id < 999999) || + ((routine = bootstrap_server_routines[InP->msgh_id - 999999]) == 0)) { + OutP->RetCode = MIG_BAD_ID; + return FALSE; + } + (*routine) (InP, &OutP->Head); + return TRUE; +} + +mig_external mig_routine_t bootstrap_server_routine + (const mach_msg_header_t *InHeadP) +{ + register int msgh_id; + + msgh_id = InHeadP->msgh_id - 999999; + + if ((msgh_id > 1) || (msgh_id < 0)) + return 0; + + return bootstrap_server_routines[msgh_id]; +} + diff --git a/boot-proxy-exc/bootstrapServer.d b/boot-proxy-exc/bootstrapServer.d new file mode 100644 index 00000000..619201f5 --- /dev/null +++ b/boot-proxy-exc/bootstrapServer.d @@ -0,0 +1,28 @@ +bootstrapServer.o bootstrapServer_pic.o bootstrapServer_p.o bootstrapServer.d: bootstrapServer.c /usr/local/include/mach/boolean.h \ + /usr/local/include/mach/machine/boolean.h \ + /usr/local/include/mach/kern_return.h \ + /usr/local/include/mach/machine/kern_return.h \ + /usr/local/include/mach/message.h /usr/local/include/mach/port.h \ + /usr/local/include/mach/machine/vm_types.h \ + /usr/local/include/mach/mig_errors.h /usr/include/mach/mig_support.h \ + /usr/local/include/mach/std_types.h /usr/include/sys/types.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h /usr/include/gnu/stubs-pthread.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/time.h /usr/lib/gcc/i486-gnu/4.2.4/include/stddef.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/bits/byteswap.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/pthread/pthreadtypes.h \ + /usr/include/xlocale.h /usr/include/bits/pthread.h \ + /usr/include/bits/thread-attr.h /usr/include/sched.h \ + /usr/include/bits/sched.h /usr/include/bits/mutex-attr.h \ + /usr/include/bits/mutex.h /usr/include/bits/spin-lock.h \ + /usr/include/bits/condition-attr.h /usr/include/bits/condition.h \ + /usr/include/bits/rwlock-attr.h /usr/include/bits/rwlock.h \ + /usr/include/bits/barrier-attr.h /usr/include/bits/barrier.h \ + /usr/include/bits/thread-specific.h /usr/include/bits/once.h \ + /usr/include/string.h /usr/include/bits/string.h \ + /usr/include/bits/string2.h /usr/include/stdlib.h diff --git a/boot-proxy-exc/bootstrapServer.o b/boot-proxy-exc/bootstrapServer.o Binary files differnew file mode 100644 index 00000000..9e119ae9 --- /dev/null +++ b/boot-proxy-exc/bootstrapServer.o diff --git a/boot-proxy-exc/bootstrap_S.h b/boot-proxy-exc/bootstrap_S.h new file mode 100644 index 00000000..a93c8052 --- /dev/null +++ b/boot-proxy-exc/bootstrap_S.h @@ -0,0 +1,33 @@ +#ifndef _bootstrap_server_ +#define _bootstrap_server_ + +/* Module bootstrap */ + +#include <mach/kern_return.h> +#include <mach/port.h> +#include <mach/message.h> + +#include <mach/std_types.h> + +/* Routine bootstrap_privileged_ports */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t do_bootstrap_privileged_ports +#if defined(LINTLIBRARY) + (bootstrap, priv_host, priv_device) + mach_port_t bootstrap; + mach_port_t *priv_host; + mach_port_t *priv_device; +{ return do_bootstrap_privileged_ports(bootstrap, priv_host, priv_device); } +#else +( + mach_port_t bootstrap, + mach_port_t *priv_host, + mach_port_t *priv_device +); +#endif + +#endif /* not defined(_bootstrap_server_) */ diff --git a/boot-proxy-exc/device.defs b/boot-proxy-exc/device.defs new file mode 100644 index 00000000..70472689 --- /dev/null +++ b/boot-proxy-exc/device.defs @@ -0,0 +1 @@ +#include <device/device.defs> diff --git a/boot-proxy-exc/device_reply.defs b/boot-proxy-exc/device_reply.defs new file mode 100644 index 00000000..69930311 --- /dev/null +++ b/boot-proxy-exc/device_reply.defs @@ -0,0 +1 @@ +#include <device/device_reply.defs> diff --git a/boot-proxy-exc/device_reply.udefs.d b/boot-proxy-exc/device_reply.udefs.d new file mode 100644 index 00000000..5c71bec5 --- /dev/null +++ b/boot-proxy-exc/device_reply.udefs.d @@ -0,0 +1,5 @@ +device_replyUser.c device_reply_U.h: device_reply.defs \ + /usr/local/include/device/device_reply.defs \ + /usr/local/include/mach/std_types.defs \ + /usr/local/include/mach/machine/machine_types.defs \ + /usr/local/include/device/device_types.defs diff --git a/boot-proxy-exc/device_replyUser.c b/boot-proxy-exc/device_replyUser.c new file mode 100644 index 00000000..5735b1be --- /dev/null +++ b/boot-proxy-exc/device_replyUser.c @@ -0,0 +1,374 @@ +#ifndef _GNU_SOURCE +#define _GNU_SOURCE 1 +#endif + +#include "device_reply_U.h" +#define EXPORT_BOOLEAN +#include <mach/boolean.h> +#include <mach/kern_return.h> +#include <mach/message.h> +#include <mach/notify.h> +#include <mach/mach_types.h> +#include <mach/mig_errors.h> +#include <mach/mig_support.h> +#include <mach/msg_type.h> +/* LINTLIBRARY */ + +#ifndef mig_internal +#define mig_internal static +#endif + +#ifndef mig_external +#define mig_external +#endif + +#ifndef TypeCheck +#define TypeCheck 1 +#endif + +#ifndef UseExternRCSId +#define UseExternRCSId 1 +#endif + +#define BAD_TYPECHECK(type, check) ({\ + union { mach_msg_type_t t; unsigned32_t w; } _t, _c;\ + _t.t = *(type); _c.t = *(check); _t.w != _c.w; }) +#define msgh_request_port msgh_remote_port +#define msgh_reply_port msgh_local_port + +#include <mach/std_types.h> +#include <device/device_types.h> +#include <device/net_status.h> + +/* SimpleRoutine device_open_reply */ +mig_external kern_return_t ds_device_open_reply +( + mach_port_t reply_port, + mach_msg_type_name_t reply_portPoly, + kern_return_t return_code, + mach_port_t device_port +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t return_codeType; + kern_return_t return_code; + mach_msg_type_t device_portType; + mach_port_t device_port; + } Request; + + union { + Request In; + } Mess; + + register Request *InP = &Mess.In; + + + auto const mach_msg_type_t return_codeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t device_portType = { + /* msgt_name = */ 20, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->return_codeType = return_codeType; + + InP->return_code = return_code; + + InP->device_portType = device_portType; + + InP->device_port = device_port; + + InP->Head.msgh_bits = MACH_MSGH_BITS_COMPLEX| + MACH_MSGH_BITS(reply_portPoly, 0); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = reply_port; + InP->Head.msgh_reply_port = MACH_PORT_NULL; + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2900; + + return __mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, 40, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); +} + +/* SimpleRoutine device_write_reply */ +mig_external kern_return_t ds_device_write_reply +( + mach_port_t reply_port, + mach_msg_type_name_t reply_portPoly, + kern_return_t return_code, + int bytes_written +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t return_codeType; + kern_return_t return_code; + mach_msg_type_t bytes_writtenType; + int bytes_written; + } Request; + + union { + Request In; + } Mess; + + register Request *InP = &Mess.In; + + + auto const mach_msg_type_t return_codeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t bytes_writtenType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->return_codeType = return_codeType; + + InP->return_code = return_code; + + InP->bytes_writtenType = bytes_writtenType; + + InP->bytes_written = bytes_written; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(reply_portPoly, 0); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = reply_port; + InP->Head.msgh_reply_port = MACH_PORT_NULL; + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2902; + + return __mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, 40, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); +} + +/* SimpleRoutine device_write_reply_inband */ +mig_external kern_return_t ds_device_write_reply_inband +( + mach_port_t reply_port, + mach_msg_type_name_t reply_portPoly, + kern_return_t return_code, + int bytes_written +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t return_codeType; + kern_return_t return_code; + mach_msg_type_t bytes_writtenType; + int bytes_written; + } Request; + + union { + Request In; + } Mess; + + register Request *InP = &Mess.In; + + + auto const mach_msg_type_t return_codeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t bytes_writtenType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->return_codeType = return_codeType; + + InP->return_code = return_code; + + InP->bytes_writtenType = bytes_writtenType; + + InP->bytes_written = bytes_written; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(reply_portPoly, 0); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = reply_port; + InP->Head.msgh_reply_port = MACH_PORT_NULL; + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2903; + + return __mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, 40, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); +} + +/* SimpleRoutine device_read_reply */ +mig_external kern_return_t ds_device_read_reply +( + mach_port_t reply_port, + mach_msg_type_name_t reply_portPoly, + kern_return_t return_code, + io_buf_ptr_t data, + mach_msg_type_number_t dataCnt +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t return_codeType; + kern_return_t return_code; + mach_msg_type_long_t dataType; + io_buf_ptr_t data; + } Request; + + union { + Request In; + } Mess; + + register Request *InP = &Mess.In; + + + auto const mach_msg_type_t return_codeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_long_t dataType = { + { + /* msgt_name = */ 0, + /* msgt_size = */ 0, + /* msgt_number = */ 0, + /* msgt_inline = */ FALSE, + /* msgt_longform = */ TRUE, + /* msgt_deallocate = */ TRUE, + /* msgt_unused = */ 0 + }, + /* msgtl_name = */ 9, + /* msgtl_size = */ 8, + /* msgtl_number = */ 0, + }; + + InP->return_codeType = return_codeType; + + InP->return_code = return_code; + + InP->dataType = dataType; + + InP->data = data; + + InP->dataType.msgtl_number = dataCnt; + + InP->Head.msgh_bits = MACH_MSGH_BITS_COMPLEX| + MACH_MSGH_BITS(reply_portPoly, 0); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = reply_port; + InP->Head.msgh_reply_port = MACH_PORT_NULL; + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2904; + + return __mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, 48, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); +} + +/* SimpleRoutine device_read_reply_inband */ +mig_external kern_return_t ds_device_read_reply_inband +( + mach_port_t reply_port, + mach_msg_type_name_t reply_portPoly, + kern_return_t return_code, + io_buf_ptr_inband_t data, + mach_msg_type_number_t dataCnt +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t return_codeType; + kern_return_t return_code; + mach_msg_type_t dataType; + char data[128]; + } Request; + + union { + Request In; + } Mess; + + register Request *InP = &Mess.In; + + unsigned int msgh_size; + + auto const mach_msg_type_t return_codeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t dataType = { + /* msgt_name = */ 8, + /* msgt_size = */ 8, + /* msgt_number = */ 128, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->return_codeType = return_codeType; + + InP->return_code = return_code; + + InP->dataType = dataType; + + if (dataCnt > 128) { + return MIG_ARRAY_TOO_LARGE; + } + else { + memcpy(InP->data, data, dataCnt); + } + + InP->dataType.msgt_number = dataCnt; + + msgh_size = 36 + ((dataCnt + 3) & ~3); + InP->Head.msgh_bits = + MACH_MSGH_BITS(reply_portPoly, 0); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = reply_port; + InP->Head.msgh_reply_port = MACH_PORT_NULL; + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2905; + + return __mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, msgh_size, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); +} diff --git a/boot-proxy-exc/device_replyUser.d b/boot-proxy-exc/device_replyUser.d new file mode 100644 index 00000000..de52e30e --- /dev/null +++ b/boot-proxy-exc/device_replyUser.d @@ -0,0 +1,48 @@ +device_replyUser.o device_replyUser_pic.o device_replyUser_p.o device_replyUser.d: device_replyUser.c device_reply_U.h \ + /usr/local/include/mach/kern_return.h \ + /usr/local/include/mach/machine/kern_return.h \ + /usr/local/include/mach/port.h /usr/local/include/mach/boolean.h \ + /usr/local/include/mach/machine/boolean.h \ + /usr/local/include/mach/machine/vm_types.h \ + /usr/local/include/mach/message.h /usr/local/include/mach/std_types.h \ + /usr/local/include/device/device_types.h \ + /usr/local/include/device/net_status.h /usr/local/include/device/bpf.h \ + /usr/include/sys/types.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/include/gnu/stubs-pthread.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/time.h \ + /usr/lib/gcc/i486-gnu/4.2.4/include/stddef.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/bits/byteswap.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/pthread/pthreadtypes.h /usr/include/xlocale.h \ + /usr/include/bits/pthread.h /usr/include/bits/thread-attr.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/mutex-attr.h /usr/include/bits/mutex.h \ + /usr/include/bits/spin-lock.h /usr/include/bits/condition-attr.h \ + /usr/include/bits/condition.h /usr/include/bits/rwlock-attr.h \ + /usr/include/bits/rwlock.h /usr/include/bits/barrier-attr.h \ + /usr/include/bits/barrier.h /usr/include/bits/thread-specific.h \ + /usr/include/bits/once.h /usr/local/include/mach/notify.h \ + /usr/local/include/mach/mach_types.h \ + /usr/local/include/mach/host_info.h /usr/local/include/mach/machine.h \ + /usr/local/include/mach/memory_object.h \ + /usr/local/include/mach/pc_sample.h \ + /usr/local/include/mach/processor_info.h \ + /usr/local/include/mach/task_info.h \ + /usr/local/include/mach/time_value.h \ + /usr/local/include/mach/task_special_ports.h \ + /usr/local/include/mach/thread_info.h /usr/local/include/mach/policy.h \ + /usr/local/include/mach/thread_special_ports.h \ + /usr/local/include/mach/thread_status.h \ + /usr/local/include/mach/machine/thread_status.h \ + /usr/local/include/mach/machine/fp_reg.h \ + /usr/local/include/mach/vm_attributes.h \ + /usr/local/include/mach/vm_inherit.h /usr/local/include/mach/vm_prot.h \ + /usr/local/include/mach/vm_statistics.h \ + /usr/local/include/mach/mig_errors.h /usr/include/mach/mig_support.h \ + /usr/include/string.h /usr/include/bits/string.h \ + /usr/include/bits/string2.h /usr/include/stdlib.h \ + /usr/local/include/mach/msg_type.h diff --git a/boot-proxy-exc/device_replyUser.o b/boot-proxy-exc/device_replyUser.o Binary files differnew file mode 100644 index 00000000..97a560c2 --- /dev/null +++ b/boot-proxy-exc/device_replyUser.o diff --git a/boot-proxy-exc/device_reply_U.h b/boot-proxy-exc/device_reply_U.h new file mode 100644 index 00000000..d70cd5b3 --- /dev/null +++ b/boot-proxy-exc/device_reply_U.h @@ -0,0 +1,133 @@ +#ifndef _device_reply_user_ +#define _device_reply_user_ + +/* Module device_reply */ + +#include <mach/kern_return.h> +#include <mach/port.h> +#include <mach/message.h> + +#include <mach/std_types.h> +#include <device/device_types.h> +#include <device/net_status.h> + +/* SimpleRoutine device_open_reply */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t ds_device_open_reply +#if defined(LINTLIBRARY) + (reply_port, reply_portPoly, return_code, device_port) + mach_port_t reply_port; + mach_msg_type_name_t reply_portPoly; + kern_return_t return_code; + mach_port_t device_port; +{ return ds_device_open_reply(reply_port, reply_portPoly, return_code, device_port); } +#else +( + mach_port_t reply_port, + mach_msg_type_name_t reply_portPoly, + kern_return_t return_code, + mach_port_t device_port +); +#endif + +/* SimpleRoutine device_write_reply */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t ds_device_write_reply +#if defined(LINTLIBRARY) + (reply_port, reply_portPoly, return_code, bytes_written) + mach_port_t reply_port; + mach_msg_type_name_t reply_portPoly; + kern_return_t return_code; + int bytes_written; +{ return ds_device_write_reply(reply_port, reply_portPoly, return_code, bytes_written); } +#else +( + mach_port_t reply_port, + mach_msg_type_name_t reply_portPoly, + kern_return_t return_code, + int bytes_written +); +#endif + +/* SimpleRoutine device_write_reply_inband */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t ds_device_write_reply_inband +#if defined(LINTLIBRARY) + (reply_port, reply_portPoly, return_code, bytes_written) + mach_port_t reply_port; + mach_msg_type_name_t reply_portPoly; + kern_return_t return_code; + int bytes_written; +{ return ds_device_write_reply_inband(reply_port, reply_portPoly, return_code, bytes_written); } +#else +( + mach_port_t reply_port, + mach_msg_type_name_t reply_portPoly, + kern_return_t return_code, + int bytes_written +); +#endif + +/* SimpleRoutine device_read_reply */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t ds_device_read_reply +#if defined(LINTLIBRARY) + (reply_port, reply_portPoly, return_code, data, dataCnt) + mach_port_t reply_port; + mach_msg_type_name_t reply_portPoly; + kern_return_t return_code; + io_buf_ptr_t data; + mach_msg_type_number_t dataCnt; +{ return ds_device_read_reply(reply_port, reply_portPoly, return_code, data, dataCnt); } +#else +( + mach_port_t reply_port, + mach_msg_type_name_t reply_portPoly, + kern_return_t return_code, + io_buf_ptr_t data, + mach_msg_type_number_t dataCnt +); +#endif + +/* SimpleRoutine device_read_reply_inband */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t ds_device_read_reply_inband +#if defined(LINTLIBRARY) + (reply_port, reply_portPoly, return_code, data, dataCnt) + mach_port_t reply_port; + mach_msg_type_name_t reply_portPoly; + kern_return_t return_code; + io_buf_ptr_inband_t data; + mach_msg_type_number_t dataCnt; +{ return ds_device_read_reply_inband(reply_port, reply_portPoly, return_code, data, dataCnt); } +#else +( + mach_port_t reply_port, + mach_msg_type_name_t reply_portPoly, + kern_return_t return_code, + io_buf_ptr_inband_t data, + mach_msg_type_number_t dataCnt +); +#endif + +#endif /* not defined(_device_reply_user_) */ diff --git a/boot-proxy-exc/exc.defs b/boot-proxy-exc/exc.defs new file mode 100644 index 00000000..ab864488 --- /dev/null +++ b/boot-proxy-exc/exc.defs @@ -0,0 +1 @@ +#include <mach/exc.defs> diff --git a/boot-proxy-exc/exc.sdefs.d b/boot-proxy-exc/exc.sdefs.d new file mode 100644 index 00000000..fa3b90b2 --- /dev/null +++ b/boot-proxy-exc/exc.sdefs.d @@ -0,0 +1,3 @@ +excServer.c exc_S.h: exc.defs /usr/local/include/mach/exc.defs \ + /usr/local/include/mach/std_types.defs \ + /usr/local/include/mach/machine/machine_types.defs diff --git a/boot-proxy-exc/excServer.c b/boot-proxy-exc/excServer.c new file mode 100644 index 00000000..9c3191dd --- /dev/null +++ b/boot-proxy-exc/excServer.c @@ -0,0 +1,205 @@ +/* Module exc */ + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE 1 +#endif + +#define EXPORT_BOOLEAN +#include <mach/boolean.h> +#include <mach/kern_return.h> +#include <mach/message.h> +#include <mach/mig_errors.h> +#include <mach/mig_support.h> + +#ifndef mig_internal +#define mig_internal static +#endif + +#ifndef mig_external +#define mig_external +#endif + +#ifndef TypeCheck +#define TypeCheck 1 +#endif + +#ifndef UseExternRCSId +#define UseExternRCSId 1 +#endif + +#define BAD_TYPECHECK(type, check) ({\ + union { mach_msg_type_t t; unsigned32_t w; } _t, _c;\ + _t.t = *(type); _c.t = *(check); _t.w != _c.w; }) +#define msgh_request_port msgh_local_port +#define MACH_MSGH_BITS_REQUEST(bits) MACH_MSGH_BITS_LOCAL(bits) +#define msgh_reply_port msgh_remote_port +#define MACH_MSGH_BITS_REPLY(bits) MACH_MSGH_BITS_REMOTE(bits) + +#include <mach/std_types.h> + +/* Routine exception_raise */ +mig_internal void _Xexception_raise + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t threadType; + mach_port_t thread; + mach_msg_type_t taskType; + mach_port_t task; + mach_msg_type_t exceptionType; + integer_t exception; + mach_msg_type_t codeType; + integer_t code; + mach_msg_type_t subcodeType; + integer_t subcode; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t catch_exception_raise + (mach_port_t exception_port, mach_port_t thread, mach_port_t task, integer_t exception, integer_t code, integer_t subcode); + + auto const mach_msg_type_t threadCheck = { + /* msgt_name = */ 17, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t taskCheck = { + /* msgt_name = */ 17, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t exceptionCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t codeCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t subcodeCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 64) || + !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->threadType, &threadCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->taskType, &taskCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->exceptionType, &exceptionCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->codeType, &codeCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->subcodeType, &subcodeCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = catch_exception_raise(In0P->Head.msgh_request_port, In0P->thread, In0P->task, In0P->exception, In0P->code, In0P->subcode); +} + +static mig_routine_t exc_server_routines[] = { + _Xexception_raise, +}; + +mig_external boolean_t exc_server + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + register mach_msg_header_t *InP = InHeadP; + register mig_reply_header_t *OutP = (mig_reply_header_t *) OutHeadP; + + auto const mach_msg_type_t RetCodeType = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + register mig_routine_t routine; + + OutP->Head.msgh_bits = MACH_MSGH_BITS(MACH_MSGH_BITS_REPLY(InP->msgh_bits), 0); + OutP->Head.msgh_size = sizeof *OutP; + OutP->Head.msgh_remote_port = InP->msgh_reply_port; + OutP->Head.msgh_local_port = MACH_PORT_NULL; + OutP->Head.msgh_seqno = 0; + OutP->Head.msgh_id = InP->msgh_id + 100; + + OutP->RetCodeType = RetCodeType; + + if ((InP->msgh_id > 2400) || (InP->msgh_id < 2400) || + ((routine = exc_server_routines[InP->msgh_id - 2400]) == 0)) { + OutP->RetCode = MIG_BAD_ID; + return FALSE; + } + (*routine) (InP, &OutP->Head); + return TRUE; +} + +mig_external mig_routine_t exc_server_routine + (const mach_msg_header_t *InHeadP) +{ + register int msgh_id; + + msgh_id = InHeadP->msgh_id - 2400; + + if ((msgh_id > 0) || (msgh_id < 0)) + return 0; + + return exc_server_routines[msgh_id]; +} + diff --git a/boot-proxy-exc/excServer.d b/boot-proxy-exc/excServer.d new file mode 100644 index 00000000..47c93cfd --- /dev/null +++ b/boot-proxy-exc/excServer.d @@ -0,0 +1,28 @@ +excServer.o excServer_pic.o excServer_p.o excServer.d: excServer.c /usr/local/include/mach/boolean.h \ + /usr/local/include/mach/machine/boolean.h \ + /usr/local/include/mach/kern_return.h \ + /usr/local/include/mach/machine/kern_return.h \ + /usr/local/include/mach/message.h /usr/local/include/mach/port.h \ + /usr/local/include/mach/machine/vm_types.h \ + /usr/local/include/mach/mig_errors.h /usr/include/mach/mig_support.h \ + /usr/local/include/mach/std_types.h /usr/include/sys/types.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h /usr/include/gnu/stubs-pthread.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/time.h /usr/lib/gcc/i486-gnu/4.2.4/include/stddef.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/bits/byteswap.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/pthread/pthreadtypes.h \ + /usr/include/xlocale.h /usr/include/bits/pthread.h \ + /usr/include/bits/thread-attr.h /usr/include/sched.h \ + /usr/include/bits/sched.h /usr/include/bits/mutex-attr.h \ + /usr/include/bits/mutex.h /usr/include/bits/spin-lock.h \ + /usr/include/bits/condition-attr.h /usr/include/bits/condition.h \ + /usr/include/bits/rwlock-attr.h /usr/include/bits/rwlock.h \ + /usr/include/bits/barrier-attr.h /usr/include/bits/barrier.h \ + /usr/include/bits/thread-specific.h /usr/include/bits/once.h \ + /usr/include/string.h /usr/include/bits/string.h \ + /usr/include/bits/string2.h /usr/include/stdlib.h diff --git a/boot-proxy-exc/excServer.o b/boot-proxy-exc/excServer.o Binary files differnew file mode 100644 index 00000000..a27525fe --- /dev/null +++ b/boot-proxy-exc/excServer.o diff --git a/boot-proxy-exc/exc_S.h b/boot-proxy-exc/exc_S.h new file mode 100644 index 00000000..5b2c327a --- /dev/null +++ b/boot-proxy-exc/exc_S.h @@ -0,0 +1,39 @@ +#ifndef _exc_server_ +#define _exc_server_ + +/* Module exc */ + +#include <mach/kern_return.h> +#include <mach/port.h> +#include <mach/message.h> + +#include <mach/std_types.h> + +/* Routine exception_raise */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t catch_exception_raise +#if defined(LINTLIBRARY) + (exception_port, thread, task, exception, code, subcode) + mach_port_t exception_port; + mach_port_t thread; + mach_port_t task; + integer_t exception; + integer_t code; + integer_t subcode; +{ return catch_exception_raise(exception_port, thread, task, exception, code, subcode); } +#else +( + mach_port_t exception_port, + mach_port_t thread, + mach_port_t task, + integer_t exception, + integer_t code, + integer_t subcode +); +#endif + +#endif /* not defined(_exc_server_) */ diff --git a/boot-proxy-exc/exc_impl.c b/boot-proxy-exc/exc_impl.c new file mode 100644 index 00000000..1c6900bb --- /dev/null +++ b/boot-proxy-exc/exc_impl.c @@ -0,0 +1,69 @@ +/* + Copyright (C) 2009 Free Software Foundation, Inc. + Written by Zheng Da. + + This file is part of the GNU Hurd. + + The GNU Hurd is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + The GNU Hurd 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with the GNU Hurd; see the file COPYING. If not, write to + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/* This file implements the server-side RPC functions of mach_host. */ + +#include <mach.h> +#include <hurd.h> +#include <assert.h> + +#include "util.h" +#include "mach_proxy.h" + +kern_return_t +catch_exception_raise (mach_port_t exception_port, mach_port_t thread, + mach_port_t task, integer_t exception, + integer_t code, integer_t subcode) +{ + error_t err; + struct task_info *fault_task_pi = NULL; + debug (""); + + int match_task (struct task_info *task_pi) + { + if (task_pi->task_port == task) + { + fault_task_pi = task_pi; + ports_port_ref (fault_task_pi); + return 1; + } + return 0; + } + foreach_task (match_task); + + if (fault_task_pi == NULL) + { + fault_task_pi = ports_lookup_port (port_bucket, task, task_portclass); + if (fault_task_pi) + info ("find the task: %d from libports", task); + } + + if (fault_task_pi == NULL) + { + info ("cannot find the task: %d", task); + return EINVAL; + } + + err = catch_exception_raise (fault_task_pi->user_exc_port, + thread, fault_task_pi->task.port_right, + exception, code, subcode); + ports_port_deref (fault_task_pi); + return err; +} diff --git a/boot-proxy-exc/exc_impl.c~ b/boot-proxy-exc/exc_impl.c~ new file mode 100644 index 00000000..a99a7e3c --- /dev/null +++ b/boot-proxy-exc/exc_impl.c~ @@ -0,0 +1,67 @@ +/* + Copyright (C) 2009 Free Software Foundation, Inc. + Written by Zheng Da. + + This file is part of the GNU Hurd. + + The GNU Hurd is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + The GNU Hurd 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with the GNU Hurd; see the file COPYING. If not, write to + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/* This file implements the server-side RPC functions of mach_host. */ + +#include <mach.h> +#include <hurd.h> +#include <assert.h> + +#include "util.h" +#include "mach_proxy.h" + +kern_return_t +catch_exception_raise (mach_port_t exception_port, mach_port_t thread, + mach_port_t task, integer_t exception, + integer_t code, integer_t subcode) +{ + error_t err; + struct task_info *fault_task_pi = NULL; + debug (""); + + int match_task (struct task_info *task_pi) + { + if (task_pi->task_port == task) + { + fault_task_pi = task_pi; + ports_port_ref (fault_task_pi); + return 1; + } + return 0; + } + foreach_task (match_task); + + if (fault_task_pi == NULL) + { + fault_task_pi = ports_lookup_port (port_bucket, task, task_portclass); + } + + if (fault_task_pi == NULL) + { + info ("cannot find the task: %d", task); + return EINVAL; + } + + err = catch_exception_raise (fault_task_pi->user_exc_port, + thread, fault_task_pi->task.port_right, + exception, code, subcode); + ports_port_deref (fault_task_pi); + return err; +} diff --git a/boot-proxy-exc/exc_impl.d b/boot-proxy-exc/exc_impl.d new file mode 100644 index 00000000..cd3f2a26 --- /dev/null +++ b/boot-proxy-exc/exc_impl.d @@ -0,0 +1,86 @@ +exc_impl.o exc_impl_pic.o exc_impl_p.o exc_impl.d: exc_impl.c /usr/include/mach.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/include/gnu/stubs-pthread.h /usr/local/include/mach/mach_types.h \ + /usr/local/include/mach/host_info.h /usr/local/include/mach/machine.h \ + /usr/local/include/mach/machine/vm_types.h \ + /usr/local/include/mach/boolean.h \ + /usr/local/include/mach/machine/boolean.h \ + /usr/local/include/mach/memory_object.h /usr/local/include/mach/port.h \ + /usr/local/include/mach/pc_sample.h \ + /usr/local/include/mach/processor_info.h \ + /usr/local/include/mach/task_info.h \ + /usr/local/include/mach/time_value.h \ + /usr/local/include/mach/task_special_ports.h \ + /usr/local/include/mach/thread_info.h /usr/local/include/mach/policy.h \ + /usr/local/include/mach/thread_special_ports.h \ + /usr/local/include/mach/thread_status.h \ + /usr/local/include/mach/machine/thread_status.h \ + /usr/local/include/mach/machine/fp_reg.h \ + /usr/local/include/mach/vm_attributes.h \ + /usr/local/include/mach/vm_inherit.h /usr/local/include/mach/vm_prot.h \ + /usr/local/include/mach/vm_statistics.h \ + /usr/local/include/mach/std_types.h \ + /usr/local/include/mach/kern_return.h \ + /usr/local/include/mach/machine/kern_return.h /usr/include/mach_init.h \ + /usr/include/mach/mach_traps.h /usr/local/include/mach/message.h \ + /usr/include/mach/mach_interface.h /usr/include/mach/mach_port.h \ + /usr/include/mach/mach_host.h /usr/include/mach-shortcuts.h \ + /usr/include/stdio.h /usr/include/hurd.h \ + /usr/local/include/mach/mig_errors.h ../hurd/hurd_types.h \ + /usr/include/sys/types.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/time.h \ + /usr/lib/gcc/i486-gnu/4.2.4/include/stddef.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/bits/byteswap.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/pthread/pthreadtypes.h /usr/include/xlocale.h \ + /usr/include/bits/pthread.h /usr/include/bits/thread-attr.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/mutex-attr.h /usr/include/bits/mutex.h \ + /usr/include/bits/spin-lock.h /usr/include/bits/condition-attr.h \ + /usr/include/bits/condition.h /usr/include/bits/rwlock-attr.h \ + /usr/include/bits/rwlock.h /usr/include/bits/barrier-attr.h \ + /usr/include/bits/barrier.h /usr/include/bits/thread-specific.h \ + /usr/include/bits/once.h /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/hurd/auth.h /usr/local/include/device/device_types.h \ + /usr/local/include/device/net_status.h /usr/local/include/device/bpf.h \ + /usr/include/sys/stat.h /usr/include/bits/stat.h \ + /usr/include/sys/statfs.h /usr/include/bits/statfs.h \ + /usr/include/sys/resource.h /usr/include/bits/resource.h \ + /usr/include/sys/utsname.h /usr/include/bits/utsname.h \ + /usr/include/hurd/process.h /usr/include/hurd/fs.h \ + /usr/include/hurd/io.h /usr/include/hurd/port.h \ + /usr/include/hurd/userlink.h /usr/include/hurd/signal.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/sys/ucontext.h /usr/include/bits/sigthread.h \ + /usr/include/hurd/msg.h ../include/cthreads.h \ + ../include/../libthreads/cthreads.h /usr/include/stdlib.h \ + /usr/include/bits/waitflags.h /usr/include/bits/waitstatus.h \ + /usr/include/alloca.h /usr/local/include/mach/machine/vm_param.h \ + /usr/include/machine-sp.h /usr/include/spin-lock.h \ + /usr/include/lock-intern.h /usr/include/machine-lock.h \ + /usr/include/setjmp.h /usr/include/bits/setjmp.h \ + /usr/include/hurd/threadvar.h \ + /usr/lib/gcc/i486-gnu/4.2.4/include/stdarg.h /usr/include/assert.h \ + util.h /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/wchar.h /usr/include/bits/stdio-lock.h \ + /usr/include/bits/libc-lock.h /usr/include/bits/stdio_lim.h \ + /usr/include/bits/sys_errlist.h /usr/include/bits/stdio.h \ + /usr/include/string.h /usr/include/bits/string.h \ + /usr/include/bits/string2.h /usr/include/sys/socket.h \ + /usr/include/sys/uio.h /usr/include/bits/uio.h \ + /usr/include/bits/socket.h /usr/lib/gcc/i486-gnu/4.2.4/include/limits.h \ + /usr/lib/gcc/i486-gnu/4.2.4/include/syslimits.h /usr/include/limits.h \ + /usr/include/bits/posix1_lim.h /usr/include/bits/local_lim.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/xopen_lim.h \ + /usr/include/bits/sockaddr.h /usr/include/arpa/inet.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/wchar.h /usr/include/bits/in.h \ + /usr/include/netinet/ip.h /usr/include/syslog.h \ + /usr/include/sys/syslog.h /usr/include/bits/syslog-path.h mach_proxy.h \ + ../hurd/ports.h ../hurd/../libports/ports.h ../hurd/ihash.h \ + ../hurd/../libihash/ihash.h /usr/local/include/mach/notify.h list.h diff --git a/boot-proxy-exc/exc_impl.o b/boot-proxy-exc/exc_impl.o Binary files differnew file mode 100644 index 00000000..d07822d9 --- /dev/null +++ b/boot-proxy-exc/exc_impl.o diff --git a/boot-proxy-exc/frank1.ld b/boot-proxy-exc/frank1.ld new file mode 100644 index 00000000..9de827ae --- /dev/null +++ b/boot-proxy-exc/frank1.ld @@ -0,0 +1,94 @@ +OUTPUT_FORMAT("elf32-i386", "elf32-i386", + "elf32-i386") +OUTPUT_ARCH(i386) +ENTRY(_start) + SEARCH_DIR(/usr/local/i386-gnuelf/lib); +/* Do we need any of these for elf? + __DYNAMIC = 0; */ +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + . = 0x10020; + .text : + { + *(.text) + *(.interp) + *(.hash) + *(.dynsym) + *(.dynstr) + *(.rel.text) + *(.rela.text) + *(.rel.data) + *(.rela.data) + *(.rel.rodata) + *(.rela.rodata) + *(.rel.got) + *(.rela.got) + *(.rel.ctors) + *(.rela.ctors) + *(.rel.dtors) + *(.rela.dtors) + *(.rel.init) + *(.rela.init) + *(.rel.fini) + *(.rela.fini) + *(.rel.bss) + *(.rela.bss) + *(.rel.plt) + *(.rela.plt) + *(.init) + *(.plt) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + *(.fini) + *(.rodata) + *(.rodata1) + _etext = .; + PROVIDE (etext = .); + . = ALIGN(0x1000); + } =0x9090 + . = ALIGN(0x1000); + .data : + { + *(.data) + CONSTRUCTORS + + *(.data1) + *(.ctors) + *(.dtors) + *(.got.plt) *(.got) + *(.dynamic) + /* We want the small data sections together, so single-instruction offsets + can access them all, and initialized data all before uninitialized, so + we can shorten the on-disk segment size. */ + *(.sdata) + _edata = .; + PROVIDE (edata = .); + . = ALIGN(0x10); +} + __bss_start = .; + .bss : + { + *(.sbss) *(.scommon) + *(.dynbss) + *(.bss) + *(COMMON) + _end = ALIGN(4) ; + PROVIDE (end = ALIGN(4)); + } + /* These are needed for ELF backends which have not yet been + converted to the new style linker. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + /* DWARF debug sections. + Symbols in the .debug DWARF section are relative to the beginning of the + section so we begin .debug at 0. It's not clear yet what needs to happen + for the others. */ + .debug 0 : { *(.debug) } + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + .debug_sfnames 0 : { *(.debug_sfnames) } + .line 0 : { *(.line) } + /* These must appear regardless of . */ +} diff --git a/boot-proxy-exc/frankemul.ld b/boot-proxy-exc/frankemul.ld new file mode 100644 index 00000000..413953ef --- /dev/null +++ b/boot-proxy-exc/frankemul.ld @@ -0,0 +1,107 @@ +OUTPUT_FORMAT("elf32-i386", "elf32-i386", + "elf32-i386") +OUTPUT_ARCH(i386) +ENTRY(_start) + SEARCH_DIR(/usr/local/i386-gnuelf/lib); +/* Do we need any of these for elf? + __DYNAMIC = 0; */ +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + . = 0x10020; + .text : + { + *(.text) + *(.interp) + *(.hash) + *(.dynsym) + *(.dynstr) + *(.rel.text) + *(.rela.text) + *(.rel.data) + *(.rela.data) + *(.rel.rodata) + *(.rela.rodata) + *(.rel.got) + *(.rela.got) + *(.rel.ctors) + *(.rela.ctors) + *(.rel.dtors) + *(.rela.dtors) + *(.rel.init) + *(.rela.init) + *(.rel.fini) + *(.rela.fini) + *(.rel.bss) + *(.rela.bss) + *(.rel.plt) + *(.rela.plt) + *(.init) + *(.plt) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + *(.fini) + *(.rodata) + *(.rodata1) +*(_hurd_ioctl_handler_lists) +*(_hurd_pgrp_changed_hook) +*(_hurd_fork_locks) +*(_hurd_subinit) +*(__libc_atexit) +*(_hurd_fd_subinit) +*(_hurd_preinit_hook) +*(_hurd_fork_child_hook) +*(_hurd_fork_parent_hook) +*(_hurd_fork_prepare_hook) +*(_hurd_reauth_hook) +*(_hurd_proc_subinit) +*(__libc_subinit) + _etext = .; + PROVIDE (etext = .); + . = ALIGN(0x1000); + } =0x9090 + . = ALIGN(0x1000); + .data : + { + *(.data) + CONSTRUCTORS + + *(.data1) + *(.ctors) + *(.dtors) + *(.got.plt) *(.got) + *(.dynamic) + /* We want the small data sections together, so single-instruction offsets + can access them all, and initialized data all before uninitialized, so + we can shorten the on-disk segment size. */ + *(.sdata) + _edata = .; + PROVIDE (edata = .); + . = ALIGN(0x10); +} + __bss_start = .; + .bss : + { + *(.sbss) *(.scommon) + *(.dynbss) + *(.bss) + *(COMMON) + _end = ALIGN(4) ; + PROVIDE (end = ALIGN(4)); + } + /* These are needed for ELF backends which have not yet been + converted to the new style linker. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + /* DWARF debug sections. + Symbols in the .debug DWARF section are relative to the beginning of the + section so we begin .debug at 0. It's not clear yet what needs to happen + for the others. */ + .debug 0 : { *(.debug) } + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + .debug_sfnames 0 : { *(.debug_sfnames) } + .line 0 : { *(.line) } + /* These must appear regardless of . */ +} diff --git a/boot-proxy-exc/io.sdefs.d b/boot-proxy-exc/io.sdefs.d new file mode 100644 index 00000000..81cdf15c --- /dev/null +++ b/boot-proxy-exc/io.sdefs.d @@ -0,0 +1,5 @@ +ioServer.c io_S.h: ../hurd/io.defs ../hurd/hurd_types.defs \ + /usr/local/include/mach/std_types.defs \ + /usr/local/include/mach/machine/machine_types.defs \ + /usr/local/include/mach/mach_types.defs \ + /usr/local/include/device/device_types.defs /usr/include/bits/utsname.h diff --git a/boot-proxy-exc/ioServer.c b/boot-proxy-exc/ioServer.c new file mode 100644 index 00000000..627acbdf --- /dev/null +++ b/boot-proxy-exc/ioServer.c @@ -0,0 +1,1873 @@ +/* Module io */ + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE 1 +#endif + +#define EXPORT_BOOLEAN +#include <mach/boolean.h> +#include <mach/kern_return.h> +#include <mach/message.h> +#include <mach/mig_errors.h> +#include <mach/mig_support.h> + +#ifndef mig_internal +#define mig_internal static +#endif + +#ifndef mig_external +#define mig_external +#endif + +#ifndef TypeCheck +#define TypeCheck 1 +#endif + +#ifndef UseExternRCSId +#define UseExternRCSId 1 +#endif + +#define BAD_TYPECHECK(type, check) ({\ + union { mach_msg_type_t t; unsigned32_t w; } _t, _c;\ + _t.t = *(type); _c.t = *(check); _t.w != _c.w; }) +#define msgh_request_port msgh_local_port +#define MACH_MSGH_BITS_REQUEST(bits) MACH_MSGH_BITS_LOCAL(bits) +#define msgh_reply_port msgh_remote_port +#define MACH_MSGH_BITS_REPLY(bits) MACH_MSGH_BITS_REMOTE(bits) + +#include <mach/std_types.h> +#include <mach/mach_types.h> +#include <device/device_types.h> +#include <device/net_status.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/statfs.h> +#include <sys/resource.h> +#include <sys/utsname.h> +#include <hurd/hurd_types.h> + +/* Routine io_write */ +mig_internal void _Xio_write + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_long_t dataType; + char data[2048]; + mach_msg_type_t offsetType; + loff_t offset; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t amountType; + vm_size_t amount; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Request *In1P; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_io_write + (io_t io_object, mach_port_t reply, mach_msg_type_name_t replyPoly, data_t data, mach_msg_type_number_t dataCnt, loff_t offset, vm_size_t *amount); + +#if TypeCheck + boolean_t msgh_simple; +#endif /* TypeCheck */ + + unsigned int msgh_size; + unsigned int msgh_size_delta; + + auto const mach_msg_type_t offsetCheck = { + /* msgt_name = */ 11, + /* msgt_size = */ 64, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t amountType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + msgh_size = In0P->Head.msgh_size; + msgh_simple = !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX); + if ((msgh_size < 48)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if ((In0P->dataType.msgtl_header.msgt_longform != TRUE) || + (In0P->dataType.msgtl_name != 8) || + (In0P->dataType.msgtl_size != 8)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + msgh_size_delta = (In0P->dataType.msgtl_header.msgt_inline) ? (In0P->dataType.msgtl_number + 3) & ~3 : sizeof(char *); +#if TypeCheck + if (msgh_size != 48 + msgh_size_delta) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + In1P = (Request *) ((char *) In0P + msgh_size_delta - 2048); + +#if TypeCheck + if (BAD_TYPECHECK(&In1P->offsetType, &offsetCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_io_write(In0P->Head.msgh_request_port, In0P->Head.msgh_reply_port, MACH_MSGH_BITS_REPLY(In0P->Head.msgh_bits), (In0P->dataType.msgtl_header.msgt_inline) ? In0P->data : *((char **)In0P->data), In0P->dataType.msgtl_number, In1P->offset, &OutP->amount); + if (OutP->RetCode == KERN_SUCCESS) + if (!In0P->dataType.msgtl_header.msgt_inline) + __mig_deallocate(* (vm_offset_t *) In0P->data, In0P->dataType.msgtl_number); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_size = 40; + + OutP->amountType = amountType; +} + +/* Routine io_read */ +mig_internal void _Xio_read + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t offsetType; + loff_t offset; + mach_msg_type_t amountType; + vm_size_t amount; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_long_t dataType; + char data[2048]; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_io_read + (io_t io_object, mach_port_t reply, mach_msg_type_name_t replyPoly, data_t *data, mach_msg_type_number_t *dataCnt, loff_t offset, vm_size_t amount); + + boolean_t msgh_simple; + auto const mach_msg_type_t offsetCheck = { + /* msgt_name = */ 11, + /* msgt_size = */ 64, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t amountCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_long_t dataType = { + { + /* msgt_name = */ 0, + /* msgt_size = */ 0, + /* msgt_number = */ 0, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ TRUE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }, + /* msgtl_name = */ 8, + /* msgtl_size = */ 8, + /* msgtl_number = */ 2048, + }; + + mach_msg_type_number_t dataCnt; + + char *dataP; + +#if TypeCheck + if ((In0P->Head.msgh_size != 44) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->offsetType, &offsetCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->amountType, &amountCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + dataP = OutP->data; + dataCnt = 2048; + + OutP->RetCode = S_io_read(In0P->Head.msgh_request_port, In0P->Head.msgh_reply_port, MACH_MSGH_BITS_REPLY(In0P->Head.msgh_bits), &dataP, &dataCnt, In0P->offset, In0P->amount); + if (OutP->RetCode != KERN_SUCCESS) + return; + + msgh_simple = TRUE; + + OutP->dataType = dataType; + if (dataP != OutP->data) { + OutP->dataType.msgtl_header.msgt_inline = FALSE; + OutP->dataType.msgtl_header.msgt_deallocate = TRUE; + *((char **)OutP->data) = dataP; + msgh_simple = FALSE; + } + + OutP->dataType.msgtl_number = dataCnt; + OutP->Head.msgh_size = 44 + ((OutP->dataType.msgtl_header.msgt_inline) ? (dataCnt + 3) & ~3 : sizeof(char *)); + + if (!msgh_simple) + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; +} + +/* Routine io_seek */ +mig_internal void _Xio_seek + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t offsetType; + loff_t offset; + mach_msg_type_t whenceType; + int whence; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t newpType; + loff_t newp; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_io_seek + (io_t io_object, mach_port_t reply, mach_msg_type_name_t replyPoly, loff_t offset, int whence, loff_t *newp); + + auto const mach_msg_type_t offsetCheck = { + /* msgt_name = */ 11, + /* msgt_size = */ 64, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t whenceCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t newpType = { + /* msgt_name = */ 11, + /* msgt_size = */ 64, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 44) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->offsetType, &offsetCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->whenceType, &whenceCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_io_seek(In0P->Head.msgh_request_port, In0P->Head.msgh_reply_port, MACH_MSGH_BITS_REPLY(In0P->Head.msgh_bits), In0P->offset, In0P->whence, &OutP->newp); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_size = 44; + + OutP->newpType = newpType; +} + +/* Routine io_readable */ +mig_internal void _Xio_readable + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t amountType; + vm_size_t amount; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_io_readable + (io_t io_object, mach_port_t reply, mach_msg_type_name_t replyPoly, vm_size_t *amount); + + auto const mach_msg_type_t amountType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_io_readable(In0P->Head.msgh_request_port, In0P->Head.msgh_reply_port, MACH_MSGH_BITS_REPLY(In0P->Head.msgh_bits), &OutP->amount); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_size = 40; + + OutP->amountType = amountType; +} + +/* Routine io_set_all_openmodes */ +mig_internal void _Xio_set_all_openmodes + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t newbitsType; + int newbits; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_io_set_all_openmodes + (io_t io_object, mach_port_t reply, mach_msg_type_name_t replyPoly, int newbits); + + auto const mach_msg_type_t newbitsCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->newbitsType, &newbitsCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_io_set_all_openmodes(In0P->Head.msgh_request_port, In0P->Head.msgh_reply_port, MACH_MSGH_BITS_REPLY(In0P->Head.msgh_bits), In0P->newbits); +} + +/* Routine io_get_openmodes */ +mig_internal void _Xio_get_openmodes + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t bitsType; + int bits; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_io_get_openmodes + (io_t io_object, mach_port_t reply, mach_msg_type_name_t replyPoly, int *bits); + + auto const mach_msg_type_t bitsType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_io_get_openmodes(In0P->Head.msgh_request_port, In0P->Head.msgh_reply_port, MACH_MSGH_BITS_REPLY(In0P->Head.msgh_bits), &OutP->bits); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_size = 40; + + OutP->bitsType = bitsType; +} + +/* Routine io_set_some_openmodes */ +mig_internal void _Xio_set_some_openmodes + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t bits_to_setType; + int bits_to_set; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_io_set_some_openmodes + (io_t io_object, mach_port_t reply, mach_msg_type_name_t replyPoly, int bits_to_set); + + auto const mach_msg_type_t bits_to_setCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->bits_to_setType, &bits_to_setCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_io_set_some_openmodes(In0P->Head.msgh_request_port, In0P->Head.msgh_reply_port, MACH_MSGH_BITS_REPLY(In0P->Head.msgh_bits), In0P->bits_to_set); +} + +/* Routine io_clear_some_openmodes */ +mig_internal void _Xio_clear_some_openmodes + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t bits_to_clearType; + int bits_to_clear; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_io_clear_some_openmodes + (io_t io_object, mach_port_t reply, mach_msg_type_name_t replyPoly, int bits_to_clear); + + auto const mach_msg_type_t bits_to_clearCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->bits_to_clearType, &bits_to_clearCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_io_clear_some_openmodes(In0P->Head.msgh_request_port, In0P->Head.msgh_reply_port, MACH_MSGH_BITS_REPLY(In0P->Head.msgh_bits), In0P->bits_to_clear); +} + +/* Routine io_async */ +mig_internal void _Xio_async + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t notify_portType; + mach_port_t notify_port; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t async_id_portType; + mach_port_t async_id_port; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_io_async + (io_t io_object, mach_port_t reply, mach_msg_type_name_t replyPoly, mach_port_t notify_port, mach_port_t *async_id_port, mach_msg_type_name_t *async_id_portPoly); + + boolean_t msgh_simple; + auto const mach_msg_type_t notify_portCheck = { + /* msgt_name = */ 17, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t async_id_portType = { + /* msgt_name = */ -1, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + mach_msg_type_name_t async_id_portPoly; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->notify_portType, ¬ify_portCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_io_async(In0P->Head.msgh_request_port, In0P->Head.msgh_reply_port, MACH_MSGH_BITS_REPLY(In0P->Head.msgh_bits), In0P->notify_port, &OutP->async_id_port, &async_id_portPoly); + if (OutP->RetCode != KERN_SUCCESS) + return; + + msgh_simple = TRUE; + OutP->Head.msgh_size = 40; + + OutP->async_id_portType = async_id_portType; + + if (MACH_MSG_TYPE_PORT_ANY(async_id_portPoly)) + msgh_simple = FALSE; + + OutP->async_id_portType.msgt_name = async_id_portPoly; + + if (!msgh_simple) + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; +} + +/* Routine io_mod_owner */ +mig_internal void _Xio_mod_owner + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t ownerType; + pid_t owner; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_io_mod_owner + (io_t io_object, mach_port_t reply, mach_msg_type_name_t replyPoly, pid_t owner); + + auto const mach_msg_type_t ownerCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->ownerType, &ownerCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_io_mod_owner(In0P->Head.msgh_request_port, In0P->Head.msgh_reply_port, MACH_MSGH_BITS_REPLY(In0P->Head.msgh_bits), In0P->owner); +} + +/* Routine io_get_owner */ +mig_internal void _Xio_get_owner + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t ownerType; + pid_t owner; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_io_get_owner + (io_t io_object, mach_port_t reply, mach_msg_type_name_t replyPoly, pid_t *owner); + + auto const mach_msg_type_t ownerType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_io_get_owner(In0P->Head.msgh_request_port, In0P->Head.msgh_reply_port, MACH_MSGH_BITS_REPLY(In0P->Head.msgh_bits), &OutP->owner); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_size = 40; + + OutP->ownerType = ownerType; +} + +/* Routine io_get_icky_async_id */ +mig_internal void _Xio_get_icky_async_id + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t icky_async_id_portType; + mach_port_t icky_async_id_port; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_io_get_icky_async_id + (io_t io_object, mach_port_t reply, mach_msg_type_name_t replyPoly, mach_port_t *icky_async_id_port, mach_msg_type_name_t *icky_async_id_portPoly); + + boolean_t msgh_simple; + auto const mach_msg_type_t icky_async_id_portType = { + /* msgt_name = */ -1, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + mach_msg_type_name_t icky_async_id_portPoly; + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_io_get_icky_async_id(In0P->Head.msgh_request_port, In0P->Head.msgh_reply_port, MACH_MSGH_BITS_REPLY(In0P->Head.msgh_bits), &OutP->icky_async_id_port, &icky_async_id_portPoly); + if (OutP->RetCode != KERN_SUCCESS) + return; + + msgh_simple = TRUE; + OutP->Head.msgh_size = 40; + + OutP->icky_async_id_portType = icky_async_id_portType; + + if (MACH_MSG_TYPE_PORT_ANY(icky_async_id_portPoly)) + msgh_simple = FALSE; + + OutP->icky_async_id_portType.msgt_name = icky_async_id_portPoly; + + if (!msgh_simple) + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; +} + +/* Routine io_select */ +mig_internal void _Xio_select + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t select_typeType; + int select_type; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t select_typeType; + int select_type; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_io_select + (io_t io_object, mach_port_t reply, mach_msg_type_name_t replyPoly, int *select_type); + + auto const mach_msg_type_t select_typeCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t select_typeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->select_typeType, &select_typeCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_io_select(In0P->Head.msgh_request_port, In0P->Head.msgh_reply_port, MACH_MSGH_BITS_REPLY(In0P->Head.msgh_bits), &In0P->select_type); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_size = 40; + + OutP->select_typeType = select_typeType; + + OutP->select_type = In0P->select_type; +} + +/* Routine io_stat */ +mig_internal void _Xio_stat + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t stat_infoType; + io_statbuf_t stat_info; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_io_stat + (io_t stat_object, mach_port_t reply, mach_msg_type_name_t replyPoly, io_statbuf_t *stat_info); + + auto const mach_msg_type_t stat_infoType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 32, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_io_stat(In0P->Head.msgh_request_port, In0P->Head.msgh_reply_port, MACH_MSGH_BITS_REPLY(In0P->Head.msgh_bits), &OutP->stat_info); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_size = 164; + + OutP->stat_infoType = stat_infoType; +} + +/* SimpleRoutine io_reauthenticate */ +mig_internal void _Xio_reauthenticate + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t rendezvous2Type; + mach_port_t rendezvous2; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_io_reauthenticate + (io_t auth_object, mach_port_t reply, mach_msg_type_name_t replyPoly, mach_port_t rendezvous2); + + auto const mach_msg_type_t rendezvous2Check = { + /* msgt_name = */ 17, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->rendezvous2Type, &rendezvous2Check)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_io_reauthenticate(In0P->Head.msgh_request_port, In0P->Head.msgh_reply_port, MACH_MSGH_BITS_REPLY(In0P->Head.msgh_bits), In0P->rendezvous2); +} + +/* Routine io_restrict_auth */ +mig_internal void _Xio_restrict_auth + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_long_t uidsType; + uid_t uids[512]; + mach_msg_type_long_t gidsType; + uid_t gids[512]; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t new_objectType; + mach_port_t new_object; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Request *In1P; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_io_restrict_auth + (io_t io_object, mach_port_t reply, mach_msg_type_name_t replyPoly, mach_port_t *new_object, mach_msg_type_name_t *new_objectPoly, idarray_t uids, mach_msg_type_number_t uidsCnt, idarray_t gids, mach_msg_type_number_t gidsCnt); + + boolean_t msgh_simple; + unsigned int msgh_size; + unsigned int msgh_size_delta; + + auto const mach_msg_type_t new_objectType = { + /* msgt_name = */ -1, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + mach_msg_type_name_t new_objectPoly; + +#if TypeCheck + msgh_size = In0P->Head.msgh_size; + msgh_simple = !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX); + if ((msgh_size < 48)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if ((In0P->uidsType.msgtl_header.msgt_longform != TRUE) || + (In0P->uidsType.msgtl_name != 2) || + (In0P->uidsType.msgtl_size != 32)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + msgh_size_delta = (In0P->uidsType.msgtl_header.msgt_inline) ? 4 * In0P->uidsType.msgtl_number : sizeof(uid_t *); +#if TypeCheck + if (msgh_size < 48 + msgh_size_delta) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } + msgh_size -= msgh_size_delta; +#endif /* TypeCheck */ + + In1P = (Request *) ((char *) In0P + msgh_size_delta - 2048); + +#if TypeCheck + if ((In1P->gidsType.msgtl_header.msgt_longform != TRUE) || + (In1P->gidsType.msgtl_name != 2) || + (In1P->gidsType.msgtl_size != 32)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (msgh_size != 48 + ((In1P->gidsType.msgtl_header.msgt_inline) ? 4 * In1P->gidsType.msgtl_number : sizeof(uid_t *))) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_io_restrict_auth(In0P->Head.msgh_request_port, In0P->Head.msgh_reply_port, MACH_MSGH_BITS_REPLY(In0P->Head.msgh_bits), &OutP->new_object, &new_objectPoly, (In0P->uidsType.msgtl_header.msgt_inline) ? In0P->uids : *((uid_t **)In0P->uids), In0P->uidsType.msgtl_number, (In1P->gidsType.msgtl_header.msgt_inline) ? In1P->gids : *((uid_t **)In1P->gids), In1P->gidsType.msgtl_number); + if (OutP->RetCode == KERN_SUCCESS) + if (!In1P->gidsType.msgtl_header.msgt_inline) + __mig_deallocate(* (vm_offset_t *) In1P->gids, 4 * In1P->gidsType.msgtl_number); + if (OutP->RetCode == KERN_SUCCESS) + if (!In0P->uidsType.msgtl_header.msgt_inline) + __mig_deallocate(* (vm_offset_t *) In0P->uids, 4 * In0P->uidsType.msgtl_number); + if (OutP->RetCode != KERN_SUCCESS) + return; + + msgh_simple = TRUE; + OutP->Head.msgh_size = 40; + + OutP->new_objectType = new_objectType; + + if (MACH_MSG_TYPE_PORT_ANY(new_objectPoly)) + msgh_simple = FALSE; + + OutP->new_objectType.msgt_name = new_objectPoly; + + if (!msgh_simple) + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; +} + +/* Routine io_duplicate */ +mig_internal void _Xio_duplicate + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t newportType; + mach_port_t newport; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_io_duplicate + (io_t io_object, mach_port_t reply, mach_msg_type_name_t replyPoly, mach_port_t *newport, mach_msg_type_name_t *newportPoly); + + boolean_t msgh_simple; + auto const mach_msg_type_t newportType = { + /* msgt_name = */ -1, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + mach_msg_type_name_t newportPoly; + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_io_duplicate(In0P->Head.msgh_request_port, In0P->Head.msgh_reply_port, MACH_MSGH_BITS_REPLY(In0P->Head.msgh_bits), &OutP->newport, &newportPoly); + if (OutP->RetCode != KERN_SUCCESS) + return; + + msgh_simple = TRUE; + OutP->Head.msgh_size = 40; + + OutP->newportType = newportType; + + if (MACH_MSG_TYPE_PORT_ANY(newportPoly)) + msgh_simple = FALSE; + + OutP->newportType.msgt_name = newportPoly; + + if (!msgh_simple) + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; +} + +/* Routine io_server_version */ +mig_internal void _Xio_server_version + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t server_nameType; + string_t server_name; + mach_msg_type_t server_major_versionType; + int server_major_version; + mach_msg_type_t server_minor_versionType; + int server_minor_version; + mach_msg_type_t server_edit_levelType; + int server_edit_level; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_io_server_version + (io_t vers_object, mach_port_t reply, mach_msg_type_name_t replyPoly, string_t server_name, int *server_major_version, int *server_minor_version, int *server_edit_level); + + auto const mach_msg_type_t server_nameType = { + /* msgt_name = */ MACH_MSG_TYPE_STRING_C, + /* msgt_size = */ 8, + /* msgt_number = */ 1024, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t server_major_versionType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t server_minor_versionType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t server_edit_levelType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_io_server_version(In0P->Head.msgh_request_port, In0P->Head.msgh_reply_port, MACH_MSGH_BITS_REPLY(In0P->Head.msgh_bits), OutP->server_name, &OutP->server_major_version, &OutP->server_minor_version, &OutP->server_edit_level); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_size = 1084; + + OutP->server_nameType = server_nameType; + + OutP->server_major_versionType = server_major_versionType; + + OutP->server_minor_versionType = server_minor_versionType; + + OutP->server_edit_levelType = server_edit_levelType; +} + +/* Routine io_map */ +mig_internal void _Xio_map + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t memobjrdType; + mach_port_t memobjrd; + mach_msg_type_t memobjwtType; + mach_port_t memobjwt; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_io_map + (io_t io_object, mach_port_t reply, mach_msg_type_name_t replyPoly, mach_port_t *memobjrd, mach_msg_type_name_t *memobjrdPoly, mach_port_t *memobjwt, mach_msg_type_name_t *memobjwtPoly); + + boolean_t msgh_simple; + auto const mach_msg_type_t memobjrdType = { + /* msgt_name = */ -1, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t memobjwtType = { + /* msgt_name = */ -1, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + mach_msg_type_name_t memobjrdPoly; + mach_msg_type_name_t memobjwtPoly; + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_io_map(In0P->Head.msgh_request_port, In0P->Head.msgh_reply_port, MACH_MSGH_BITS_REPLY(In0P->Head.msgh_bits), &OutP->memobjrd, &memobjrdPoly, &OutP->memobjwt, &memobjwtPoly); + if (OutP->RetCode != KERN_SUCCESS) + return; + + msgh_simple = TRUE; + OutP->Head.msgh_size = 48; + + OutP->memobjrdType = memobjrdType; + + if (MACH_MSG_TYPE_PORT_ANY(memobjrdPoly)) + msgh_simple = FALSE; + + OutP->memobjrdType.msgt_name = memobjrdPoly; + + OutP->memobjwtType = memobjwtType; + + if (MACH_MSG_TYPE_PORT_ANY(memobjwtPoly)) + msgh_simple = FALSE; + + OutP->memobjwtType.msgt_name = memobjwtPoly; + + if (!msgh_simple) + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; +} + +/* Routine io_map_cntl */ +mig_internal void _Xio_map_cntl + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t memobjType; + mach_port_t memobj; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_io_map_cntl + (io_t io_object, mach_port_t reply, mach_msg_type_name_t replyPoly, mach_port_t *memobj, mach_msg_type_name_t *memobjPoly); + + boolean_t msgh_simple; + auto const mach_msg_type_t memobjType = { + /* msgt_name = */ -1, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + mach_msg_type_name_t memobjPoly; + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_io_map_cntl(In0P->Head.msgh_request_port, In0P->Head.msgh_reply_port, MACH_MSGH_BITS_REPLY(In0P->Head.msgh_bits), &OutP->memobj, &memobjPoly); + if (OutP->RetCode != KERN_SUCCESS) + return; + + msgh_simple = TRUE; + OutP->Head.msgh_size = 40; + + OutP->memobjType = memobjType; + + if (MACH_MSG_TYPE_PORT_ANY(memobjPoly)) + msgh_simple = FALSE; + + OutP->memobjType.msgt_name = memobjPoly; + + if (!msgh_simple) + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; +} + +/* Routine io_get_conch */ +mig_internal void _Xio_get_conch + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_io_get_conch + (io_t io_object, mach_port_t reply, mach_msg_type_name_t replyPoly); + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_io_get_conch(In0P->Head.msgh_request_port, In0P->Head.msgh_reply_port, MACH_MSGH_BITS_REPLY(In0P->Head.msgh_bits)); +} + +/* Routine io_release_conch */ +mig_internal void _Xio_release_conch + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_io_release_conch + (io_t io_object, mach_port_t reply, mach_msg_type_name_t replyPoly); + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_io_release_conch(In0P->Head.msgh_request_port, In0P->Head.msgh_reply_port, MACH_MSGH_BITS_REPLY(In0P->Head.msgh_bits)); +} + +/* Routine io_eofnotify */ +mig_internal void _Xio_eofnotify + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_io_eofnotify + (io_t io_object, mach_port_t reply, mach_msg_type_name_t replyPoly); + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_io_eofnotify(In0P->Head.msgh_request_port, In0P->Head.msgh_reply_port, MACH_MSGH_BITS_REPLY(In0P->Head.msgh_bits)); +} + +/* Routine io_prenotify */ +mig_internal void _Xio_prenotify + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t write_startType; + vm_offset_t write_start; + mach_msg_type_t write_endType; + vm_offset_t write_end; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_io_prenotify + (io_t io_object, mach_port_t reply, mach_msg_type_name_t replyPoly, vm_offset_t write_start, vm_offset_t write_end); + + auto const mach_msg_type_t write_startCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t write_endCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->write_startType, &write_startCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->write_endType, &write_endCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_io_prenotify(In0P->Head.msgh_request_port, In0P->Head.msgh_reply_port, MACH_MSGH_BITS_REPLY(In0P->Head.msgh_bits), In0P->write_start, In0P->write_end); +} + +/* Routine io_postnotify */ +mig_internal void _Xio_postnotify + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t write_startType; + vm_offset_t write_start; + mach_msg_type_t write_endType; + vm_offset_t write_end; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_io_postnotify + (io_t io_object, mach_port_t reply, mach_msg_type_name_t replyPoly, vm_offset_t write_start, vm_offset_t write_end); + + auto const mach_msg_type_t write_startCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t write_endCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->write_startType, &write_startCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->write_endType, &write_endCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_io_postnotify(In0P->Head.msgh_request_port, In0P->Head.msgh_reply_port, MACH_MSGH_BITS_REPLY(In0P->Head.msgh_bits), In0P->write_start, In0P->write_end); +} + +/* Routine io_readnotify */ +mig_internal void _Xio_readnotify + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_io_readnotify + (io_t io_object, mach_port_t reply, mach_msg_type_name_t replyPoly); + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_io_readnotify(In0P->Head.msgh_request_port, In0P->Head.msgh_reply_port, MACH_MSGH_BITS_REPLY(In0P->Head.msgh_bits)); +} + +/* Routine io_readsleep */ +mig_internal void _Xio_readsleep + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_io_readsleep + (io_t io_object, mach_port_t reply, mach_msg_type_name_t replyPoly); + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_io_readsleep(In0P->Head.msgh_request_port, In0P->Head.msgh_reply_port, MACH_MSGH_BITS_REPLY(In0P->Head.msgh_bits)); +} + +/* Routine io_sigio */ +mig_internal void _Xio_sigio + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_io_sigio + (io_t io_object, mach_port_t reply, mach_msg_type_name_t replyPoly); + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_io_sigio(In0P->Head.msgh_request_port, In0P->Head.msgh_reply_port, MACH_MSGH_BITS_REPLY(In0P->Head.msgh_bits)); +} + +/* Routine io_pathconf */ +mig_internal void _Xio_pathconf + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t nameType; + int name; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t valueType; + int value; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_io_pathconf + (io_t io_object, mach_port_t reply, mach_msg_type_name_t replyPoly, int name, int *value); + + auto const mach_msg_type_t nameCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t valueType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->nameType, &nameCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_io_pathconf(In0P->Head.msgh_request_port, In0P->Head.msgh_reply_port, MACH_MSGH_BITS_REPLY(In0P->Head.msgh_bits), In0P->name, &OutP->value); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_size = 40; + + OutP->valueType = valueType; +} + +/* Routine io_identity */ +mig_internal void _Xio_identity + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t idportType; + mach_port_t idport; + mach_msg_type_t fsidportType; + mach_port_t fsidport; + mach_msg_type_t filenoType; + ino64_t fileno; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_io_identity + (io_t io_object, mach_port_t reply, mach_msg_type_name_t replyPoly, mach_port_t *idport, mach_msg_type_name_t *idportPoly, mach_port_t *fsidport, mach_msg_type_name_t *fsidportPoly, ino64_t *fileno); + + boolean_t msgh_simple; + auto const mach_msg_type_t idportType = { + /* msgt_name = */ -1, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t fsidportType = { + /* msgt_name = */ -1, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t filenoType = { + /* msgt_name = */ 11, + /* msgt_size = */ 64, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + mach_msg_type_name_t idportPoly; + mach_msg_type_name_t fsidportPoly; + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_io_identity(In0P->Head.msgh_request_port, In0P->Head.msgh_reply_port, MACH_MSGH_BITS_REPLY(In0P->Head.msgh_bits), &OutP->idport, &idportPoly, &OutP->fsidport, &fsidportPoly, &OutP->fileno); + if (OutP->RetCode != KERN_SUCCESS) + return; + + msgh_simple = TRUE; + OutP->Head.msgh_size = 60; + + OutP->idportType = idportType; + + if (MACH_MSG_TYPE_PORT_ANY(idportPoly)) + msgh_simple = FALSE; + + OutP->idportType.msgt_name = idportPoly; + + OutP->fsidportType = fsidportType; + + if (MACH_MSG_TYPE_PORT_ANY(fsidportPoly)) + msgh_simple = FALSE; + + OutP->fsidportType.msgt_name = fsidportPoly; + + OutP->filenoType = filenoType; + + if (!msgh_simple) + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; +} + +/* Routine io_revoke */ +mig_internal void _Xio_revoke + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_io_revoke + (io_t io_object, mach_port_t reply, mach_msg_type_name_t replyPoly); + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_io_revoke(In0P->Head.msgh_request_port, In0P->Head.msgh_reply_port, MACH_MSGH_BITS_REPLY(In0P->Head.msgh_bits)); +} + +static mig_routine_t io_server_routines[] = { + _Xio_write, + _Xio_read, + _Xio_seek, + _Xio_readable, + _Xio_set_all_openmodes, + _Xio_get_openmodes, + _Xio_set_some_openmodes, + _Xio_clear_some_openmodes, + _Xio_async, + _Xio_mod_owner, + _Xio_get_owner, + _Xio_get_icky_async_id, + _Xio_select, + _Xio_stat, + _Xio_reauthenticate, + _Xio_restrict_auth, + _Xio_duplicate, + _Xio_server_version, + _Xio_map, + _Xio_map_cntl, + _Xio_get_conch, + _Xio_release_conch, + _Xio_eofnotify, + _Xio_prenotify, + _Xio_postnotify, + _Xio_readnotify, + _Xio_readsleep, + _Xio_sigio, + _Xio_pathconf, + _Xio_identity, + _Xio_revoke, +}; + +mig_external boolean_t io_server + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + register mach_msg_header_t *InP = InHeadP; + register mig_reply_header_t *OutP = (mig_reply_header_t *) OutHeadP; + + auto const mach_msg_type_t RetCodeType = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + register mig_routine_t routine; + + OutP->Head.msgh_bits = MACH_MSGH_BITS(MACH_MSGH_BITS_REPLY(InP->msgh_bits), 0); + OutP->Head.msgh_size = sizeof *OutP; + OutP->Head.msgh_remote_port = InP->msgh_reply_port; + OutP->Head.msgh_local_port = MACH_PORT_NULL; + OutP->Head.msgh_seqno = 0; + OutP->Head.msgh_id = InP->msgh_id + 100; + + OutP->RetCodeType = RetCodeType; + + if ((InP->msgh_id > 21030) || (InP->msgh_id < 21000) || + ((routine = io_server_routines[InP->msgh_id - 21000]) == 0)) { + OutP->RetCode = MIG_BAD_ID; + return FALSE; + } + (*routine) (InP, &OutP->Head); + return TRUE; +} + +mig_external mig_routine_t io_server_routine + (const mach_msg_header_t *InHeadP) +{ + register int msgh_id; + + msgh_id = InHeadP->msgh_id - 21000; + + if ((msgh_id > 30) || (msgh_id < 0)) + return 0; + + return io_server_routines[msgh_id]; +} + diff --git a/boot-proxy-exc/ioServer.d b/boot-proxy-exc/ioServer.d new file mode 100644 index 00000000..1d717e6b --- /dev/null +++ b/boot-proxy-exc/ioServer.d @@ -0,0 +1,51 @@ +ioServer.o ioServer_pic.o ioServer_p.o ioServer.d: ioServer.c /usr/local/include/mach/boolean.h \ + /usr/local/include/mach/machine/boolean.h \ + /usr/local/include/mach/kern_return.h \ + /usr/local/include/mach/machine/kern_return.h \ + /usr/local/include/mach/message.h /usr/local/include/mach/port.h \ + /usr/local/include/mach/machine/vm_types.h \ + /usr/local/include/mach/mig_errors.h /usr/include/mach/mig_support.h \ + /usr/local/include/mach/std_types.h /usr/include/sys/types.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h /usr/include/gnu/stubs-pthread.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/time.h /usr/lib/gcc/i486-gnu/4.2.4/include/stddef.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/bits/byteswap.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/pthread/pthreadtypes.h \ + /usr/include/xlocale.h /usr/include/bits/pthread.h \ + /usr/include/bits/thread-attr.h /usr/include/sched.h \ + /usr/include/bits/sched.h /usr/include/bits/mutex-attr.h \ + /usr/include/bits/mutex.h /usr/include/bits/spin-lock.h \ + /usr/include/bits/condition-attr.h /usr/include/bits/condition.h \ + /usr/include/bits/rwlock-attr.h /usr/include/bits/rwlock.h \ + /usr/include/bits/barrier-attr.h /usr/include/bits/barrier.h \ + /usr/include/bits/thread-specific.h /usr/include/bits/once.h \ + /usr/include/string.h /usr/include/bits/string.h \ + /usr/include/bits/string2.h /usr/include/stdlib.h \ + /usr/local/include/mach/mach_types.h \ + /usr/local/include/mach/host_info.h /usr/local/include/mach/machine.h \ + /usr/local/include/mach/memory_object.h \ + /usr/local/include/mach/pc_sample.h \ + /usr/local/include/mach/processor_info.h \ + /usr/local/include/mach/task_info.h \ + /usr/local/include/mach/time_value.h \ + /usr/local/include/mach/task_special_ports.h \ + /usr/local/include/mach/thread_info.h /usr/local/include/mach/policy.h \ + /usr/local/include/mach/thread_special_ports.h \ + /usr/local/include/mach/thread_status.h \ + /usr/local/include/mach/machine/thread_status.h \ + /usr/local/include/mach/machine/fp_reg.h \ + /usr/local/include/mach/vm_attributes.h \ + /usr/local/include/mach/vm_inherit.h /usr/local/include/mach/vm_prot.h \ + /usr/local/include/mach/vm_statistics.h \ + /usr/local/include/device/device_types.h \ + /usr/local/include/device/net_status.h /usr/local/include/device/bpf.h \ + /usr/include/sys/stat.h /usr/include/bits/stat.h \ + /usr/include/sys/statfs.h /usr/include/bits/statfs.h \ + /usr/include/sys/resource.h /usr/include/bits/resource.h \ + /usr/include/sys/utsname.h /usr/include/bits/utsname.h \ + ../hurd/hurd_types.h /usr/include/errno.h /usr/include/bits/errno.h diff --git a/boot-proxy-exc/ioServer.o b/boot-proxy-exc/ioServer.o Binary files differnew file mode 100644 index 00000000..c10f4932 --- /dev/null +++ b/boot-proxy-exc/ioServer.o diff --git a/boot-proxy-exc/io_S.h b/boot-proxy-exc/io_S.h new file mode 100644 index 00000000..847bff40 --- /dev/null +++ b/boot-proxy-exc/io_S.h @@ -0,0 +1,782 @@ +#ifndef _io_server_ +#define _io_server_ + +/* Module io */ + +#include <mach/kern_return.h> +#include <mach/port.h> +#include <mach/message.h> + +#include <mach/std_types.h> +#include <mach/mach_types.h> +#include <device/device_types.h> +#include <device/net_status.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/statfs.h> +#include <sys/resource.h> +#include <sys/utsname.h> +#include <hurd/hurd_types.h> + +/* Routine io_write */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_io_write +#if defined(LINTLIBRARY) + (io_object, reply, replyPoly, data, dataCnt, offset, amount) + io_t io_object; + mach_port_t reply; + mach_msg_type_name_t replyPoly; + data_t data; + mach_msg_type_number_t dataCnt; + loff_t offset; + vm_size_t *amount; +{ return S_io_write(io_object, reply, replyPoly, data, dataCnt, offset, amount); } +#else +( + io_t io_object, + mach_port_t reply, + mach_msg_type_name_t replyPoly, + data_t data, + mach_msg_type_number_t dataCnt, + loff_t offset, + vm_size_t *amount +); +#endif + +/* Routine io_read */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_io_read +#if defined(LINTLIBRARY) + (io_object, reply, replyPoly, data, dataCnt, offset, amount) + io_t io_object; + mach_port_t reply; + mach_msg_type_name_t replyPoly; + data_t *data; + mach_msg_type_number_t *dataCnt; + loff_t offset; + vm_size_t amount; +{ return S_io_read(io_object, reply, replyPoly, data, dataCnt, offset, amount); } +#else +( + io_t io_object, + mach_port_t reply, + mach_msg_type_name_t replyPoly, + data_t *data, + mach_msg_type_number_t *dataCnt, + loff_t offset, + vm_size_t amount +); +#endif + +/* Routine io_seek */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_io_seek +#if defined(LINTLIBRARY) + (io_object, reply, replyPoly, offset, whence, newp) + io_t io_object; + mach_port_t reply; + mach_msg_type_name_t replyPoly; + loff_t offset; + int whence; + loff_t *newp; +{ return S_io_seek(io_object, reply, replyPoly, offset, whence, newp); } +#else +( + io_t io_object, + mach_port_t reply, + mach_msg_type_name_t replyPoly, + loff_t offset, + int whence, + loff_t *newp +); +#endif + +/* Routine io_readable */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_io_readable +#if defined(LINTLIBRARY) + (io_object, reply, replyPoly, amount) + io_t io_object; + mach_port_t reply; + mach_msg_type_name_t replyPoly; + vm_size_t *amount; +{ return S_io_readable(io_object, reply, replyPoly, amount); } +#else +( + io_t io_object, + mach_port_t reply, + mach_msg_type_name_t replyPoly, + vm_size_t *amount +); +#endif + +/* Routine io_set_all_openmodes */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_io_set_all_openmodes +#if defined(LINTLIBRARY) + (io_object, reply, replyPoly, newbits) + io_t io_object; + mach_port_t reply; + mach_msg_type_name_t replyPoly; + int newbits; +{ return S_io_set_all_openmodes(io_object, reply, replyPoly, newbits); } +#else +( + io_t io_object, + mach_port_t reply, + mach_msg_type_name_t replyPoly, + int newbits +); +#endif + +/* Routine io_get_openmodes */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_io_get_openmodes +#if defined(LINTLIBRARY) + (io_object, reply, replyPoly, bits) + io_t io_object; + mach_port_t reply; + mach_msg_type_name_t replyPoly; + int *bits; +{ return S_io_get_openmodes(io_object, reply, replyPoly, bits); } +#else +( + io_t io_object, + mach_port_t reply, + mach_msg_type_name_t replyPoly, + int *bits +); +#endif + +/* Routine io_set_some_openmodes */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_io_set_some_openmodes +#if defined(LINTLIBRARY) + (io_object, reply, replyPoly, bits_to_set) + io_t io_object; + mach_port_t reply; + mach_msg_type_name_t replyPoly; + int bits_to_set; +{ return S_io_set_some_openmodes(io_object, reply, replyPoly, bits_to_set); } +#else +( + io_t io_object, + mach_port_t reply, + mach_msg_type_name_t replyPoly, + int bits_to_set +); +#endif + +/* Routine io_clear_some_openmodes */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_io_clear_some_openmodes +#if defined(LINTLIBRARY) + (io_object, reply, replyPoly, bits_to_clear) + io_t io_object; + mach_port_t reply; + mach_msg_type_name_t replyPoly; + int bits_to_clear; +{ return S_io_clear_some_openmodes(io_object, reply, replyPoly, bits_to_clear); } +#else +( + io_t io_object, + mach_port_t reply, + mach_msg_type_name_t replyPoly, + int bits_to_clear +); +#endif + +/* Routine io_async */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_io_async +#if defined(LINTLIBRARY) + (io_object, reply, replyPoly, notify_port, async_id_port, async_id_portPoly) + io_t io_object; + mach_port_t reply; + mach_msg_type_name_t replyPoly; + mach_port_t notify_port; + mach_port_t *async_id_port; + mach_msg_type_name_t *async_id_portPoly; +{ return S_io_async(io_object, reply, replyPoly, notify_port, async_id_port, async_id_portPoly); } +#else +( + io_t io_object, + mach_port_t reply, + mach_msg_type_name_t replyPoly, + mach_port_t notify_port, + mach_port_t *async_id_port, + mach_msg_type_name_t *async_id_portPoly +); +#endif + +/* Routine io_mod_owner */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_io_mod_owner +#if defined(LINTLIBRARY) + (io_object, reply, replyPoly, owner) + io_t io_object; + mach_port_t reply; + mach_msg_type_name_t replyPoly; + pid_t owner; +{ return S_io_mod_owner(io_object, reply, replyPoly, owner); } +#else +( + io_t io_object, + mach_port_t reply, + mach_msg_type_name_t replyPoly, + pid_t owner +); +#endif + +/* Routine io_get_owner */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_io_get_owner +#if defined(LINTLIBRARY) + (io_object, reply, replyPoly, owner) + io_t io_object; + mach_port_t reply; + mach_msg_type_name_t replyPoly; + pid_t *owner; +{ return S_io_get_owner(io_object, reply, replyPoly, owner); } +#else +( + io_t io_object, + mach_port_t reply, + mach_msg_type_name_t replyPoly, + pid_t *owner +); +#endif + +/* Routine io_get_icky_async_id */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_io_get_icky_async_id +#if defined(LINTLIBRARY) + (io_object, reply, replyPoly, icky_async_id_port, icky_async_id_portPoly) + io_t io_object; + mach_port_t reply; + mach_msg_type_name_t replyPoly; + mach_port_t *icky_async_id_port; + mach_msg_type_name_t *icky_async_id_portPoly; +{ return S_io_get_icky_async_id(io_object, reply, replyPoly, icky_async_id_port, icky_async_id_portPoly); } +#else +( + io_t io_object, + mach_port_t reply, + mach_msg_type_name_t replyPoly, + mach_port_t *icky_async_id_port, + mach_msg_type_name_t *icky_async_id_portPoly +); +#endif + +/* Routine io_select */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_io_select +#if defined(LINTLIBRARY) + (io_object, reply, replyPoly, select_type) + io_t io_object; + mach_port_t reply; + mach_msg_type_name_t replyPoly; + int *select_type; +{ return S_io_select(io_object, reply, replyPoly, select_type); } +#else +( + io_t io_object, + mach_port_t reply, + mach_msg_type_name_t replyPoly, + int *select_type +); +#endif + +/* Routine io_stat */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_io_stat +#if defined(LINTLIBRARY) + (stat_object, reply, replyPoly, stat_info) + io_t stat_object; + mach_port_t reply; + mach_msg_type_name_t replyPoly; + io_statbuf_t *stat_info; +{ return S_io_stat(stat_object, reply, replyPoly, stat_info); } +#else +( + io_t stat_object, + mach_port_t reply, + mach_msg_type_name_t replyPoly, + io_statbuf_t *stat_info +); +#endif + +/* SimpleRoutine io_reauthenticate */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_io_reauthenticate +#if defined(LINTLIBRARY) + (auth_object, reply, replyPoly, rendezvous2) + io_t auth_object; + mach_port_t reply; + mach_msg_type_name_t replyPoly; + mach_port_t rendezvous2; +{ return S_io_reauthenticate(auth_object, reply, replyPoly, rendezvous2); } +#else +( + io_t auth_object, + mach_port_t reply, + mach_msg_type_name_t replyPoly, + mach_port_t rendezvous2 +); +#endif + +/* Routine io_restrict_auth */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_io_restrict_auth +#if defined(LINTLIBRARY) + (io_object, reply, replyPoly, new_object, new_objectPoly, uids, uidsCnt, gids, gidsCnt) + io_t io_object; + mach_port_t reply; + mach_msg_type_name_t replyPoly; + mach_port_t *new_object; + mach_msg_type_name_t *new_objectPoly; + idarray_t uids; + mach_msg_type_number_t uidsCnt; + idarray_t gids; + mach_msg_type_number_t gidsCnt; +{ return S_io_restrict_auth(io_object, reply, replyPoly, new_object, new_objectPoly, uids, uidsCnt, gids, gidsCnt); } +#else +( + io_t io_object, + mach_port_t reply, + mach_msg_type_name_t replyPoly, + mach_port_t *new_object, + mach_msg_type_name_t *new_objectPoly, + idarray_t uids, + mach_msg_type_number_t uidsCnt, + idarray_t gids, + mach_msg_type_number_t gidsCnt +); +#endif + +/* Routine io_duplicate */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_io_duplicate +#if defined(LINTLIBRARY) + (io_object, reply, replyPoly, newport, newportPoly) + io_t io_object; + mach_port_t reply; + mach_msg_type_name_t replyPoly; + mach_port_t *newport; + mach_msg_type_name_t *newportPoly; +{ return S_io_duplicate(io_object, reply, replyPoly, newport, newportPoly); } +#else +( + io_t io_object, + mach_port_t reply, + mach_msg_type_name_t replyPoly, + mach_port_t *newport, + mach_msg_type_name_t *newportPoly +); +#endif + +/* Routine io_server_version */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_io_server_version +#if defined(LINTLIBRARY) + (vers_object, reply, replyPoly, server_name, server_major_version, server_minor_version, server_edit_level) + io_t vers_object; + mach_port_t reply; + mach_msg_type_name_t replyPoly; + string_t server_name; + int *server_major_version; + int *server_minor_version; + int *server_edit_level; +{ return S_io_server_version(vers_object, reply, replyPoly, server_name, server_major_version, server_minor_version, server_edit_level); } +#else +( + io_t vers_object, + mach_port_t reply, + mach_msg_type_name_t replyPoly, + string_t server_name, + int *server_major_version, + int *server_minor_version, + int *server_edit_level +); +#endif + +/* Routine io_map */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_io_map +#if defined(LINTLIBRARY) + (io_object, reply, replyPoly, memobjrd, memobjrdPoly, memobjwt, memobjwtPoly) + io_t io_object; + mach_port_t reply; + mach_msg_type_name_t replyPoly; + mach_port_t *memobjrd; + mach_msg_type_name_t *memobjrdPoly; + mach_port_t *memobjwt; + mach_msg_type_name_t *memobjwtPoly; +{ return S_io_map(io_object, reply, replyPoly, memobjrd, memobjrdPoly, memobjwt, memobjwtPoly); } +#else +( + io_t io_object, + mach_port_t reply, + mach_msg_type_name_t replyPoly, + mach_port_t *memobjrd, + mach_msg_type_name_t *memobjrdPoly, + mach_port_t *memobjwt, + mach_msg_type_name_t *memobjwtPoly +); +#endif + +/* Routine io_map_cntl */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_io_map_cntl +#if defined(LINTLIBRARY) + (io_object, reply, replyPoly, memobj, memobjPoly) + io_t io_object; + mach_port_t reply; + mach_msg_type_name_t replyPoly; + mach_port_t *memobj; + mach_msg_type_name_t *memobjPoly; +{ return S_io_map_cntl(io_object, reply, replyPoly, memobj, memobjPoly); } +#else +( + io_t io_object, + mach_port_t reply, + mach_msg_type_name_t replyPoly, + mach_port_t *memobj, + mach_msg_type_name_t *memobjPoly +); +#endif + +/* Routine io_get_conch */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_io_get_conch +#if defined(LINTLIBRARY) + (io_object, reply, replyPoly) + io_t io_object; + mach_port_t reply; + mach_msg_type_name_t replyPoly; +{ return S_io_get_conch(io_object, reply, replyPoly); } +#else +( + io_t io_object, + mach_port_t reply, + mach_msg_type_name_t replyPoly +); +#endif + +/* Routine io_release_conch */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_io_release_conch +#if defined(LINTLIBRARY) + (io_object, reply, replyPoly) + io_t io_object; + mach_port_t reply; + mach_msg_type_name_t replyPoly; +{ return S_io_release_conch(io_object, reply, replyPoly); } +#else +( + io_t io_object, + mach_port_t reply, + mach_msg_type_name_t replyPoly +); +#endif + +/* Routine io_eofnotify */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_io_eofnotify +#if defined(LINTLIBRARY) + (io_object, reply, replyPoly) + io_t io_object; + mach_port_t reply; + mach_msg_type_name_t replyPoly; +{ return S_io_eofnotify(io_object, reply, replyPoly); } +#else +( + io_t io_object, + mach_port_t reply, + mach_msg_type_name_t replyPoly +); +#endif + +/* Routine io_prenotify */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_io_prenotify +#if defined(LINTLIBRARY) + (io_object, reply, replyPoly, write_start, write_end) + io_t io_object; + mach_port_t reply; + mach_msg_type_name_t replyPoly; + vm_offset_t write_start; + vm_offset_t write_end; +{ return S_io_prenotify(io_object, reply, replyPoly, write_start, write_end); } +#else +( + io_t io_object, + mach_port_t reply, + mach_msg_type_name_t replyPoly, + vm_offset_t write_start, + vm_offset_t write_end +); +#endif + +/* Routine io_postnotify */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_io_postnotify +#if defined(LINTLIBRARY) + (io_object, reply, replyPoly, write_start, write_end) + io_t io_object; + mach_port_t reply; + mach_msg_type_name_t replyPoly; + vm_offset_t write_start; + vm_offset_t write_end; +{ return S_io_postnotify(io_object, reply, replyPoly, write_start, write_end); } +#else +( + io_t io_object, + mach_port_t reply, + mach_msg_type_name_t replyPoly, + vm_offset_t write_start, + vm_offset_t write_end +); +#endif + +/* Routine io_readnotify */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_io_readnotify +#if defined(LINTLIBRARY) + (io_object, reply, replyPoly) + io_t io_object; + mach_port_t reply; + mach_msg_type_name_t replyPoly; +{ return S_io_readnotify(io_object, reply, replyPoly); } +#else +( + io_t io_object, + mach_port_t reply, + mach_msg_type_name_t replyPoly +); +#endif + +/* Routine io_readsleep */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_io_readsleep +#if defined(LINTLIBRARY) + (io_object, reply, replyPoly) + io_t io_object; + mach_port_t reply; + mach_msg_type_name_t replyPoly; +{ return S_io_readsleep(io_object, reply, replyPoly); } +#else +( + io_t io_object, + mach_port_t reply, + mach_msg_type_name_t replyPoly +); +#endif + +/* Routine io_sigio */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_io_sigio +#if defined(LINTLIBRARY) + (io_object, reply, replyPoly) + io_t io_object; + mach_port_t reply; + mach_msg_type_name_t replyPoly; +{ return S_io_sigio(io_object, reply, replyPoly); } +#else +( + io_t io_object, + mach_port_t reply, + mach_msg_type_name_t replyPoly +); +#endif + +/* Routine io_pathconf */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_io_pathconf +#if defined(LINTLIBRARY) + (io_object, reply, replyPoly, name, value) + io_t io_object; + mach_port_t reply; + mach_msg_type_name_t replyPoly; + int name; + int *value; +{ return S_io_pathconf(io_object, reply, replyPoly, name, value); } +#else +( + io_t io_object, + mach_port_t reply, + mach_msg_type_name_t replyPoly, + int name, + int *value +); +#endif + +/* Routine io_identity */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_io_identity +#if defined(LINTLIBRARY) + (io_object, reply, replyPoly, idport, idportPoly, fsidport, fsidportPoly, fileno) + io_t io_object; + mach_port_t reply; + mach_msg_type_name_t replyPoly; + mach_port_t *idport; + mach_msg_type_name_t *idportPoly; + mach_port_t *fsidport; + mach_msg_type_name_t *fsidportPoly; + ino64_t *fileno; +{ return S_io_identity(io_object, reply, replyPoly, idport, idportPoly, fsidport, fsidportPoly, fileno); } +#else +( + io_t io_object, + mach_port_t reply, + mach_msg_type_name_t replyPoly, + mach_port_t *idport, + mach_msg_type_name_t *idportPoly, + mach_port_t *fsidport, + mach_msg_type_name_t *fsidportPoly, + ino64_t *fileno +); +#endif + +/* Routine io_revoke */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_io_revoke +#if defined(LINTLIBRARY) + (io_object, reply, replyPoly) + io_t io_object; + mach_port_t reply; + mach_msg_type_name_t replyPoly; +{ return S_io_revoke(io_object, reply, replyPoly); } +#else +( + io_t io_object, + mach_port_t reply, + mach_msg_type_name_t replyPoly +); +#endif + +#endif /* not defined(_io_server_) */ diff --git a/boot-proxy-exc/io_reply.udefs.d b/boot-proxy-exc/io_reply.udefs.d new file mode 100644 index 00000000..e8395a61 --- /dev/null +++ b/boot-proxy-exc/io_reply.udefs.d @@ -0,0 +1,5 @@ +io_replyUser.c io_reply_U.h: ../hurd/io_reply.defs ../hurd/hurd_types.defs \ + /usr/local/include/mach/std_types.defs \ + /usr/local/include/mach/machine/machine_types.defs \ + /usr/local/include/mach/mach_types.defs \ + /usr/local/include/device/device_types.defs /usr/include/bits/utsname.h diff --git a/boot-proxy-exc/io_replyUser.c b/boot-proxy-exc/io_replyUser.c new file mode 100644 index 00000000..046033fa --- /dev/null +++ b/boot-proxy-exc/io_replyUser.c @@ -0,0 +1,1600 @@ +#ifndef _GNU_SOURCE +#define _GNU_SOURCE 1 +#endif + +#include "io_reply_U.h" +#define EXPORT_BOOLEAN +#include <mach/boolean.h> +#include <mach/kern_return.h> +#include <mach/message.h> +#include <mach/notify.h> +#include <mach/mach_types.h> +#include <mach/mig_errors.h> +#include <mach/mig_support.h> +#include <mach/msg_type.h> +/* LINTLIBRARY */ + +#ifndef mig_internal +#define mig_internal static +#endif + +#ifndef mig_external +#define mig_external +#endif + +#ifndef TypeCheck +#define TypeCheck 1 +#endif + +#ifndef UseExternRCSId +#define UseExternRCSId 1 +#endif + +#define BAD_TYPECHECK(type, check) ({\ + union { mach_msg_type_t t; unsigned32_t w; } _t, _c;\ + _t.t = *(type); _c.t = *(check); _t.w != _c.w; }) +#define msgh_request_port msgh_remote_port +#define msgh_reply_port msgh_local_port + +#include <mach/std_types.h> +#include <mach/mach_types.h> +#include <device/device_types.h> +#include <device/net_status.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/statfs.h> +#include <sys/resource.h> +#include <sys/utsname.h> +#include <hurd/hurd_types.h> + +/* SimpleRoutine io_write_reply */ +mig_external kern_return_t io_write_reply +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code, + vm_size_t amount +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t return_codeType; + kern_return_t return_code; + mach_msg_type_t amountType; + vm_size_t amount; + } Request; + + union { + Request In; + } Mess; + + register Request *InP = &Mess.In; + + + auto const mach_msg_type_t return_codeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t amountType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->return_codeType = return_codeType; + + InP->return_code = return_code; + + InP->amountType = amountType; + + InP->amount = amount; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(replyPoly, 0); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = reply; + InP->Head.msgh_reply_port = MACH_PORT_NULL; + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 21100; + + return __mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, 40, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); +} + +/* SimpleRoutine io_read_reply */ +mig_external kern_return_t io_read_reply +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code, + data_t data, + mach_msg_type_number_t dataCnt +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t return_codeType; + kern_return_t return_code; + mach_msg_type_long_t dataType; + char data[2048]; + } Request; + + union { + Request In; + } Mess; + + register Request *InP = &Mess.In; + + boolean_t msgh_simple = TRUE; + unsigned int msgh_size; + + auto const mach_msg_type_t return_codeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_long_t dataType = { + { + /* msgt_name = */ 0, + /* msgt_size = */ 0, + /* msgt_number = */ 0, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ TRUE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }, + /* msgtl_name = */ 8, + /* msgtl_size = */ 8, + /* msgtl_number = */ 2048, + }; + + if (MACH_MSG_TYPE_PORT_ANY(replyPoly)) + msgh_simple = FALSE; + + InP->return_codeType = return_codeType; + + InP->return_code = return_code; + + InP->dataType = dataType; + + if (dataCnt > 2048) { + InP->dataType.msgtl_header.msgt_inline = FALSE; + *((char **)InP->data) = data; + msgh_simple = FALSE; + } + else { + memcpy(InP->data, data, dataCnt); + } + + InP->dataType.msgtl_number = dataCnt; + + msgh_size = 44 + ((InP->dataType.msgtl_header.msgt_inline) ? (dataCnt + 3) & ~3 : sizeof(char *)); + InP->Head.msgh_bits = msgh_simple ? + MACH_MSGH_BITS(replyPoly, 0) : + (MACH_MSGH_BITS_COMPLEX| + MACH_MSGH_BITS(replyPoly, 0)); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = reply; + InP->Head.msgh_reply_port = MACH_PORT_NULL; + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 21101; + + return __mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, msgh_size, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); +} + +/* SimpleRoutine io_seek_reply */ +mig_external kern_return_t io_seek_reply +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code, + loff_t newp +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t return_codeType; + kern_return_t return_code; + mach_msg_type_t newpType; + loff_t newp; + } Request; + + union { + Request In; + } Mess; + + register Request *InP = &Mess.In; + + + auto const mach_msg_type_t return_codeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t newpType = { + /* msgt_name = */ 11, + /* msgt_size = */ 64, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->return_codeType = return_codeType; + + InP->return_code = return_code; + + InP->newpType = newpType; + + InP->newp = newp; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(replyPoly, 0); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = reply; + InP->Head.msgh_reply_port = MACH_PORT_NULL; + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 21102; + + return __mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, 44, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); +} + +/* SimpleRoutine io_readable_reply */ +mig_external kern_return_t io_readable_reply +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code, + vm_size_t amount +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t return_codeType; + kern_return_t return_code; + mach_msg_type_t amountType; + vm_size_t amount; + } Request; + + union { + Request In; + } Mess; + + register Request *InP = &Mess.In; + + + auto const mach_msg_type_t return_codeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t amountType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->return_codeType = return_codeType; + + InP->return_code = return_code; + + InP->amountType = amountType; + + InP->amount = amount; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(replyPoly, 0); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = reply; + InP->Head.msgh_reply_port = MACH_PORT_NULL; + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 21103; + + return __mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, 40, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); +} + +/* SimpleRoutine io_set_all_openmodes_reply */ +mig_external kern_return_t io_set_all_openmodes_reply +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t return_codeType; + kern_return_t return_code; + } Request; + + union { + Request In; + } Mess; + + register Request *InP = &Mess.In; + + + auto const mach_msg_type_t return_codeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->return_codeType = return_codeType; + + InP->return_code = return_code; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(replyPoly, 0); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = reply; + InP->Head.msgh_reply_port = MACH_PORT_NULL; + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 21104; + + return __mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, 32, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); +} + +/* SimpleRoutine io_get_openmodes_reply */ +mig_external kern_return_t io_get_openmodes_reply +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code, + int bits +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t return_codeType; + kern_return_t return_code; + mach_msg_type_t bitsType; + int bits; + } Request; + + union { + Request In; + } Mess; + + register Request *InP = &Mess.In; + + + auto const mach_msg_type_t return_codeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t bitsType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->return_codeType = return_codeType; + + InP->return_code = return_code; + + InP->bitsType = bitsType; + + InP->bits = bits; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(replyPoly, 0); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = reply; + InP->Head.msgh_reply_port = MACH_PORT_NULL; + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 21105; + + return __mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, 40, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); +} + +/* SimpleRoutine io_set_some_openmodes_reply */ +mig_external kern_return_t io_set_some_openmodes_reply +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t return_codeType; + kern_return_t return_code; + } Request; + + union { + Request In; + } Mess; + + register Request *InP = &Mess.In; + + + auto const mach_msg_type_t return_codeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->return_codeType = return_codeType; + + InP->return_code = return_code; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(replyPoly, 0); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = reply; + InP->Head.msgh_reply_port = MACH_PORT_NULL; + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 21106; + + return __mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, 32, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); +} + +/* SimpleRoutine io_clear_some_openmodes_reply */ +mig_external kern_return_t io_clear_some_openmodes_reply +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t return_codeType; + kern_return_t return_code; + } Request; + + union { + Request In; + } Mess; + + register Request *InP = &Mess.In; + + + auto const mach_msg_type_t return_codeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->return_codeType = return_codeType; + + InP->return_code = return_code; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(replyPoly, 0); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = reply; + InP->Head.msgh_reply_port = MACH_PORT_NULL; + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 21107; + + return __mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, 32, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); +} + +/* SimpleRoutine io_async_reply */ +mig_external kern_return_t io_async_reply +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code, + mach_port_t async_id_port, + mach_msg_type_name_t async_id_portPoly +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t return_codeType; + kern_return_t return_code; + mach_msg_type_t async_id_portType; + mach_port_t async_id_port; + } Request; + + union { + Request In; + } Mess; + + register Request *InP = &Mess.In; + + boolean_t msgh_simple = TRUE; + + auto const mach_msg_type_t return_codeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t async_id_portType = { + /* msgt_name = */ -1, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + if (MACH_MSG_TYPE_PORT_ANY(replyPoly)) + msgh_simple = FALSE; + + InP->return_codeType = return_codeType; + + InP->return_code = return_code; + + InP->async_id_portType = async_id_portType; + + InP->async_id_port = async_id_port; + + if (MACH_MSG_TYPE_PORT_ANY(async_id_portPoly)) + msgh_simple = FALSE; + + InP->async_id_portType.msgt_name = async_id_portPoly; + + InP->Head.msgh_bits = msgh_simple ? + MACH_MSGH_BITS(replyPoly, 0) : + (MACH_MSGH_BITS_COMPLEX| + MACH_MSGH_BITS(replyPoly, 0)); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = reply; + InP->Head.msgh_reply_port = MACH_PORT_NULL; + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 21108; + + return __mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, 40, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); +} + +/* SimpleRoutine io_mod_owner_reply */ +mig_external kern_return_t io_mod_owner_reply +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t return_codeType; + kern_return_t return_code; + } Request; + + union { + Request In; + } Mess; + + register Request *InP = &Mess.In; + + + auto const mach_msg_type_t return_codeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->return_codeType = return_codeType; + + InP->return_code = return_code; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(replyPoly, 0); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = reply; + InP->Head.msgh_reply_port = MACH_PORT_NULL; + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 21109; + + return __mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, 32, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); +} + +/* SimpleRoutine io_get_owner_reply */ +mig_external kern_return_t io_get_owner_reply +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code, + pid_t owner +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t return_codeType; + kern_return_t return_code; + mach_msg_type_t ownerType; + pid_t owner; + } Request; + + union { + Request In; + } Mess; + + register Request *InP = &Mess.In; + + + auto const mach_msg_type_t return_codeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t ownerType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->return_codeType = return_codeType; + + InP->return_code = return_code; + + InP->ownerType = ownerType; + + InP->owner = owner; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(replyPoly, 0); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = reply; + InP->Head.msgh_reply_port = MACH_PORT_NULL; + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 21110; + + return __mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, 40, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); +} + +/* SimpleRoutine io_get_icky_async_id_reply */ +mig_external kern_return_t io_get_icky_async_id_reply +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code, + mach_port_t id_port, + mach_msg_type_name_t id_portPoly +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t return_codeType; + kern_return_t return_code; + mach_msg_type_t id_portType; + mach_port_t id_port; + } Request; + + union { + Request In; + } Mess; + + register Request *InP = &Mess.In; + + boolean_t msgh_simple = TRUE; + + auto const mach_msg_type_t return_codeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t id_portType = { + /* msgt_name = */ -1, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + if (MACH_MSG_TYPE_PORT_ANY(replyPoly)) + msgh_simple = FALSE; + + InP->return_codeType = return_codeType; + + InP->return_code = return_code; + + InP->id_portType = id_portType; + + InP->id_port = id_port; + + if (MACH_MSG_TYPE_PORT_ANY(id_portPoly)) + msgh_simple = FALSE; + + InP->id_portType.msgt_name = id_portPoly; + + InP->Head.msgh_bits = msgh_simple ? + MACH_MSGH_BITS(replyPoly, 0) : + (MACH_MSGH_BITS_COMPLEX| + MACH_MSGH_BITS(replyPoly, 0)); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = reply; + InP->Head.msgh_reply_port = MACH_PORT_NULL; + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 21111; + + return __mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, 40, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); +} + +/* SimpleRoutine io_select_reply */ +mig_external kern_return_t io_select_reply +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code, + int select_result +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t return_codeType; + kern_return_t return_code; + mach_msg_type_t select_resultType; + int select_result; + } Request; + + union { + Request In; + } Mess; + + register Request *InP = &Mess.In; + + + auto const mach_msg_type_t return_codeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t select_resultType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->return_codeType = return_codeType; + + InP->return_code = return_code; + + InP->select_resultType = select_resultType; + + InP->select_result = select_result; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(replyPoly, 0); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = reply; + InP->Head.msgh_reply_port = MACH_PORT_NULL; + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 21112; + + return __mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, 40, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); +} + +/* SimpleRoutine io_stat_reply */ +mig_external kern_return_t io_stat_reply +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code, + io_statbuf_t stat_info +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t return_codeType; + kern_return_t return_code; + mach_msg_type_t stat_infoType; + io_statbuf_t stat_info; + } Request; + + union { + Request In; + } Mess; + + register Request *InP = &Mess.In; + + + auto const mach_msg_type_t return_codeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t stat_infoType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 32, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->return_codeType = return_codeType; + + InP->return_code = return_code; + + InP->stat_infoType = stat_infoType; + + InP->stat_info = stat_info; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(replyPoly, 0); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = reply; + InP->Head.msgh_reply_port = MACH_PORT_NULL; + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 21113; + + return __mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, 164, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); +} + +/* SimpleRoutine io_restrict_auth_reply */ +mig_external kern_return_t io_restrict_auth_reply +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code, + mach_port_t new_object, + mach_msg_type_name_t new_objectPoly +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t return_codeType; + kern_return_t return_code; + mach_msg_type_t new_objectType; + mach_port_t new_object; + } Request; + + union { + Request In; + } Mess; + + register Request *InP = &Mess.In; + + boolean_t msgh_simple = TRUE; + + auto const mach_msg_type_t return_codeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t new_objectType = { + /* msgt_name = */ -1, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + if (MACH_MSG_TYPE_PORT_ANY(replyPoly)) + msgh_simple = FALSE; + + InP->return_codeType = return_codeType; + + InP->return_code = return_code; + + InP->new_objectType = new_objectType; + + InP->new_object = new_object; + + if (MACH_MSG_TYPE_PORT_ANY(new_objectPoly)) + msgh_simple = FALSE; + + InP->new_objectType.msgt_name = new_objectPoly; + + InP->Head.msgh_bits = msgh_simple ? + MACH_MSGH_BITS(replyPoly, 0) : + (MACH_MSGH_BITS_COMPLEX| + MACH_MSGH_BITS(replyPoly, 0)); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = reply; + InP->Head.msgh_reply_port = MACH_PORT_NULL; + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 21115; + + return __mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, 40, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); +} + +/* SimpleRoutine io_duplicate_reply */ +mig_external kern_return_t io_duplicate_reply +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code, + mach_port_t newport, + mach_msg_type_name_t newportPoly +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t return_codeType; + kern_return_t return_code; + mach_msg_type_t newportType; + mach_port_t newport; + } Request; + + union { + Request In; + } Mess; + + register Request *InP = &Mess.In; + + boolean_t msgh_simple = TRUE; + + auto const mach_msg_type_t return_codeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t newportType = { + /* msgt_name = */ -1, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + if (MACH_MSG_TYPE_PORT_ANY(replyPoly)) + msgh_simple = FALSE; + + InP->return_codeType = return_codeType; + + InP->return_code = return_code; + + InP->newportType = newportType; + + InP->newport = newport; + + if (MACH_MSG_TYPE_PORT_ANY(newportPoly)) + msgh_simple = FALSE; + + InP->newportType.msgt_name = newportPoly; + + InP->Head.msgh_bits = msgh_simple ? + MACH_MSGH_BITS(replyPoly, 0) : + (MACH_MSGH_BITS_COMPLEX| + MACH_MSGH_BITS(replyPoly, 0)); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = reply; + InP->Head.msgh_reply_port = MACH_PORT_NULL; + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 21116; + + return __mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, 40, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); +} + +/* SimpleRoutine io_map_reply */ +mig_external kern_return_t io_map_reply +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code, + mach_port_t rdobject, + mach_msg_type_name_t rdobjectPoly, + mach_port_t wrobject, + mach_msg_type_name_t wrobjectPoly +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t return_codeType; + kern_return_t return_code; + mach_msg_type_t rdobjectType; + mach_port_t rdobject; + mach_msg_type_t wrobjectType; + mach_port_t wrobject; + } Request; + + union { + Request In; + } Mess; + + register Request *InP = &Mess.In; + + boolean_t msgh_simple = TRUE; + + auto const mach_msg_type_t return_codeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t rdobjectType = { + /* msgt_name = */ -1, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t wrobjectType = { + /* msgt_name = */ -1, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + if (MACH_MSG_TYPE_PORT_ANY(replyPoly)) + msgh_simple = FALSE; + + InP->return_codeType = return_codeType; + + InP->return_code = return_code; + + InP->rdobjectType = rdobjectType; + + InP->rdobject = rdobject; + + if (MACH_MSG_TYPE_PORT_ANY(rdobjectPoly)) + msgh_simple = FALSE; + + InP->rdobjectType.msgt_name = rdobjectPoly; + + InP->wrobjectType = wrobjectType; + + InP->wrobject = wrobject; + + if (MACH_MSG_TYPE_PORT_ANY(wrobjectPoly)) + msgh_simple = FALSE; + + InP->wrobjectType.msgt_name = wrobjectPoly; + + InP->Head.msgh_bits = msgh_simple ? + MACH_MSGH_BITS(replyPoly, 0) : + (MACH_MSGH_BITS_COMPLEX| + MACH_MSGH_BITS(replyPoly, 0)); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = reply; + InP->Head.msgh_reply_port = MACH_PORT_NULL; + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 21117; + + return __mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, 48, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); +} + +/* SimpleRoutine io_map_cntl_reply */ +mig_external kern_return_t io_map_cntl_reply +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code, + mach_port_t memobj, + mach_msg_type_name_t memobjPoly +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t return_codeType; + kern_return_t return_code; + mach_msg_type_t memobjType; + mach_port_t memobj; + } Request; + + union { + Request In; + } Mess; + + register Request *InP = &Mess.In; + + boolean_t msgh_simple = TRUE; + + auto const mach_msg_type_t return_codeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t memobjType = { + /* msgt_name = */ -1, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + if (MACH_MSG_TYPE_PORT_ANY(replyPoly)) + msgh_simple = FALSE; + + InP->return_codeType = return_codeType; + + InP->return_code = return_code; + + InP->memobjType = memobjType; + + InP->memobj = memobj; + + if (MACH_MSG_TYPE_PORT_ANY(memobjPoly)) + msgh_simple = FALSE; + + InP->memobjType.msgt_name = memobjPoly; + + InP->Head.msgh_bits = msgh_simple ? + MACH_MSGH_BITS(replyPoly, 0) : + (MACH_MSGH_BITS_COMPLEX| + MACH_MSGH_BITS(replyPoly, 0)); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = reply; + InP->Head.msgh_reply_port = MACH_PORT_NULL; + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 21118; + + return __mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, 40, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); +} + +/* SimpleRoutine io_get_conch_reply */ +mig_external kern_return_t io_get_conch_reply +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t return_codeType; + kern_return_t return_code; + } Request; + + union { + Request In; + } Mess; + + register Request *InP = &Mess.In; + + + auto const mach_msg_type_t return_codeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->return_codeType = return_codeType; + + InP->return_code = return_code; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(replyPoly, 0); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = reply; + InP->Head.msgh_reply_port = MACH_PORT_NULL; + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 21119; + + return __mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, 32, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); +} + +/* SimpleRoutine io_release_conch_reply */ +mig_external kern_return_t io_release_conch_reply +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t return_codeType; + kern_return_t return_code; + } Request; + + union { + Request In; + } Mess; + + register Request *InP = &Mess.In; + + + auto const mach_msg_type_t return_codeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->return_codeType = return_codeType; + + InP->return_code = return_code; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(replyPoly, 0); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = reply; + InP->Head.msgh_reply_port = MACH_PORT_NULL; + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 21120; + + return __mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, 32, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); +} + +/* SimpleRoutine io_eofnotify_reply */ +mig_external kern_return_t io_eofnotify_reply +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t return_codeType; + kern_return_t return_code; + } Request; + + union { + Request In; + } Mess; + + register Request *InP = &Mess.In; + + + auto const mach_msg_type_t return_codeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->return_codeType = return_codeType; + + InP->return_code = return_code; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(replyPoly, 0); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = reply; + InP->Head.msgh_reply_port = MACH_PORT_NULL; + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 21121; + + return __mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, 32, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); +} + +/* SimpleRoutine io_prenotify_reply */ +mig_external kern_return_t io_prenotify_reply +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t return_codeType; + kern_return_t return_code; + } Request; + + union { + Request In; + } Mess; + + register Request *InP = &Mess.In; + + + auto const mach_msg_type_t return_codeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->return_codeType = return_codeType; + + InP->return_code = return_code; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(replyPoly, 0); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = reply; + InP->Head.msgh_reply_port = MACH_PORT_NULL; + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 21122; + + return __mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, 32, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); +} + +/* SimpleRoutine io_postnotify_reply */ +mig_external kern_return_t io_postnotify_reply +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t return_codeType; + kern_return_t return_code; + } Request; + + union { + Request In; + } Mess; + + register Request *InP = &Mess.In; + + + auto const mach_msg_type_t return_codeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->return_codeType = return_codeType; + + InP->return_code = return_code; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(replyPoly, 0); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = reply; + InP->Head.msgh_reply_port = MACH_PORT_NULL; + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 21123; + + return __mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, 32, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); +} + +/* SimpleRoutine io_readnotify_reply */ +mig_external kern_return_t io_readnotify_reply +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t return_codeType; + kern_return_t return_code; + } Request; + + union { + Request In; + } Mess; + + register Request *InP = &Mess.In; + + + auto const mach_msg_type_t return_codeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->return_codeType = return_codeType; + + InP->return_code = return_code; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(replyPoly, 0); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = reply; + InP->Head.msgh_reply_port = MACH_PORT_NULL; + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 21124; + + return __mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, 32, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); +} + +/* SimpleRoutine io_readsleep_reply */ +mig_external kern_return_t io_readsleep_reply +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t return_codeType; + kern_return_t return_code; + } Request; + + union { + Request In; + } Mess; + + register Request *InP = &Mess.In; + + + auto const mach_msg_type_t return_codeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->return_codeType = return_codeType; + + InP->return_code = return_code; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(replyPoly, 0); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = reply; + InP->Head.msgh_reply_port = MACH_PORT_NULL; + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 21125; + + return __mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, 32, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); +} + +/* SimpleRoutine io_sigio_reply */ +mig_external kern_return_t io_sigio_reply +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t return_codeType; + kern_return_t return_code; + } Request; + + union { + Request In; + } Mess; + + register Request *InP = &Mess.In; + + + auto const mach_msg_type_t return_codeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->return_codeType = return_codeType; + + InP->return_code = return_code; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(replyPoly, 0); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = reply; + InP->Head.msgh_reply_port = MACH_PORT_NULL; + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 21126; + + return __mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, 32, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); +} diff --git a/boot-proxy-exc/io_replyUser.d b/boot-proxy-exc/io_replyUser.d new file mode 100644 index 00000000..7be6d40a --- /dev/null +++ b/boot-proxy-exc/io_replyUser.d @@ -0,0 +1,53 @@ +io_replyUser.o io_replyUser_pic.o io_replyUser_p.o io_replyUser.d: io_replyUser.c io_reply_U.h \ + /usr/local/include/mach/kern_return.h \ + /usr/local/include/mach/machine/kern_return.h \ + /usr/local/include/mach/port.h /usr/local/include/mach/boolean.h \ + /usr/local/include/mach/machine/boolean.h \ + /usr/local/include/mach/machine/vm_types.h \ + /usr/local/include/mach/message.h /usr/local/include/mach/std_types.h \ + /usr/local/include/mach/mach_types.h \ + /usr/local/include/mach/host_info.h /usr/local/include/mach/machine.h \ + /usr/local/include/mach/memory_object.h \ + /usr/local/include/mach/pc_sample.h \ + /usr/local/include/mach/processor_info.h \ + /usr/local/include/mach/task_info.h \ + /usr/local/include/mach/time_value.h \ + /usr/local/include/mach/task_special_ports.h \ + /usr/local/include/mach/thread_info.h /usr/local/include/mach/policy.h \ + /usr/local/include/mach/thread_special_ports.h \ + /usr/local/include/mach/thread_status.h \ + /usr/local/include/mach/machine/thread_status.h \ + /usr/local/include/mach/machine/fp_reg.h \ + /usr/local/include/mach/vm_attributes.h \ + /usr/local/include/mach/vm_inherit.h /usr/local/include/mach/vm_prot.h \ + /usr/local/include/mach/vm_statistics.h \ + /usr/local/include/device/device_types.h \ + /usr/local/include/device/net_status.h /usr/local/include/device/bpf.h \ + /usr/include/sys/types.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/include/gnu/stubs-pthread.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/time.h \ + /usr/lib/gcc/i486-gnu/4.2.4/include/stddef.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/bits/byteswap.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/pthread/pthreadtypes.h /usr/include/xlocale.h \ + /usr/include/bits/pthread.h /usr/include/bits/thread-attr.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/mutex-attr.h /usr/include/bits/mutex.h \ + /usr/include/bits/spin-lock.h /usr/include/bits/condition-attr.h \ + /usr/include/bits/condition.h /usr/include/bits/rwlock-attr.h \ + /usr/include/bits/rwlock.h /usr/include/bits/barrier-attr.h \ + /usr/include/bits/barrier.h /usr/include/bits/thread-specific.h \ + /usr/include/bits/once.h /usr/include/sys/stat.h \ + /usr/include/bits/stat.h /usr/include/sys/statfs.h \ + /usr/include/bits/statfs.h /usr/include/sys/resource.h \ + /usr/include/bits/resource.h /usr/include/sys/utsname.h \ + /usr/include/bits/utsname.h ../hurd/hurd_types.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/local/include/mach/notify.h \ + /usr/local/include/mach/mig_errors.h /usr/include/mach/mig_support.h \ + /usr/include/string.h /usr/include/bits/string.h \ + /usr/include/bits/string2.h /usr/include/stdlib.h \ + /usr/local/include/mach/msg_type.h diff --git a/boot-proxy-exc/io_replyUser.o b/boot-proxy-exc/io_replyUser.o Binary files differnew file mode 100644 index 00000000..c7ca7690 --- /dev/null +++ b/boot-proxy-exc/io_replyUser.o diff --git a/boot-proxy-exc/io_reply_U.h b/boot-proxy-exc/io_reply_U.h new file mode 100644 index 00000000..38a9eaa8 --- /dev/null +++ b/boot-proxy-exc/io_reply_U.h @@ -0,0 +1,613 @@ +#ifndef _io_reply_user_ +#define _io_reply_user_ + +/* Module io_reply */ + +#include <mach/kern_return.h> +#include <mach/port.h> +#include <mach/message.h> + +#include <mach/std_types.h> +#include <mach/mach_types.h> +#include <device/device_types.h> +#include <device/net_status.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/statfs.h> +#include <sys/resource.h> +#include <sys/utsname.h> +#include <hurd/hurd_types.h> + +/* SimpleRoutine io_write_reply */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t io_write_reply +#if defined(LINTLIBRARY) + (reply, replyPoly, return_code, amount) + mach_port_t reply; + mach_msg_type_name_t replyPoly; + kern_return_t return_code; + vm_size_t amount; +{ return io_write_reply(reply, replyPoly, return_code, amount); } +#else +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code, + vm_size_t amount +); +#endif + +/* SimpleRoutine io_read_reply */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t io_read_reply +#if defined(LINTLIBRARY) + (reply, replyPoly, return_code, data, dataCnt) + mach_port_t reply; + mach_msg_type_name_t replyPoly; + kern_return_t return_code; + data_t data; + mach_msg_type_number_t dataCnt; +{ return io_read_reply(reply, replyPoly, return_code, data, dataCnt); } +#else +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code, + data_t data, + mach_msg_type_number_t dataCnt +); +#endif + +/* SimpleRoutine io_seek_reply */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t io_seek_reply +#if defined(LINTLIBRARY) + (reply, replyPoly, return_code, newp) + mach_port_t reply; + mach_msg_type_name_t replyPoly; + kern_return_t return_code; + loff_t newp; +{ return io_seek_reply(reply, replyPoly, return_code, newp); } +#else +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code, + loff_t newp +); +#endif + +/* SimpleRoutine io_readable_reply */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t io_readable_reply +#if defined(LINTLIBRARY) + (reply, replyPoly, return_code, amount) + mach_port_t reply; + mach_msg_type_name_t replyPoly; + kern_return_t return_code; + vm_size_t amount; +{ return io_readable_reply(reply, replyPoly, return_code, amount); } +#else +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code, + vm_size_t amount +); +#endif + +/* SimpleRoutine io_set_all_openmodes_reply */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t io_set_all_openmodes_reply +#if defined(LINTLIBRARY) + (reply, replyPoly, return_code) + mach_port_t reply; + mach_msg_type_name_t replyPoly; + kern_return_t return_code; +{ return io_set_all_openmodes_reply(reply, replyPoly, return_code); } +#else +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code +); +#endif + +/* SimpleRoutine io_get_openmodes_reply */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t io_get_openmodes_reply +#if defined(LINTLIBRARY) + (reply, replyPoly, return_code, bits) + mach_port_t reply; + mach_msg_type_name_t replyPoly; + kern_return_t return_code; + int bits; +{ return io_get_openmodes_reply(reply, replyPoly, return_code, bits); } +#else +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code, + int bits +); +#endif + +/* SimpleRoutine io_set_some_openmodes_reply */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t io_set_some_openmodes_reply +#if defined(LINTLIBRARY) + (reply, replyPoly, return_code) + mach_port_t reply; + mach_msg_type_name_t replyPoly; + kern_return_t return_code; +{ return io_set_some_openmodes_reply(reply, replyPoly, return_code); } +#else +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code +); +#endif + +/* SimpleRoutine io_clear_some_openmodes_reply */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t io_clear_some_openmodes_reply +#if defined(LINTLIBRARY) + (reply, replyPoly, return_code) + mach_port_t reply; + mach_msg_type_name_t replyPoly; + kern_return_t return_code; +{ return io_clear_some_openmodes_reply(reply, replyPoly, return_code); } +#else +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code +); +#endif + +/* SimpleRoutine io_async_reply */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t io_async_reply +#if defined(LINTLIBRARY) + (reply, replyPoly, return_code, async_id_port, async_id_portPoly) + mach_port_t reply; + mach_msg_type_name_t replyPoly; + kern_return_t return_code; + mach_port_t async_id_port; + mach_msg_type_name_t async_id_portPoly; +{ return io_async_reply(reply, replyPoly, return_code, async_id_port, async_id_portPoly); } +#else +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code, + mach_port_t async_id_port, + mach_msg_type_name_t async_id_portPoly +); +#endif + +/* SimpleRoutine io_mod_owner_reply */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t io_mod_owner_reply +#if defined(LINTLIBRARY) + (reply, replyPoly, return_code) + mach_port_t reply; + mach_msg_type_name_t replyPoly; + kern_return_t return_code; +{ return io_mod_owner_reply(reply, replyPoly, return_code); } +#else +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code +); +#endif + +/* SimpleRoutine io_get_owner_reply */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t io_get_owner_reply +#if defined(LINTLIBRARY) + (reply, replyPoly, return_code, owner) + mach_port_t reply; + mach_msg_type_name_t replyPoly; + kern_return_t return_code; + pid_t owner; +{ return io_get_owner_reply(reply, replyPoly, return_code, owner); } +#else +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code, + pid_t owner +); +#endif + +/* SimpleRoutine io_get_icky_async_id_reply */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t io_get_icky_async_id_reply +#if defined(LINTLIBRARY) + (reply, replyPoly, return_code, id_port, id_portPoly) + mach_port_t reply; + mach_msg_type_name_t replyPoly; + kern_return_t return_code; + mach_port_t id_port; + mach_msg_type_name_t id_portPoly; +{ return io_get_icky_async_id_reply(reply, replyPoly, return_code, id_port, id_portPoly); } +#else +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code, + mach_port_t id_port, + mach_msg_type_name_t id_portPoly +); +#endif + +/* SimpleRoutine io_select_reply */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t io_select_reply +#if defined(LINTLIBRARY) + (reply, replyPoly, return_code, select_result) + mach_port_t reply; + mach_msg_type_name_t replyPoly; + kern_return_t return_code; + int select_result; +{ return io_select_reply(reply, replyPoly, return_code, select_result); } +#else +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code, + int select_result +); +#endif + +/* SimpleRoutine io_stat_reply */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t io_stat_reply +#if defined(LINTLIBRARY) + (reply, replyPoly, return_code, stat_info) + mach_port_t reply; + mach_msg_type_name_t replyPoly; + kern_return_t return_code; + io_statbuf_t stat_info; +{ return io_stat_reply(reply, replyPoly, return_code, stat_info); } +#else +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code, + io_statbuf_t stat_info +); +#endif + +/* SimpleRoutine io_restrict_auth_reply */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t io_restrict_auth_reply +#if defined(LINTLIBRARY) + (reply, replyPoly, return_code, new_object, new_objectPoly) + mach_port_t reply; + mach_msg_type_name_t replyPoly; + kern_return_t return_code; + mach_port_t new_object; + mach_msg_type_name_t new_objectPoly; +{ return io_restrict_auth_reply(reply, replyPoly, return_code, new_object, new_objectPoly); } +#else +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code, + mach_port_t new_object, + mach_msg_type_name_t new_objectPoly +); +#endif + +/* SimpleRoutine io_duplicate_reply */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t io_duplicate_reply +#if defined(LINTLIBRARY) + (reply, replyPoly, return_code, newport, newportPoly) + mach_port_t reply; + mach_msg_type_name_t replyPoly; + kern_return_t return_code; + mach_port_t newport; + mach_msg_type_name_t newportPoly; +{ return io_duplicate_reply(reply, replyPoly, return_code, newport, newportPoly); } +#else +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code, + mach_port_t newport, + mach_msg_type_name_t newportPoly +); +#endif + +/* SimpleRoutine io_map_reply */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t io_map_reply +#if defined(LINTLIBRARY) + (reply, replyPoly, return_code, rdobject, rdobjectPoly, wrobject, wrobjectPoly) + mach_port_t reply; + mach_msg_type_name_t replyPoly; + kern_return_t return_code; + mach_port_t rdobject; + mach_msg_type_name_t rdobjectPoly; + mach_port_t wrobject; + mach_msg_type_name_t wrobjectPoly; +{ return io_map_reply(reply, replyPoly, return_code, rdobject, rdobjectPoly, wrobject, wrobjectPoly); } +#else +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code, + mach_port_t rdobject, + mach_msg_type_name_t rdobjectPoly, + mach_port_t wrobject, + mach_msg_type_name_t wrobjectPoly +); +#endif + +/* SimpleRoutine io_map_cntl_reply */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t io_map_cntl_reply +#if defined(LINTLIBRARY) + (reply, replyPoly, return_code, memobj, memobjPoly) + mach_port_t reply; + mach_msg_type_name_t replyPoly; + kern_return_t return_code; + mach_port_t memobj; + mach_msg_type_name_t memobjPoly; +{ return io_map_cntl_reply(reply, replyPoly, return_code, memobj, memobjPoly); } +#else +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code, + mach_port_t memobj, + mach_msg_type_name_t memobjPoly +); +#endif + +/* SimpleRoutine io_get_conch_reply */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t io_get_conch_reply +#if defined(LINTLIBRARY) + (reply, replyPoly, return_code) + mach_port_t reply; + mach_msg_type_name_t replyPoly; + kern_return_t return_code; +{ return io_get_conch_reply(reply, replyPoly, return_code); } +#else +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code +); +#endif + +/* SimpleRoutine io_release_conch_reply */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t io_release_conch_reply +#if defined(LINTLIBRARY) + (reply, replyPoly, return_code) + mach_port_t reply; + mach_msg_type_name_t replyPoly; + kern_return_t return_code; +{ return io_release_conch_reply(reply, replyPoly, return_code); } +#else +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code +); +#endif + +/* SimpleRoutine io_eofnotify_reply */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t io_eofnotify_reply +#if defined(LINTLIBRARY) + (reply, replyPoly, return_code) + mach_port_t reply; + mach_msg_type_name_t replyPoly; + kern_return_t return_code; +{ return io_eofnotify_reply(reply, replyPoly, return_code); } +#else +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code +); +#endif + +/* SimpleRoutine io_prenotify_reply */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t io_prenotify_reply +#if defined(LINTLIBRARY) + (reply, replyPoly, return_code) + mach_port_t reply; + mach_msg_type_name_t replyPoly; + kern_return_t return_code; +{ return io_prenotify_reply(reply, replyPoly, return_code); } +#else +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code +); +#endif + +/* SimpleRoutine io_postnotify_reply */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t io_postnotify_reply +#if defined(LINTLIBRARY) + (reply, replyPoly, return_code) + mach_port_t reply; + mach_msg_type_name_t replyPoly; + kern_return_t return_code; +{ return io_postnotify_reply(reply, replyPoly, return_code); } +#else +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code +); +#endif + +/* SimpleRoutine io_readnotify_reply */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t io_readnotify_reply +#if defined(LINTLIBRARY) + (reply, replyPoly, return_code) + mach_port_t reply; + mach_msg_type_name_t replyPoly; + kern_return_t return_code; +{ return io_readnotify_reply(reply, replyPoly, return_code); } +#else +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code +); +#endif + +/* SimpleRoutine io_readsleep_reply */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t io_readsleep_reply +#if defined(LINTLIBRARY) + (reply, replyPoly, return_code) + mach_port_t reply; + mach_msg_type_name_t replyPoly; + kern_return_t return_code; +{ return io_readsleep_reply(reply, replyPoly, return_code); } +#else +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code +); +#endif + +/* SimpleRoutine io_sigio_reply */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t io_sigio_reply +#if defined(LINTLIBRARY) + (reply, replyPoly, return_code) + mach_port_t reply; + mach_msg_type_name_t replyPoly; + kern_return_t return_code; +{ return io_sigio_reply(reply, replyPoly, return_code); } +#else +( + mach_port_t reply, + mach_msg_type_name_t replyPoly, + kern_return_t return_code +); +#endif + +#endif /* not defined(_io_reply_user_) */ diff --git a/boot-proxy-exc/list.c b/boot-proxy-exc/list.c new file mode 100644 index 00000000..db555f35 --- /dev/null +++ b/boot-proxy-exc/list.c @@ -0,0 +1,52 @@ +/* + Copyright (C) 2009 Free Software Foundation, Inc. + Written by Zheng Da. + + This file is part of the GNU Hurd. + + The GNU Hurd is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + The GNU Hurd 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with the GNU Hurd; see the file COPYING. If not, write to + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/* This file implements a double linked list. */ + +#include "list.h" + +void entry_init (struct list *entry) +{ + entry->next = entry; + entry->prev = entry; +} + +void add_entry_head (struct list *head, struct list *entry) +{ + entry->next = head->next; + head->next->prev = entry; + head->next = entry; + entry->prev = head; +} + +void add_entry_end (struct list *head, struct list *entry) +{ + entry->next = head; + entry->prev = head->prev; + head->prev->next = entry; + head->prev = entry; +} + +void remove_entry (struct list *entry) +{ + entry->next->prev = entry->prev; + entry->prev->next = entry->next; +} + diff --git a/boot-proxy-exc/list.d b/boot-proxy-exc/list.d new file mode 100644 index 00000000..86aac7da --- /dev/null +++ b/boot-proxy-exc/list.d @@ -0,0 +1 @@ +list.o list_pic.o list_p.o list.d: list.c list.h /usr/lib/gcc/i486-gnu/4.2.4/include/stddef.h diff --git a/boot-proxy-exc/list.h b/boot-proxy-exc/list.h new file mode 100644 index 00000000..f3f7585f --- /dev/null +++ b/boot-proxy-exc/list.h @@ -0,0 +1,40 @@ +/* + Copyright (C) 2009 Free Software Foundation, Inc. + Written by Zheng Da. + + This file is part of the GNU Hurd. + + The GNU Hurd is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + The GNU Hurd 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with the GNU Hurd; see the file COPYING. If not, write to + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef __LIST_H__ +#define __LIST_H__ + +#include <stddef.h> + +struct list +{ + struct list *next, *prev; +}; + +void entry_init (struct list *entry); +void add_entry_head (struct list *head, struct list *entry); +void add_entry_end (struct list *head, struct list *entry); +void remove_entry (struct list *entry); + +#define LIST_HEADER(head) struct list head = {&head, &head} +#define EMPTY_LIST(head) ((head)->next == (head)) +#define LIST_ENTRY(entry, type, field) ((type *) (((char *) entry) - offsetof (type, field))) + +#endif diff --git a/boot-proxy-exc/list.o b/boot-proxy-exc/list.o Binary files differnew file mode 100644 index 00000000..438da39b --- /dev/null +++ b/boot-proxy-exc/list.o diff --git a/boot-proxy-exc/mach-crt0.c b/boot-proxy-exc/mach-crt0.c new file mode 100644 index 00000000..0469424e --- /dev/null +++ b/boot-proxy-exc/mach-crt0.c @@ -0,0 +1,158 @@ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989 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. + */ +/* + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * William Jolitz. + * + * Redistribution and use in source and binary forms are permitted + * provided that: (1) source distributions retain this entire copyright + * notice and comment, and (2) distributions including binaries display + * the following acknowledgement: ``This product includes software + * developed by the University of California, Berkeley and its contributors'' + * in the documentation or other materials provided with the distribution + * and in all advertising materials mentioning features or use of this + * software. Neither the name of the University nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +#ifndef lint +static char sccsid[] = "@(#)crt0.c 5.2 (Berkeley) 5/14/90"; +#endif /* not lint */ + +/* + * C start up routine. + * Robert Henry, UCB, 20 Oct 81 + * + * We make the following (true) assumptions: + * 1) when the kernel calls start, it does a jump to location 2, + * and thus avoids the register save mask. We are NOT called + * with a calls! see sys1.c:setregs(). + * 2) The only register variable that we can trust is sp, + * which points to the base of the kernel calling frame. + * Do NOT believe the documentation in exec(2) regarding the + * values of fp and ap. + * 3) We can allocate as many register variables as we want, + * and don't have to save them for anybody. + * 4) Because of the ways that asm's work, we can't have + * any automatic variables allocated on the stack, because + * we must catch the value of sp before any automatics are + * allocated. + */ + +#include <mach/machine/asm.h> + +int __data_start = 0; +char **environ = (char **)0; +#ifdef paranoid +static int fd; +#endif paranoid + +int (*mach_init_routine)(); +int (*_cthread_init_routine)(); +int (*_cthread_exit_routine)(); +int (*_monstartup_routine)(); +int (*_StrongBox_init_routine)(); +int errno = 0; +int exit(); + +extern int main(); + +extern unsigned char etext; +int _start() +{ + __label__ eprol; + struct kframe { + int kargc; + char *kargv[1]; /* size depends on kargc */ + char kargstr[1]; /* size varies */ + char kenvstr[1]; /* size varies */ + }; + /* + * ALL REGISTER VARIABLES!!! + */ + register struct kframe *kfp; /* r10 */ + register char **targv; + register char **argv; + +#ifdef lint + kfp = 0; + initcode = initcode = 0; +#else not lint +#define Entry_sp() \ +({ int _spl__, _tmp1__; \ + asm volatile("leal 4(%%ebp), %0" : "=r" (_spl__) : "r" (_tmp1__)); \ + _spl__; }) + + kfp = (struct kframe *)Entry_sp(); +#endif not lint + for (argv = targv = &kfp->kargv[0]; *targv++; /* void */) + /* void */ ; + if (targv >= (char **)(*argv)) + --targv; + environ = targv; + if (mach_init_routine) + (void) mach_init_routine(); + + eprol: +#ifdef paranoid + /* + * The standard I/O library assumes that file descriptors 0, 1, and 2 + * are open. If one of these descriptors is closed prior to the start + * of the process, I/O gets very confused. To avoid this problem, we + * insure that the first three file descriptors are open before calling + * main(). Normally this is undefined, as it adds two unnecessary + * system calls. + */ + do { + fd = open("/dev/null", 2); + } while (fd >= 0 && fd < 3); + close(fd); +#endif paranoid + + + if (_cthread_init_routine) { + int new_sp; + new_sp = (*_cthread_init_routine)(); + if (new_sp) { + asm volatile("movl %0, %%esp" : : "g" (new_sp) ); + } + } + if (_StrongBox_init_routine) (*_StrongBox_init_routine)(); + + if (_monstartup_routine) { + _monstartup_routine(&&eprol, &etext); + } + + (* (_cthread_exit_routine ? _cthread_exit_routine : exit)) + (main(kfp->kargc, argv, targv)); +} diff --git a/boot-proxy-exc/mach_host_impl.c b/boot-proxy-exc/mach_host_impl.c new file mode 100644 index 00000000..c5fc8967 --- /dev/null +++ b/boot-proxy-exc/mach_host_impl.c @@ -0,0 +1,544 @@ +/* + Copyright (C) 2009 Free Software Foundation, Inc. + Written by Zheng Da. + + This file is part of the GNU Hurd. + + The GNU Hurd is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + The GNU Hurd 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with the GNU Hurd; see the file COPYING. If not, write to + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/* This file implements the server-side RPC functions of mach_host. */ + +#include <stdio.h> +#include <assert.h> + +#include <mach.h> +#include <hurd.h> +#include <hurd/ports.h> + +#include "util.h" +#include "list.h" +#include "mach_proxy.h" + +extern mach_port_t privileged_host_port; + +/* Set task priority. */ +kern_return_t +S_task_priority (mach_port_t task, int priority, boolean_t change_threads) +{ + struct task_info *task_pi; + error_t err; + + task_pi = ports_lookup_port (port_bucket, task, task_portclass); + if (task_pi == NULL) + return EOPNOTSUPP; + err = task_priority (task_pi->task_port, priority, change_threads); + debug ("%s", strerror (err)); + ports_port_deref (task_pi); + return err; +} + +/* Routine processor_set_tasks */ +kern_return_t +S_processor_set_tasks (mach_port_t processor_set, task_array_t *task_list, + mach_msg_type_number_t *task_listCnt) +{ + error_t err = 0; + mach_port_t *subhurd_tasks = NULL; + int size = 0; + /* no pseudo task port is created for the kernel task. */ + int num = 0; + int tot_nbtasks = ports_count_class (task_portclass) + num; + + size = tot_nbtasks * sizeof (mach_port_t); + err = vm_allocate (mach_task_self (), + (vm_address_t *) (void *) &subhurd_tasks, + size, 1); + if (err) + goto out; + + int get_pseudo_task_port (struct task_info *task_pi) + { + assert (num < tot_nbtasks); + subhurd_tasks[num++] = ports_get_right (task_pi); + return 0; + } + + foreach_task (get_pseudo_task_port); + assert (num == tot_nbtasks); + debug ("get %d tasks", tot_nbtasks); + *task_list = subhurd_tasks; + *task_listCnt = tot_nbtasks; + +out: + /* I enable the class here, + * so no pseudo task port can be created when I count the number of tasks. */ + ports_enable_class (task_portclass); + /* The array will be deallocated after it is sent, + * but the task ports in it don't need to, + * because I only call ports_get_right() + * and the reference count isn't increased. */ + return err; +} + +/* Get control port for a processor set. */ +kern_return_t +S_host_processor_set_priv (mach_port_t host_priv, mach_port_t set_name, + mach_port_t *set, mach_msg_type_name_t *setPoly) +{ + extern struct port_class *other_portclass; + struct port_info *pi; + kern_return_t ret = 0; + + // TODO create a port for each processor set + // I should create the port for the processor set only once. + ret = ports_create_port (other_portclass, port_bucket, + sizeof (*pi), &pi); + debug ("%s", strerror (ret)); + if (ret) + return ret; + *set = ports_get_right (pi); + *setPoly = MACH_MSG_TYPE_MAKE_SEND; + ports_port_deref (pi); + return ret; +} + +/* Routine host_reboot */ +kern_return_t +S_host_reboot (mach_port_t host_priv, int options) +{ + debug (""); + assert (0); + // TODO + return EOPNOTSUPP; +} + +/* Routine vm_wire */ +kern_return_t +S_vm_wire (mach_port_t host_priv, mach_port_t task, + vm_address_t address, vm_size_t size, vm_prot_t access) +{ + debug (""); + assert (0); + // TODO + return EOPNOTSUPP; +} + +/* Routine thread_wire */ +kern_return_t +S_thread_wire (mach_port_t host_priv, mach_port_t thread, boolean_t wired) +{ + debug (""); + assert (0); + // TODO + return EOPNOTSUPP; +} + +//////////the request to the host isn't forwarded by the proxy////////// + +/* Routine host_processor_sets */ +kern_return_t +S_host_processor_sets (mach_port_t host, + processor_set_name_array_t *processor_sets, + mach_msg_type_number_t *processor_setsCnt) +{ + debug (""); + assert (0); + // the request to the host isn't forwarded. + return EOPNOTSUPP; +} + +/* Routine host_get_time */ +kern_return_t +S_host_get_time (mach_port_t host, time_value_t *current_time) +{ + debug (""); + assert (0); + // the request to the host isn't forwarded. + return EOPNOTSUPP; +} + +/* Routine host_info */ +kern_return_t +S_host_info (mach_port_t host, int flavor, host_info_t host_info_out, + mach_msg_type_number_t *host_info_outCnt) +{ + debug (""); + assert (0); + // the request to the host isn't forwarded. + return EOPNOTSUPP; +} + +/* Get string describing current kernel version. */ +kern_return_t +S_host_kernel_version (mach_port_t host, kernel_version_t kernel_version) +{ + debug (""); + assert (0); + // the proxy doesn't forward the request to the host port. + return EOPNOTSUPP; +} + +///////////////////the RPCs not used by Hurd////////////////////// + +/* Get list of processors on this host. */ +kern_return_t +S_host_processors (mach_port_t host_priv, + processor_array_t *processor_list, + mach_msg_type_number_t *processor_listCnt) +{ + debug (""); + assert (0); + // Hurd currently doesn't use it. + return EOPNOTSUPP; +} + +/* Start processor. */ +kern_return_t +S_processor_start (mach_port_t processor) +{ + debug (""); + assert (0); + // Hurd currently doesn't use it. + return EOPNOTSUPP; +} + +/* Exit processor -- may not be restartable. */ +kern_return_t +S_processor_exit (mach_port_t processor) +{ + debug (""); + assert (0); + // Hurd currently doesn't use it. + return EOPNOTSUPP; +} + +/* Get default processor set for host. */ +kern_return_t +S_processor_set_default (mach_port_t host, mach_port_t *default_set) +{ + debug (""); + assert (0); + // Hurd currently doesn't use it. + return EOPNOTSUPP; +} + +/* + * Create new processor set. Returns real port for manipulations, + * and name port for obtaining information. + */ +kern_return_t +S_processor_set_create (mach_port_t host, mach_port_t *new_set, + mach_port_t *new_name) +{ + debug (""); + assert (0); + // Hurd currently doesn't use it. + return EOPNOTSUPP; +} + +/* Destroy processor set. */ +kern_return_t +S_processor_set_destroy (mach_port_t set) +{ + debug (""); + assert (0); + // Hurd currently doesn't use it. + return EOPNOTSUPP; +} + +/* Assign processor to processor set. */ +kern_return_t +S_processor_assign (mach_port_t processor, mach_port_t new_set, boolean_t wait) +{ + debug (""); + assert (0); + // Hurd currently doesn't use it. + return EOPNOTSUPP; +} + +/* Get current assignment for thread. */ +kern_return_t +S_processor_get_assignment (mach_port_t processor, mach_port_t *assigned_set) +{ + debug (""); + assert (0); + // Hurd currently doesn't use it. + return EOPNOTSUPP; +} + +/* Assign task to processor set. */ +kern_return_t +S_task_assign (mach_port_t task, mach_port_t new_set, boolean_t assign_threads) +{ + debug (""); + assert (0); + // Hurd currently doesn't use it. + return EOPNOTSUPP; +} + +/* Assign task to default set. */ +kern_return_t +S_task_assign_default (mach_port_t task, boolean_t assign_threads) +{ + debug (""); + assert (0); + // Hurd currently doesn't use it. + return EOPNOTSUPP; +} + +/* Get current assignment for task. */ +kern_return_t +S_task_get_assignment (mach_port_t task, mach_port_t *assigned_set) +{ + debug (""); + assert (0); + // Hurd currently doesn't use it. + return EOPNOTSUPP; +} + +/* Set max priority for processor_set. */ +kern_return_t +S_processor_set_max_priority (mach_port_t processor_set, int max_priority, + boolean_t change_threads) +{ + debug (""); + assert (0); + // Hurd currently doesn't use it. + return EOPNOTSUPP; +} + +/* Routine processor_set_policy_enable */ +kern_return_t +S_processor_set_policy_enable (mach_port_t processor_set, int policy) +{ + debug (""); + assert (0); + // Hurd currently doesn't use it. + return EOPNOTSUPP; +} + +/* Routine processor_set_policy_disable */ +kern_return_t +S_processor_set_policy_disable (mach_port_t processor_set, int policy, + boolean_t change_threads) +{ + debug (""); + assert (0); + // Hurd currently doesn't use it. + return EOPNOTSUPP; +} + +/* Routine processor_set_threads */ +kern_return_t +S_processor_set_threads (mach_port_t processor_set, + thread_array_t *thread_list, + mach_msg_type_number_t *thread_listCnt) +{ + debug (""); + assert (0); + // Hurd currently doesn't use it. + return EOPNOTSUPP; +} + +/* Routine host_set_time */ +kern_return_t +S_host_set_time (mach_port_t host_priv, time_value_t new_time) +{ + debug (""); + assert (0); + // Hurd currently doesn't use it. + return EOPNOTSUPP; +} + +/* Routine host_adjust_time */ +kern_return_t +S_host_adjust_time (mach_port_t host_priv, time_value_t new_adjustment, + time_value_t *old_adjustment) +{ + debug (""); + assert (0); + // Hurd currently doesn't use it. + return EOPNOTSUPP; +} + +/* Routine processor_info */ +kern_return_t +S_processor_info (mach_port_t processor, int flavor, mach_port_t *host, + processor_info_t processor_info_out, + mach_msg_type_number_t *processor_info_outCnt) +{ + debug (""); + assert (0); + // Hurd currently doesn't use it. + return EOPNOTSUPP; +} + +/* Routine processor_set_info */ +kern_return_t +S_processor_set_info (mach_port_t set_name, int flavor, mach_port_t *host, + processor_set_info_t info_out, + mach_msg_type_number_t *info_outCnt) +{ + debug (""); + assert (0); + // Hurd currently doesn't use it. + return EOPNOTSUPP; +} + +/* Routine processor_control */ +kern_return_t +S_processor_control (mach_port_t processor, processor_info_t processor_cmd, + mach_msg_type_number_t processor_cmdCnt) +{ + debug (""); + assert (0); + // Hurd currently doesn't use it. + return EOPNOTSUPP; +} + +/* Routine host_get_boot_info */ +kern_return_t +S_host_get_boot_info (mach_port_t host_priv, kernel_boot_info_t boot_info) +{ + debug (""); + assert (0); + // Hurd currently doesn't use it. + return EOPNOTSUPP; +} + +///////////////////it's not a proxy for thread requests/////////////////// + +/* Assign thread to processor set. */ +kern_return_t +S_thread_assign (mach_port_t thread, mach_port_t new_set) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Assign thread to default set. */ +kern_return_t +S_thread_assign_default (mach_port_t thread) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Get current assignment for thread. */ +kern_return_t +S_thread_get_assignment (mach_port_t thread, mach_port_t *assigned_set) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Set priority for thread. */ +kern_return_t S_thread_priority (mach_port_t thread, int priority, + boolean_t set_max) +{ + debug (""); + assert (0); + return thread_priority (thread, priority, set_max); +} + +/* Set max priority for thread. */ +kern_return_t S_thread_max_priority (mach_port_t thread, + mach_port_t processor_set, + int max_priority) +{ + debug (""); + assert (0); + return thread_max_priority (thread, processor_set, max_priority); +} + +/* Routine thread_depress_abort */ +kern_return_t S_thread_depress_abort (mach_port_t thread) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Set policy for thread */ +kern_return_t S_thread_policy (mach_port_t thread, int policy, int data) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +////////////////////don't support obsolete requests/////////////////////// + +/* Routine yyy_host_info */ +/* obsolete */ +kern_return_t +S_yyy_host_info (mach_port_t host, int flavor, host_info_t host_info_out, + mach_msg_type_number_t *host_info_outCnt) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Routine yyy_processor_info */ +/* obsolete */ +kern_return_t +S_yyy_processor_info (mach_port_t processor, int flavor, mach_port_t *host, + processor_info_t processor_info_out, + mach_msg_type_number_t *processor_info_outCnt) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Routine yyy_processor_control */ +/* obsolete */ +kern_return_t +S_yyy_processor_control (mach_port_t processor, + processor_info_t processor_cmd, + mach_msg_type_number_t processor_cmdCnt) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* + * Get rights to default processor set for host. + * Replaced by host_processor_set_priv. + */ +kern_return_t +S_xxx_processor_set_default_priv (mach_port_t host, mach_port_t *default_set) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Routine yyy_processor_set_info */ +/* obsolete */ +kern_return_t +S_yyy_processor_set_info (mach_port_t set_name, int flavor, + mach_port_t *host, processor_set_info_t info_out, + mach_msg_type_number_t *info_outCnt) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} diff --git a/boot-proxy-exc/mach_host_impl.c~ b/boot-proxy-exc/mach_host_impl.c~ new file mode 100644 index 00000000..0ce0d0b6 --- /dev/null +++ b/boot-proxy-exc/mach_host_impl.c~ @@ -0,0 +1,545 @@ +/* + Copyright (C) 2009 Free Software Foundation, Inc. + Written by Zheng Da. + + This file is part of the GNU Hurd. + + The GNU Hurd is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + The GNU Hurd 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with the GNU Hurd; see the file COPYING. If not, write to + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/* This file implements the server-side RPC functions of mach_host. */ + +#include <stdio.h> +#include <assert.h> + +#include <mach.h> +#include <hurd.h> +#include <hurd/ports.h> + +#include "util.h" +#include "list.h" +#include "mach_proxy.h" + +extern mach_port_t privileged_host_port; + +/* Set task priority. */ +kern_return_t +S_task_priority (mach_port_t task, int priority, boolean_t change_threads) +{ + struct task_info *task_pi; + error_t err; + + task_pi = ports_lookup_port (port_bucket, task, task_portclass); + if (task_pi == NULL) + return EOPNOTSUPP; + err = task_priority (task_pi->task_port, priority, change_threads); + debug ("%s", strerror (err)); + ports_port_deref (task_pi); + return err; +} + +/* Routine processor_set_tasks */ +kern_return_t +S_processor_set_tasks (mach_port_t processor_set, task_array_t *task_list, + mach_msg_type_number_t *task_listCnt) +{ + error_t err = 0; + mach_port_t *subhurd_tasks = NULL; + int size = 0; + /* no pseudo task port is created for the kernel task. */ + int num = 0; + int tot_nbtasks = ports_count_class (task_portclass) + num; + + size = tot_nbtasks * sizeof (mach_port_t); + err = vm_allocate (mach_task_self (), + (vm_address_t *) (void *) &subhurd_tasks, + size, 1); + if (err) + goto out; + + int get_pseudo_task_port (struct task_info *task_pi) + { + assert (num < tot_nbtasks); + subhurd_tasks[num++] = ports_get_right (task_pi); + return 0; + } + + foreach_task (get_pseudo_task_port); + assert (num == tot_nbtasks); + debug ("get %d tasks", tot_nbtasks); + *task_list = subhurd_tasks; + *task_listCnt = tot_nbtasks; + +out: + /* I enable the class here, + * so no pseudo task port can be created when I count the number of tasks. */ + ports_enable_class (task_portclass); + /* The array will be deallocated after it is sent, + * but the task ports in it don't need to, + * because I only call ports_get_right() + * and the reference count isn't increased. */ + return err; +} + +/* Get control port for a processor set. */ +kern_return_t +S_host_processor_set_priv (mach_port_t host_priv, mach_port_t set_name, + mach_port_t *set, mach_msg_type_name_t *setPoly) +{ + extern struct port_class *other_portclass; + struct port_info *pi; + kern_return_t ret = 0; + + // TODO create a port for each processor set + debug (""); + // TODO I should create the port for the processor set only once. + ret = ports_create_port (other_portclass, port_bucket, + sizeof (*pi), &pi); + debug ("%s", strerror (ret)); + if (ret) + return ret; + *set = ports_get_right (pi); + *setPoly = MACH_MSG_TYPE_MAKE_SEND; + ports_port_deref (pi); + return ret; +} + +/* Routine host_reboot */ +kern_return_t +S_host_reboot (mach_port_t host_priv, int options) +{ + debug (""); + assert (0); + // TODO + return EOPNOTSUPP; +} + +/* Routine vm_wire */ +kern_return_t +S_vm_wire (mach_port_t host_priv, mach_port_t task, + vm_address_t address, vm_size_t size, vm_prot_t access) +{ + debug (""); + assert (0); + // TODO + return EOPNOTSUPP; +} + +/* Routine thread_wire */ +kern_return_t +S_thread_wire (mach_port_t host_priv, mach_port_t thread, boolean_t wired) +{ + debug (""); + assert (0); + // TODO + return EOPNOTSUPP; +} + +//////////the request to the host isn't forwarded by the proxy////////// + +/* Routine host_processor_sets */ +kern_return_t +S_host_processor_sets (mach_port_t host, + processor_set_name_array_t *processor_sets, + mach_msg_type_number_t *processor_setsCnt) +{ + debug (""); + assert (0); + // the request to the host isn't forwarded. + return EOPNOTSUPP; +} + +/* Routine host_get_time */ +kern_return_t +S_host_get_time (mach_port_t host, time_value_t *current_time) +{ + debug (""); + assert (0); + // the request to the host isn't forwarded. + return EOPNOTSUPP; +} + +/* Routine host_info */ +kern_return_t +S_host_info (mach_port_t host, int flavor, host_info_t host_info_out, + mach_msg_type_number_t *host_info_outCnt) +{ + debug (""); + assert (0); + // the request to the host isn't forwarded. + return EOPNOTSUPP; +} + +/* Get string describing current kernel version. */ +kern_return_t +S_host_kernel_version (mach_port_t host, kernel_version_t kernel_version) +{ + debug (""); + assert (0); + // the proxy doesn't forward the request to the host port. + return EOPNOTSUPP; +} + +///////////////////the RPCs not used by Hurd////////////////////// + +/* Get list of processors on this host. */ +kern_return_t +S_host_processors (mach_port_t host_priv, + processor_array_t *processor_list, + mach_msg_type_number_t *processor_listCnt) +{ + debug (""); + assert (0); + // Hurd currently doesn't use it. + return EOPNOTSUPP; +} + +/* Start processor. */ +kern_return_t +S_processor_start (mach_port_t processor) +{ + debug (""); + assert (0); + // Hurd currently doesn't use it. + return EOPNOTSUPP; +} + +/* Exit processor -- may not be restartable. */ +kern_return_t +S_processor_exit (mach_port_t processor) +{ + debug (""); + assert (0); + // Hurd currently doesn't use it. + return EOPNOTSUPP; +} + +/* Get default processor set for host. */ +kern_return_t +S_processor_set_default (mach_port_t host, mach_port_t *default_set) +{ + debug (""); + assert (0); + // Hurd currently doesn't use it. + return EOPNOTSUPP; +} + +/* + * Create new processor set. Returns real port for manipulations, + * and name port for obtaining information. + */ +kern_return_t +S_processor_set_create (mach_port_t host, mach_port_t *new_set, + mach_port_t *new_name) +{ + debug (""); + assert (0); + // Hurd currently doesn't use it. + return EOPNOTSUPP; +} + +/* Destroy processor set. */ +kern_return_t +S_processor_set_destroy (mach_port_t set) +{ + debug (""); + assert (0); + // Hurd currently doesn't use it. + return EOPNOTSUPP; +} + +/* Assign processor to processor set. */ +kern_return_t +S_processor_assign (mach_port_t processor, mach_port_t new_set, boolean_t wait) +{ + debug (""); + assert (0); + // Hurd currently doesn't use it. + return EOPNOTSUPP; +} + +/* Get current assignment for thread. */ +kern_return_t +S_processor_get_assignment (mach_port_t processor, mach_port_t *assigned_set) +{ + debug (""); + assert (0); + // Hurd currently doesn't use it. + return EOPNOTSUPP; +} + +/* Assign task to processor set. */ +kern_return_t +S_task_assign (mach_port_t task, mach_port_t new_set, boolean_t assign_threads) +{ + debug (""); + assert (0); + // Hurd currently doesn't use it. + return EOPNOTSUPP; +} + +/* Assign task to default set. */ +kern_return_t +S_task_assign_default (mach_port_t task, boolean_t assign_threads) +{ + debug (""); + assert (0); + // Hurd currently doesn't use it. + return EOPNOTSUPP; +} + +/* Get current assignment for task. */ +kern_return_t +S_task_get_assignment (mach_port_t task, mach_port_t *assigned_set) +{ + debug (""); + assert (0); + // Hurd currently doesn't use it. + return EOPNOTSUPP; +} + +/* Set max priority for processor_set. */ +kern_return_t +S_processor_set_max_priority (mach_port_t processor_set, int max_priority, + boolean_t change_threads) +{ + debug (""); + assert (0); + // Hurd currently doesn't use it. + return EOPNOTSUPP; +} + +/* Routine processor_set_policy_enable */ +kern_return_t +S_processor_set_policy_enable (mach_port_t processor_set, int policy) +{ + debug (""); + assert (0); + // Hurd currently doesn't use it. + return EOPNOTSUPP; +} + +/* Routine processor_set_policy_disable */ +kern_return_t +S_processor_set_policy_disable (mach_port_t processor_set, int policy, + boolean_t change_threads) +{ + debug (""); + assert (0); + // Hurd currently doesn't use it. + return EOPNOTSUPP; +} + +/* Routine processor_set_threads */ +kern_return_t +S_processor_set_threads (mach_port_t processor_set, + thread_array_t *thread_list, + mach_msg_type_number_t *thread_listCnt) +{ + debug (""); + assert (0); + // Hurd currently doesn't use it. + return EOPNOTSUPP; +} + +/* Routine host_set_time */ +kern_return_t +S_host_set_time (mach_port_t host_priv, time_value_t new_time) +{ + debug (""); + assert (0); + // Hurd currently doesn't use it. + return EOPNOTSUPP; +} + +/* Routine host_adjust_time */ +kern_return_t +S_host_adjust_time (mach_port_t host_priv, time_value_t new_adjustment, + time_value_t *old_adjustment) +{ + debug (""); + assert (0); + // Hurd currently doesn't use it. + return EOPNOTSUPP; +} + +/* Routine processor_info */ +kern_return_t +S_processor_info (mach_port_t processor, int flavor, mach_port_t *host, + processor_info_t processor_info_out, + mach_msg_type_number_t *processor_info_outCnt) +{ + debug (""); + assert (0); + // Hurd currently doesn't use it. + return EOPNOTSUPP; +} + +/* Routine processor_set_info */ +kern_return_t +S_processor_set_info (mach_port_t set_name, int flavor, mach_port_t *host, + processor_set_info_t info_out, + mach_msg_type_number_t *info_outCnt) +{ + debug (""); + assert (0); + // Hurd currently doesn't use it. + return EOPNOTSUPP; +} + +/* Routine processor_control */ +kern_return_t +S_processor_control (mach_port_t processor, processor_info_t processor_cmd, + mach_msg_type_number_t processor_cmdCnt) +{ + debug (""); + assert (0); + // Hurd currently doesn't use it. + return EOPNOTSUPP; +} + +/* Routine host_get_boot_info */ +kern_return_t +S_host_get_boot_info (mach_port_t host_priv, kernel_boot_info_t boot_info) +{ + debug (""); + assert (0); + // Hurd currently doesn't use it. + return EOPNOTSUPP; +} + +///////////////////it's not a proxy for thread requests/////////////////// + +/* Assign thread to processor set. */ +kern_return_t +S_thread_assign (mach_port_t thread, mach_port_t new_set) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Assign thread to default set. */ +kern_return_t +S_thread_assign_default (mach_port_t thread) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Get current assignment for thread. */ +kern_return_t +S_thread_get_assignment (mach_port_t thread, mach_port_t *assigned_set) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Set priority for thread. */ +kern_return_t S_thread_priority (mach_port_t thread, int priority, + boolean_t set_max) +{ + debug (""); + assert (0); + return thread_priority (thread, priority, set_max); +} + +/* Set max priority for thread. */ +kern_return_t S_thread_max_priority (mach_port_t thread, + mach_port_t processor_set, + int max_priority) +{ + debug (""); + assert (0); + return thread_max_priority (thread, processor_set, max_priority); +} + +/* Routine thread_depress_abort */ +kern_return_t S_thread_depress_abort (mach_port_t thread) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Set policy for thread */ +kern_return_t S_thread_policy (mach_port_t thread, int policy, int data) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +////////////////////don't support obsolete requests/////////////////////// + +/* Routine yyy_host_info */ +/* obsolete */ +kern_return_t +S_yyy_host_info (mach_port_t host, int flavor, host_info_t host_info_out, + mach_msg_type_number_t *host_info_outCnt) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Routine yyy_processor_info */ +/* obsolete */ +kern_return_t +S_yyy_processor_info (mach_port_t processor, int flavor, mach_port_t *host, + processor_info_t processor_info_out, + mach_msg_type_number_t *processor_info_outCnt) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Routine yyy_processor_control */ +/* obsolete */ +kern_return_t +S_yyy_processor_control (mach_port_t processor, + processor_info_t processor_cmd, + mach_msg_type_number_t processor_cmdCnt) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* + * Get rights to default processor set for host. + * Replaced by host_processor_set_priv. + */ +kern_return_t +S_xxx_processor_set_default_priv (mach_port_t host, mach_port_t *default_set) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Routine yyy_processor_set_info */ +/* obsolete */ +kern_return_t +S_yyy_processor_set_info (mach_port_t set_name, int flavor, + mach_port_t *host, processor_set_info_t info_out, + mach_msg_type_number_t *info_outCnt) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} diff --git a/boot-proxy-exc/mach_host_impl.d b/boot-proxy-exc/mach_host_impl.d new file mode 100644 index 00000000..0a4b951e --- /dev/null +++ b/boot-proxy-exc/mach_host_impl.d @@ -0,0 +1,88 @@ +mach_host_impl.o mach_host_impl_pic.o mach_host_impl_p.o mach_host_impl.d: mach_host_impl.c /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h /usr/include/gnu/stubs-pthread.h \ + /usr/lib/gcc/i486-gnu/4.2.4/include/stddef.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/lib/gcc/i486-gnu/4.2.4/include/stdarg.h \ + /usr/include/bits/stdio-lock.h /usr/include/bits/libc-lock.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/bits/stdio.h /usr/include/assert.h /usr/include/mach.h \ + /usr/local/include/mach/mach_types.h \ + /usr/local/include/mach/host_info.h /usr/local/include/mach/machine.h \ + /usr/local/include/mach/machine/vm_types.h \ + /usr/local/include/mach/boolean.h \ + /usr/local/include/mach/machine/boolean.h \ + /usr/local/include/mach/memory_object.h /usr/local/include/mach/port.h \ + /usr/local/include/mach/pc_sample.h \ + /usr/local/include/mach/processor_info.h \ + /usr/local/include/mach/task_info.h \ + /usr/local/include/mach/time_value.h \ + /usr/local/include/mach/task_special_ports.h \ + /usr/local/include/mach/thread_info.h /usr/local/include/mach/policy.h \ + /usr/local/include/mach/thread_special_ports.h \ + /usr/local/include/mach/thread_status.h \ + /usr/local/include/mach/machine/thread_status.h \ + /usr/local/include/mach/machine/fp_reg.h \ + /usr/local/include/mach/vm_attributes.h \ + /usr/local/include/mach/vm_inherit.h /usr/local/include/mach/vm_prot.h \ + /usr/local/include/mach/vm_statistics.h \ + /usr/local/include/mach/std_types.h \ + /usr/local/include/mach/kern_return.h \ + /usr/local/include/mach/machine/kern_return.h /usr/include/mach_init.h \ + /usr/include/mach/mach_traps.h /usr/local/include/mach/message.h \ + /usr/include/mach/mach_interface.h /usr/include/mach/mach_port.h \ + /usr/include/mach/mach_host.h /usr/include/mach-shortcuts.h \ + /usr/include/hurd.h /usr/local/include/mach/mig_errors.h \ + ../hurd/hurd_types.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/bits/byteswap.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/pthread/pthreadtypes.h \ + /usr/include/xlocale.h /usr/include/bits/pthread.h \ + /usr/include/bits/thread-attr.h /usr/include/sched.h \ + /usr/include/bits/sched.h /usr/include/bits/mutex-attr.h \ + /usr/include/bits/mutex.h /usr/include/bits/spin-lock.h \ + /usr/include/bits/condition-attr.h /usr/include/bits/condition.h \ + /usr/include/bits/rwlock-attr.h /usr/include/bits/rwlock.h \ + /usr/include/bits/barrier-attr.h /usr/include/bits/barrier.h \ + /usr/include/bits/thread-specific.h /usr/include/bits/once.h \ + /usr/include/errno.h /usr/include/bits/errno.h /usr/include/hurd/auth.h \ + /usr/local/include/device/device_types.h \ + /usr/local/include/device/net_status.h /usr/local/include/device/bpf.h \ + /usr/include/sys/stat.h /usr/include/bits/stat.h \ + /usr/include/sys/statfs.h /usr/include/bits/statfs.h \ + /usr/include/sys/resource.h /usr/include/bits/resource.h \ + /usr/include/sys/utsname.h /usr/include/bits/utsname.h \ + /usr/include/hurd/process.h /usr/include/hurd/fs.h \ + /usr/include/hurd/io.h /usr/include/hurd/port.h \ + /usr/include/hurd/userlink.h /usr/include/hurd/signal.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/sys/ucontext.h /usr/include/bits/sigthread.h \ + /usr/include/hurd/msg.h ../include/cthreads.h \ + ../include/../libthreads/cthreads.h /usr/include/stdlib.h \ + /usr/include/bits/waitflags.h /usr/include/bits/waitstatus.h \ + /usr/include/alloca.h /usr/local/include/mach/machine/vm_param.h \ + /usr/include/machine-sp.h /usr/include/spin-lock.h \ + /usr/include/lock-intern.h /usr/include/machine-lock.h \ + /usr/include/setjmp.h /usr/include/bits/setjmp.h \ + /usr/include/hurd/threadvar.h ../hurd/ports.h \ + ../hurd/../libports/ports.h ../hurd/ihash.h ../hurd/../libihash/ihash.h \ + /usr/lib/gcc/i486-gnu/4.2.4/include/limits.h \ + /usr/lib/gcc/i486-gnu/4.2.4/include/syslimits.h /usr/include/limits.h \ + /usr/include/bits/posix1_lim.h /usr/include/bits/local_lim.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/xopen_lim.h \ + /usr/include/stdint.h /usr/include/bits/wchar.h \ + /usr/local/include/mach/notify.h util.h /usr/include/string.h \ + /usr/include/bits/string.h /usr/include/bits/string2.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/arpa/inet.h \ + /usr/include/netinet/in.h /usr/include/bits/in.h \ + /usr/include/netinet/ip.h /usr/include/syslog.h \ + /usr/include/sys/syslog.h /usr/include/bits/syslog-path.h list.h \ + mach_proxy.h diff --git a/boot-proxy-exc/mach_host_impl.o b/boot-proxy-exc/mach_host_impl.o Binary files differnew file mode 100644 index 00000000..c35ed7d5 --- /dev/null +++ b/boot-proxy-exc/mach_host_impl.o diff --git a/boot-proxy-exc/mach_impl.c b/boot-proxy-exc/mach_impl.c new file mode 100644 index 00000000..abead5a9 --- /dev/null +++ b/boot-proxy-exc/mach_impl.c @@ -0,0 +1,909 @@ +/* + Copyright (C) 2009 Free Software Foundation, Inc. + Written by Zheng Da. + + This file is part of the GNU Hurd. + + The GNU Hurd is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + The GNU Hurd 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with the GNU Hurd; see the file COPYING. If not, write to + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/* This file implements the server-side RPC functions of mach_host. */ + +#include <string.h> +#include <mach.h> +#include <hurd.h> +#include <assert.h> + +#include "util.h" +#include "mach_proxy.h" +#include "list.h" + +/* Routine task_create */ +kern_return_t +S_task_create (mach_port_t target_task, boolean_t inherit_memory, + mach_port_t *child_task, mach_msg_type_name_t *child_taskPoly) +{ + struct task_info *target_task_pi; + task_t real_child_task; + task_t pseudo_child_task; + error_t err; + + target_task_pi = ports_lookup_port (port_bucket, + target_task, task_portclass); + if (target_task_pi == NULL) + return EOPNOTSUPP; + err = task_create (target_task_pi->task_port, + inherit_memory, &real_child_task); + debug ("get a request from task %d: %s", + target_task_pi->task_port, strerror (err)); + ports_port_deref (target_task_pi); + if (err) + return err; + + err = create_pseudo_task (real_child_task, &pseudo_child_task); + if (err) + { + task_terminate (real_child_task); + return err; + } + + *child_task = pseudo_child_task; + *child_taskPoly = MACH_MSG_TYPE_COPY_SEND; + + debug ("new task: %d", real_child_task); + return err; +} + +/* Routine task_terminate */ +kern_return_t +S_task_terminate (mach_port_t target_task) +{ + struct task_info *target_task_pi; + error_t err; + + target_task_pi = ports_lookup_port (port_bucket, + target_task, task_portclass); + if (target_task_pi == NULL) + return EOPNOTSUPP; + err = task_terminate (target_task_pi->task_port); + debug ("get request from task %d: %s", + target_task_pi->task_port, strerror (err)); + ports_destroy_right (target_task_pi); + ports_port_deref (target_task_pi); + return err; +} + +/* Routine task_info */ +kern_return_t +S_task_info (mach_port_t target_task, int flavor, + task_info_t task_info_out, + mach_msg_type_number_t *task_info_outCnt) +{ + struct task_info *target_task_pi; + error_t err; + + target_task_pi = ports_lookup_port (port_bucket, + target_task, task_portclass); + if (target_task_pi == NULL) + return EOPNOTSUPP; + + err = task_info (target_task_pi->task_port, flavor, + task_info_out, task_info_outCnt); + debug ("%s", strerror (err)); + ports_port_deref (target_task_pi); + return err; +} + +/* Routine vm_allocate */ +kern_return_t +S_vm_allocate (mach_port_t target_task, vm_address_t *address, + vm_size_t size, boolean_t anywhere) +{ + struct task_info *target_task_pi; + error_t err; + + target_task_pi = ports_lookup_port (port_bucket, + target_task, task_portclass); + if (target_task_pi == NULL) + return EOPNOTSUPP; + + /* This should be enough. */ + err = vm_allocate (target_task_pi->task_port, address, size, anywhere); + debug ("request is from task %d, address: %d, size: %d, anywhere: %d, %s", + target_task_pi->task_port, *address, size, anywhere, strerror (err)); + ports_port_deref (target_task_pi); + return err; +} + +/* Routine vm_deallocate */ +kern_return_t +S_vm_deallocate (mach_port_t target_task, + vm_address_t address, vm_size_t size) +{ + struct task_info *target_task_pi; + error_t err; + + target_task_pi = ports_lookup_port (port_bucket, + target_task, task_portclass); + if (target_task_pi == NULL) + return EOPNOTSUPP; + err = vm_deallocate (target_task_pi->task_port, address, size); + debug ("get a request from task %d: %s", + target_task_pi->task_port, strerror (err)); + ports_port_deref (target_task_pi); + return err; +} + +/* Routine vm_protect */ +kern_return_t +S_vm_protect (mach_port_t target_task, vm_address_t address, + vm_size_t size, boolean_t set_maximum, + vm_prot_t new_protection) +{ + struct task_info *target_task_pi; + error_t err; + + target_task_pi = ports_lookup_port (port_bucket, + target_task, task_portclass); + if (target_task_pi == NULL) + return EOPNOTSUPP; + err = vm_protect (target_task_pi->task_port, address, + size, set_maximum, new_protection); + debug ("request is from task %d: %s", + target_task_pi->task_port, strerror (err)); + ports_port_deref (target_task_pi); + return err; +} + +/* Routine vm_inherit */ +kern_return_t +S_vm_inherit (mach_port_t target_task, vm_address_t address, + vm_size_t size, vm_inherit_t new_inheritance) +{ + struct task_info *target_task_pi; + error_t err; + + target_task_pi = ports_lookup_port (port_bucket, + target_task, task_portclass); + if (target_task_pi == NULL) + return EOPNOTSUPP; + err = vm_inherit (target_task_pi->task_port, address, + size, new_inheritance); + debug ("%s", strerror (err)); + ports_port_deref (target_task_pi); + return err; +} + +/* Routine vm_read */ +kern_return_t +S_vm_read (mach_port_t target_task, vm_address_t address, + vm_size_t size, vm_offset_t *data, + mach_msg_type_number_t *dataCnt) +{ + struct task_info *target_task_pi; + error_t err; + + target_task_pi = ports_lookup_port (port_bucket, + target_task, task_portclass); + if (target_task_pi == NULL) + return EOPNOTSUPP; + + err = vm_read (target_task_pi->task_port, address, size, data, dataCnt); + debug ("get a request from task %d: %s", + target_task_pi->task_port, strerror (err)); + ports_port_deref (target_task_pi); + /* The deallocation bit is set.*/ + return err; +} + +/* Routine vm_write */ +kern_return_t +S_vm_write (mach_port_t target_task, vm_address_t address, + vm_offset_t data, mach_msg_type_number_t dataCnt) +{ + struct task_info *target_task_pi; + error_t err; + + target_task_pi = ports_lookup_port (port_bucket, + target_task, task_portclass); + if (target_task_pi == NULL) + return EOPNOTSUPP; + err = vm_write (target_task_pi->task_port, address, data, dataCnt); + debug ("get a request from task %d: %s", + target_task_pi->task_port, strerror (err)); + ports_port_deref (target_task_pi); + /* the proxy get the mapped pages from the client, + * deallocate it here. */ + vm_deallocate (mach_task_self (), data, dataCnt); + return err; +} + +/* Routine vm_copy */ +kern_return_t +S_vm_copy (mach_port_t target_task, vm_address_t source_address, + vm_size_t size, vm_address_t dest_address) +{ + struct task_info *target_task_pi; + error_t err; + + target_task_pi = ports_lookup_port (port_bucket, + target_task, task_portclass); + if (target_task_pi == NULL) + return EOPNOTSUPP; + + err = vm_copy (target_task_pi->task_port, source_address, + size, dest_address); + debug ("%s", strerror (err)); + ports_port_deref (target_task_pi); + return err; +} + +/* Routine vm_region */ +kern_return_t +S_vm_region (mach_port_t target_task, vm_address_t *address, + vm_size_t *size, vm_prot_t *protection, + vm_prot_t *max_protection, vm_inherit_t *inheritance, + boolean_t *is_shared, mach_port_t *object_name, + vm_offset_t *offset) +{ + struct task_info *target_task_pi; + error_t err; + + target_task_pi = ports_lookup_port (port_bucket, + target_task, task_portclass); + if (target_task_pi == NULL) + return EOPNOTSUPP; + + err = vm_region (target_task_pi->task_port, address, size, protection, + max_protection, inheritance, is_shared, object_name, offset); + debug ("get a request from task %d: %s, object: %d", + target_task_pi->task_port, strerror (err), *object_name); + ports_port_deref (target_task_pi); + return err; +} + +/* Routine vm_statistics */ +kern_return_t +S_vm_statistics (mach_port_t target_task, vm_statistics_data_t *vm_stats) +{ + struct task_info *target_task_pi; + error_t err; + + target_task_pi = ports_lookup_port (port_bucket, + target_task, task_portclass); + if (target_task_pi == NULL) + return EOPNOTSUPP; + + err = vm_statistics (target_task_pi->task_port, vm_stats); + debug ("request is from task %d: %s", + target_task_pi->task_port, strerror (err)); + ports_port_deref (target_task_pi); + return err; +} + +/* Routine mach_ports_register */ +kern_return_t +S_mach_ports_register (mach_port_t target_task, + mach_port_array_t init_port_set, + mach_msg_type_number_t init_port_setCnt) +{ + debug (""); + assert (0); + // not used by Hurd + return EOPNOTSUPP; +} + +/* Routine mach_ports_lookup */ +kern_return_t +S_mach_ports_lookup (mach_port_t target_task, + mach_port_array_t *init_port_set, + mach_msg_type_number_t *init_port_setCnt) +{ + debug (""); + assert (0); + // not used by Hurd + return EOPNOTSUPP; +} + +/* Routine vm_set_default_memory_manager */ +kern_return_t +S_vm_set_default_memory_manager (mach_port_t host_priv, + mach_port_t *default_manager) +{ + extern mach_port_t defpager; + debug (""); + *default_manager = defpager; + return 0; +} + + +/* Routine xxx_task_info */ +kern_return_t +S_xxx_task_info (mach_port_t target_task, int flavor, + task_info_t task_info_out, + mach_msg_type_number_t *task_info_outCnt) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Routine xxx_host_info */ +kern_return_t +S_xxx_host_info (mach_port_t target_task, machine_info_data_t *info) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Routine xxx_slot_info */ +kern_return_t +S_xxx_slot_info (mach_port_t target_task, int slot, machine_slot_data_t *info) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Routine xxx_cpu_control */ +kern_return_t +S_xxx_cpu_control (mach_port_t target_task, int cpu, boolean_t running) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Routine task_suspend */ +kern_return_t +S_task_suspend (mach_port_t target_task) +{ + struct task_info *target_task_pi; + error_t err; + + target_task_pi = ports_lookup_port (port_bucket, + target_task, task_portclass); + if (target_task_pi == NULL) + return EOPNOTSUPP; + err = task_suspend (target_task_pi->task_port); + debug ("get request from task %d: %s", + target_task_pi->task_port, strerror (err)); + ports_port_deref (target_task_pi); + return err; +} + +/* Routine task_resume */ +kern_return_t +S_task_resume (mach_port_t target_task) +{ + struct task_info *target_task_pi; + error_t err; + + target_task_pi = ports_lookup_port (port_bucket, + target_task, task_portclass); + if (target_task_pi == NULL) + return EOPNOTSUPP; + + err = task_resume (target_task_pi->task_port); + debug ("get request from task %d: %s", + target_task_pi->task_port, strerror (err)); + ports_port_deref (target_task_pi); + return err; +} + +/* Routine task_get_special_port */ +kern_return_t +S_task_get_special_port (mach_port_t target_task, int which_port, + mach_port_t *special_port, + mach_msg_type_name_t *special_portPoly) +{ + struct task_info *target_task_pi; + error_t err; + + target_task_pi = ports_lookup_port (port_bucket, + target_task, task_portclass); + if (target_task_pi == NULL) + return EOPNOTSUPP; + + err = task_get_special_port (target_task_pi->task_port, + which_port, special_port); + debug ("request is from task %d (%d, %d): %s\n", + target_task_pi->task_port, which_port, *special_port, strerror (err)); + ports_port_deref (target_task_pi); + if (err) + return err; + *special_portPoly = MACH_MSG_TYPE_MOVE_SEND; + return err; +} + +/* Routine task_set_special_port */ +kern_return_t +S_task_set_special_port (mach_port_t target_task, int which_port, + mach_port_t special_port) +{ + struct task_info *target_task_pi; + error_t err; + + target_task_pi = ports_lookup_port (port_bucket, + target_task, task_portclass); + if (target_task_pi == NULL) + return EOPNOTSUPP; + + if (which_port == TASK_EXCEPTION_PORT) + { + struct port_info *new_exc_pi; + struct port_info *old_exc_pi; + mach_port_t old_user_exc_port; + mach_port_t new_exc_port; + + err = ports_create_port (exc_portclass, port_bucket, + sizeof (new_exc_pi), &new_exc_pi); + if (err) + { + ports_port_deref (target_task_pi); + return err; + } + new_exc_port = ports_get_send_right (new_exc_pi); + + mutex_lock (&target_task_pi->lock); + old_exc_pi = target_task_pi->exc_pi; + old_user_exc_port = target_task_pi->user_exc_port; + err = task_set_special_port (target_task_pi->task_port, + which_port, new_exc_port); + target_task_pi->user_exc_port = special_port; + target_task_pi->exc_pi = new_exc_pi; + mutex_unlock (&target_task_pi->lock); + + ports_port_deref (new_exc_pi); + if (old_user_exc_port) + mach_port_deallocate (mach_task_self (), old_user_exc_port); + if (old_exc_pi) + ports_destroy_right (old_exc_pi); + debug ("get request from task %d (%d, %d): %s", + target_task_pi->task_port, which_port, + special_port, strerror (err)); + } + else + { + err = task_set_special_port (target_task_pi->task_port, + which_port, special_port); + debug ("get request from task %d (%d, %d): %s", + target_task_pi->task_port, which_port, + special_port, strerror (err)); + mach_port_deallocate (mach_task_self (), special_port); + } + ports_port_deref (target_task_pi); + return err; +} + +/* Routine task_ras_control */ +kern_return_t +S_task_ras_control (mach_port_t target_task, vm_address_t basepc, + vm_address_t boundspc, int flavor) +{ + struct task_info *target_task_pi; + error_t err; + + target_task_pi = ports_lookup_port (port_bucket, + target_task, task_portclass); + if (target_task_pi == NULL) + return EOPNOTSUPP; + err = task_ras_control (target_task_pi->task_port, basepc, boundspc, flavor); + debug ("%s", strerror (err)); + ports_port_deref (target_task_pi); + return err; +} + +/* Routine vm_map */ +kern_return_t +S_vm_map (mach_port_t target_task, vm_address_t *address, vm_size_t size, + vm_address_t mask, boolean_t anywhere, mach_port_t memory_object, + vm_offset_t offset, boolean_t copy, vm_prot_t cur_protection, + vm_prot_t max_protection, vm_inherit_t inheritance) +{ + struct task_info *target_task_pi; + error_t err; + + target_task_pi = ports_lookup_port (port_bucket, + target_task, task_portclass); + if (target_task_pi == NULL) + return EOPNOTSUPP; + err = vm_map (target_task_pi->task_port, address, size, mask, + anywhere, memory_object, offset, copy, + cur_protection, max_protection, inheritance); + debug ("request is from task %d, anywhere: %d: %s", + target_task_pi->task_port, anywhere, strerror (err)); + ports_port_deref (target_task_pi); + mach_port_deallocate (mach_task_self (), memory_object); + return err; +} + +/* Routine vm_machine_attribute */ +kern_return_t +S_vm_machine_attribute (mach_port_t target_task, vm_address_t address, + vm_size_t size, vm_machine_attribute_t attribute, + vm_machine_attribute_val_t *value) +{ + struct task_info *target_task_pi; + error_t err; + + target_task_pi = ports_lookup_port (port_bucket, + target_task, task_portclass); + if (target_task_pi == NULL) + return EOPNOTSUPP; + err = vm_machine_attribute (target_task_pi->task_port, address, + size, attribute, value); + debug ("%s", strerror (err)); + ports_port_deref (target_task_pi); + return err; +} + +/* Routine task_threads */ +kern_return_t +S_task_threads (mach_port_t target_task, thread_array_t *thread_list, + mach_msg_type_number_t *thread_listCnt) +{ + struct task_info *target_task_pi; + error_t err; + + target_task_pi = ports_lookup_port (port_bucket, + target_task, task_portclass); + if (target_task_pi == NULL) + return EOPNOTSUPP; + + // TODO: use move send + err = task_threads (target_task_pi->task_port, + thread_list, thread_listCnt); + debug ("get a request from task %d: %s", + target_task_pi->task_port, strerror (err)); +// info ("task_threads: %s, number of threads: %d", +// strerror (err), *thread_listCnt); + ports_port_deref (target_task_pi); + return err; +} + +/* Routine thread_create */ +kern_return_t +S_thread_create (mach_port_t parent_task, mach_port_t *child_thread, + mach_msg_type_name_t *child_threadPoly) +{ + struct task_info *target_task_pi; + error_t err; + + target_task_pi = ports_lookup_port (port_bucket, + parent_task, task_portclass); + if (target_task_pi == NULL) + return EOPNOTSUPP; + err = thread_create (target_task_pi->task_port, child_thread); + debug ("get a request from task %d: thread port: %d: %s", + target_task_pi->task_port, *child_thread, strerror (err)); + ports_port_deref (target_task_pi); + *child_threadPoly = MACH_MSG_TYPE_MOVE_SEND; + return err; +} + +////////////////////it doesn't forward thread request//////////////// + +/* Routine thread_suspend */ +kern_return_t +S_thread_suspend (mach_port_t target_thread) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Routine thread_resume */ +kern_return_t +S_thread_resume (mach_port_t target_thread) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Routine thread_abort */ +kern_return_t +S_thread_abort (mach_port_t target_thread) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Routine xxx_thread_get_state */ +kern_return_t +S_xxx_thread_get_state (mach_port_t target_thread, int flavor, + thread_state_t old_state, + mach_msg_type_number_t *old_stateCnt) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Routine xxx_thread_set_state */ +kern_return_t +S_xxx_thread_set_state (mach_port_t target_thread, int flavor, + thread_state_t new_state, + mach_msg_type_number_t new_stateCnt) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Routine xxx_thread_info */ +kern_return_t +S_xxx_thread_info (mach_port_t target_thread, int flavor, + thread_info_t thread_info_out, + mach_msg_type_number_t *thread_info_outCnt) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Routine thread_get_special_port */ +kern_return_t +S_thread_get_special_port (mach_port_t thread, int which_port, + mach_port_t *special_port) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Routine thread_set_special_port */ +kern_return_t +S_thread_set_special_port (mach_port_t thread, int which_port, + mach_port_t special_port) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Routine thread_terminate */ +kern_return_t +S_thread_terminate (mach_port_t target_thread) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Routine thread_get_state */ +kern_return_t +S_thread_get_state (mach_port_t target_thread, int flavor, + thread_state_t old_state, + mach_msg_type_number_t *old_stateCnt) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Routine thread_set_state */ +kern_return_t +S_thread_set_state (mach_port_t target_thread, int flavor, + thread_state_t new_state, + mach_msg_type_number_t new_stateCnt) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Routine thread_info */ +kern_return_t +S_thread_info (mach_port_t target_thread, int flavor, + thread_info_t thread_info_out, + mach_msg_type_number_t *thread_info_outCnt) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/////////////////////RPC related to memory object//////////////////// +//////////////////they are not needed to be forwarded//////////////// + +/* SimpleRoutine memory_object_data_provided */ +kern_return_t +S_memory_object_data_provided (mach_port_t memory_control, + vm_offset_t offset, vm_offset_t data, + mach_msg_type_number_t dataCnt, + vm_prot_t lock_value) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* SimpleRoutine memory_object_data_unavailable */ +kern_return_t +S_memory_object_data_unavailable (mach_port_t memory_control, + vm_offset_t offset, vm_size_t size) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Routine memory_object_get_attributes */ +kern_return_t +S_memory_object_get_attributes (mach_port_t memory_control, + boolean_t *object_ready, boolean_t *may_cache, + memory_object_copy_strategy_t *copy_strategy) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* SimpleRoutine xxx_memory_object_lock_request */ +kern_return_t +S_xxx_memory_object_lock_request (mach_port_t memory_control, + vm_offset_t offset, vm_size_t size, + boolean_t should_clean, + boolean_t should_flush, + vm_prot_t lock_value, + mach_port_t reply_to, + mach_msg_type_name_t reply_toPoly) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* SimpleRoutine memory_object_lock_request */ +kern_return_t +S_memory_object_lock_request ( mach_port_t memory_control, + vm_offset_t offset, vm_size_t size, + memory_object_return_t should_return, + boolean_t should_flush, + vm_prot_t lock_value, mach_port_t reply_to, + mach_msg_type_name_t reply_toPoly) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* SimpleRoutine memory_object_data_error */ +kern_return_t +S_memory_object_data_error (mach_port_t memory_control, + vm_offset_t offset, vm_size_t size, + kern_return_t error_value) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* SimpleRoutine memory_object_set_attributes */ +kern_return_t +S_memory_object_set_attributes (mach_port_t memory_control, + boolean_t object_ready, boolean_t may_cache, + memory_object_copy_strategy_t copy_strategy) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* SimpleRoutine memory_object_destroy */ +kern_return_t +S_memory_object_destroy (mach_port_t memory_control, kern_return_t reason) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* SimpleRoutine memory_object_data_supply */ +kern_return_t +S_memory_object_data_supply (mach_port_t memory_control, + vm_offset_t offset, vm_offset_t data, + mach_msg_type_number_t dataCnt, + vm_prot_t lock_value, boolean_t precious, + mach_port_t reply_to, + mach_msg_type_name_t reply_toPoly) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* SimpleRoutine memory_object_ready */ +kern_return_t +S_memory_object_ready (mach_port_t memory_control, boolean_t may_cache, + memory_object_copy_strategy_t copy_strategy) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* SimpleRoutine memory_object_change_attributes */ +kern_return_t +S_memory_object_change_attributes (mach_port_t memory_control, + boolean_t may_cache, + memory_object_copy_strategy_t copy_strategy, + mach_port_t reply_to, + mach_msg_type_name_t reply_toPoly) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +///////////////////////RPCs related to emulation///////////////////// +//////////////////////subhurd doesn't support it.//////////////////// + +/* Routine task_get_emulation_vector */ +kern_return_t +S_task_get_emulation_vector (mach_port_t task, int *vector_start, + emulation_vector_t *emulation_vector, + mach_msg_type_number_t *emulation_vectorCnt) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Routine task_set_emulation_vector */ +kern_return_t +S_task_set_emulation_vector (mach_port_t task, int vector_start, + emulation_vector_t emulation_vector, + mach_msg_type_number_t emulation_vectorCnt) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Routine xxx_task_get_emulation_vector */ +kern_return_t +S_xxx_task_get_emulation_vector (mach_port_t task, int *vector_start, + emulation_vector_t emulation_vector, + mach_msg_type_number_t *emulation_vectorCnt) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Routine xxx_task_set_emulation_vector */ +kern_return_t +S_xxx_task_set_emulation_vector (mach_port_t task, int vector_start, + emulation_vector_t emulation_vector, + mach_msg_type_number_t emulation_vectorCnt) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Routine task_set_emulation */ +kern_return_t +S_task_set_emulation (mach_port_t target_port, + vm_address_t routine_entry_pt, int routine_number) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} diff --git a/boot-proxy-exc/mach_impl.c~ b/boot-proxy-exc/mach_impl.c~ new file mode 100644 index 00000000..a5c53197 --- /dev/null +++ b/boot-proxy-exc/mach_impl.c~ @@ -0,0 +1,906 @@ +/* + Copyright (C) 2009 Free Software Foundation, Inc. + Written by Zheng Da. + + This file is part of the GNU Hurd. + + The GNU Hurd is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + The GNU Hurd 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with the GNU Hurd; see the file COPYING. If not, write to + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/* This file implements the server-side RPC functions of mach_host. */ + +#include <string.h> +#include <mach.h> +#include <hurd.h> +#include <assert.h> + +#include "util.h" +#include "mach_proxy.h" +#include "list.h" + +/* Routine task_create */ +kern_return_t +S_task_create (mach_port_t target_task, boolean_t inherit_memory, + mach_port_t *child_task, mach_msg_type_name_t *child_taskPoly) +{ + struct task_info *target_task_pi; + task_t real_child_task; + task_t pseudo_child_task; + error_t err; + + target_task_pi = ports_lookup_port (port_bucket, + target_task, task_portclass); + if (target_task_pi == NULL) + return EOPNOTSUPP; + err = task_create (target_task_pi->task_port, + inherit_memory, &real_child_task); + debug ("get a request from task %d: %s", + target_task_pi->task_port, strerror (err)); + ports_port_deref (target_task_pi); + if (err) + return err; + + err = create_pseudo_task (real_child_task, &pseudo_child_task); + if (err) + { + task_terminate (real_child_task); + return err; + } + + *child_task = pseudo_child_task; + *child_taskPoly = MACH_MSG_TYPE_COPY_SEND; + + debug ("new task: %d", real_child_task); + return err; +} + +/* Routine task_terminate */ +kern_return_t +S_task_terminate (mach_port_t target_task) +{ + struct task_info *target_task_pi; + error_t err; + + target_task_pi = ports_lookup_port (port_bucket, + target_task, task_portclass); + if (target_task_pi == NULL) + return EOPNOTSUPP; + err = task_terminate (target_task_pi->task_port); + debug ("get request from task %d: %s", + target_task_pi->task_port, strerror (err)); + ports_destroy_right (target_task_pi); + ports_port_deref (target_task_pi); + return err; +} + +/* Routine task_info */ +kern_return_t +S_task_info (mach_port_t target_task, int flavor, + task_info_t task_info_out, + mach_msg_type_number_t *task_info_outCnt) +{ + struct task_info *target_task_pi; + error_t err; + + target_task_pi = ports_lookup_port (port_bucket, + target_task, task_portclass); + if (target_task_pi == NULL) + return EOPNOTSUPP; + + err = task_info (target_task_pi->task_port, flavor, + task_info_out, task_info_outCnt); + debug ("%s", strerror (err)); + ports_port_deref (target_task_pi); + return err; +} + +/* Routine vm_allocate */ +kern_return_t +S_vm_allocate (mach_port_t target_task, vm_address_t *address, + vm_size_t size, boolean_t anywhere) +{ + struct task_info *target_task_pi; + error_t err; + + target_task_pi = ports_lookup_port (port_bucket, + target_task, task_portclass); + if (target_task_pi == NULL) + return EOPNOTSUPP; + + /* This should be enough. */ + err = vm_allocate (target_task_pi->task_port, address, size, anywhere); + debug ("request is from task %d, address: %d, size: %d, anywhere: %d, %s", + target_task_pi->task_port, *address, size, anywhere, strerror (err)); + ports_port_deref (target_task_pi); + return err; +} + +/* Routine vm_deallocate */ +kern_return_t +S_vm_deallocate (mach_port_t target_task, + vm_address_t address, vm_size_t size) +{ + struct task_info *target_task_pi; + error_t err; + + target_task_pi = ports_lookup_port (port_bucket, + target_task, task_portclass); + if (target_task_pi == NULL) + return EOPNOTSUPP; + err = vm_deallocate (target_task_pi->task_port, address, size); + debug ("get a request from task %d: %s", + target_task_pi->task_port, strerror (err)); + ports_port_deref (target_task_pi); + return err; +} + +/* Routine vm_protect */ +kern_return_t +S_vm_protect (mach_port_t target_task, vm_address_t address, + vm_size_t size, boolean_t set_maximum, + vm_prot_t new_protection) +{ + struct task_info *target_task_pi; + error_t err; + + target_task_pi = ports_lookup_port (port_bucket, + target_task, task_portclass); + if (target_task_pi == NULL) + return EOPNOTSUPP; + err = vm_protect (target_task_pi->task_port, address, + size, set_maximum, new_protection); + debug ("request is from task %d: %s", + target_task_pi->task_port, strerror (err)); + ports_port_deref (target_task_pi); + return err; +} + +/* Routine vm_inherit */ +kern_return_t +S_vm_inherit (mach_port_t target_task, vm_address_t address, + vm_size_t size, vm_inherit_t new_inheritance) +{ + struct task_info *target_task_pi; + error_t err; + + target_task_pi = ports_lookup_port (port_bucket, + target_task, task_portclass); + if (target_task_pi == NULL) + return EOPNOTSUPP; + err = vm_inherit (target_task_pi->task_port, address, + size, new_inheritance); + debug ("%s", strerror (err)); + ports_port_deref (target_task_pi); + return err; +} + +/* Routine vm_read */ +kern_return_t +S_vm_read (mach_port_t target_task, vm_address_t address, + vm_size_t size, vm_offset_t *data, + mach_msg_type_number_t *dataCnt) +{ + struct task_info *target_task_pi; + error_t err; + + target_task_pi = ports_lookup_port (port_bucket, + target_task, task_portclass); + if (target_task_pi == NULL) + return EOPNOTSUPP; + + err = vm_read (target_task_pi->task_port, address, size, data, dataCnt); + debug ("get a request from task %d: %s", + target_task_pi->task_port, strerror (err)); + ports_port_deref (target_task_pi); + /* The deallocation bit is set.*/ + return err; +} + +/* Routine vm_write */ +kern_return_t +S_vm_write (mach_port_t target_task, vm_address_t address, + vm_offset_t data, mach_msg_type_number_t dataCnt) +{ + struct task_info *target_task_pi; + error_t err; + + target_task_pi = ports_lookup_port (port_bucket, + target_task, task_portclass); + if (target_task_pi == NULL) + return EOPNOTSUPP; + err = vm_write (target_task_pi->task_port, address, data, dataCnt); + debug ("get a request from task %d: %s", + target_task_pi->task_port, strerror (err)); + ports_port_deref (target_task_pi); + /* the proxy get the mapped pages from the client, + * deallocate it here. */ + vm_deallocate (mach_task_self (), data, dataCnt); + return err; +} + +/* Routine vm_copy */ +kern_return_t +S_vm_copy (mach_port_t target_task, vm_address_t source_address, + vm_size_t size, vm_address_t dest_address) +{ + struct task_info *target_task_pi; + error_t err; + + target_task_pi = ports_lookup_port (port_bucket, + target_task, task_portclass); + if (target_task_pi == NULL) + return EOPNOTSUPP; + + err = vm_copy (target_task_pi->task_port, source_address, + size, dest_address); + debug ("%s", strerror (err)); + ports_port_deref (target_task_pi); + return err; +} + +/* Routine vm_region */ +kern_return_t +S_vm_region (mach_port_t target_task, vm_address_t *address, + vm_size_t *size, vm_prot_t *protection, + vm_prot_t *max_protection, vm_inherit_t *inheritance, + boolean_t *is_shared, mach_port_t *object_name, + vm_offset_t *offset) +{ + struct task_info *target_task_pi; + error_t err; + + target_task_pi = ports_lookup_port (port_bucket, + target_task, task_portclass); + if (target_task_pi == NULL) + return EOPNOTSUPP; + + err = vm_region (target_task_pi->task_port, address, size, protection, + max_protection, inheritance, is_shared, object_name, offset); + debug ("get a request from task %d: %s, object: %d", + target_task_pi->task_port, strerror (err), *object_name); + ports_port_deref (target_task_pi); + return err; +} + +/* Routine vm_statistics */ +kern_return_t +S_vm_statistics (mach_port_t target_task, vm_statistics_data_t *vm_stats) +{ + struct task_info *target_task_pi; + error_t err; + + target_task_pi = ports_lookup_port (port_bucket, + target_task, task_portclass); + if (target_task_pi == NULL) + return EOPNOTSUPP; + + err = vm_statistics (target_task_pi->task_port, vm_stats); + debug ("request is from task %d: %s", + target_task_pi->task_port, strerror (err)); + ports_port_deref (target_task_pi); + return err; +} + +/* Routine mach_ports_register */ +kern_return_t +S_mach_ports_register (mach_port_t target_task, + mach_port_array_t init_port_set, + mach_msg_type_number_t init_port_setCnt) +{ + debug (""); + assert (0); + // not used by Hurd + return EOPNOTSUPP; +} + +/* Routine mach_ports_lookup */ +kern_return_t +S_mach_ports_lookup (mach_port_t target_task, + mach_port_array_t *init_port_set, + mach_msg_type_number_t *init_port_setCnt) +{ + debug (""); + assert (0); + // not used by Hurd + return EOPNOTSUPP; +} + +/* Routine vm_set_default_memory_manager */ +kern_return_t +S_vm_set_default_memory_manager (mach_port_t host_priv, + mach_port_t *default_manager) +{ + extern mach_port_t defpager; + debug (""); + *default_manager = defpager; + return 0; +} + + +/* Routine xxx_task_info */ +kern_return_t +S_xxx_task_info (mach_port_t target_task, int flavor, + task_info_t task_info_out, + mach_msg_type_number_t *task_info_outCnt) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Routine xxx_host_info */ +kern_return_t +S_xxx_host_info (mach_port_t target_task, machine_info_data_t *info) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Routine xxx_slot_info */ +kern_return_t +S_xxx_slot_info (mach_port_t target_task, int slot, machine_slot_data_t *info) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Routine xxx_cpu_control */ +kern_return_t +S_xxx_cpu_control (mach_port_t target_task, int cpu, boolean_t running) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Routine task_suspend */ +kern_return_t +S_task_suspend (mach_port_t target_task) +{ + struct task_info *target_task_pi; + error_t err; + + target_task_pi = ports_lookup_port (port_bucket, + target_task, task_portclass); + if (target_task_pi == NULL) + return EOPNOTSUPP; + err = task_suspend (target_task_pi->task_port); + debug ("get request from task %d: %s", + target_task_pi->task_port, strerror (err)); + ports_port_deref (target_task_pi); + return err; +} + +/* Routine task_resume */ +kern_return_t +S_task_resume (mach_port_t target_task) +{ + struct task_info *target_task_pi; + error_t err; + + target_task_pi = ports_lookup_port (port_bucket, + target_task, task_portclass); + if (target_task_pi == NULL) + return EOPNOTSUPP; + + err = task_resume (target_task_pi->task_port); + debug ("get request from task %d: %s", + target_task_pi->task_port, strerror (err)); + ports_port_deref (target_task_pi); + return err; +} + +/* Routine task_get_special_port */ +kern_return_t +S_task_get_special_port (mach_port_t target_task, int which_port, + mach_port_t *special_port, + mach_msg_type_name_t *special_portPoly) +{ + struct task_info *target_task_pi; + error_t err; + + target_task_pi = ports_lookup_port (port_bucket, + target_task, task_portclass); + if (target_task_pi == NULL) + return EOPNOTSUPP; + + err = task_get_special_port (target_task_pi->task_port, + which_port, special_port); + debug ("request is from task %d (%d, %d): %s\n", + target_task_pi->task_port, which_port, *special_port, strerror (err)); + ports_port_deref (target_task_pi); + if (err) + return err; + *special_portPoly = MACH_MSG_TYPE_MOVE_SEND; + return err; +} + +/* Routine task_set_special_port */ +kern_return_t +S_task_set_special_port (mach_port_t target_task, int which_port, + mach_port_t special_port) +{ + struct task_info *target_task_pi; + error_t err; + + target_task_pi = ports_lookup_port (port_bucket, + target_task, task_portclass); + if (target_task_pi == NULL) + return EOPNOTSUPP; + + if (which_port == TASK_EXCEPTION_PORT) + { + struct port_info *new_exc_pi; + struct port_info *old_exc_pi; + mach_port_t old_user_exc_port; + mach_port_t new_exc_port; + + err = ports_create_port (exc_portclass, port_bucket, + sizeof (new_exc_pi), &new_exc_pi); + if (err) + { + ports_port_deref (target_task_pi); + return err; + } + new_exc_port = ports_get_send_right (new_exc_pi); + + mutex_lock (&target_task_pi->lock); + old_exc_pi = target_task_pi->exc_pi; + old_user_exc_port = target_task_pi->user_exc_port; + err = task_set_special_port (target_task_pi->task_port, + which_port, new_exc_port); + target_task_pi->user_exc_port = special_port; + target_task_pi->exc_pi = new_exc_pi; + mutex_unlock (&target_task_pi->lock); + + ports_port_deref (new_exc_pi); + if (old_user_exc_port) + mach_port_deallocate (mach_task_self (), old_user_exc_port); + if (old_exc_pi) + ports_destroy_right (old_exc_pi); + } + else + { + err = task_set_special_port (target_task_pi->task_port, + which_port, special_port); + debug ("get request from task %d (%d, %d): %s", + target_task_pi->task_port, which_port, + special_port, strerror (err)); + mach_port_deallocate (mach_task_self (), special_port); + } + ports_port_deref (target_task_pi); + return err; +} + +/* Routine task_ras_control */ +kern_return_t +S_task_ras_control (mach_port_t target_task, vm_address_t basepc, + vm_address_t boundspc, int flavor) +{ + struct task_info *target_task_pi; + error_t err; + + target_task_pi = ports_lookup_port (port_bucket, + target_task, task_portclass); + if (target_task_pi == NULL) + return EOPNOTSUPP; + err = task_ras_control (target_task_pi->task_port, basepc, boundspc, flavor); + debug ("%s", strerror (err)); + ports_port_deref (target_task_pi); + return err; +} + +/* Routine vm_map */ +kern_return_t +S_vm_map (mach_port_t target_task, vm_address_t *address, vm_size_t size, + vm_address_t mask, boolean_t anywhere, mach_port_t memory_object, + vm_offset_t offset, boolean_t copy, vm_prot_t cur_protection, + vm_prot_t max_protection, vm_inherit_t inheritance) +{ + struct task_info *target_task_pi; + error_t err; + + target_task_pi = ports_lookup_port (port_bucket, + target_task, task_portclass); + if (target_task_pi == NULL) + return EOPNOTSUPP; + err = vm_map (target_task_pi->task_port, address, size, mask, + anywhere, memory_object, offset, copy, + cur_protection, max_protection, inheritance); + debug ("request is from task %d, anywhere: %d: %s", + target_task_pi->task_port, anywhere, strerror (err)); + ports_port_deref (target_task_pi); + mach_port_deallocate (mach_task_self (), memory_object); + return err; +} + +/* Routine vm_machine_attribute */ +kern_return_t +S_vm_machine_attribute (mach_port_t target_task, vm_address_t address, + vm_size_t size, vm_machine_attribute_t attribute, + vm_machine_attribute_val_t *value) +{ + struct task_info *target_task_pi; + error_t err; + + target_task_pi = ports_lookup_port (port_bucket, + target_task, task_portclass); + if (target_task_pi == NULL) + return EOPNOTSUPP; + err = vm_machine_attribute (target_task_pi->task_port, address, + size, attribute, value); + debug ("%s", strerror (err)); + ports_port_deref (target_task_pi); + return err; +} + +/* Routine task_threads */ +kern_return_t +S_task_threads (mach_port_t target_task, thread_array_t *thread_list, + mach_msg_type_number_t *thread_listCnt) +{ + struct task_info *target_task_pi; + error_t err; + + target_task_pi = ports_lookup_port (port_bucket, + target_task, task_portclass); + if (target_task_pi == NULL) + return EOPNOTSUPP; + + // TODO: use move send + err = task_threads (target_task_pi->task_port, + thread_list, thread_listCnt); + debug ("get a request from task %d: %s", + target_task_pi->task_port, strerror (err)); +// info ("task_threads: %s, number of threads: %d", +// strerror (err), *thread_listCnt); + ports_port_deref (target_task_pi); + return err; +} + +/* Routine thread_create */ +kern_return_t +S_thread_create (mach_port_t parent_task, mach_port_t *child_thread, + mach_msg_type_name_t *child_threadPoly) +{ + struct task_info *target_task_pi; + error_t err; + + target_task_pi = ports_lookup_port (port_bucket, + parent_task, task_portclass); + if (target_task_pi == NULL) + return EOPNOTSUPP; + err = thread_create (target_task_pi->task_port, child_thread); + debug ("get a request from task %d: thread port: %d: %s", + target_task_pi->task_port, *child_thread, strerror (err)); + ports_port_deref (target_task_pi); + *child_threadPoly = MACH_MSG_TYPE_MOVE_SEND; + return err; +} + +////////////////////it doesn't forward thread request//////////////// + +/* Routine thread_suspend */ +kern_return_t +S_thread_suspend (mach_port_t target_thread) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Routine thread_resume */ +kern_return_t +S_thread_resume (mach_port_t target_thread) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Routine thread_abort */ +kern_return_t +S_thread_abort (mach_port_t target_thread) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Routine xxx_thread_get_state */ +kern_return_t +S_xxx_thread_get_state (mach_port_t target_thread, int flavor, + thread_state_t old_state, + mach_msg_type_number_t *old_stateCnt) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Routine xxx_thread_set_state */ +kern_return_t +S_xxx_thread_set_state (mach_port_t target_thread, int flavor, + thread_state_t new_state, + mach_msg_type_number_t new_stateCnt) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Routine xxx_thread_info */ +kern_return_t +S_xxx_thread_info (mach_port_t target_thread, int flavor, + thread_info_t thread_info_out, + mach_msg_type_number_t *thread_info_outCnt) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Routine thread_get_special_port */ +kern_return_t +S_thread_get_special_port (mach_port_t thread, int which_port, + mach_port_t *special_port) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Routine thread_set_special_port */ +kern_return_t +S_thread_set_special_port (mach_port_t thread, int which_port, + mach_port_t special_port) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Routine thread_terminate */ +kern_return_t +S_thread_terminate (mach_port_t target_thread) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Routine thread_get_state */ +kern_return_t +S_thread_get_state (mach_port_t target_thread, int flavor, + thread_state_t old_state, + mach_msg_type_number_t *old_stateCnt) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Routine thread_set_state */ +kern_return_t +S_thread_set_state (mach_port_t target_thread, int flavor, + thread_state_t new_state, + mach_msg_type_number_t new_stateCnt) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Routine thread_info */ +kern_return_t +S_thread_info (mach_port_t target_thread, int flavor, + thread_info_t thread_info_out, + mach_msg_type_number_t *thread_info_outCnt) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/////////////////////RPC related to memory object//////////////////// +//////////////////they are not needed to be forwarded//////////////// + +/* SimpleRoutine memory_object_data_provided */ +kern_return_t +S_memory_object_data_provided (mach_port_t memory_control, + vm_offset_t offset, vm_offset_t data, + mach_msg_type_number_t dataCnt, + vm_prot_t lock_value) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* SimpleRoutine memory_object_data_unavailable */ +kern_return_t +S_memory_object_data_unavailable (mach_port_t memory_control, + vm_offset_t offset, vm_size_t size) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Routine memory_object_get_attributes */ +kern_return_t +S_memory_object_get_attributes (mach_port_t memory_control, + boolean_t *object_ready, boolean_t *may_cache, + memory_object_copy_strategy_t *copy_strategy) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* SimpleRoutine xxx_memory_object_lock_request */ +kern_return_t +S_xxx_memory_object_lock_request (mach_port_t memory_control, + vm_offset_t offset, vm_size_t size, + boolean_t should_clean, + boolean_t should_flush, + vm_prot_t lock_value, + mach_port_t reply_to, + mach_msg_type_name_t reply_toPoly) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* SimpleRoutine memory_object_lock_request */ +kern_return_t +S_memory_object_lock_request ( mach_port_t memory_control, + vm_offset_t offset, vm_size_t size, + memory_object_return_t should_return, + boolean_t should_flush, + vm_prot_t lock_value, mach_port_t reply_to, + mach_msg_type_name_t reply_toPoly) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* SimpleRoutine memory_object_data_error */ +kern_return_t +S_memory_object_data_error (mach_port_t memory_control, + vm_offset_t offset, vm_size_t size, + kern_return_t error_value) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* SimpleRoutine memory_object_set_attributes */ +kern_return_t +S_memory_object_set_attributes (mach_port_t memory_control, + boolean_t object_ready, boolean_t may_cache, + memory_object_copy_strategy_t copy_strategy) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* SimpleRoutine memory_object_destroy */ +kern_return_t +S_memory_object_destroy (mach_port_t memory_control, kern_return_t reason) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* SimpleRoutine memory_object_data_supply */ +kern_return_t +S_memory_object_data_supply (mach_port_t memory_control, + vm_offset_t offset, vm_offset_t data, + mach_msg_type_number_t dataCnt, + vm_prot_t lock_value, boolean_t precious, + mach_port_t reply_to, + mach_msg_type_name_t reply_toPoly) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* SimpleRoutine memory_object_ready */ +kern_return_t +S_memory_object_ready (mach_port_t memory_control, boolean_t may_cache, + memory_object_copy_strategy_t copy_strategy) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* SimpleRoutine memory_object_change_attributes */ +kern_return_t +S_memory_object_change_attributes (mach_port_t memory_control, + boolean_t may_cache, + memory_object_copy_strategy_t copy_strategy, + mach_port_t reply_to, + mach_msg_type_name_t reply_toPoly) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +///////////////////////RPCs related to emulation///////////////////// +//////////////////////subhurd doesn't support it.//////////////////// + +/* Routine task_get_emulation_vector */ +kern_return_t +S_task_get_emulation_vector (mach_port_t task, int *vector_start, + emulation_vector_t *emulation_vector, + mach_msg_type_number_t *emulation_vectorCnt) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Routine task_set_emulation_vector */ +kern_return_t +S_task_set_emulation_vector (mach_port_t task, int vector_start, + emulation_vector_t emulation_vector, + mach_msg_type_number_t emulation_vectorCnt) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Routine xxx_task_get_emulation_vector */ +kern_return_t +S_xxx_task_get_emulation_vector (mach_port_t task, int *vector_start, + emulation_vector_t emulation_vector, + mach_msg_type_number_t *emulation_vectorCnt) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Routine xxx_task_set_emulation_vector */ +kern_return_t +S_xxx_task_set_emulation_vector (mach_port_t task, int vector_start, + emulation_vector_t emulation_vector, + mach_msg_type_number_t emulation_vectorCnt) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} + +/* Routine task_set_emulation */ +kern_return_t +S_task_set_emulation (mach_port_t target_port, + vm_address_t routine_entry_pt, int routine_number) +{ + debug (""); + assert (0); + return EOPNOTSUPP; +} diff --git a/boot-proxy-exc/mach_impl.d b/boot-proxy-exc/mach_impl.d new file mode 100644 index 00000000..9f431f50 --- /dev/null +++ b/boot-proxy-exc/mach_impl.d @@ -0,0 +1,86 @@ +mach_impl.o mach_impl_pic.o mach_impl_p.o mach_impl.d: mach_impl.c /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/include/gnu/stubs-pthread.h \ + /usr/lib/gcc/i486-gnu/4.2.4/include/stddef.h /usr/include/xlocale.h \ + /usr/include/bits/string.h /usr/include/bits/string2.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/bits/byteswap.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/stdlib.h /usr/include/mach.h \ + /usr/local/include/mach/mach_types.h \ + /usr/local/include/mach/host_info.h /usr/local/include/mach/machine.h \ + /usr/local/include/mach/machine/vm_types.h \ + /usr/local/include/mach/boolean.h \ + /usr/local/include/mach/machine/boolean.h \ + /usr/local/include/mach/memory_object.h /usr/local/include/mach/port.h \ + /usr/local/include/mach/pc_sample.h \ + /usr/local/include/mach/processor_info.h \ + /usr/local/include/mach/task_info.h \ + /usr/local/include/mach/time_value.h \ + /usr/local/include/mach/task_special_ports.h \ + /usr/local/include/mach/thread_info.h /usr/local/include/mach/policy.h \ + /usr/local/include/mach/thread_special_ports.h \ + /usr/local/include/mach/thread_status.h \ + /usr/local/include/mach/machine/thread_status.h \ + /usr/local/include/mach/machine/fp_reg.h \ + /usr/local/include/mach/vm_attributes.h \ + /usr/local/include/mach/vm_inherit.h /usr/local/include/mach/vm_prot.h \ + /usr/local/include/mach/vm_statistics.h \ + /usr/local/include/mach/std_types.h \ + /usr/local/include/mach/kern_return.h \ + /usr/local/include/mach/machine/kern_return.h /usr/include/mach_init.h \ + /usr/include/mach/mach_traps.h /usr/local/include/mach/message.h \ + /usr/include/mach/mach_interface.h /usr/include/mach/mach_port.h \ + /usr/include/mach/mach_host.h /usr/include/mach-shortcuts.h \ + /usr/include/stdio.h /usr/include/hurd.h \ + /usr/local/include/mach/mig_errors.h ../hurd/hurd_types.h \ + /usr/include/sys/types.h /usr/include/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/pthread/pthreadtypes.h \ + /usr/include/bits/pthread.h /usr/include/bits/thread-attr.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/mutex-attr.h /usr/include/bits/mutex.h \ + /usr/include/bits/spin-lock.h /usr/include/bits/condition-attr.h \ + /usr/include/bits/condition.h /usr/include/bits/rwlock-attr.h \ + /usr/include/bits/rwlock.h /usr/include/bits/barrier-attr.h \ + /usr/include/bits/barrier.h /usr/include/bits/thread-specific.h \ + /usr/include/bits/once.h /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/hurd/auth.h /usr/local/include/device/device_types.h \ + /usr/local/include/device/net_status.h /usr/local/include/device/bpf.h \ + /usr/include/sys/stat.h /usr/include/bits/stat.h \ + /usr/include/sys/statfs.h /usr/include/bits/statfs.h \ + /usr/include/sys/resource.h /usr/include/bits/resource.h \ + /usr/include/sys/utsname.h /usr/include/bits/utsname.h \ + /usr/include/hurd/process.h /usr/include/hurd/fs.h \ + /usr/include/hurd/io.h /usr/include/hurd/port.h \ + /usr/include/hurd/userlink.h /usr/include/hurd/signal.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/sys/ucontext.h /usr/include/bits/sigthread.h \ + /usr/include/hurd/msg.h ../include/cthreads.h \ + ../include/../libthreads/cthreads.h /usr/include/bits/waitflags.h \ + /usr/include/bits/waitstatus.h /usr/include/alloca.h \ + /usr/local/include/mach/machine/vm_param.h /usr/include/machine-sp.h \ + /usr/include/spin-lock.h /usr/include/lock-intern.h \ + /usr/include/machine-lock.h /usr/include/setjmp.h \ + /usr/include/bits/setjmp.h /usr/include/hurd/threadvar.h \ + /usr/lib/gcc/i486-gnu/4.2.4/include/stdarg.h /usr/include/assert.h \ + util.h /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/wchar.h /usr/include/bits/stdio-lock.h \ + /usr/include/bits/libc-lock.h /usr/include/bits/stdio_lim.h \ + /usr/include/bits/sys_errlist.h /usr/include/bits/stdio.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i486-gnu/4.2.4/include/limits.h \ + /usr/lib/gcc/i486-gnu/4.2.4/include/syslimits.h /usr/include/limits.h \ + /usr/include/bits/posix1_lim.h /usr/include/bits/local_lim.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/xopen_lim.h \ + /usr/include/bits/sockaddr.h /usr/include/arpa/inet.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/wchar.h /usr/include/bits/in.h \ + /usr/include/netinet/ip.h /usr/include/syslog.h \ + /usr/include/sys/syslog.h /usr/include/bits/syslog-path.h mach_proxy.h \ + ../hurd/ports.h ../hurd/../libports/ports.h ../hurd/ihash.h \ + ../hurd/../libihash/ihash.h /usr/local/include/mach/notify.h list.h diff --git a/boot-proxy-exc/mach_impl.o b/boot-proxy-exc/mach_impl.o Binary files differnew file mode 100644 index 00000000..ce418d43 --- /dev/null +++ b/boot-proxy-exc/mach_impl.o diff --git a/boot-proxy-exc/mach_port_impl.c b/boot-proxy-exc/mach_port_impl.c new file mode 100644 index 00000000..b421280b --- /dev/null +++ b/boot-proxy-exc/mach_port_impl.c @@ -0,0 +1,375 @@ +/* + Copyright (C) 2009 Free Software Foundation, Inc. + Written by Zheng Da. + + This file is part of the GNU Hurd. + + The GNU Hurd is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + The GNU Hurd 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with the GNU Hurd; see the file COPYING. If not, write to + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/* This file implements the server-side RPC functions of mach_host. */ + +#include <mach.h> +#include <hurd.h> +#include <string.h> +#include <assert.h> + +#include "util.h" +#include "mach_proxy.h" + +kern_return_t +S_mach_port_names (mach_port_t task, mach_port_array_t *names, + mach_msg_type_number_t *namesCnt, + mach_port_type_array_t *types, + mach_msg_type_number_t *typesCnt) +{ + struct task_info *task_pi; + error_t err; + + task_pi = ports_lookup_port (port_bucket, task, task_portclass); + if (task_pi == NULL) + return EOPNOTSUPP; + err = mach_port_names (task_pi->task_port, + names, namesCnt, types, typesCnt); + debug ("%s", strerror (err)); + /* The deallocation bit is set, + * so 'names' and 'types' will be deallocated after the reply is sent. */ + ports_port_deref (task_pi); + return err; +} + +/* Routine mach_port_type */ +kern_return_t +S_mach_port_type (mach_port_t task, mach_port_t name, mach_port_type_t *ptype) +{ + struct task_info *task_pi; + error_t err; + + task_pi = ports_lookup_port (port_bucket, task, task_portclass); + if (task_pi == NULL) + return EOPNOTSUPP; + err = mach_port_type (task_pi->task_port, name, ptype); + debug ("%s", strerror (err)); + ports_port_deref (task_pi); + return err; +} + +/* Routine mach_port_rename */ +kern_return_t +S_mach_port_rename (mach_port_t task, + mach_port_t old_name, mach_port_t new_name) +{ + struct task_info *task_pi; + error_t err; + + task_pi = ports_lookup_port (port_bucket, task, task_portclass); + if (task_pi == NULL) + return EOPNOTSUPP; + /* old_name and new_name are just names, + * so I don't need to deallocate them. + * It should be the same for other RPCs that only deal with port names */ + err = mach_port_rename (task_pi->task_port, old_name, new_name); + debug ("%s", strerror (err)); + ports_port_deref (task_pi); + return err; +} + +/* Routine mach_port_allocate_name */ +kern_return_t +S_mach_port_allocate_name (mach_port_t task, + mach_port_right_t right, mach_port_t name) +{ + struct task_info *task_pi; + error_t err; + + task_pi = ports_lookup_port (port_bucket, task, task_portclass); + if (task_pi == NULL) + return EOPNOTSUPP; + err = mach_port_allocate_name (task_pi->task_port, right, name); + debug ("%s", strerror (err)); + ports_port_deref (task_pi); + return err; +} + +/* Routine mach_port_allocate */ +kern_return_t +S_mach_port_allocate (mach_port_t task, + mach_port_right_t right, mach_port_t *name) +{ + struct task_info *task_pi; + error_t err; + + task_pi = ports_lookup_port (port_bucket, task, task_portclass); + if (task_pi == NULL) + return EOPNOTSUPP; + err = mach_port_allocate (task_pi->task_port, right, name); + debug ("get a request from task %d: %s", task_pi->task_port, strerror (err)); + ports_port_deref (task_pi); + return err; +} + +/* Routine mach_port_destroy */ +kern_return_t +S_mach_port_destroy (mach_port_t task, mach_port_t name) +{ + struct task_info *task_pi; + error_t err; + + task_pi = ports_lookup_port (port_bucket, task, task_portclass); + if (task_pi == NULL) + return EOPNOTSUPP; + err = mach_port_destroy (task_pi->task_port, name); + debug ("get a request from port %d: %s", + task_pi->task_port, strerror (err)); + ports_port_deref (task_pi); + return err; +} + +/* Routine mach_port_deallocate */ +kern_return_t +S_mach_port_deallocate (mach_port_t task, mach_port_t name) +{ + struct task_info *task_pi; + error_t err; + + task_pi = ports_lookup_port (port_bucket, task, task_portclass); + if (task_pi == NULL) + return EOPNOTSUPP; + err = mach_port_deallocate (task_pi->task_port, name); + debug ("get a request from task %d, name: %d, %s", + task_pi->task_port, name, strerror (err)); + ports_port_deref (task_pi); + return err; +} + +/* Routine mach_port_get_refs */ +kern_return_t +S_mach_port_get_refs (mach_port_t task, mach_port_t name, + mach_port_right_t right, mach_port_urefs_t *refs) +{ + struct task_info *task_pi; + error_t err; + + task_pi = ports_lookup_port (port_bucket, task, task_portclass); + if (task_pi == NULL) + return EOPNOTSUPP; + err = mach_port_get_refs (task_pi->task_port, name, right, refs); + debug ("%s", strerror (err)); + ports_port_deref (task_pi); + return err; +} + +/* Routine mach_port_mod_refs */ +kern_return_t +S_mach_port_mod_refs (mach_port_t task, mach_port_t name, + mach_port_right_t right, mach_port_delta_t delta) +{ + struct task_info *task_pi; + error_t err; + + task_pi = ports_lookup_port (port_bucket, task, task_portclass); + if (task_pi == NULL) + return EOPNOTSUPP; + err = mach_port_mod_refs (task_pi->task_port, name, right, delta); + debug ("get a request from task %d: port: %d, right: %d, delta: %d, %s", + task_pi->task_port, name, right, delta, strerror (err)); + ports_port_deref (task_pi); + return err; +} + +/* Routine old_mach_port_get_receive_status */ +kern_return_t +S_old_mach_port_get_receive_status (mach_port_t task, mach_port_t name, + old_mach_port_status_t *status) +{ + debug ("%s", strerror (EOPNOTSUPP)); + assert (0); + /* Hurd currently doesn't use it. */ + return EOPNOTSUPP; +} + +/* Routine mach_port_set_qlimit */ +kern_return_t +S_mach_port_set_qlimit (mach_port_t task, mach_port_t name, + mach_port_msgcount_t qlimit) +{ + struct task_info *task_pi; + error_t err; + + task_pi = ports_lookup_port (port_bucket, task, task_portclass); + if (task_pi == NULL) + return EOPNOTSUPP; + err = mach_port_set_qlimit (task_pi->task_port, name, qlimit); + debug ("%s", strerror (err)); + ports_port_deref (task_pi); + return err; +} + +/* Routine mach_port_set_mscount */ +kern_return_t +S_mach_port_set_mscount (mach_port_t task, mach_port_t name, + mach_port_mscount_t mscount) +{ + struct task_info *task_pi; + error_t err; + + task_pi = ports_lookup_port (port_bucket, task, task_portclass); + if (task_pi == NULL) + return EOPNOTSUPP; + err = mach_port_set_mscount (task_pi->task_port, name, mscount); + debug ("%s", strerror (err)); + ports_port_deref (task_pi); + return err; +} + +/* Routine mach_port_get_set_status */ +kern_return_t +S_mach_port_get_set_status (mach_port_t task, mach_port_t name, + mach_port_array_t *members, + mach_msg_type_number_t *membersCnt) +{ + struct task_info *task_pi; + error_t err; + + task_pi = ports_lookup_port (port_bucket, task, task_portclass); + if (task_pi == NULL) + return EOPNOTSUPP; + err = mach_port_get_set_status (task_pi->task_port, + name, members, membersCnt); + debug ("%s", strerror (err)); + ports_port_deref (task_pi); + /* The deallocation bit is set, + * so 'members' will be deallocated after the reply is sent. */ + return err; +} + +/* Routine mach_port_move_member */ +kern_return_t +S_mach_port_move_member (mach_port_t task, mach_port_t member, + mach_port_t after) +{ + struct task_info *task_pi; + error_t err; + + task_pi = ports_lookup_port (port_bucket, task, task_portclass); + if (task_pi == NULL) + return EOPNOTSUPP; + err = mach_port_move_member (task_pi->task_port, member, after); + debug ("%s", strerror (err)); + ports_port_deref (task_pi); + return err; +} + +/* Routine mach_port_request_notification */ +kern_return_t +S_mach_port_request_notification (mach_port_t task, mach_port_t name, + mach_msg_id_t id, mach_port_mscount_t sync, + mach_port_t notify, mach_port_t *previous, + mach_msg_type_name_t *previousPoly) +{ + struct task_info *task_pi; + mach_msg_type_name_t notify_type = MACH_MSG_TYPE_MOVE_SEND_ONCE; + error_t err; + + task_pi = ports_lookup_port (port_bucket, task, task_portclass); + if (task_pi == NULL) + return EOPNOTSUPP; + /* notify is send-once right from the client. */ + err = mach_port_request_notification (task_pi->task_port, name, id, sync, + notify, notify_type, previous); + debug ("get a request from task %d, port: %d, id: %d, notify: %d, notify_type: %d, old port: %d, %s", + task_pi->task_port, name, id, notify, notify_type, *previous, strerror (err)); + ports_port_deref (task_pi); + if (err) + return err; + *previousPoly = MACH_MSG_TYPE_MOVE_SEND_ONCE; + + return 0; +} + +/* Routine mach_port_insert_right */ +kern_return_t +S_mach_port_insert_right (mach_port_t task, mach_port_t name, + mach_port_t poly, mach_msg_type_name_t polyPoly) +{ + struct task_info *task_pi; + error_t err; + + task_pi = ports_lookup_port (port_bucket, task, task_portclass); + if (task_pi == NULL) + return EOPNOTSUPP; + /* polyPoly can only be three possible values: MACH_MSG_TYPE_PORT_SEND, + * MACH_MSG_TYPE_PORT_SEND_ONCE and MACH_MSG_TYPE_PORT_RECEIVE, + * so port will be deallocated when mach_port_insert_right is called. */ + err = mach_port_insert_right (task_pi->task_port, name, poly, polyPoly); + debug ("get a request from task %d: %s", task_pi->task_port, strerror (err)); + ports_port_deref (task_pi); + return err; +} + +/* Routine mach_port_extract_right */ +kern_return_t +S_mach_port_extract_right (mach_port_t task, mach_port_t name, + mach_msg_type_name_t msgt_name, mach_port_t *poly, + mach_msg_type_name_t *polyPoly) +{ + struct task_info *task_pi; + error_t err; + + task_pi = ports_lookup_port (port_bucket, task, task_portclass); + if (task_pi == NULL) + return EOPNOTSUPP; + err = mach_port_extract_right (task_pi->task_port, name, msgt_name, + poly, polyPoly); + debug ("%s", strerror (err)); + ports_port_deref (task_pi); + /* *polyPoly can only be MACH_MSG_TYPE_PORT_SEND, MACH_MSG_TYPE_PORT_RECEIVE, + * or MACH_MSG_TYPE_PORT_SEND_ONCE, so the port extracted from 'task' + * will be moved to the client. */ + return err; +} + +/* Routine mach_port_get_receive_status */ +kern_return_t +S_mach_port_get_receive_status (mach_port_t task, mach_port_t name, + mach_port_status_t *status) +{ + struct task_info *task_pi; + error_t err; + + task_pi = ports_lookup_port (port_bucket, task, task_portclass); + if (task_pi == NULL) + return EOPNOTSUPP; + err = mach_port_get_receive_status (task_pi->task_port, name, status); + debug ("%s", strerror (err)); + ports_port_deref (task_pi); + return err; +} + +/* Routine mach_port_set_seqno */ +kern_return_t +S_mach_port_set_seqno (mach_port_t task, mach_port_t name, + mach_port_seqno_t seqno) +{ + struct task_info *task_pi; + error_t err; + + task_pi = ports_lookup_port (port_bucket, task, task_portclass); + if (task_pi == NULL) + return EOPNOTSUPP; + err = mach_port_set_seqno (task_pi->task_port, name, seqno); + debug ("%s", strerror (err)); + ports_port_deref (task_pi); + return err; +} diff --git a/boot-proxy-exc/mach_port_impl.c~ b/boot-proxy-exc/mach_port_impl.c~ new file mode 100644 index 00000000..b49ae789 --- /dev/null +++ b/boot-proxy-exc/mach_port_impl.c~ @@ -0,0 +1,377 @@ +/* + Copyright (C) 2009 Free Software Foundation, Inc. + Written by Zheng Da. + + This file is part of the GNU Hurd. + + The GNU Hurd is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + The GNU Hurd 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with the GNU Hurd; see the file COPYING. If not, write to + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/* This file implements the server-side RPC functions of mach_host. */ + +#include <mach.h> +#include <hurd.h> +#include <string.h> +#include <assert.h> + +#include "util.h" +#include "mach_proxy.h" + +kern_return_t +S_mach_port_names (mach_port_t task, mach_port_array_t *names, + mach_msg_type_number_t *namesCnt, + mach_port_type_array_t *types, + mach_msg_type_number_t *typesCnt) +{ + struct task_info *task_pi; + error_t err; + + task_pi = ports_lookup_port (port_bucket, task, task_portclass); + if (task_pi == NULL) + return EOPNOTSUPP; + err = mach_port_names (task_pi->task_port, + names, namesCnt, types, typesCnt); + debug ("%s", strerror (err)); + /* The deallocation bit is set, + * so 'names' and 'types' will be deallocated after the reply is sent. */ + ports_port_deref (task_pi); + return err; +} + +/* Routine mach_port_type */ +kern_return_t +S_mach_port_type (mach_port_t task, mach_port_t name, mach_port_type_t *ptype) +{ + struct task_info *task_pi; + error_t err; + + task_pi = ports_lookup_port (port_bucket, task, task_portclass); + if (task_pi == NULL) + return EOPNOTSUPP; + err = mach_port_type (task_pi->task_port, name, ptype); + debug ("%s", strerror (err)); + ports_port_deref (task_pi); + return err; +} + +/* Routine mach_port_rename */ +kern_return_t +S_mach_port_rename (mach_port_t task, + mach_port_t old_name, mach_port_t new_name) +{ + struct task_info *task_pi; + error_t err; + + task_pi = ports_lookup_port (port_bucket, task, task_portclass); + if (task_pi == NULL) + return EOPNOTSUPP; + /* old_name and new_name are just names, + * so I don't need to deallocate them. + * It should be the same for other RPCs that only deal with port names */ + err = mach_port_rename (task_pi->task_port, old_name, new_name); + debug ("%s", strerror (err)); + ports_port_deref (task_pi); + return err; +} + +/* Routine mach_port_allocate_name */ +kern_return_t +S_mach_port_allocate_name (mach_port_t task, + mach_port_right_t right, mach_port_t name) +{ + struct task_info *task_pi; + error_t err; + + task_pi = ports_lookup_port (port_bucket, task, task_portclass); + if (task_pi == NULL) + return EOPNOTSUPP; + err = mach_port_allocate_name (task_pi->task_port, right, name); + debug ("%s", strerror (err)); + ports_port_deref (task_pi); + return err; +} + +/* Routine mach_port_allocate */ +kern_return_t +S_mach_port_allocate (mach_port_t task, + mach_port_right_t right, mach_port_t *name) +{ + struct task_info *task_pi; + error_t err; + + task_pi = ports_lookup_port (port_bucket, task, task_portclass); + if (task_pi == NULL) + return EOPNOTSUPP; + err = mach_port_allocate (task_pi->task_port, right, name); + debug ("get a request from task %d: %s", task_pi->task_port, strerror (err)); + ports_port_deref (task_pi); + return err; +} + +/* Routine mach_port_destroy */ +kern_return_t +S_mach_port_destroy (mach_port_t task, mach_port_t name) +{ + struct task_info *task_pi; + error_t err; + + task_pi = ports_lookup_port (port_bucket, task, task_portclass); + if (task_pi == NULL) + return EOPNOTSUPP; + err = mach_port_destroy (task_pi->task_port, name); + debug ("get a request from port %d: %s", + task_pi->task_port, strerror (err)); + ports_port_deref (task_pi); + return err; +} + +/* Routine mach_port_deallocate */ +kern_return_t +S_mach_port_deallocate (mach_port_t task, mach_port_t name) +{ + struct task_info *task_pi; + error_t err; + + task_pi = ports_lookup_port (port_bucket, task, task_portclass); + if (task_pi == NULL) + return EOPNOTSUPP; + err = mach_port_deallocate (task_pi->task_port, name); + debug ("get a request from task %d, name: %d, %s", + task_pi->task_port, name, strerror (err)); + ports_port_deref (task_pi); + return err; +} + +/* Routine mach_port_get_refs */ +kern_return_t +S_mach_port_get_refs (mach_port_t task, mach_port_t name, + mach_port_right_t right, mach_port_urefs_t *refs) +{ + struct task_info *task_pi; + error_t err; + + task_pi = ports_lookup_port (port_bucket, task, task_portclass); + if (task_pi == NULL) + return EOPNOTSUPP; + err = mach_port_get_refs (task_pi->task_port, name, right, refs); + debug ("%s", strerror (err)); + ports_port_deref (task_pi); + return err; +} + +/* Routine mach_port_mod_refs */ +kern_return_t +S_mach_port_mod_refs (mach_port_t task, mach_port_t name, + mach_port_right_t right, mach_port_delta_t delta) +{ + struct task_info *task_pi; + error_t err; + + task_pi = ports_lookup_port (port_bucket, task, task_portclass); + if (task_pi == NULL) + return EOPNOTSUPP; + err = mach_port_mod_refs (task_pi->task_port, name, right, delta); + debug ("get a request from task %d: port: %d, right: %d, delta: %d, %s", + task_pi->task_port, name, right, delta, strerror (err)); + ports_port_deref (task_pi); + return err; +} + +/* Routine old_mach_port_get_receive_status */ +kern_return_t +S_old_mach_port_get_receive_status (mach_port_t task, mach_port_t name, + old_mach_port_status_t *status) +{ + debug ("%s", strerror (EOPNOTSUPP)); + assert (0); + /* Hurd currently doesn't use it. */ + return EOPNOTSUPP; +} + +/* Routine mach_port_set_qlimit */ +kern_return_t +S_mach_port_set_qlimit (mach_port_t task, mach_port_t name, + mach_port_msgcount_t qlimit) +{ + struct task_info *task_pi; + error_t err; + + task_pi = ports_lookup_port (port_bucket, task, task_portclass); + if (task_pi == NULL) + return EOPNOTSUPP; + err = mach_port_set_qlimit (task_pi->task_port, name, qlimit); + debug ("%s", strerror (err)); + ports_port_deref (task_pi); + return err; +} + +/* Routine mach_port_set_mscount */ +kern_return_t +S_mach_port_set_mscount (mach_port_t task, mach_port_t name, + mach_port_mscount_t mscount) +{ + struct task_info *task_pi; + error_t err; + + task_pi = ports_lookup_port (port_bucket, task, task_portclass); + if (task_pi == NULL) + return EOPNOTSUPP; + err = mach_port_set_mscount (task_pi->task_port, name, mscount); + debug ("%s", strerror (err)); + ports_port_deref (task_pi); + return err; +} + +/* Routine mach_port_get_set_status */ +kern_return_t +S_mach_port_get_set_status (mach_port_t task, mach_port_t name, + mach_port_array_t *members, + mach_msg_type_number_t *membersCnt) +{ + struct task_info *task_pi; + error_t err; + + task_pi = ports_lookup_port (port_bucket, task, task_portclass); + if (task_pi == NULL) + return EOPNOTSUPP; + err = mach_port_get_set_status (task_pi->task_port, + name, members, membersCnt); + debug ("%s", strerror (err)); + ports_port_deref (task_pi); + /* The deallocation bit is set, + * so 'members' will be deallocated after the reply is sent. */ + return err; +} + +/* Routine mach_port_move_member */ +kern_return_t +S_mach_port_move_member (mach_port_t task, mach_port_t member, + mach_port_t after) +{ + struct task_info *task_pi; + error_t err; + + task_pi = ports_lookup_port (port_bucket, task, task_portclass); + if (task_pi == NULL) + return EOPNOTSUPP; + err = mach_port_move_member (task_pi->task_port, member, after); + debug ("%s", strerror (err)); + ports_port_deref (task_pi); + return err; +} + +/* Routine mach_port_request_notification */ +kern_return_t +S_mach_port_request_notification (mach_port_t task, mach_port_t name, + mach_msg_id_t id, mach_port_mscount_t sync, + mach_port_t notify, mach_port_t *previous, + mach_msg_type_name_t *previousPoly) +{ + struct task_info *task_pi; + mach_msg_type_name_t notify_type = MACH_MSG_TYPE_MOVE_SEND_ONCE; + error_t err; + + task_pi = ports_lookup_port (port_bucket, task, task_portclass); + if (task_pi == NULL) + return EOPNOTSUPP; + if (notify == 0) + notify_type = 0; + /* notify is send-once right from the client. */ + err = mach_port_request_notification (task_pi->task_port, name, id, sync, + notify, notify_type, previous); + debug ("get a request from task %d, port: %d, id: %d, notify: %d, notify_type: %d, old port: %d, %s", + task_pi->task_port, name, id, notify, notify_type, *previous, strerror (err)); + ports_port_deref (task_pi); + if (err) + return err; + *previousPoly = MACH_MSG_TYPE_MOVE_SEND_ONCE; + + return 0; +} + +/* Routine mach_port_insert_right */ +kern_return_t +S_mach_port_insert_right (mach_port_t task, mach_port_t name, + mach_port_t poly, mach_msg_type_name_t polyPoly) +{ + struct task_info *task_pi; + error_t err; + + task_pi = ports_lookup_port (port_bucket, task, task_portclass); + if (task_pi == NULL) + return EOPNOTSUPP; + /* polyPoly can only be three possible values: MACH_MSG_TYPE_PORT_SEND, + * MACH_MSG_TYPE_PORT_SEND_ONCE and MACH_MSG_TYPE_PORT_RECEIVE, + * so port will be deallocated when mach_port_insert_right is called. */ + err = mach_port_insert_right (task_pi->task_port, name, poly, polyPoly); + debug ("get a request from task %d: %s", task_pi->task_port, strerror (err)); + ports_port_deref (task_pi); + return err; +} + +/* Routine mach_port_extract_right */ +kern_return_t +S_mach_port_extract_right (mach_port_t task, mach_port_t name, + mach_msg_type_name_t msgt_name, mach_port_t *poly, + mach_msg_type_name_t *polyPoly) +{ + struct task_info *task_pi; + error_t err; + + task_pi = ports_lookup_port (port_bucket, task, task_portclass); + if (task_pi == NULL) + return EOPNOTSUPP; + err = mach_port_extract_right (task_pi->task_port, name, msgt_name, + poly, polyPoly); + debug ("%s", strerror (err)); + ports_port_deref (task_pi); + /* *polyPoly can only be MACH_MSG_TYPE_PORT_SEND, MACH_MSG_TYPE_PORT_RECEIVE, + * or MACH_MSG_TYPE_PORT_SEND_ONCE, so the port extracted from 'task' + * will be moved to the client. */ + return err; +} + +/* Routine mach_port_get_receive_status */ +kern_return_t +S_mach_port_get_receive_status (mach_port_t task, mach_port_t name, + mach_port_status_t *status) +{ + struct task_info *task_pi; + error_t err; + + task_pi = ports_lookup_port (port_bucket, task, task_portclass); + if (task_pi == NULL) + return EOPNOTSUPP; + err = mach_port_get_receive_status (task_pi->task_port, name, status); + debug ("%s", strerror (err)); + ports_port_deref (task_pi); + return err; +} + +/* Routine mach_port_set_seqno */ +kern_return_t +S_mach_port_set_seqno (mach_port_t task, mach_port_t name, + mach_port_seqno_t seqno) +{ + struct task_info *task_pi; + error_t err; + + task_pi = ports_lookup_port (port_bucket, task, task_portclass); + if (task_pi == NULL) + return EOPNOTSUPP; + err = mach_port_set_seqno (task_pi->task_port, name, seqno); + debug ("%s", strerror (err)); + ports_port_deref (task_pi); + return err; +} diff --git a/boot-proxy-exc/mach_port_impl.d b/boot-proxy-exc/mach_port_impl.d new file mode 100644 index 00000000..785fdadb --- /dev/null +++ b/boot-proxy-exc/mach_port_impl.d @@ -0,0 +1,87 @@ +mach_port_impl.o mach_port_impl_pic.o mach_port_impl_p.o mach_port_impl.d: mach_port_impl.c /usr/include/mach.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h /usr/include/gnu/stubs-pthread.h \ + /usr/local/include/mach/mach_types.h \ + /usr/local/include/mach/host_info.h /usr/local/include/mach/machine.h \ + /usr/local/include/mach/machine/vm_types.h \ + /usr/local/include/mach/boolean.h \ + /usr/local/include/mach/machine/boolean.h \ + /usr/local/include/mach/memory_object.h /usr/local/include/mach/port.h \ + /usr/local/include/mach/pc_sample.h \ + /usr/local/include/mach/processor_info.h \ + /usr/local/include/mach/task_info.h \ + /usr/local/include/mach/time_value.h \ + /usr/local/include/mach/task_special_ports.h \ + /usr/local/include/mach/thread_info.h /usr/local/include/mach/policy.h \ + /usr/local/include/mach/thread_special_ports.h \ + /usr/local/include/mach/thread_status.h \ + /usr/local/include/mach/machine/thread_status.h \ + /usr/local/include/mach/machine/fp_reg.h \ + /usr/local/include/mach/vm_attributes.h \ + /usr/local/include/mach/vm_inherit.h /usr/local/include/mach/vm_prot.h \ + /usr/local/include/mach/vm_statistics.h \ + /usr/local/include/mach/std_types.h \ + /usr/local/include/mach/kern_return.h \ + /usr/local/include/mach/machine/kern_return.h /usr/include/mach_init.h \ + /usr/include/mach/mach_traps.h /usr/local/include/mach/message.h \ + /usr/include/mach/mach_interface.h /usr/include/mach/mach_port.h \ + /usr/include/mach/mach_host.h /usr/include/mach-shortcuts.h \ + /usr/include/stdio.h /usr/include/hurd.h \ + /usr/local/include/mach/mig_errors.h ../hurd/hurd_types.h \ + /usr/include/sys/types.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/time.h \ + /usr/lib/gcc/i486-gnu/4.2.4/include/stddef.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/bits/byteswap.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/pthread/pthreadtypes.h /usr/include/xlocale.h \ + /usr/include/bits/pthread.h /usr/include/bits/thread-attr.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/mutex-attr.h /usr/include/bits/mutex.h \ + /usr/include/bits/spin-lock.h /usr/include/bits/condition-attr.h \ + /usr/include/bits/condition.h /usr/include/bits/rwlock-attr.h \ + /usr/include/bits/rwlock.h /usr/include/bits/barrier-attr.h \ + /usr/include/bits/barrier.h /usr/include/bits/thread-specific.h \ + /usr/include/bits/once.h /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/hurd/auth.h /usr/local/include/device/device_types.h \ + /usr/local/include/device/net_status.h /usr/local/include/device/bpf.h \ + /usr/include/sys/stat.h /usr/include/bits/stat.h \ + /usr/include/sys/statfs.h /usr/include/bits/statfs.h \ + /usr/include/sys/resource.h /usr/include/bits/resource.h \ + /usr/include/sys/utsname.h /usr/include/bits/utsname.h \ + /usr/include/hurd/process.h /usr/include/hurd/fs.h \ + /usr/include/hurd/io.h /usr/include/hurd/port.h \ + /usr/include/hurd/userlink.h /usr/include/hurd/signal.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/sys/ucontext.h /usr/include/bits/sigthread.h \ + /usr/include/hurd/msg.h ../include/cthreads.h \ + ../include/../libthreads/cthreads.h /usr/include/stdlib.h \ + /usr/include/bits/waitflags.h /usr/include/bits/waitstatus.h \ + /usr/include/alloca.h /usr/local/include/mach/machine/vm_param.h \ + /usr/include/machine-sp.h /usr/include/spin-lock.h \ + /usr/include/lock-intern.h /usr/include/machine-lock.h \ + /usr/include/setjmp.h /usr/include/bits/setjmp.h \ + /usr/include/hurd/threadvar.h \ + /usr/lib/gcc/i486-gnu/4.2.4/include/stdarg.h /usr/include/string.h \ + /usr/include/bits/string.h /usr/include/bits/string2.h \ + /usr/include/assert.h util.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/stdio-lock.h /usr/include/bits/libc-lock.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/bits/stdio.h /usr/include/sys/socket.h \ + /usr/include/sys/uio.h /usr/include/bits/uio.h \ + /usr/include/bits/socket.h /usr/lib/gcc/i486-gnu/4.2.4/include/limits.h \ + /usr/lib/gcc/i486-gnu/4.2.4/include/syslimits.h /usr/include/limits.h \ + /usr/include/bits/posix1_lim.h /usr/include/bits/local_lim.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/xopen_lim.h \ + /usr/include/bits/sockaddr.h /usr/include/arpa/inet.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/wchar.h /usr/include/bits/in.h \ + /usr/include/netinet/ip.h /usr/include/syslog.h \ + /usr/include/sys/syslog.h /usr/include/bits/syslog-path.h mach_proxy.h \ + ../hurd/ports.h ../hurd/../libports/ports.h ../hurd/ihash.h \ + ../hurd/../libihash/ihash.h /usr/local/include/mach/notify.h list.h diff --git a/boot-proxy-exc/mach_port_impl.o b/boot-proxy-exc/mach_port_impl.o Binary files differnew file mode 100644 index 00000000..97e15d06 --- /dev/null +++ b/boot-proxy-exc/mach_port_impl.o diff --git a/boot-proxy-exc/mach_proxy.c b/boot-proxy-exc/mach_proxy.c new file mode 100644 index 00000000..cc599353 --- /dev/null +++ b/boot-proxy-exc/mach_proxy.c @@ -0,0 +1,97 @@ +/* + Copyright (C) 2009 Free Software Foundation, Inc. + Written by Zheng Da. + + This file is part of the GNU Hurd. + + The GNU Hurd is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + The GNU Hurd 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with the GNU Hurd; see the file COPYING. If not, write to + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include <string.h> + +#include "util.h" +#include "mach_proxy.h" + +static LIST_HEADER (tasks_head); + +static struct mutex tasks_lock = MUTEX_INITIALIZER; + +int create_pseudo_task (task_t real_task, task_t *ret_pseudo_task) +{ + /* the first task is the kernel task. */ + struct task_info *task_pi; + task_t pseudo_task; + error_t err; + + err = ports_create_port (task_portclass, port_bucket, + sizeof (struct task_info), &task_pi); + if (err) + return err; + + task_pi->task_port = real_task; + task_pi->exc_pi = NULL; + task_pi->user_exc_port = 0; + mutex_init (&task_pi->lock); + entry_init (&task_pi->list); + mutex_lock (&tasks_lock); + add_entry_end (&tasks_head, &task_pi->list); + mutex_unlock (&tasks_lock); + + pseudo_task = ports_get_right (task_pi); + mach_port_insert_right (mach_task_self (), pseudo_task, pseudo_task, + MACH_MSG_TYPE_MAKE_SEND); + ports_port_deref (task_pi); + + if (ret_pseudo_task) + *ret_pseudo_task = pseudo_task; + + err = task_set_kernel_port (real_task, pseudo_task); + if (err) + { + debug ("fail to set the kernel port: %s", strerror (err)); + ports_destroy_right (task_pi); + } + + return err; +} + +void clean_pseudo_task (void *pi) +{ + struct task_info *task = pi; + + debug ("remove a pseudo task from the list"); + mutex_lock (&tasks_lock); + remove_entry (&task->list); + mutex_unlock (&tasks_lock); + + if (task->exc_pi) + ports_destroy_right (task->exc_pi); + if (task->user_exc_port) + mach_port_deallocate (mach_task_self (), task->user_exc_port); +} + +void foreach_task (task_callback_t callback) +{ + struct list *entry = &tasks_head; + mutex_lock (&tasks_lock); + for (entry = tasks_head.next; entry != &tasks_head; entry = entry->next) + { +// mutex_unlock (&tasks_lock); + struct task_info *task_pi = LIST_ENTRY (entry, struct task_info, list); + if (callback (task_pi)) + break; +// mutex_lock (&tasks_lock); + } + mutex_unlock (&tasks_lock); +} diff --git a/boot-proxy-exc/mach_proxy.c~ b/boot-proxy-exc/mach_proxy.c~ new file mode 100644 index 00000000..1bb46821 --- /dev/null +++ b/boot-proxy-exc/mach_proxy.c~ @@ -0,0 +1,97 @@ +/* + Copyright (C) 2009 Free Software Foundation, Inc. + Written by Zheng Da. + + This file is part of the GNU Hurd. + + The GNU Hurd is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + The GNU Hurd 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with the GNU Hurd; see the file COPYING. If not, write to + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include <string.h> + +#include "util.h" +#include "mach_proxy.h" + +static LIST_HEADER (tasks_head); + +static struct mutex tasks_lock = MUTEX_INITIALIZER; + +int create_pseudo_task (task_t real_task, task_t *ret_pseudo_task) +{ + /* the first task is the kernel task. */ + struct task_info *task_pi; + task_t pseudo_task; + error_t err; + + err = ports_create_port (task_portclass, port_bucket, + sizeof (struct task_info), &task_pi); + if (err) + return err; + + task_pi->task_port = real_task; + task_pi->exc_pi = NULL; + task_pi->user_exc_port = 0; + mutex_info (&task_pi->lock); + entry_init (&task_pi->list); + mutex_lock (&tasks_lock); + add_entry_end (&tasks_head, &task_pi->list); + mutex_unlock (&tasks_lock); + + pseudo_task = ports_get_right (task_pi); + mach_port_insert_right (mach_task_self (), pseudo_task, pseudo_task, + MACH_MSG_TYPE_MAKE_SEND); + ports_port_deref (task_pi); + + if (ret_pseudo_task) + *ret_pseudo_task = pseudo_task; + + err = task_set_kernel_port (real_task, pseudo_task); + if (err) + { + debug ("fail to set the kernel port: %s", strerror (err)); + ports_destroy_right (task_pi); + } + + return err; +} + +void clean_pseudo_task (void *pi) +{ + struct task_info *task = pi; + + debug ("remove a pseudo task from the list"); + mutex_lock (&tasks_lock); + remove_entry (&task->list); + mutex_unlock (&tasks_lock); + + if (task->exc_pi) + ports_destroy_right (task->exc_pi); + if (task->user_exc_port) + mach_port_deallocate (mach_task_self (), task->user_exc_port); +} + +void foreach_task (task_callback_t callback) +{ + struct list *entry = &tasks_head; + mutex_lock (&tasks_lock); + for (entry = tasks_head.next; entry != &tasks_head; entry = entry->next) + { +// mutex_unlock (&tasks_lock); + struct task_info *task_pi = LIST_ENTRY (entry, struct task_info, list); + if (callback (task_pi)) + break; +// mutex_lock (&tasks_lock); + } + mutex_unlock (&tasks_lock); +} diff --git a/boot-proxy-exc/mach_proxy.d b/boot-proxy-exc/mach_proxy.d new file mode 100644 index 00000000..572bb21b --- /dev/null +++ b/boot-proxy-exc/mach_proxy.d @@ -0,0 +1,85 @@ +mach_proxy.o mach_proxy_pic.o mach_proxy_p.o mach_proxy.d: mach_proxy.c /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/include/gnu/stubs-pthread.h \ + /usr/lib/gcc/i486-gnu/4.2.4/include/stddef.h /usr/include/xlocale.h \ + /usr/include/bits/string.h /usr/include/bits/string2.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/bits/byteswap.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/stdlib.h util.h \ + /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/wchar.h /usr/lib/gcc/i486-gnu/4.2.4/include/stdarg.h \ + /usr/include/bits/stdio-lock.h /usr/include/bits/libc-lock.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/bits/stdio.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/pthread/pthreadtypes.h /usr/include/bits/pthread.h \ + /usr/include/bits/thread-attr.h /usr/include/sched.h \ + /usr/include/bits/sched.h /usr/include/bits/mutex-attr.h \ + /usr/include/bits/mutex.h /usr/include/bits/spin-lock.h \ + /usr/include/bits/condition-attr.h /usr/include/bits/condition.h \ + /usr/include/bits/rwlock-attr.h /usr/include/bits/rwlock.h \ + /usr/include/bits/barrier-attr.h /usr/include/bits/barrier.h \ + /usr/include/bits/thread-specific.h /usr/include/bits/once.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i486-gnu/4.2.4/include/limits.h \ + /usr/lib/gcc/i486-gnu/4.2.4/include/syslimits.h /usr/include/limits.h \ + /usr/include/bits/posix1_lim.h /usr/include/bits/local_lim.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/xopen_lim.h \ + /usr/include/bits/sockaddr.h /usr/include/arpa/inet.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/wchar.h /usr/include/bits/in.h \ + /usr/include/netinet/ip.h /usr/include/syslog.h \ + /usr/include/sys/syslog.h /usr/include/bits/syslog-path.h \ + /usr/include/mach.h /usr/local/include/mach/mach_types.h \ + /usr/local/include/mach/host_info.h /usr/local/include/mach/machine.h \ + /usr/local/include/mach/machine/vm_types.h \ + /usr/local/include/mach/boolean.h \ + /usr/local/include/mach/machine/boolean.h \ + /usr/local/include/mach/memory_object.h /usr/local/include/mach/port.h \ + /usr/local/include/mach/pc_sample.h \ + /usr/local/include/mach/processor_info.h \ + /usr/local/include/mach/task_info.h \ + /usr/local/include/mach/time_value.h \ + /usr/local/include/mach/task_special_ports.h \ + /usr/local/include/mach/thread_info.h /usr/local/include/mach/policy.h \ + /usr/local/include/mach/thread_special_ports.h \ + /usr/local/include/mach/thread_status.h \ + /usr/local/include/mach/machine/thread_status.h \ + /usr/local/include/mach/machine/fp_reg.h \ + /usr/local/include/mach/vm_attributes.h \ + /usr/local/include/mach/vm_inherit.h /usr/local/include/mach/vm_prot.h \ + /usr/local/include/mach/vm_statistics.h \ + /usr/local/include/mach/std_types.h \ + /usr/local/include/mach/kern_return.h \ + /usr/local/include/mach/machine/kern_return.h /usr/include/mach_init.h \ + /usr/include/mach/mach_traps.h /usr/local/include/mach/message.h \ + /usr/include/mach/mach_interface.h /usr/include/mach/mach_port.h \ + /usr/include/mach/mach_host.h /usr/include/mach-shortcuts.h \ + /usr/include/hurd.h /usr/local/include/mach/mig_errors.h \ + ../hurd/hurd_types.h /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/hurd/auth.h /usr/local/include/device/device_types.h \ + /usr/local/include/device/net_status.h /usr/local/include/device/bpf.h \ + /usr/include/sys/stat.h /usr/include/bits/stat.h \ + /usr/include/sys/statfs.h /usr/include/bits/statfs.h \ + /usr/include/sys/resource.h /usr/include/bits/resource.h \ + /usr/include/sys/utsname.h /usr/include/bits/utsname.h \ + /usr/include/hurd/process.h /usr/include/hurd/fs.h \ + /usr/include/hurd/io.h /usr/include/hurd/port.h \ + /usr/include/hurd/userlink.h /usr/include/hurd/signal.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/sys/ucontext.h /usr/include/bits/sigthread.h \ + /usr/include/hurd/msg.h ../include/cthreads.h \ + ../include/../libthreads/cthreads.h /usr/include/bits/waitflags.h \ + /usr/include/bits/waitstatus.h /usr/include/alloca.h \ + /usr/local/include/mach/machine/vm_param.h /usr/include/machine-sp.h \ + /usr/include/spin-lock.h /usr/include/lock-intern.h \ + /usr/include/machine-lock.h /usr/include/setjmp.h \ + /usr/include/bits/setjmp.h /usr/include/hurd/threadvar.h mach_proxy.h \ + ../hurd/ports.h ../hurd/../libports/ports.h ../hurd/ihash.h \ + ../hurd/../libihash/ihash.h /usr/local/include/mach/notify.h list.h diff --git a/boot-proxy-exc/mach_proxy.h b/boot-proxy-exc/mach_proxy.h new file mode 100644 index 00000000..15f9c397 --- /dev/null +++ b/boot-proxy-exc/mach_proxy.h @@ -0,0 +1,60 @@ +/* + Copyright (C) 2009 Free Software Foundation, Inc. + Written by Zheng Da. + + This file is part of the GNU Hurd. + + The GNU Hurd is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + The GNU Hurd 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with the GNU Hurd; see the file COPYING. If not, write to + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef PROXY_H +#define PROXY_H + +#include <mach.h> +#include <hurd.h> +#include <hurd/ports.h> + +#include "list.h" + +struct task_info +{ + struct port_info task; + task_t task_port; + struct port_info *exc_pi; + volatile mach_port_t user_exc_port; + struct mutex lock; + /* The linked list is used to keep the order of tasks */ + struct list list; +}; + +struct thread_info +{ + struct port_info thread; + thread_t thread_port; +}; + +typedef int (*task_callback_t) (struct task_info *); + +extern struct port_bucket *port_bucket; +extern struct port_class *task_portclass; +extern struct port_class *exc_portclass; +extern struct port_class *thread_portclass; + +int create_pseudo_task (task_t real_task, task_t *ret_pseudo_task); +void clean_pseudo_task (void *pi); +void foreach_task (task_callback_t callback); + +#define UNTESTED + +#endif diff --git a/boot-proxy-exc/mach_proxy.h~ b/boot-proxy-exc/mach_proxy.h~ new file mode 100644 index 00000000..a7806c1f --- /dev/null +++ b/boot-proxy-exc/mach_proxy.h~ @@ -0,0 +1,59 @@ +/* + Copyright (C) 2009 Free Software Foundation, Inc. + Written by Zheng Da. + + This file is part of the GNU Hurd. + + The GNU Hurd is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + The GNU Hurd 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with the GNU Hurd; see the file COPYING. If not, write to + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef PROXY_H +#define PROXY_H + +#include <mach.h> +#include <hurd.h> +#include <hurd/ports.h> + +#include "list.h" + +struct task_info +{ + struct port_info task; + task_t task_port; + struct port_info *exc_pi; + volatile mach_port_t user_exc_port; + struct mutex lock; + /* The linked list is used to keep the order of tasks */ + struct list list; +}; + +struct thread_info +{ + struct port_info thread; + thread_t thread_port; +}; + +typedef int (*task_callback_t) (struct task_info *); + +extern struct port_bucket *port_bucket; +extern struct port_class *task_portclass; +extern struct port_class *thread_portclass; + +int create_pseudo_task (task_t real_task, task_t *ret_pseudo_task); +void clean_pseudo_task (void *pi); +void foreach_task (task_callback_t callback); + +#define UNTESTED + +#endif diff --git a/boot-proxy-exc/mach_proxy.o b/boot-proxy-exc/mach_proxy.o Binary files differnew file mode 100644 index 00000000..7ac633f5 --- /dev/null +++ b/boot-proxy-exc/mach_proxy.o diff --git a/boot-proxy-exc/notify.defs b/boot-proxy-exc/notify.defs new file mode 100644 index 00000000..2014be5c --- /dev/null +++ b/boot-proxy-exc/notify.defs @@ -0,0 +1 @@ +#include <mach/notify.defs> diff --git a/boot-proxy-exc/notify.sdefs.d b/boot-proxy-exc/notify.sdefs.d new file mode 100644 index 00000000..6f5ca2e4 --- /dev/null +++ b/boot-proxy-exc/notify.sdefs.d @@ -0,0 +1,3 @@ +notifyServer.c notify_S.h: notify.defs /usr/local/include/mach/notify.defs \ + /usr/local/include/mach/std_types.defs \ + /usr/local/include/mach/machine/machine_types.defs diff --git a/boot-proxy-exc/notifyServer.c b/boot-proxy-exc/notifyServer.c new file mode 100644 index 00000000..7965461a --- /dev/null +++ b/boot-proxy-exc/notifyServer.c @@ -0,0 +1,353 @@ +/* Module notify */ + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE 1 +#endif + +#define EXPORT_BOOLEAN +#include <mach/boolean.h> +#include <mach/kern_return.h> +#include <mach/message.h> +#include <mach/mig_errors.h> +#include <mach/mig_support.h> + +#ifndef mig_internal +#define mig_internal static +#endif + +#ifndef mig_external +#define mig_external +#endif + +#ifndef TypeCheck +#define TypeCheck 1 +#endif + +#ifndef UseExternRCSId +#define UseExternRCSId 1 +#endif + +#define BAD_TYPECHECK(type, check) ({\ + union { mach_msg_type_t t; unsigned32_t w; } _t, _c;\ + _t.t = *(type); _c.t = *(check); _t.w != _c.w; }) +#define msgh_request_port msgh_local_port +#define MACH_MSGH_BITS_REQUEST(bits) MACH_MSGH_BITS_LOCAL(bits) +#define msgh_reply_port msgh_remote_port +#define MACH_MSGH_BITS_REPLY(bits) MACH_MSGH_BITS_REMOTE(bits) + +#include <mach/std_types.h> + +/* SimpleRoutine mach_notify_port_deleted */ +mig_internal void _Xmach_notify_port_deleted + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t nameType; + mach_port_t name; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t do_mach_notify_port_deleted + (mach_port_t notify, mach_port_t name); + + auto const mach_msg_type_t nameCheck = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->nameType, &nameCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = do_mach_notify_port_deleted(In0P->Head.msgh_request_port, In0P->name); +} + +/* SimpleRoutine mach_notify_msg_accepted */ +mig_internal void _Xmach_notify_msg_accepted + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t nameType; + mach_port_t name; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t do_mach_notify_msg_accepted + (mach_port_t notify, mach_port_t name); + + auto const mach_msg_type_t nameCheck = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->nameType, &nameCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = do_mach_notify_msg_accepted(In0P->Head.msgh_request_port, In0P->name); +} + +/* SimpleRoutine mach_notify_port_destroyed */ +mig_internal void _Xmach_notify_port_destroyed + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t rightsType; + mach_port_t rights; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t do_mach_notify_port_destroyed + (mach_port_t notify, mach_port_t rights); + + auto const mach_msg_type_t rightsCheck = { + /* msgt_name = */ 16, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->rightsType, &rightsCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = do_mach_notify_port_destroyed(In0P->Head.msgh_request_port, In0P->rights); +} + +/* SimpleRoutine mach_notify_no_senders */ +mig_internal void _Xmach_notify_no_senders + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t mscountType; + mach_port_mscount_t mscount; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t do_mach_notify_no_senders + (mach_port_t notify, mach_port_mscount_t mscount); + + auto const mach_msg_type_t mscountCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->mscountType, &mscountCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = do_mach_notify_no_senders(In0P->Head.msgh_request_port, In0P->mscount); +} + +/* SimpleRoutine mach_notify_send_once */ +mig_internal void _Xmach_notify_send_once + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t do_mach_notify_send_once + (mach_port_t notify); + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = do_mach_notify_send_once(In0P->Head.msgh_request_port); +} + +/* SimpleRoutine mach_notify_dead_name */ +mig_internal void _Xmach_notify_dead_name + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t nameType; + mach_port_t name; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t do_mach_notify_dead_name + (mach_port_t notify, mach_port_t name); + + auto const mach_msg_type_t nameCheck = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->nameType, &nameCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = do_mach_notify_dead_name(In0P->Head.msgh_request_port, In0P->name); +} + +static mig_routine_t notify_server_routines[] = { + 0, + _Xmach_notify_port_deleted, + _Xmach_notify_msg_accepted, + 0, + 0, + _Xmach_notify_port_destroyed, + _Xmach_notify_no_senders, + _Xmach_notify_send_once, + _Xmach_notify_dead_name, +}; + +mig_external boolean_t notify_server + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + register mach_msg_header_t *InP = InHeadP; + register mig_reply_header_t *OutP = (mig_reply_header_t *) OutHeadP; + + auto const mach_msg_type_t RetCodeType = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + register mig_routine_t routine; + + OutP->Head.msgh_bits = MACH_MSGH_BITS(MACH_MSGH_BITS_REPLY(InP->msgh_bits), 0); + OutP->Head.msgh_size = sizeof *OutP; + OutP->Head.msgh_remote_port = InP->msgh_reply_port; + OutP->Head.msgh_local_port = MACH_PORT_NULL; + OutP->Head.msgh_seqno = 0; + OutP->Head.msgh_id = InP->msgh_id + 100; + + OutP->RetCodeType = RetCodeType; + + if ((InP->msgh_id > 72) || (InP->msgh_id < 64) || + ((routine = notify_server_routines[InP->msgh_id - 64]) == 0)) { + OutP->RetCode = MIG_BAD_ID; + return FALSE; + } + (*routine) (InP, &OutP->Head); + return TRUE; +} + +mig_external mig_routine_t notify_server_routine + (const mach_msg_header_t *InHeadP) +{ + register int msgh_id; + + msgh_id = InHeadP->msgh_id - 64; + + if ((msgh_id > 8) || (msgh_id < 0)) + return 0; + + return notify_server_routines[msgh_id]; +} + diff --git a/boot-proxy-exc/notifyServer.d b/boot-proxy-exc/notifyServer.d new file mode 100644 index 00000000..75a5b8a3 --- /dev/null +++ b/boot-proxy-exc/notifyServer.d @@ -0,0 +1,28 @@ +notifyServer.o notifyServer_pic.o notifyServer_p.o notifyServer.d: notifyServer.c /usr/local/include/mach/boolean.h \ + /usr/local/include/mach/machine/boolean.h \ + /usr/local/include/mach/kern_return.h \ + /usr/local/include/mach/machine/kern_return.h \ + /usr/local/include/mach/message.h /usr/local/include/mach/port.h \ + /usr/local/include/mach/machine/vm_types.h \ + /usr/local/include/mach/mig_errors.h /usr/include/mach/mig_support.h \ + /usr/local/include/mach/std_types.h /usr/include/sys/types.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h /usr/include/gnu/stubs-pthread.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/time.h /usr/lib/gcc/i486-gnu/4.2.4/include/stddef.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/bits/byteswap.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/pthread/pthreadtypes.h \ + /usr/include/xlocale.h /usr/include/bits/pthread.h \ + /usr/include/bits/thread-attr.h /usr/include/sched.h \ + /usr/include/bits/sched.h /usr/include/bits/mutex-attr.h \ + /usr/include/bits/mutex.h /usr/include/bits/spin-lock.h \ + /usr/include/bits/condition-attr.h /usr/include/bits/condition.h \ + /usr/include/bits/rwlock-attr.h /usr/include/bits/rwlock.h \ + /usr/include/bits/barrier-attr.h /usr/include/bits/barrier.h \ + /usr/include/bits/thread-specific.h /usr/include/bits/once.h \ + /usr/include/string.h /usr/include/bits/string.h \ + /usr/include/bits/string2.h /usr/include/stdlib.h diff --git a/boot-proxy-exc/notifyServer.o b/boot-proxy-exc/notifyServer.o Binary files differnew file mode 100644 index 00000000..cde195b7 --- /dev/null +++ b/boot-proxy-exc/notifyServer.o diff --git a/boot-proxy-exc/notify_S.h b/boot-proxy-exc/notify_S.h new file mode 100644 index 00000000..ac3f4659 --- /dev/null +++ b/boot-proxy-exc/notify_S.h @@ -0,0 +1,124 @@ +#ifndef _notify_server_ +#define _notify_server_ + +/* Module notify */ + +#include <mach/kern_return.h> +#include <mach/port.h> +#include <mach/message.h> + +#include <mach/std_types.h> + +/* SimpleRoutine mach_notify_port_deleted */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t do_mach_notify_port_deleted +#if defined(LINTLIBRARY) + (notify, name) + mach_port_t notify; + mach_port_t name; +{ return do_mach_notify_port_deleted(notify, name); } +#else +( + mach_port_t notify, + mach_port_t name +); +#endif + +/* SimpleRoutine mach_notify_msg_accepted */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t do_mach_notify_msg_accepted +#if defined(LINTLIBRARY) + (notify, name) + mach_port_t notify; + mach_port_t name; +{ return do_mach_notify_msg_accepted(notify, name); } +#else +( + mach_port_t notify, + mach_port_t name +); +#endif + +/* SimpleRoutine mach_notify_port_destroyed */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t do_mach_notify_port_destroyed +#if defined(LINTLIBRARY) + (notify, rights) + mach_port_t notify; + mach_port_t rights; +{ return do_mach_notify_port_destroyed(notify, rights); } +#else +( + mach_port_t notify, + mach_port_t rights +); +#endif + +/* SimpleRoutine mach_notify_no_senders */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t do_mach_notify_no_senders +#if defined(LINTLIBRARY) + (notify, mscount) + mach_port_t notify; + mach_port_mscount_t mscount; +{ return do_mach_notify_no_senders(notify, mscount); } +#else +( + mach_port_t notify, + mach_port_mscount_t mscount +); +#endif + +/* SimpleRoutine mach_notify_send_once */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t do_mach_notify_send_once +#if defined(LINTLIBRARY) + (notify) + mach_port_t notify; +{ return do_mach_notify_send_once(notify); } +#else +( + mach_port_t notify +); +#endif + +/* SimpleRoutine mach_notify_dead_name */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t do_mach_notify_dead_name +#if defined(LINTLIBRARY) + (notify, name) + mach_port_t notify; + mach_port_t name; +{ return do_mach_notify_dead_name(notify, name); } +#else +( + mach_port_t notify, + mach_port_t name +); +#endif + +#endif /* not defined(_notify_server_) */ diff --git a/boot-proxy-exc/ourdevice.defs b/boot-proxy-exc/ourdevice.defs new file mode 100644 index 00000000..1b8ac442 --- /dev/null +++ b/boot-proxy-exc/ourdevice.defs @@ -0,0 +1,383 @@ +# 1 "device.defs" +# 1 "<built-in>" +# 1 "<command-line>" +# 1 "device.defs" +# 1 "/usr/local/include/device/device.defs" 1 3 +# 39 "/usr/local/include/device/device.defs" 3 +subsystem + + + + device 2800; + +# 1 "/usr/local/include/mach/std_types.defs" 1 3 +# 33 "/usr/local/include/mach/std_types.defs" 3 +type char = MACH_MSG_TYPE_CHAR; +type short = MACH_MSG_TYPE_INTEGER_16; +type int = MACH_MSG_TYPE_INTEGER_32; +type int32 = MACH_MSG_TYPE_INTEGER_32; +type int64 = MACH_MSG_TYPE_INTEGER_64; +type boolean_t = MACH_MSG_TYPE_BOOLEAN; +type unsigned = MACH_MSG_TYPE_INTEGER_32; +type unsigned32 = MACH_MSG_TYPE_INTEGER_32; +type unsigned64 = MACH_MSG_TYPE_INTEGER_64; + + +# 1 "/usr/local/include/mach/machine/machine_types.defs" 1 3 +# 50 "/usr/local/include/mach/machine/machine_types.defs" 3 +type natural_t = unsigned32; +# 59 "/usr/local/include/mach/machine/machine_types.defs" 3 +type integer_t = int32; +# 45 "/usr/local/include/mach/std_types.defs" 2 3 + +type kern_return_t = int; + +type pointer_t = ^array[] of MACH_MSG_TYPE_BYTE + ctype: vm_offset_t; + + +type mach_port_t = MACH_MSG_TYPE_COPY_SEND; +type mach_port_array_t = array[] of mach_port_t; + +type mach_port_name_t = MACH_MSG_TYPE_PORT_NAME + ctype: mach_port_t; +type mach_port_name_array_t = array[] of mach_port_name_t + ctype: mach_port_array_t; + +type mach_port_right_t = natural_t; + +type mach_port_type_t = natural_t; +type mach_port_type_array_t = array[] of mach_port_type_t; + +type mach_port_urefs_t = natural_t; +type mach_port_delta_t = integer_t; +type mach_port_seqno_t = natural_t; +type mach_port_mscount_t = unsigned; +type mach_port_msgcount_t = unsigned; +type mach_port_rights_t = unsigned; +type mach_msg_id_t = integer_t; +type mach_msg_type_name_t = unsigned; +type mach_msg_type_number_t = natural_t; + +type mach_port_move_receive_t = MACH_MSG_TYPE_MOVE_RECEIVE + ctype: mach_port_t; +type mach_port_copy_send_t = MACH_MSG_TYPE_COPY_SEND + ctype: mach_port_t; +type mach_port_make_send_t = MACH_MSG_TYPE_MAKE_SEND + ctype: mach_port_t; +type mach_port_move_send_t = MACH_MSG_TYPE_MOVE_SEND + ctype: mach_port_t; +type mach_port_make_send_once_t = MACH_MSG_TYPE_MAKE_SEND_ONCE + ctype: mach_port_t; +type mach_port_move_send_once_t = MACH_MSG_TYPE_MOVE_SEND_ONCE + ctype: mach_port_t; + +type mach_port_receive_t = MACH_MSG_TYPE_PORT_RECEIVE + ctype: mach_port_t; +type mach_port_send_t = MACH_MSG_TYPE_PORT_SEND + ctype: mach_port_t; +type mach_port_send_once_t = MACH_MSG_TYPE_PORT_SEND_ONCE + ctype: mach_port_t; + +type mach_port_poly_t = polymorphic + ctype: mach_port_t; + +import <mach/std_types.h>; +# 46 "/usr/local/include/device/device.defs" 2 3 +# 1 "/usr/local/include/mach/mach_types.defs" 1 3 +# 61 "/usr/local/include/mach/mach_types.defs" 3 +type mach_port_status_t = struct[9] of integer_t; + +type old_mach_port_status_t = struct[8] of integer_t; + +type task_t = mach_port_t + ctype: mach_port_t + + + + + + ; +# 85 "/usr/local/include/mach/mach_types.defs" 3 +type thread_t = mach_port_t + ctype: mach_port_t + + + + + + ; + +type thread_state_t = array[*:1024] of natural_t; + +type task_array_t = ^array[] of task_t; +type thread_array_t = ^array[] of thread_t; + +type vm_task_t = mach_port_t + ctype: mach_port_t + + + + + ; + +type ipc_space_t = mach_port_t + ctype: mach_port_t + + + + + ; + +type vm_address_t = natural_t; +type vm_offset_t = natural_t; +type vm_size_t = natural_t; +type vm_prot_t = int; +type vm_inherit_t = int; +type vm_statistics_data_t = struct[13] of integer_t; +type vm_machine_attribute_t = int; +type vm_machine_attribute_val_t = int; + +type thread_info_t = array[*:1024] of natural_t; +type thread_basic_info_data_t = struct[11] of integer_t; +type thread_sched_info_data_t = struct[7] of integer_t; + +type task_info_t = array[*:1024] of natural_t; +type task_basic_info_data_t = struct[8] of integer_t; +type task_events_info = struct[7] of natural_t; +type task_thread_times_info_data_t = struct[4] of integer_t; + + +type memory_object_t = mach_port_t + ctype: mach_port_t + + + + ; + +type memory_object_control_t = mach_port_t + ctype: mach_port_t + + + + ; + +type memory_object_name_t = mach_port_t + ctype: mach_port_t + + + + + ; + +type memory_object_copy_strategy_t = int; +type memory_object_return_t = int; + +type machine_info_data_t = struct[5] of integer_t; +type machine_slot_data_t = struct[8] of integer_t; + +type host_t = mach_port_t + ctype: mach_port_t + + + + + ; + +type host_priv_t = mach_port_t + ctype: mach_port_t + + + + ; + +type host_info_t = array[*:1024] of natural_t; +type host_basic_info_data_t = struct[5] of integer_t; +type host_sched_info_data_t = struct[2] of integer_t; +type host_load_info_data_t = struct[6] of integer_t; + + +type processor_t = mach_port_t + ctype: mach_port_t + + + + + ; + +type processor_array_t = ^array[] of processor_t; +type processor_info_t = array[*:1024] of natural_t; +type processor_basic_info_data_t = struct[5] of integer_t; + + +type processor_set_t = mach_port_t + ctype: mach_port_t + + + + + + ; + +type processor_set_array_t = ^array[] of processor_set_t; + +type processor_set_name_t = mach_port_t + ctype: mach_port_t + + + + + + ; + +type processor_set_name_array_t = ^array[] of processor_set_name_t; + +type processor_set_info_t = array[*:1024] of natural_t; +type processor_set_basic_info_data_t = struct[5] of integer_t; +type processor_set_sched_info_data_t = struct[2] of integer_t; + + +type kernel_version_t = (MACH_MSG_TYPE_STRING, 512*8); + +type kernel_boot_info_t = (MACH_MSG_TYPE_STRING, 4096*8); + +type time_value_t = struct[2] of integer_t; + +type emulation_vector_t = ^array[] of vm_offset_t; + +type xxx_emulation_vector_t = array[*:1024] of vm_offset_t + ctype: emulation_vector_t; + + +type rpc_signature_info_t = array[*:1024] of int; +# 250 "/usr/local/include/mach/mach_types.defs" 3 +import <mach/mach_types.h>; +# 47 "/usr/local/include/device/device.defs" 2 3 +# 1 "/usr/local/include/device/device_types.defs" 1 3 +# 42 "/usr/local/include/device/device_types.defs" 3 +type recnum_t = unsigned32; +type dev_mode_t = unsigned32; +type dev_flavor_t = unsigned32; +type dev_name_t = (MACH_MSG_TYPE_STRING_C, 8*128); +type dev_status_t = array[*:1024] of int; +type io_buf_ptr_t = ^array[] of MACH_MSG_TYPE_INTEGER_8; +type io_buf_ptr_inband_t= array[*:128] of char; +type filter_t = short; +type filter_array_t = array[*:128] of filter_t; + +type device_t = mach_port_t + ctype: mach_port_t + + + + + + ; + +import <device/device_types.h>; +import <device/net_status.h>; +# 48 "/usr/local/include/device/device.defs" 2 3 + +serverprefix ds_; + +type reply_port_t = MACH_MSG_TYPE_MAKE_SEND_ONCE | polymorphic + ctype: mach_port_t; + +routine device_open( + master_port : mach_port_t; + sreplyport reply_port : reply_port_t; + mode : dev_mode_t; + name : dev_name_t; + out device : mach_port_send_t + ); + +routine device_close( + device : device_t + ); + +routine device_write( + device : device_t; + sreplyport reply_port : reply_port_t; + in mode : dev_mode_t; + in recnum : recnum_t; + in data : io_buf_ptr_t; + out bytes_written : int + ); + +routine device_write_inband( + device : device_t; + sreplyport reply_port : reply_port_t; + in mode : dev_mode_t; + in recnum : recnum_t; + in data : io_buf_ptr_inband_t; + out bytes_written : int + ); + +routine device_read( + device : device_t; + sreplyport reply_port : reply_port_t; + in mode : dev_mode_t; + in recnum : recnum_t; + in bytes_wanted : int; + out data : io_buf_ptr_t + ); + +routine device_read_inband( + device : device_t; + sreplyport reply_port : reply_port_t; + in mode : dev_mode_t; + in recnum : recnum_t; + in bytes_wanted : int; + out data : io_buf_ptr_inband_t + ); + + +routine xxx_device_set_status( + device : device_t; + in flavor : dev_flavor_t; + in status : dev_status_t, IsLong + ); + + +routine xxx_device_get_status( + device : device_t; + in flavor : dev_flavor_t; + out status : dev_status_t, IsLong + ); + + +routine xxx_device_set_filter( + device : device_t; + in receive_port : mach_port_send_t; + in priority : int; + in filter : filter_array_t, IsLong + ); + +routine device_map( + device : device_t; + in prot : vm_prot_t; + in offset : vm_offset_t; + in size : vm_size_t; + out pager : memory_object_t; + in unmap : int + ); + +routine device_set_status( + device : device_t; + in flavor : dev_flavor_t; + in status : dev_status_t + ); + +routine device_get_status( + device : device_t; + in flavor : dev_flavor_t; + out status : dev_status_t, CountInOut + ); + +routine device_set_filter( + device : device_t; + in receive_port : mach_port_send_t; + in priority : int; + in filter : filter_array_t + ); +# 1 "device.defs" 2 diff --git a/boot-proxy-exc/ourdevice.sdefs.d b/boot-proxy-exc/ourdevice.sdefs.d new file mode 100644 index 00000000..95384eeb --- /dev/null +++ b/boot-proxy-exc/ourdevice.sdefs.d @@ -0,0 +1 @@ +ourdeviceServer.c ourdevice_S.h: ourdevice.defs diff --git a/boot-proxy-exc/ourdeviceServer.c b/boot-proxy-exc/ourdeviceServer.c new file mode 100644 index 00000000..3db5fd8d --- /dev/null +++ b/boot-proxy-exc/ourdeviceServer.c @@ -0,0 +1,1179 @@ +/* Module device */ + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE 1 +#endif + +#define EXPORT_BOOLEAN +#include <mach/boolean.h> +#include <mach/kern_return.h> +#include <mach/message.h> +#include <mach/mig_errors.h> +#include <mach/mig_support.h> + +#ifndef mig_internal +#define mig_internal static +#endif + +#ifndef mig_external +#define mig_external +#endif + +#ifndef TypeCheck +#define TypeCheck 1 +#endif + +#ifndef UseExternRCSId +#define UseExternRCSId 1 +#endif + +#define BAD_TYPECHECK(type, check) ({\ + union { mach_msg_type_t t; unsigned32_t w; } _t, _c;\ + _t.t = *(type); _c.t = *(check); _t.w != _c.w; }) +#define msgh_request_port msgh_local_port +#define MACH_MSGH_BITS_REQUEST(bits) MACH_MSGH_BITS_LOCAL(bits) +#define msgh_reply_port msgh_remote_port +#define MACH_MSGH_BITS_REPLY(bits) MACH_MSGH_BITS_REMOTE(bits) + +#include <mach/std_types.h> +#include <mach/mach_types.h> +#include <device/device_types.h> +#include <device/net_status.h> + +/* Routine device_open */ +mig_internal void _Xdevice_open + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t modeType; + dev_mode_t mode; + mach_msg_type_long_t nameType; + dev_name_t name; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t deviceType; + mach_port_t device; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t ds_device_open + (mach_port_t master_port, mach_port_t reply_port, mach_msg_type_name_t reply_portPoly, dev_mode_t mode, dev_name_t name, mach_port_t *device, mach_msg_type_name_t *devicePoly); + + boolean_t msgh_simple; + auto const mach_msg_type_t modeCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t deviceType = { + /* msgt_name = */ -1, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + mach_msg_type_name_t devicePoly; + +#if TypeCheck + if ((In0P->Head.msgh_size != 172) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->modeType, &modeCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if ((In0P->nameType.msgtl_header.msgt_inline != TRUE) || + (In0P->nameType.msgtl_header.msgt_longform != TRUE) || + (In0P->nameType.msgtl_name != 12) || + (In0P->nameType.msgtl_number != 1) || + (In0P->nameType.msgtl_size != 1024)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = ds_device_open(In0P->Head.msgh_request_port, In0P->Head.msgh_reply_port, MACH_MSGH_BITS_REPLY(In0P->Head.msgh_bits), In0P->mode, In0P->name, &OutP->device, &devicePoly); + if (OutP->RetCode != KERN_SUCCESS) + return; + + msgh_simple = TRUE; + OutP->Head.msgh_size = 40; + + OutP->deviceType = deviceType; + + if (MACH_MSG_TYPE_PORT_ANY(devicePoly)) + msgh_simple = FALSE; + + OutP->deviceType.msgt_name = devicePoly; + + if (!msgh_simple) + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; +} + +/* Routine device_close */ +mig_internal void _Xdevice_close + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t ds_device_close + (mach_port_t device); + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = ds_device_close(In0P->Head.msgh_request_port); +} + +/* Routine device_write */ +mig_internal void _Xdevice_write + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t modeType; + dev_mode_t mode; + mach_msg_type_t recnumType; + recnum_t recnum; + mach_msg_type_long_t dataType; + io_buf_ptr_t data; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t bytes_writtenType; + int bytes_written; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t ds_device_write + (mach_port_t device, mach_port_t reply_port, mach_msg_type_name_t reply_portPoly, dev_mode_t mode, recnum_t recnum, io_buf_ptr_t data, mach_msg_type_number_t dataCnt, int *bytes_written); + + auto const mach_msg_type_t modeCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t recnumCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t bytes_writtenType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 56) || + !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->modeType, &modeCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->recnumType, &recnumCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if ((In0P->dataType.msgtl_header.msgt_inline != FALSE) || + (In0P->dataType.msgtl_header.msgt_longform != TRUE) || + (In0P->dataType.msgtl_name != 9) || + (In0P->dataType.msgtl_size != 8)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = ds_device_write(In0P->Head.msgh_request_port, In0P->Head.msgh_reply_port, MACH_MSGH_BITS_REPLY(In0P->Head.msgh_bits), In0P->mode, In0P->recnum, In0P->data, In0P->dataType.msgtl_number, &OutP->bytes_written); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_size = 40; + + OutP->bytes_writtenType = bytes_writtenType; +} + +/* Routine device_write_inband */ +mig_internal void _Xdevice_write_inband + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t modeType; + dev_mode_t mode; + mach_msg_type_t recnumType; + recnum_t recnum; + mach_msg_type_t dataType; + char data[128]; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t bytes_writtenType; + int bytes_written; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t ds_device_write_inband + (mach_port_t device, mach_port_t reply_port, mach_msg_type_name_t reply_portPoly, dev_mode_t mode, recnum_t recnum, io_buf_ptr_inband_t data, mach_msg_type_number_t dataCnt, int *bytes_written); + + unsigned int msgh_size; + + auto const mach_msg_type_t modeCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t recnumCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t bytes_writtenType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + msgh_size = In0P->Head.msgh_size; + if ((msgh_size < 44) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->modeType, &modeCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->recnumType, &recnumCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if ((In0P->dataType.msgt_inline != TRUE) || + (In0P->dataType.msgt_longform != FALSE) || + (In0P->dataType.msgt_name != 8) || + (In0P->dataType.msgt_size != 8)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (msgh_size != 44 + ((In0P->dataType.msgt_number + 3) & ~3)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = ds_device_write_inband(In0P->Head.msgh_request_port, In0P->Head.msgh_reply_port, MACH_MSGH_BITS_REPLY(In0P->Head.msgh_bits), In0P->mode, In0P->recnum, In0P->data, In0P->dataType.msgt_number, &OutP->bytes_written); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_size = 40; + + OutP->bytes_writtenType = bytes_writtenType; +} + +/* Routine device_read */ +mig_internal void _Xdevice_read + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t modeType; + dev_mode_t mode; + mach_msg_type_t recnumType; + recnum_t recnum; + mach_msg_type_t bytes_wantedType; + int bytes_wanted; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_long_t dataType; + io_buf_ptr_t data; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t ds_device_read + (mach_port_t device, mach_port_t reply_port, mach_msg_type_name_t reply_portPoly, dev_mode_t mode, recnum_t recnum, int bytes_wanted, io_buf_ptr_t *data, mach_msg_type_number_t *dataCnt); + + auto const mach_msg_type_t modeCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t recnumCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t bytes_wantedCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_long_t dataType = { + { + /* msgt_name = */ 0, + /* msgt_size = */ 0, + /* msgt_number = */ 0, + /* msgt_inline = */ FALSE, + /* msgt_longform = */ TRUE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }, + /* msgtl_name = */ 9, + /* msgtl_size = */ 8, + /* msgtl_number = */ 0, + }; + + mach_msg_type_number_t dataCnt; + +#if TypeCheck + if ((In0P->Head.msgh_size != 48) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->modeType, &modeCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->recnumType, &recnumCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->bytes_wantedType, &bytes_wantedCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = ds_device_read(In0P->Head.msgh_request_port, In0P->Head.msgh_reply_port, MACH_MSGH_BITS_REPLY(In0P->Head.msgh_bits), In0P->mode, In0P->recnum, In0P->bytes_wanted, &OutP->data, &dataCnt); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; + OutP->Head.msgh_size = 48; + + OutP->dataType = dataType; + + OutP->dataType.msgtl_number = dataCnt; +} + +/* Routine device_read_inband */ +mig_internal void _Xdevice_read_inband + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t modeType; + dev_mode_t mode; + mach_msg_type_t recnumType; + recnum_t recnum; + mach_msg_type_t bytes_wantedType; + int bytes_wanted; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t dataType; + char data[128]; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t ds_device_read_inband + (mach_port_t device, mach_port_t reply_port, mach_msg_type_name_t reply_portPoly, dev_mode_t mode, recnum_t recnum, int bytes_wanted, io_buf_ptr_inband_t data, mach_msg_type_number_t *dataCnt); + + auto const mach_msg_type_t modeCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t recnumCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t bytes_wantedCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t dataType = { + /* msgt_name = */ 8, + /* msgt_size = */ 8, + /* msgt_number = */ 128, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + mach_msg_type_number_t dataCnt; + +#if TypeCheck + if ((In0P->Head.msgh_size != 48) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->modeType, &modeCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->recnumType, &recnumCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->bytes_wantedType, &bytes_wantedCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + dataCnt = 128; + + OutP->RetCode = ds_device_read_inband(In0P->Head.msgh_request_port, In0P->Head.msgh_reply_port, MACH_MSGH_BITS_REPLY(In0P->Head.msgh_bits), In0P->mode, In0P->recnum, In0P->bytes_wanted, OutP->data, &dataCnt); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->dataType = dataType; + + OutP->dataType.msgt_number = dataCnt; + OutP->Head.msgh_size = 36 + ((dataCnt + 3) & ~3); +} + +/* Routine xxx_device_set_status */ +mig_internal void _Xxxx_device_set_status + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t flavorType; + dev_flavor_t flavor; + mach_msg_type_long_t statusType; + int status[1024]; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t ds_xxx_device_set_status + (mach_port_t device, dev_flavor_t flavor, dev_status_t status, mach_msg_type_number_t statusCnt); + + unsigned int msgh_size; + + auto const mach_msg_type_t flavorCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + msgh_size = In0P->Head.msgh_size; + if ((msgh_size < 44) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->flavorType, &flavorCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if ((In0P->statusType.msgtl_header.msgt_inline != TRUE) || + (In0P->statusType.msgtl_header.msgt_longform != TRUE) || + (In0P->statusType.msgtl_name != 2) || + (In0P->statusType.msgtl_size != 32)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (msgh_size != 44 + (4 * In0P->statusType.msgtl_number)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = ds_xxx_device_set_status(In0P->Head.msgh_request_port, In0P->flavor, In0P->status, In0P->statusType.msgtl_number); +} + +/* Routine xxx_device_get_status */ +mig_internal void _Xxxx_device_get_status + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t flavorType; + dev_flavor_t flavor; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_long_t statusType; + int status[1024]; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t ds_xxx_device_get_status + (mach_port_t device, dev_flavor_t flavor, dev_status_t status, mach_msg_type_number_t *statusCnt); + + auto const mach_msg_type_t flavorCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_long_t statusType = { + { + /* msgt_name = */ 0, + /* msgt_size = */ 0, + /* msgt_number = */ 0, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ TRUE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }, + /* msgtl_name = */ 2, + /* msgtl_size = */ 32, + /* msgtl_number = */ 1024, + }; + + mach_msg_type_number_t statusCnt; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->flavorType, &flavorCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + statusCnt = 1024; + + OutP->RetCode = ds_xxx_device_get_status(In0P->Head.msgh_request_port, In0P->flavor, OutP->status, &statusCnt); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->statusType = statusType; + + OutP->statusType.msgtl_number = statusCnt; + OutP->Head.msgh_size = 44 + (4 * statusCnt); +} + +/* Routine xxx_device_set_filter */ +mig_internal void _Xxxx_device_set_filter + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t receive_portType; + mach_port_t receive_port; + mach_msg_type_t priorityType; + int priority; + mach_msg_type_long_t filterType; + filter_t filter[128]; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t ds_xxx_device_set_filter + (mach_port_t device, mach_port_t receive_port, int priority, filter_array_t filter, mach_msg_type_number_t filterCnt); + + unsigned int msgh_size; + + auto const mach_msg_type_t receive_portCheck = { + /* msgt_name = */ 17, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t priorityCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + msgh_size = In0P->Head.msgh_size; + if ((msgh_size < 52) || + !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->receive_portType, &receive_portCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->priorityType, &priorityCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if ((In0P->filterType.msgtl_header.msgt_inline != TRUE) || + (In0P->filterType.msgtl_header.msgt_longform != TRUE) || + (In0P->filterType.msgtl_name != 1) || + (In0P->filterType.msgtl_size != 16)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (msgh_size != 52 + ((2 * In0P->filterType.msgtl_number + 3) & ~3)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = ds_xxx_device_set_filter(In0P->Head.msgh_request_port, In0P->receive_port, In0P->priority, In0P->filter, In0P->filterType.msgtl_number); +} + +/* Routine device_map */ +mig_internal void _Xdevice_map + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t protType; + vm_prot_t prot; + mach_msg_type_t offsetType; + vm_offset_t offset; + mach_msg_type_t sizeType; + vm_size_t size; + mach_msg_type_t unmapType; + int unmap; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t pagerType; + mach_port_t pager; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t ds_device_map + (mach_port_t device, vm_prot_t prot, vm_offset_t offset, vm_size_t size, mach_port_t *pager, int unmap); + + auto const mach_msg_type_t protCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t offsetCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t sizeCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t unmapCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t pagerType = { + /* msgt_name = */ 19, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 56) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->protType, &protCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->offsetType, &offsetCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->sizeType, &sizeCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->unmapType, &unmapCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = ds_device_map(In0P->Head.msgh_request_port, In0P->prot, In0P->offset, In0P->size, &OutP->pager, In0P->unmap); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; + OutP->Head.msgh_size = 40; + + OutP->pagerType = pagerType; +} + +/* Routine device_set_status */ +mig_internal void _Xdevice_set_status + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t flavorType; + dev_flavor_t flavor; + mach_msg_type_t statusType; + int status[1024]; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t ds_device_set_status + (mach_port_t device, dev_flavor_t flavor, dev_status_t status, mach_msg_type_number_t statusCnt); + + unsigned int msgh_size; + + auto const mach_msg_type_t flavorCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + msgh_size = In0P->Head.msgh_size; + if ((msgh_size < 36) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->flavorType, &flavorCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if ((In0P->statusType.msgt_inline != TRUE) || + (In0P->statusType.msgt_longform != FALSE) || + (In0P->statusType.msgt_name != 2) || + (In0P->statusType.msgt_size != 32)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (msgh_size != 36 + (4 * In0P->statusType.msgt_number)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = ds_device_set_status(In0P->Head.msgh_request_port, In0P->flavor, In0P->status, In0P->statusType.msgt_number); +} + +/* Routine device_get_status */ +mig_internal void _Xdevice_get_status + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t flavorType; + dev_flavor_t flavor; + mach_msg_type_t statusCntType; + mach_msg_type_number_t statusCnt; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t statusType; + int status[1024]; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t ds_device_get_status + (mach_port_t device, dev_flavor_t flavor, dev_status_t status, mach_msg_type_number_t *statusCnt); + + auto const mach_msg_type_t flavorCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t statusCntCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t statusType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1024, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + mach_msg_type_number_t statusCnt; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->flavorType, &flavorCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->statusCntType, &statusCntCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + statusCnt = 1024; + if (In0P->statusCnt < statusCnt) + statusCnt = In0P->statusCnt; + + OutP->RetCode = ds_device_get_status(In0P->Head.msgh_request_port, In0P->flavor, OutP->status, &statusCnt); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->statusType = statusType; + + OutP->statusType.msgt_number = statusCnt; + OutP->Head.msgh_size = 36 + (4 * statusCnt); +} + +/* Routine device_set_filter */ +mig_internal void _Xdevice_set_filter + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t receive_portType; + mach_port_t receive_port; + mach_msg_type_t priorityType; + int priority; + mach_msg_type_t filterType; + filter_t filter[128]; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t ds_device_set_filter + (mach_port_t device, mach_port_t receive_port, int priority, filter_array_t filter, mach_msg_type_number_t filterCnt); + + unsigned int msgh_size; + + auto const mach_msg_type_t receive_portCheck = { + /* msgt_name = */ 17, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t priorityCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + msgh_size = In0P->Head.msgh_size; + if ((msgh_size < 44) || + !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->receive_portType, &receive_portCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->priorityType, &priorityCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if ((In0P->filterType.msgt_inline != TRUE) || + (In0P->filterType.msgt_longform != FALSE) || + (In0P->filterType.msgt_name != 1) || + (In0P->filterType.msgt_size != 16)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (msgh_size != 44 + ((2 * In0P->filterType.msgt_number + 3) & ~3)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = ds_device_set_filter(In0P->Head.msgh_request_port, In0P->receive_port, In0P->priority, In0P->filter, In0P->filterType.msgt_number); +} + +static mig_routine_t device_server_routines[] = { + _Xdevice_open, + _Xdevice_close, + _Xdevice_write, + _Xdevice_write_inband, + _Xdevice_read, + _Xdevice_read_inband, + _Xxxx_device_set_status, + _Xxxx_device_get_status, + _Xxxx_device_set_filter, + _Xdevice_map, + _Xdevice_set_status, + _Xdevice_get_status, + _Xdevice_set_filter, +}; + +mig_external boolean_t device_server + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + register mach_msg_header_t *InP = InHeadP; + register mig_reply_header_t *OutP = (mig_reply_header_t *) OutHeadP; + + auto const mach_msg_type_t RetCodeType = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + register mig_routine_t routine; + + OutP->Head.msgh_bits = MACH_MSGH_BITS(MACH_MSGH_BITS_REPLY(InP->msgh_bits), 0); + OutP->Head.msgh_size = sizeof *OutP; + OutP->Head.msgh_remote_port = InP->msgh_reply_port; + OutP->Head.msgh_local_port = MACH_PORT_NULL; + OutP->Head.msgh_seqno = 0; + OutP->Head.msgh_id = InP->msgh_id + 100; + + OutP->RetCodeType = RetCodeType; + + if ((InP->msgh_id > 2812) || (InP->msgh_id < 2800) || + ((routine = device_server_routines[InP->msgh_id - 2800]) == 0)) { + OutP->RetCode = MIG_BAD_ID; + return FALSE; + } + (*routine) (InP, &OutP->Head); + return TRUE; +} + +mig_external mig_routine_t device_server_routine + (const mach_msg_header_t *InHeadP) +{ + register int msgh_id; + + msgh_id = InHeadP->msgh_id - 2800; + + if ((msgh_id > 12) || (msgh_id < 0)) + return 0; + + return device_server_routines[msgh_id]; +} + diff --git a/boot-proxy-exc/ourdeviceServer.d b/boot-proxy-exc/ourdeviceServer.d new file mode 100644 index 00000000..2a11844d --- /dev/null +++ b/boot-proxy-exc/ourdeviceServer.d @@ -0,0 +1,46 @@ +ourdeviceServer.o ourdeviceServer_pic.o ourdeviceServer_p.o ourdeviceServer.d: ourdeviceServer.c /usr/local/include/mach/boolean.h \ + /usr/local/include/mach/machine/boolean.h \ + /usr/local/include/mach/kern_return.h \ + /usr/local/include/mach/machine/kern_return.h \ + /usr/local/include/mach/message.h /usr/local/include/mach/port.h \ + /usr/local/include/mach/machine/vm_types.h \ + /usr/local/include/mach/mig_errors.h /usr/include/mach/mig_support.h \ + /usr/local/include/mach/std_types.h /usr/include/sys/types.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h /usr/include/gnu/stubs-pthread.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/time.h /usr/lib/gcc/i486-gnu/4.2.4/include/stddef.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/bits/byteswap.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/pthread/pthreadtypes.h \ + /usr/include/xlocale.h /usr/include/bits/pthread.h \ + /usr/include/bits/thread-attr.h /usr/include/sched.h \ + /usr/include/bits/sched.h /usr/include/bits/mutex-attr.h \ + /usr/include/bits/mutex.h /usr/include/bits/spin-lock.h \ + /usr/include/bits/condition-attr.h /usr/include/bits/condition.h \ + /usr/include/bits/rwlock-attr.h /usr/include/bits/rwlock.h \ + /usr/include/bits/barrier-attr.h /usr/include/bits/barrier.h \ + /usr/include/bits/thread-specific.h /usr/include/bits/once.h \ + /usr/include/string.h /usr/include/bits/string.h \ + /usr/include/bits/string2.h /usr/include/stdlib.h \ + /usr/local/include/mach/mach_types.h \ + /usr/local/include/mach/host_info.h /usr/local/include/mach/machine.h \ + /usr/local/include/mach/memory_object.h \ + /usr/local/include/mach/pc_sample.h \ + /usr/local/include/mach/processor_info.h \ + /usr/local/include/mach/task_info.h \ + /usr/local/include/mach/time_value.h \ + /usr/local/include/mach/task_special_ports.h \ + /usr/local/include/mach/thread_info.h /usr/local/include/mach/policy.h \ + /usr/local/include/mach/thread_special_ports.h \ + /usr/local/include/mach/thread_status.h \ + /usr/local/include/mach/machine/thread_status.h \ + /usr/local/include/mach/machine/fp_reg.h \ + /usr/local/include/mach/vm_attributes.h \ + /usr/local/include/mach/vm_inherit.h /usr/local/include/mach/vm_prot.h \ + /usr/local/include/mach/vm_statistics.h \ + /usr/local/include/device/device_types.h \ + /usr/local/include/device/net_status.h /usr/local/include/device/bpf.h diff --git a/boot-proxy-exc/ourdeviceServer.o b/boot-proxy-exc/ourdeviceServer.o Binary files differnew file mode 100644 index 00000000..f53b978f --- /dev/null +++ b/boot-proxy-exc/ourdeviceServer.o diff --git a/boot-proxy-exc/ourdevice_S.h b/boot-proxy-exc/ourdevice_S.h new file mode 100644 index 00000000..c899ae3e --- /dev/null +++ b/boot-proxy-exc/ourdevice_S.h @@ -0,0 +1,354 @@ +#ifndef _device_server_ +#define _device_server_ + +/* Module device */ + +#include <mach/kern_return.h> +#include <mach/port.h> +#include <mach/message.h> + +#include <mach/std_types.h> +#include <mach/mach_types.h> +#include <device/device_types.h> +#include <device/net_status.h> + +/* Routine device_open */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t ds_device_open +#if defined(LINTLIBRARY) + (master_port, reply_port, reply_portPoly, mode, name, device, devicePoly) + mach_port_t master_port; + mach_port_t reply_port; + mach_msg_type_name_t reply_portPoly; + dev_mode_t mode; + dev_name_t name; + mach_port_t *device; + mach_msg_type_name_t *devicePoly; +{ return ds_device_open(master_port, reply_port, reply_portPoly, mode, name, device, devicePoly); } +#else +( + mach_port_t master_port, + mach_port_t reply_port, + mach_msg_type_name_t reply_portPoly, + dev_mode_t mode, + dev_name_t name, + mach_port_t *device, + mach_msg_type_name_t *devicePoly +); +#endif + +/* Routine device_close */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t ds_device_close +#if defined(LINTLIBRARY) + (device) + mach_port_t device; +{ return ds_device_close(device); } +#else +( + mach_port_t device +); +#endif + +/* Routine device_write */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t ds_device_write +#if defined(LINTLIBRARY) + (device, reply_port, reply_portPoly, mode, recnum, data, dataCnt, bytes_written) + mach_port_t device; + mach_port_t reply_port; + mach_msg_type_name_t reply_portPoly; + dev_mode_t mode; + recnum_t recnum; + io_buf_ptr_t data; + mach_msg_type_number_t dataCnt; + int *bytes_written; +{ return ds_device_write(device, reply_port, reply_portPoly, mode, recnum, data, dataCnt, bytes_written); } +#else +( + mach_port_t device, + mach_port_t reply_port, + mach_msg_type_name_t reply_portPoly, + dev_mode_t mode, + recnum_t recnum, + io_buf_ptr_t data, + mach_msg_type_number_t dataCnt, + int *bytes_written +); +#endif + +/* Routine device_write_inband */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t ds_device_write_inband +#if defined(LINTLIBRARY) + (device, reply_port, reply_portPoly, mode, recnum, data, dataCnt, bytes_written) + mach_port_t device; + mach_port_t reply_port; + mach_msg_type_name_t reply_portPoly; + dev_mode_t mode; + recnum_t recnum; + io_buf_ptr_inband_t data; + mach_msg_type_number_t dataCnt; + int *bytes_written; +{ return ds_device_write_inband(device, reply_port, reply_portPoly, mode, recnum, data, dataCnt, bytes_written); } +#else +( + mach_port_t device, + mach_port_t reply_port, + mach_msg_type_name_t reply_portPoly, + dev_mode_t mode, + recnum_t recnum, + io_buf_ptr_inband_t data, + mach_msg_type_number_t dataCnt, + int *bytes_written +); +#endif + +/* Routine device_read */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t ds_device_read +#if defined(LINTLIBRARY) + (device, reply_port, reply_portPoly, mode, recnum, bytes_wanted, data, dataCnt) + mach_port_t device; + mach_port_t reply_port; + mach_msg_type_name_t reply_portPoly; + dev_mode_t mode; + recnum_t recnum; + int bytes_wanted; + io_buf_ptr_t *data; + mach_msg_type_number_t *dataCnt; +{ return ds_device_read(device, reply_port, reply_portPoly, mode, recnum, bytes_wanted, data, dataCnt); } +#else +( + mach_port_t device, + mach_port_t reply_port, + mach_msg_type_name_t reply_portPoly, + dev_mode_t mode, + recnum_t recnum, + int bytes_wanted, + io_buf_ptr_t *data, + mach_msg_type_number_t *dataCnt +); +#endif + +/* Routine device_read_inband */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t ds_device_read_inband +#if defined(LINTLIBRARY) + (device, reply_port, reply_portPoly, mode, recnum, bytes_wanted, data, dataCnt) + mach_port_t device; + mach_port_t reply_port; + mach_msg_type_name_t reply_portPoly; + dev_mode_t mode; + recnum_t recnum; + int bytes_wanted; + io_buf_ptr_inband_t data; + mach_msg_type_number_t *dataCnt; +{ return ds_device_read_inband(device, reply_port, reply_portPoly, mode, recnum, bytes_wanted, data, dataCnt); } +#else +( + mach_port_t device, + mach_port_t reply_port, + mach_msg_type_name_t reply_portPoly, + dev_mode_t mode, + recnum_t recnum, + int bytes_wanted, + io_buf_ptr_inband_t data, + mach_msg_type_number_t *dataCnt +); +#endif + +/* Routine xxx_device_set_status */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t ds_xxx_device_set_status +#if defined(LINTLIBRARY) + (device, flavor, status, statusCnt) + mach_port_t device; + dev_flavor_t flavor; + dev_status_t status; + mach_msg_type_number_t statusCnt; +{ return ds_xxx_device_set_status(device, flavor, status, statusCnt); } +#else +( + mach_port_t device, + dev_flavor_t flavor, + dev_status_t status, + mach_msg_type_number_t statusCnt +); +#endif + +/* Routine xxx_device_get_status */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t ds_xxx_device_get_status +#if defined(LINTLIBRARY) + (device, flavor, status, statusCnt) + mach_port_t device; + dev_flavor_t flavor; + dev_status_t status; + mach_msg_type_number_t *statusCnt; +{ return ds_xxx_device_get_status(device, flavor, status, statusCnt); } +#else +( + mach_port_t device, + dev_flavor_t flavor, + dev_status_t status, + mach_msg_type_number_t *statusCnt +); +#endif + +/* Routine xxx_device_set_filter */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t ds_xxx_device_set_filter +#if defined(LINTLIBRARY) + (device, receive_port, priority, filter, filterCnt) + mach_port_t device; + mach_port_t receive_port; + int priority; + filter_array_t filter; + mach_msg_type_number_t filterCnt; +{ return ds_xxx_device_set_filter(device, receive_port, priority, filter, filterCnt); } +#else +( + mach_port_t device, + mach_port_t receive_port, + int priority, + filter_array_t filter, + mach_msg_type_number_t filterCnt +); +#endif + +/* Routine device_map */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t ds_device_map +#if defined(LINTLIBRARY) + (device, prot, offset, size, pager, unmap) + mach_port_t device; + vm_prot_t prot; + vm_offset_t offset; + vm_size_t size; + mach_port_t *pager; + int unmap; +{ return ds_device_map(device, prot, offset, size, pager, unmap); } +#else +( + mach_port_t device, + vm_prot_t prot, + vm_offset_t offset, + vm_size_t size, + mach_port_t *pager, + int unmap +); +#endif + +/* Routine device_set_status */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t ds_device_set_status +#if defined(LINTLIBRARY) + (device, flavor, status, statusCnt) + mach_port_t device; + dev_flavor_t flavor; + dev_status_t status; + mach_msg_type_number_t statusCnt; +{ return ds_device_set_status(device, flavor, status, statusCnt); } +#else +( + mach_port_t device, + dev_flavor_t flavor, + dev_status_t status, + mach_msg_type_number_t statusCnt +); +#endif + +/* Routine device_get_status */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t ds_device_get_status +#if defined(LINTLIBRARY) + (device, flavor, status, statusCnt) + mach_port_t device; + dev_flavor_t flavor; + dev_status_t status; + mach_msg_type_number_t *statusCnt; +{ return ds_device_get_status(device, flavor, status, statusCnt); } +#else +( + mach_port_t device, + dev_flavor_t flavor, + dev_status_t status, + mach_msg_type_number_t *statusCnt +); +#endif + +/* Routine device_set_filter */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t ds_device_set_filter +#if defined(LINTLIBRARY) + (device, receive_port, priority, filter, filterCnt) + mach_port_t device; + mach_port_t receive_port; + int priority; + filter_array_t filter; + mach_msg_type_number_t filterCnt; +{ return ds_device_set_filter(device, receive_port, priority, filter, filterCnt); } +#else +( + mach_port_t device, + mach_port_t receive_port, + int priority, + filter_array_t filter, + mach_msg_type_number_t filterCnt +); +#endif + +#endif /* not defined(_device_server_) */ diff --git a/boot-proxy-exc/ourmach.defs b/boot-proxy-exc/ourmach.defs new file mode 100644 index 00000000..a257d954 --- /dev/null +++ b/boot-proxy-exc/ourmach.defs @@ -0,0 +1,772 @@ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University. + * Copyright (c) 1993,1994 The University of Utah and + * the Computer Systems Laboratory (CSL). + * 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, THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF + * THIS SOFTWARE IN ITS "AS IS" CONDITION, AND DISCLAIM 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. + */ +/* + * Matchmaker definitions file for Mach kernel interface. + */ + +#ifdef MACH_KERNEL +simport <kern/compat_xxx_defs.h>; /* for obsolete routines */ +#endif /* MACH_KERNEL */ + +subsystem +#if KERNEL_USER + KernelUser +#endif /* KERNEL_USER */ +#if KERNEL_SERVER + KernelServer +#endif /* KERNEL_SERVER */ + mach 2000; + +serverprefix S_; + +#ifdef KERNEL_USER +userprefix r_; +#endif /* KERNEL_USER */ + +#include <mach/std_types.defs> +#include <mach/mach_types.defs> + +skip; /* old port_allocate */ +skip; /* old port_deallocate */ +skip; /* old port_enable */ +skip; /* old port_disable */ +skip; /* old port_select */ +skip; /* old port_set_backlog */ +skip; /* old port_status */ + +/* + * Create a new task with an empty set of IPC rights, + * and having an address space constructed from the + * target task (or empty, if inherit_memory is FALSE). + */ +routine task_create( + target_task : task_t; + inherit_memory : boolean_t; + out child_task : mach_port_send_t); + +/* + * Destroy the target task, causing all of its threads + * to be destroyed, all of its IPC rights to be deallocated, + * and all of its address space to be deallocated. + */ +routine task_terminate( + target_task : task_t); + +/* + * Get user-level handler entry points for all + * emulated system calls. + */ +routine task_get_emulation_vector( + task : task_t; + out vector_start : int; + out emulation_vector: emulation_vector_t); + +/* + * Establish user-level handlers for the specified + * system calls. Non-emulated system calls are specified + * with emulation_vector[i] == EML_ROUTINE_NULL. + */ +routine task_set_emulation_vector( + task : task_t; + vector_start : int; + emulation_vector: emulation_vector_t); + + +/* + * Returns the set of threads belonging to the target task. + */ +routine task_threads( + target_task : task_t; + out thread_list : thread_array_t); +/* out thread_list : thread_send_array_t = + array[] of mach_port_send_t + ctype: thread_array_t);*/ + +/* + * Returns information about the target task. + */ +routine task_info( + target_task : task_t; + flavor : int; + out task_info_out : task_info_t, CountInOut); + + +skip; /* old task_status */ +skip; /* old task_set_notify */ +skip; /* old thread_create */ + +/* + * Destroy the target thread. + */ +routine thread_terminate( + target_thread : thread_t); + +/* + * Return the selected state information for the target + * thread. If the thread is currently executing, the results + * may be stale. [Flavor THREAD_STATE_FLAVOR_LIST provides a + * list of valid flavors for the target thread.] + */ +routine thread_get_state( + target_thread : thread_t; + flavor : int; + out old_state : thread_state_t, CountInOut); + +/* + * Set the selected state information for the target thread. + * If the thread is currently executing, the state change + * may be ill-defined. + */ +routine thread_set_state( + target_thread : thread_t; + flavor : int; + new_state : thread_state_t); + +/* + * Returns information about the target thread. + */ +routine thread_info( + target_thread : thread_t; + flavor : int; + out thread_info_out : thread_info_t, CountInOut); + +skip; /* old thread_mutate */ + +/* + * Allocate zero-filled memory in the address space + * of the target task, either at the specified address, + * or wherever space can be found (if anywhere is TRUE), + * of the specified size. The address at which the + * allocation actually took place is returned. + */ +#ifdef EMULATOR +skip; /* the emulator redefines vm_allocate using vm_map */ +#else /* EMULATOR */ +routine vm_allocate( + target_task : vm_task_t; + inout address : vm_address_t; + size : vm_size_t; + anywhere : boolean_t); +#endif /* EMULATOR */ + +skip; /* old vm_allocate_with_pager */ + +/* + * Deallocate the specified range from the virtual + * address space of the target task. + */ +routine vm_deallocate( + target_task : vm_task_t; + address : vm_address_t; + size : vm_size_t); + +/* + * Set the current or maximum protection attribute + * for the specified range of the virtual address + * space of the target task. The current protection + * limits the memory access rights of threads within + * the task; the maximum protection limits the accesses + * that may be given in the current protection. + * Protections are specified as a set of {read, write, execute} + * *permissions*. + */ +routine vm_protect( + target_task : vm_task_t; + address : vm_address_t; + size : vm_size_t; + set_maximum : boolean_t; + new_protection : vm_prot_t); + +/* + * Set the inheritance attribute for the specified range + * of the virtual address space of the target task. + * The inheritance value is one of {none, copy, share}, and + * specifies how the child address space should acquire + * this memory at the time of a task_create call. + */ +routine vm_inherit( + target_task : vm_task_t; + address : vm_address_t; + size : vm_size_t; + new_inheritance : vm_inherit_t); + +/* + * Returns the contents of the specified range of the + * virtual address space of the target task. [The + * range must be aligned on a virtual page boundary, + * and must be a multiple of pages in extent. The + * protection on the specified range must permit reading.] + */ +routine vm_read( + target_task : vm_task_t; + address : vm_address_t; + size : vm_size_t; + out data : pointer_t, dealloc); + +/* + * Writes the contents of the specified range of the + * virtual address space of the target task. [The + * range must be aligned on a virtual page boundary, + * and must be a multiple of pages in extent. The + * protection on the specified range must permit writing.] + */ +routine vm_write( + target_task : vm_task_t; + address : vm_address_t; + data : pointer_t); + +/* + * Copy the contents of the source range of the virtual + * address space of the target task to the destination + * range in that same address space. [Both of the + * ranges must be aligned on a virtual page boundary, + * and must be multiples of pages in extent. The + * protection on the source range must permit reading, + * and the protection on the destination range must + * permit writing.] + */ +routine vm_copy( + target_task : vm_task_t; + source_address : vm_address_t; + size : vm_size_t; + dest_address : vm_address_t); + +/* + * Returns information about the contents of the virtual + * address space of the target task at the specified + * address. The returned protection, inheritance, sharing + * and memory object values apply to the entire range described + * by the address range returned; the memory object offset + * corresponds to the beginning of the address range. + * [If the specified address is not allocated, the next + * highest address range is described. If no addresses beyond + * the one specified are allocated, the call returns KERN_NO_SPACE.] + */ +routine vm_region( + target_task : vm_task_t; + inout address : vm_address_t; + out size : vm_size_t; + out protection : vm_prot_t; + out max_protection : vm_prot_t; + out inheritance : vm_inherit_t; + out is_shared : boolean_t; + /* avoid out-translation of the argument */ + out object_name : memory_object_name_t = + MACH_MSG_TYPE_COPY_SEND + ctype: mach_port_t; + out offset : vm_offset_t); + +/* + * Return virtual memory statistics for the host + * on which the target task resides. [Note that the + * statistics are not specific to the target task.] + */ +routine vm_statistics( + target_task : vm_task_t; + out vm_stats : vm_statistics_data_t); + +skip; /* old task_by_u*x_pid */ +skip; /* old vm_pageable */ + +/* + * Stash a handful of ports for the target task; child + * tasks inherit this stash at task_create time. + */ +routine mach_ports_register( + target_task : task_t; + init_port_set : mach_port_array_t = + ^array[] of mach_port_t); + +/* + * Retrieve the stashed ports for the target task. + */ +routine mach_ports_lookup( + target_task : task_t; + out init_port_set : mach_port_array_t = + ^array[] of mach_port_t); + +skip; /* old u*x_pid */ +skip; /* old netipc_listen */ +skip; /* old netipc_ignore */ + +/* + * Provide the data contents of a range of the given memory + * object, with the access restriction specified. [Only + * whole virtual pages of data can be accepted; partial pages + * will be discarded. Data should be provided on request, but + * may be provided in advance as desired. When data already + * held by this kernel is provided again, the new data is ignored. + * The access restriction is the subset of {read, write, execute} + * which are prohibited. The kernel may not provide any data (or + * protection) consistency among pages with different virtual page + * alignments within the same object.] + */ +simpleroutine memory_object_data_provided( + memory_control : memory_object_control_t; + offset : vm_offset_t; + data : pointer_t; + lock_value : vm_prot_t); + +/* + * Indicate that a range of the given temporary memory object does + * not exist, and that the backing memory object should be used + * instead (or zero-fill memory be used, if no backing object exists). + * [This call is intended for use only by the default memory manager. + * It should not be used to indicate a real error -- + * memory_object_data_error should be used for that purpose.] + */ +simpleroutine memory_object_data_unavailable( + memory_control : memory_object_control_t; + offset : vm_offset_t; + size : vm_size_t); + +/* + * Retrieves the attributes currently associated with + * a memory object. + */ +routine memory_object_get_attributes( + memory_control : memory_object_control_t; + out object_ready : boolean_t; + out may_cache : boolean_t; + out copy_strategy : memory_object_copy_strategy_t); + +/* + * Sets the default memory manager, the port to which + * newly-created temporary memory objects are delivered. + * [See (memory_object_default)memory_object_create.] + * The old memory manager port is returned. + */ +routine vm_set_default_memory_manager( + host_priv : host_priv_t; + inout default_manager : mach_port_copy_send_t); + +skip; /* old pager_flush_request */ + +/* + * Control use of the data associated with the given + * memory object. For each page in the given range, + * perform the following operations, in order: + * 1) restrict access to the page (disallow + * forms specified by "prot"); + * 2) write back modifications (if "should_return" + * is RETURN_DIRTY and the page is dirty, or + * "should_return" is RETURN_ALL and the page + * is either dirty or precious); and, + * 3) flush the cached copy (if "should_flush" + * is asserted). + * The set of pages is defined by a starting offset + * ("offset") and size ("size"). Only pages with the + * same page alignment as the starting offset are + * considered. + * + * A single acknowledgement is sent (to the "reply_to" + * port) when these actions are complete. + * + * There are two versions of this routine because IPC distinguishes + * between booleans and integers (a 2-valued integer is NOT a + * boolean). The new routine is backwards compatible at the C + * language interface. + */ +simpleroutine xxx_memory_object_lock_request( + memory_control : memory_object_control_t; + offset : vm_offset_t; + size : vm_size_t; + should_clean : boolean_t; + should_flush : boolean_t; + lock_value : vm_prot_t; + reply_to : mach_port_t = + MACH_MSG_TYPE_MAKE_SEND_ONCE|polymorphic); + + +simpleroutine memory_object_lock_request( + memory_control : memory_object_control_t; + offset : vm_offset_t; + size : vm_size_t; + should_return : memory_object_return_t; + should_flush : boolean_t; + lock_value : vm_prot_t; + reply_to : mach_port_t = + MACH_MSG_TYPE_MAKE_SEND_ONCE|polymorphic); + +/* obsolete */ +routine xxx_task_get_emulation_vector( + task : task_t; + out vector_start : int; + out emulation_vector: xxx_emulation_vector_t, IsLong); + +/* obsolete */ +routine xxx_task_set_emulation_vector( + task : task_t; + vector_start : int; + emulation_vector: xxx_emulation_vector_t, IsLong); + +/* + * Returns information about the host on which the + * target object resides. [This object may be + * a task, thread, or memory_object_control port.] + */ +routine xxx_host_info( + target_task : mach_port_t; + out info : machine_info_data_t); + +/* + * Returns information about a particular processor on + * the host on which the target task resides. + */ +routine xxx_slot_info( + target_task : task_t; + slot : int; + out info : machine_slot_data_t); + +/* + * Performs control operations (currently only + * turning off or on) on a particular processor on + * the host on which the target task resides. + */ +routine xxx_cpu_control( + target_task : task_t; + cpu : int; + running : boolean_t); + +skip; /* old thread_statistics */ +skip; /* old task_statistics */ +skip; /* old netport_init */ +skip; /* old netport_enter */ +skip; /* old netport_remove */ +skip; /* old thread_set_priority */ + +/* + * Increment the suspend count for the target task. + * No threads within a task may run when the suspend + * count for that task is non-zero. + */ +routine task_suspend( + target_task : task_t); + +/* + * Decrement the suspend count for the target task, + * if the count is currently non-zero. If the resulting + * suspend count is zero, then threads within the task + * that also have non-zero suspend counts may execute. + */ +routine task_resume( + target_task : task_t); + +/* + * Returns the current value of the selected special port + * associated with the target task. + */ +routine task_get_special_port( + task : task_t; + which_port : int; + out special_port : mach_port_send_t); + +/* + * Set one of the special ports associated with the + * target task. + */ +routine task_set_special_port( + task : task_t; + which_port : int; + special_port : mach_port_t); + +/* obsolete */ +routine xxx_task_info( + target_task : task_t; + flavor : int; + out task_info_out : task_info_t, IsLong); + + +/* + * Create a new thread within the target task, returning + * the port representing that new thread. The + * initial execution state of the thread is undefined. + */ +routine thread_create( + parent_task : task_t; + out child_thread : mach_port_send_t); + +/* + * Increment the suspend count for the target thread. + * Once this call has completed, the thread will not + * execute any further user or meta- instructions. + * Once suspended, a thread may not execute again until + * its suspend count is zero, and the suspend count + * for its task is also zero. + */ +routine thread_suspend( + target_thread : thread_t); + +/* + * Decrement the suspend count for the target thread, + * if that count is not already zero. + */ +routine thread_resume( + target_thread : thread_t); + +/* + * Cause any user or meta- instructions currently being + * executed by the target thread to be aborted. [Meta- + * instructions consist of the basic traps for IPC + * (e.g., msg_send, msg_receive) and self-identification + * (e.g., task_self, thread_self, thread_reply). Calls + * described by MiG interfaces are not meta-instructions + * themselves.] + */ +routine thread_abort( + target_thread : thread_t); + +/* obsolete */ +routine xxx_thread_get_state( + target_thread : thread_t; + flavor : int; + out old_state : thread_state_t, IsLong); + +/* obsolete */ +routine xxx_thread_set_state( + target_thread : thread_t; + flavor : int; + new_state : thread_state_t, IsLong); + +/* + * Returns the current value of the selected special port + * associated with the target thread. + */ +routine thread_get_special_port( + thread : thread_t; + which_port : int; + out special_port : mach_port_t); + +/* + * Set one of the special ports associated with the + * target thread. + */ +routine thread_set_special_port( + thread : thread_t; + which_port : int; + special_port : mach_port_t); + +/* obsolete */ +routine xxx_thread_info( + target_thread : thread_t; + flavor : int; + out thread_info_out : thread_info_t, IsLong); + +/* + * Establish a user-level handler for the specified + * system call. + */ +routine task_set_emulation( + target_port : task_t; + routine_entry_pt: vm_address_t; + routine_number : int); + +/* + * Establish restart pc for interrupted atomic sequences. + * This reuses the message number for the old task_get_io_port. + * See task_info.h for description of flavors. + * + */ +routine task_ras_control( + target_task : task_t; + basepc : vm_address_t; + boundspc : vm_address_t; + flavor : int); + + + +skip; /* old host_ipc_statistics */ +skip; /* old port_names */ +skip; /* old port_type */ +skip; /* old port_rename */ +skip; /* old port_allocate */ +skip; /* old port_deallocate */ +skip; /* old port_set_backlog */ +skip; /* old port_status */ +skip; /* old port_set_allocate */ +skip; /* old port_set_deallocate */ +skip; /* old port_set_add */ +skip; /* old port_set_remove */ +skip; /* old port_set_status */ +skip; /* old port_insert_send */ +skip; /* old port_extract_send */ +skip; /* old port_insert_receive */ +skip; /* old port_extract_receive */ + +/* + * Map a user-defined memory object into the virtual address + * space of the target task. If desired (anywhere is TRUE), + * the kernel will find a suitable address range of the + * specified size; else, the specific address will be allocated. + * + * The beginning address of the range will be aligned on a virtual + * page boundary, be at or beyond the address specified, and + * meet the mask requirements (bits turned on in the mask must not + * be turned on in the result); the size of the range, in bytes, + * will be rounded up to an integral number of virtual pages. + * + * The memory in the resulting range will be associated with the + * specified memory object, with the beginning of the memory range + * referring to the specified offset into the memory object. + * + * The mapping will take the current and maximum protections and + * the inheritance attributes specified; see the vm_protect and + * vm_inherit calls for a description of these attributes. + * + * If desired (copy is TRUE), the memory range will be filled + * with a copy of the data from the memory object; this copy will + * be private to this mapping in this target task. Otherwise, + * the memory in this mapping will be shared with other mappings + * of the same memory object at the same offset (in this task or + * in other tasks). [The Mach kernel only enforces shared memory + * consistency among mappings on one host with similar page alignments. + * The user-defined memory manager for this object is responsible + * for further consistency.] + */ +#ifdef EMULATOR +routine htg_vm_map( + target_task : vm_task_t; + ureplyport reply_port : mach_port_make_send_once_t; + inout address : vm_address_t; + size : vm_size_t; + mask : vm_address_t; + anywhere : boolean_t; + memory_object : memory_object_t; + offset : vm_offset_t; + copy : boolean_t; + cur_protection : vm_prot_t; + max_protection : vm_prot_t; + inheritance : vm_inherit_t); +#else /* EMULATOR */ +routine vm_map( + target_task : vm_task_t; + inout address : vm_address_t; + size : vm_size_t; + mask : vm_address_t; + anywhere : boolean_t; + memory_object : memory_object_t; + offset : vm_offset_t; + copy : boolean_t; + cur_protection : vm_prot_t; + max_protection : vm_prot_t; + inheritance : vm_inherit_t); +#endif /* EMULATOR */ + +/* + * Indicate that a range of the specified memory object cannot + * be provided at this time. [Threads waiting for memory pages + * specified by this call will experience a memory exception. + * Only threads waiting at the time of the call are affected.] + */ +simpleroutine memory_object_data_error( + memory_control : memory_object_control_t; + offset : vm_offset_t; + size : vm_size_t; + error_value : kern_return_t); + +/* + * Make decisions regarding the use of the specified + * memory object. + */ +simpleroutine memory_object_set_attributes( + memory_control : memory_object_control_t; + object_ready : boolean_t; + may_cache : boolean_t; + copy_strategy : memory_object_copy_strategy_t); + +/* + */ +simpleroutine memory_object_destroy( + memory_control : memory_object_control_t; + reason : kern_return_t); + +/* + * Provide the data contents of a range of the given memory + * object, with the access restriction specified, optional + * precious attribute, and reply message. [Only + * whole virtual pages of data can be accepted; partial pages + * will be discarded. Data should be provided on request, but + * may be provided in advance as desired. When data already + * held by this kernel is provided again, the new data is ignored. + * The access restriction is the subset of {read, write, execute} + * which are prohibited. The kernel may not provide any data (or + * protection) consistency among pages with different virtual page + * alignments within the same object. The precious value controls + * how the kernel treats the data. If it is FALSE, the kernel treats + * its copy as a temporary and may throw it away if it hasn't been + * changed. If the precious value is TRUE, the kernel treats its + * copy as a data repository and promises to return it to the manager; + * the manager may tell the kernel to throw it away instead by flushing + * and not cleaning the data -- see memory_object_lock_request. The + * reply_to port is for a compeletion message; it will be + * memory_object_supply_completed.] + */ + +simpleroutine memory_object_data_supply( + memory_control : memory_object_control_t; + offset : vm_offset_t; + data : pointer_t, Dealloc[]; + lock_value : vm_prot_t; + precious : boolean_t; + reply_to : mach_port_t = + MACH_MSG_TYPE_MAKE_SEND_ONCE|polymorphic); + +simpleroutine memory_object_ready( + memory_control : memory_object_control_t; + may_cache : boolean_t; + copy_strategy : memory_object_copy_strategy_t); + +simpleroutine memory_object_change_attributes( + memory_control : memory_object_control_t; + may_cache : boolean_t; + copy_strategy : memory_object_copy_strategy_t; + reply_to : mach_port_t = + MACH_MSG_TYPE_MAKE_SEND_ONCE|polymorphic); + +skip; /* old host_callout_statistics_reset */ +skip; /* old port_set_select */ +skip; /* old port_set_backup */ + +/* + * Set/Get special properties of memory associated + * to some virtual address range, such as cachability, + * migrability, replicability. Machine-dependent. + */ +routine vm_machine_attribute( + target_task : vm_task_t; + address : vm_address_t; + size : vm_size_t; + attribute : vm_machine_attribute_t; + inout value : vm_machine_attribute_val_t); + +skip; /* old host_fpa_counters_reset */ + +/* + * There is no more room in this interface for additional calls. + */ diff --git a/boot-proxy-exc/ourmach.sdefs.d b/boot-proxy-exc/ourmach.sdefs.d new file mode 100644 index 00000000..f061e4ac --- /dev/null +++ b/boot-proxy-exc/ourmach.sdefs.d @@ -0,0 +1,3 @@ +ourmachServer.c ourmach_S.h: ourmach.defs /usr/local/include/mach/std_types.defs \ + /usr/local/include/mach/machine/machine_types.defs \ + /usr/local/include/mach/mach_types.defs diff --git a/boot-proxy-exc/ourmachServer.c b/boot-proxy-exc/ourmachServer.c new file mode 100644 index 00000000..eb14a139 --- /dev/null +++ b/boot-proxy-exc/ourmachServer.c @@ -0,0 +1,4186 @@ +/* Module mach */ + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE 1 +#endif + +#define EXPORT_BOOLEAN +#include <mach/boolean.h> +#include <mach/kern_return.h> +#include <mach/message.h> +#include <mach/mig_errors.h> +#include <mach/mig_support.h> + +#ifndef mig_internal +#define mig_internal static +#endif + +#ifndef mig_external +#define mig_external +#endif + +#ifndef TypeCheck +#define TypeCheck 1 +#endif + +#ifndef UseExternRCSId +#define UseExternRCSId 1 +#endif + +#define BAD_TYPECHECK(type, check) ({\ + union { mach_msg_type_t t; unsigned32_t w; } _t, _c;\ + _t.t = *(type); _c.t = *(check); _t.w != _c.w; }) +#define msgh_request_port msgh_local_port +#define MACH_MSGH_BITS_REQUEST(bits) MACH_MSGH_BITS_LOCAL(bits) +#define msgh_reply_port msgh_remote_port +#define MACH_MSGH_BITS_REPLY(bits) MACH_MSGH_BITS_REMOTE(bits) + +#include <mach/std_types.h> +#include <mach/mach_types.h> + +/* Routine task_create */ +mig_internal void _Xtask_create + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t inherit_memoryType; + boolean_t inherit_memory; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t child_taskType; + mach_port_t child_task; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_task_create + (mach_port_t target_task, boolean_t inherit_memory, mach_port_t *child_task, mach_msg_type_name_t *child_taskPoly); + + boolean_t msgh_simple; + auto const mach_msg_type_t inherit_memoryCheck = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t child_taskType = { + /* msgt_name = */ -1, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + mach_msg_type_name_t child_taskPoly; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->inherit_memoryType, &inherit_memoryCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_task_create(In0P->Head.msgh_request_port, In0P->inherit_memory, &OutP->child_task, &child_taskPoly); + if (OutP->RetCode != KERN_SUCCESS) + return; + + msgh_simple = TRUE; + OutP->Head.msgh_size = 40; + + OutP->child_taskType = child_taskType; + + if (MACH_MSG_TYPE_PORT_ANY(child_taskPoly)) + msgh_simple = FALSE; + + OutP->child_taskType.msgt_name = child_taskPoly; + + if (!msgh_simple) + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; +} + +/* Routine task_terminate */ +mig_internal void _Xtask_terminate + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_task_terminate + (mach_port_t target_task); + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_task_terminate(In0P->Head.msgh_request_port); +} + +/* Routine task_get_emulation_vector */ +mig_internal void _Xtask_get_emulation_vector + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t vector_startType; + int vector_start; + mach_msg_type_long_t emulation_vectorType; + emulation_vector_t emulation_vector; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_task_get_emulation_vector + (mach_port_t task, int *vector_start, emulation_vector_t *emulation_vector, mach_msg_type_number_t *emulation_vectorCnt); + + auto const mach_msg_type_t vector_startType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_long_t emulation_vectorType = { + { + /* msgt_name = */ 0, + /* msgt_size = */ 0, + /* msgt_number = */ 0, + /* msgt_inline = */ FALSE, + /* msgt_longform = */ TRUE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }, + /* msgtl_name = */ 2, + /* msgtl_size = */ 32, + /* msgtl_number = */ 0, + }; + + mach_msg_type_number_t emulation_vectorCnt; + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_task_get_emulation_vector(In0P->Head.msgh_request_port, &OutP->vector_start, &OutP->emulation_vector, &emulation_vectorCnt); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; + OutP->Head.msgh_size = 56; + + OutP->vector_startType = vector_startType; + + OutP->emulation_vectorType = emulation_vectorType; + + OutP->emulation_vectorType.msgtl_number = emulation_vectorCnt; +} + +/* Routine task_set_emulation_vector */ +mig_internal void _Xtask_set_emulation_vector + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t vector_startType; + int vector_start; + mach_msg_type_long_t emulation_vectorType; + emulation_vector_t emulation_vector; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_task_set_emulation_vector + (mach_port_t task, int vector_start, emulation_vector_t emulation_vector, mach_msg_type_number_t emulation_vectorCnt); + + auto const mach_msg_type_t vector_startCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 48) || + !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->vector_startType, &vector_startCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if ((In0P->emulation_vectorType.msgtl_header.msgt_inline != FALSE) || + (In0P->emulation_vectorType.msgtl_header.msgt_longform != TRUE) || + (In0P->emulation_vectorType.msgtl_name != 2) || + (In0P->emulation_vectorType.msgtl_size != 32)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_task_set_emulation_vector(In0P->Head.msgh_request_port, In0P->vector_start, In0P->emulation_vector, In0P->emulation_vectorType.msgtl_number); +} + +/* Routine task_threads */ +mig_internal void _Xtask_threads + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_long_t thread_listType; + thread_array_t thread_list; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_task_threads + (mach_port_t target_task, thread_array_t *thread_list, mach_msg_type_number_t *thread_listCnt); + + auto const mach_msg_type_long_t thread_listType = { + { + /* msgt_name = */ 0, + /* msgt_size = */ 0, + /* msgt_number = */ 0, + /* msgt_inline = */ FALSE, + /* msgt_longform = */ TRUE, + /* msgt_deallocate = */ TRUE, + /* msgt_unused = */ 0 + }, + /* msgtl_name = */ 17, + /* msgtl_size = */ 32, + /* msgtl_number = */ 0, + }; + + mach_msg_type_number_t thread_listCnt; + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_task_threads(In0P->Head.msgh_request_port, &OutP->thread_list, &thread_listCnt); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; + OutP->Head.msgh_size = 48; + + OutP->thread_listType = thread_listType; + + OutP->thread_listType.msgtl_number = thread_listCnt; +} + +/* Routine task_info */ +mig_internal void _Xtask_info + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t flavorType; + int flavor; + mach_msg_type_t task_info_outCntType; + mach_msg_type_number_t task_info_outCnt; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t task_info_outType; + natural_t task_info_out[1024]; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_task_info + (mach_port_t target_task, int flavor, task_info_t task_info_out, mach_msg_type_number_t *task_info_outCnt); + + auto const mach_msg_type_t flavorCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t task_info_outCntCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t task_info_outType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1024, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + mach_msg_type_number_t task_info_outCnt; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->flavorType, &flavorCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->task_info_outCntType, &task_info_outCntCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + task_info_outCnt = 1024; + if (In0P->task_info_outCnt < task_info_outCnt) + task_info_outCnt = In0P->task_info_outCnt; + + OutP->RetCode = S_task_info(In0P->Head.msgh_request_port, In0P->flavor, OutP->task_info_out, &task_info_outCnt); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->task_info_outType = task_info_outType; + + OutP->task_info_outType.msgt_number = task_info_outCnt; + OutP->Head.msgh_size = 36 + (4 * task_info_outCnt); +} + +/* Routine thread_terminate */ +mig_internal void _Xthread_terminate + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_thread_terminate + (mach_port_t target_thread); + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_thread_terminate(In0P->Head.msgh_request_port); +} + +/* Routine thread_get_state */ +mig_internal void _Xthread_get_state + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t flavorType; + int flavor; + mach_msg_type_t old_stateCntType; + mach_msg_type_number_t old_stateCnt; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t old_stateType; + natural_t old_state[1024]; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_thread_get_state + (mach_port_t target_thread, int flavor, thread_state_t old_state, mach_msg_type_number_t *old_stateCnt); + + auto const mach_msg_type_t flavorCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t old_stateCntCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t old_stateType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1024, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + mach_msg_type_number_t old_stateCnt; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->flavorType, &flavorCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->old_stateCntType, &old_stateCntCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + old_stateCnt = 1024; + if (In0P->old_stateCnt < old_stateCnt) + old_stateCnt = In0P->old_stateCnt; + + OutP->RetCode = S_thread_get_state(In0P->Head.msgh_request_port, In0P->flavor, OutP->old_state, &old_stateCnt); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->old_stateType = old_stateType; + + OutP->old_stateType.msgt_number = old_stateCnt; + OutP->Head.msgh_size = 36 + (4 * old_stateCnt); +} + +/* Routine thread_set_state */ +mig_internal void _Xthread_set_state + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t flavorType; + int flavor; + mach_msg_type_t new_stateType; + natural_t new_state[1024]; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_thread_set_state + (mach_port_t target_thread, int flavor, thread_state_t new_state, mach_msg_type_number_t new_stateCnt); + + unsigned int msgh_size; + + auto const mach_msg_type_t flavorCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + msgh_size = In0P->Head.msgh_size; + if ((msgh_size < 36) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->flavorType, &flavorCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if ((In0P->new_stateType.msgt_inline != TRUE) || + (In0P->new_stateType.msgt_longform != FALSE) || + (In0P->new_stateType.msgt_name != 2) || + (In0P->new_stateType.msgt_size != 32)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (msgh_size != 36 + (4 * In0P->new_stateType.msgt_number)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_thread_set_state(In0P->Head.msgh_request_port, In0P->flavor, In0P->new_state, In0P->new_stateType.msgt_number); +} + +/* Routine thread_info */ +mig_internal void _Xthread_info + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t flavorType; + int flavor; + mach_msg_type_t thread_info_outCntType; + mach_msg_type_number_t thread_info_outCnt; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t thread_info_outType; + natural_t thread_info_out[1024]; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_thread_info + (mach_port_t target_thread, int flavor, thread_info_t thread_info_out, mach_msg_type_number_t *thread_info_outCnt); + + auto const mach_msg_type_t flavorCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t thread_info_outCntCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t thread_info_outType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1024, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + mach_msg_type_number_t thread_info_outCnt; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->flavorType, &flavorCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->thread_info_outCntType, &thread_info_outCntCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + thread_info_outCnt = 1024; + if (In0P->thread_info_outCnt < thread_info_outCnt) + thread_info_outCnt = In0P->thread_info_outCnt; + + OutP->RetCode = S_thread_info(In0P->Head.msgh_request_port, In0P->flavor, OutP->thread_info_out, &thread_info_outCnt); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->thread_info_outType = thread_info_outType; + + OutP->thread_info_outType.msgt_number = thread_info_outCnt; + OutP->Head.msgh_size = 36 + (4 * thread_info_outCnt); +} + +/* Routine vm_allocate */ +mig_internal void _Xvm_allocate + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t addressType; + vm_address_t address; + mach_msg_type_t sizeType; + vm_size_t size; + mach_msg_type_t anywhereType; + boolean_t anywhere; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t addressType; + vm_address_t address; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_vm_allocate + (mach_port_t target_task, vm_address_t *address, vm_size_t size, boolean_t anywhere); + + auto const mach_msg_type_t addressCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t sizeCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t anywhereCheck = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t addressType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 48) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->addressType, &addressCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->sizeType, &sizeCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->anywhereType, &anywhereCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_vm_allocate(In0P->Head.msgh_request_port, &In0P->address, In0P->size, In0P->anywhere); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_size = 40; + + OutP->addressType = addressType; + + OutP->address = In0P->address; +} + +/* Routine vm_deallocate */ +mig_internal void _Xvm_deallocate + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t addressType; + vm_address_t address; + mach_msg_type_t sizeType; + vm_size_t size; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_vm_deallocate + (mach_port_t target_task, vm_address_t address, vm_size_t size); + + auto const mach_msg_type_t addressCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t sizeCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->addressType, &addressCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->sizeType, &sizeCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_vm_deallocate(In0P->Head.msgh_request_port, In0P->address, In0P->size); +} + +/* Routine vm_protect */ +mig_internal void _Xvm_protect + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t addressType; + vm_address_t address; + mach_msg_type_t sizeType; + vm_size_t size; + mach_msg_type_t set_maximumType; + boolean_t set_maximum; + mach_msg_type_t new_protectionType; + vm_prot_t new_protection; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_vm_protect + (mach_port_t target_task, vm_address_t address, vm_size_t size, boolean_t set_maximum, vm_prot_t new_protection); + + auto const mach_msg_type_t addressCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t sizeCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t set_maximumCheck = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t new_protectionCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 56) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->addressType, &addressCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->sizeType, &sizeCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->set_maximumType, &set_maximumCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->new_protectionType, &new_protectionCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_vm_protect(In0P->Head.msgh_request_port, In0P->address, In0P->size, In0P->set_maximum, In0P->new_protection); +} + +/* Routine vm_inherit */ +mig_internal void _Xvm_inherit + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t addressType; + vm_address_t address; + mach_msg_type_t sizeType; + vm_size_t size; + mach_msg_type_t new_inheritanceType; + vm_inherit_t new_inheritance; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_vm_inherit + (mach_port_t target_task, vm_address_t address, vm_size_t size, vm_inherit_t new_inheritance); + + auto const mach_msg_type_t addressCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t sizeCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t new_inheritanceCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 48) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->addressType, &addressCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->sizeType, &sizeCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->new_inheritanceType, &new_inheritanceCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_vm_inherit(In0P->Head.msgh_request_port, In0P->address, In0P->size, In0P->new_inheritance); +} + +/* Routine vm_read */ +mig_internal void _Xvm_read + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t addressType; + vm_address_t address; + mach_msg_type_t sizeType; + vm_size_t size; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_long_t dataType; + vm_offset_t data; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_vm_read + (mach_port_t target_task, vm_address_t address, vm_size_t size, vm_offset_t *data, mach_msg_type_number_t *dataCnt); + + auto const mach_msg_type_t addressCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t sizeCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_long_t dataType = { + { + /* msgt_name = */ 0, + /* msgt_size = */ 0, + /* msgt_number = */ 0, + /* msgt_inline = */ FALSE, + /* msgt_longform = */ TRUE, + /* msgt_deallocate = */ TRUE, + /* msgt_unused = */ 0 + }, + /* msgtl_name = */ 9, + /* msgtl_size = */ 8, + /* msgtl_number = */ 0, + }; + + mach_msg_type_number_t dataCnt; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->addressType, &addressCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->sizeType, &sizeCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_vm_read(In0P->Head.msgh_request_port, In0P->address, In0P->size, &OutP->data, &dataCnt); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; + OutP->Head.msgh_size = 48; + + OutP->dataType = dataType; + + OutP->dataType.msgtl_number = dataCnt; +} + +/* Routine vm_write */ +mig_internal void _Xvm_write + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t addressType; + vm_address_t address; + mach_msg_type_long_t dataType; + vm_offset_t data; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_vm_write + (mach_port_t target_task, vm_address_t address, vm_offset_t data, mach_msg_type_number_t dataCnt); + + auto const mach_msg_type_t addressCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 48) || + !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->addressType, &addressCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if ((In0P->dataType.msgtl_header.msgt_inline != FALSE) || + (In0P->dataType.msgtl_header.msgt_longform != TRUE) || + (In0P->dataType.msgtl_name != 9) || + (In0P->dataType.msgtl_size != 8)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_vm_write(In0P->Head.msgh_request_port, In0P->address, In0P->data, In0P->dataType.msgtl_number); +} + +/* Routine vm_copy */ +mig_internal void _Xvm_copy + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t source_addressType; + vm_address_t source_address; + mach_msg_type_t sizeType; + vm_size_t size; + mach_msg_type_t dest_addressType; + vm_address_t dest_address; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_vm_copy + (mach_port_t target_task, vm_address_t source_address, vm_size_t size, vm_address_t dest_address); + + auto const mach_msg_type_t source_addressCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t sizeCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t dest_addressCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 48) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->source_addressType, &source_addressCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->sizeType, &sizeCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->dest_addressType, &dest_addressCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_vm_copy(In0P->Head.msgh_request_port, In0P->source_address, In0P->size, In0P->dest_address); +} + +/* Routine vm_region */ +mig_internal void _Xvm_region + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t addressType; + vm_address_t address; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t addressType; + vm_address_t address; + mach_msg_type_t sizeType; + vm_size_t size; + mach_msg_type_t protectionType; + vm_prot_t protection; + mach_msg_type_t max_protectionType; + vm_prot_t max_protection; + mach_msg_type_t inheritanceType; + vm_inherit_t inheritance; + mach_msg_type_t is_sharedType; + boolean_t is_shared; + mach_msg_type_t object_nameType; + mach_port_t object_name; + mach_msg_type_t offsetType; + vm_offset_t offset; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_vm_region + (mach_port_t target_task, vm_address_t *address, vm_size_t *size, vm_prot_t *protection, vm_prot_t *max_protection, vm_inherit_t *inheritance, boolean_t *is_shared, mach_port_t *object_name, vm_offset_t *offset); + + auto const mach_msg_type_t addressCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t addressType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t sizeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t protectionType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t max_protectionType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t inheritanceType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t is_sharedType = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t object_nameType = { + /* msgt_name = */ 19, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t offsetType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->addressType, &addressCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_vm_region(In0P->Head.msgh_request_port, &In0P->address, &OutP->size, &OutP->protection, &OutP->max_protection, &OutP->inheritance, &OutP->is_shared, &OutP->object_name, &OutP->offset); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; + OutP->Head.msgh_size = 96; + + OutP->addressType = addressType; + + OutP->address = In0P->address; + + OutP->sizeType = sizeType; + + OutP->protectionType = protectionType; + + OutP->max_protectionType = max_protectionType; + + OutP->inheritanceType = inheritanceType; + + OutP->is_sharedType = is_sharedType; + + OutP->object_nameType = object_nameType; + + OutP->offsetType = offsetType; +} + +/* Routine vm_statistics */ +mig_internal void _Xvm_statistics + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t vm_statsType; + vm_statistics_data_t vm_stats; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_vm_statistics + (mach_port_t target_task, vm_statistics_data_t *vm_stats); + + auto const mach_msg_type_t vm_statsType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 13, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_vm_statistics(In0P->Head.msgh_request_port, &OutP->vm_stats); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_size = 88; + + OutP->vm_statsType = vm_statsType; +} + +/* Routine mach_ports_register */ +mig_internal void _Xmach_ports_register + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_long_t init_port_setType; + mach_port_array_t init_port_set; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_mach_ports_register + (mach_port_t target_task, mach_port_array_t init_port_set, mach_msg_type_number_t init_port_setCnt); + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if ((In0P->init_port_setType.msgtl_header.msgt_inline != FALSE) || + (In0P->init_port_setType.msgtl_header.msgt_longform != TRUE) || + (In0P->init_port_setType.msgtl_name != 17) || + (In0P->init_port_setType.msgtl_size != 32)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_mach_ports_register(In0P->Head.msgh_request_port, In0P->init_port_set, In0P->init_port_setType.msgtl_number); +} + +/* Routine mach_ports_lookup */ +mig_internal void _Xmach_ports_lookup + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_long_t init_port_setType; + mach_port_array_t init_port_set; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_mach_ports_lookup + (mach_port_t target_task, mach_port_array_t *init_port_set, mach_msg_type_number_t *init_port_setCnt); + + auto const mach_msg_type_long_t init_port_setType = { + { + /* msgt_name = */ 0, + /* msgt_size = */ 0, + /* msgt_number = */ 0, + /* msgt_inline = */ FALSE, + /* msgt_longform = */ TRUE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }, + /* msgtl_name = */ 19, + /* msgtl_size = */ 32, + /* msgtl_number = */ 0, + }; + + mach_msg_type_number_t init_port_setCnt; + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_mach_ports_lookup(In0P->Head.msgh_request_port, &OutP->init_port_set, &init_port_setCnt); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; + OutP->Head.msgh_size = 48; + + OutP->init_port_setType = init_port_setType; + + OutP->init_port_setType.msgtl_number = init_port_setCnt; +} + +/* SimpleRoutine memory_object_data_provided */ +mig_internal void _Xmemory_object_data_provided + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t offsetType; + vm_offset_t offset; + mach_msg_type_long_t dataType; + vm_offset_t data; + mach_msg_type_t lock_valueType; + vm_prot_t lock_value; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_memory_object_data_provided + (mach_port_t memory_control, vm_offset_t offset, vm_offset_t data, mach_msg_type_number_t dataCnt, vm_prot_t lock_value); + + auto const mach_msg_type_t offsetCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t lock_valueCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 56) || + !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->offsetType, &offsetCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if ((In0P->dataType.msgtl_header.msgt_inline != FALSE) || + (In0P->dataType.msgtl_header.msgt_longform != TRUE) || + (In0P->dataType.msgtl_name != 9) || + (In0P->dataType.msgtl_size != 8)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->lock_valueType, &lock_valueCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_memory_object_data_provided(In0P->Head.msgh_request_port, In0P->offset, In0P->data, In0P->dataType.msgtl_number, In0P->lock_value); +} + +/* SimpleRoutine memory_object_data_unavailable */ +mig_internal void _Xmemory_object_data_unavailable + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t offsetType; + vm_offset_t offset; + mach_msg_type_t sizeType; + vm_size_t size; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_memory_object_data_unavailable + (mach_port_t memory_control, vm_offset_t offset, vm_size_t size); + + auto const mach_msg_type_t offsetCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t sizeCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->offsetType, &offsetCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->sizeType, &sizeCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_memory_object_data_unavailable(In0P->Head.msgh_request_port, In0P->offset, In0P->size); +} + +/* Routine memory_object_get_attributes */ +mig_internal void _Xmemory_object_get_attributes + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t object_readyType; + boolean_t object_ready; + mach_msg_type_t may_cacheType; + boolean_t may_cache; + mach_msg_type_t copy_strategyType; + memory_object_copy_strategy_t copy_strategy; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_memory_object_get_attributes + (mach_port_t memory_control, boolean_t *object_ready, boolean_t *may_cache, memory_object_copy_strategy_t *copy_strategy); + + auto const mach_msg_type_t object_readyType = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t may_cacheType = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t copy_strategyType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_memory_object_get_attributes(In0P->Head.msgh_request_port, &OutP->object_ready, &OutP->may_cache, &OutP->copy_strategy); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_size = 56; + + OutP->object_readyType = object_readyType; + + OutP->may_cacheType = may_cacheType; + + OutP->copy_strategyType = copy_strategyType; +} + +/* Routine vm_set_default_memory_manager */ +mig_internal void _Xvm_set_default_memory_manager + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t default_managerType; + mach_port_t default_manager; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t default_managerType; + mach_port_t default_manager; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_vm_set_default_memory_manager + (mach_port_t host_priv, mach_port_t *default_manager); + + auto const mach_msg_type_t default_managerCheck = { + /* msgt_name = */ 17, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t default_managerType = { + /* msgt_name = */ 19, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->default_managerType, &default_managerCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_vm_set_default_memory_manager(In0P->Head.msgh_request_port, &In0P->default_manager); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; + OutP->Head.msgh_size = 40; + + OutP->default_managerType = default_managerType; + + OutP->default_manager = In0P->default_manager; +} + +/* SimpleRoutine xxx_memory_object_lock_request */ +mig_internal void _Xxxx_memory_object_lock_request + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t offsetType; + vm_offset_t offset; + mach_msg_type_t sizeType; + vm_size_t size; + mach_msg_type_t should_cleanType; + boolean_t should_clean; + mach_msg_type_t should_flushType; + boolean_t should_flush; + mach_msg_type_t lock_valueType; + vm_prot_t lock_value; + mach_msg_type_t reply_toType; + mach_port_t reply_to; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_xxx_memory_object_lock_request + (mach_port_t memory_control, vm_offset_t offset, vm_size_t size, boolean_t should_clean, boolean_t should_flush, vm_prot_t lock_value, mach_port_t reply_to, mach_msg_type_name_t reply_toPoly); + +#if TypeCheck + boolean_t msgh_simple; +#endif /* TypeCheck */ + + auto const mach_msg_type_t offsetCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t sizeCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t should_cleanCheck = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t should_flushCheck = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t lock_valueCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + msgh_simple = !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX); + if ((In0P->Head.msgh_size != 72)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->offsetType, &offsetCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->sizeType, &sizeCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->should_cleanType, &should_cleanCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->should_flushType, &should_flushCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->lock_valueType, &lock_valueCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if ((In0P->reply_toType.msgt_inline != TRUE) || + (In0P->reply_toType.msgt_longform != FALSE) || + (MACH_MSG_TYPE_PORT_ANY(In0P->reply_toType.msgt_name) && msgh_simple) || + (In0P->reply_toType.msgt_number != 1) || + (In0P->reply_toType.msgt_size != 32)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_xxx_memory_object_lock_request(In0P->Head.msgh_request_port, In0P->offset, In0P->size, In0P->should_clean, In0P->should_flush, In0P->lock_value, In0P->reply_to, In0P->reply_toType.msgt_name); +} + +/* SimpleRoutine memory_object_lock_request */ +mig_internal void _Xmemory_object_lock_request + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t offsetType; + vm_offset_t offset; + mach_msg_type_t sizeType; + vm_size_t size; + mach_msg_type_t should_returnType; + memory_object_return_t should_return; + mach_msg_type_t should_flushType; + boolean_t should_flush; + mach_msg_type_t lock_valueType; + vm_prot_t lock_value; + mach_msg_type_t reply_toType; + mach_port_t reply_to; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_memory_object_lock_request + (mach_port_t memory_control, vm_offset_t offset, vm_size_t size, memory_object_return_t should_return, boolean_t should_flush, vm_prot_t lock_value, mach_port_t reply_to, mach_msg_type_name_t reply_toPoly); + +#if TypeCheck + boolean_t msgh_simple; +#endif /* TypeCheck */ + + auto const mach_msg_type_t offsetCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t sizeCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t should_returnCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t should_flushCheck = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t lock_valueCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + msgh_simple = !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX); + if ((In0P->Head.msgh_size != 72)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->offsetType, &offsetCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->sizeType, &sizeCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->should_returnType, &should_returnCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->should_flushType, &should_flushCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->lock_valueType, &lock_valueCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if ((In0P->reply_toType.msgt_inline != TRUE) || + (In0P->reply_toType.msgt_longform != FALSE) || + (MACH_MSG_TYPE_PORT_ANY(In0P->reply_toType.msgt_name) && msgh_simple) || + (In0P->reply_toType.msgt_number != 1) || + (In0P->reply_toType.msgt_size != 32)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_memory_object_lock_request(In0P->Head.msgh_request_port, In0P->offset, In0P->size, In0P->should_return, In0P->should_flush, In0P->lock_value, In0P->reply_to, In0P->reply_toType.msgt_name); +} + +/* Routine xxx_task_get_emulation_vector */ +mig_internal void _Xxxx_task_get_emulation_vector + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t vector_startType; + int vector_start; + mach_msg_type_long_t emulation_vectorType; + vm_offset_t emulation_vector[1024]; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_xxx_task_get_emulation_vector + (mach_port_t task, int *vector_start, emulation_vector_t emulation_vector, mach_msg_type_number_t *emulation_vectorCnt); + + auto const mach_msg_type_t vector_startType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_long_t emulation_vectorType = { + { + /* msgt_name = */ 0, + /* msgt_size = */ 0, + /* msgt_number = */ 0, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ TRUE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }, + /* msgtl_name = */ 2, + /* msgtl_size = */ 32, + /* msgtl_number = */ 1024, + }; + + mach_msg_type_number_t emulation_vectorCnt; + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + emulation_vectorCnt = 1024; + + OutP->RetCode = S_xxx_task_get_emulation_vector(In0P->Head.msgh_request_port, &OutP->vector_start, OutP->emulation_vector, &emulation_vectorCnt); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->vector_startType = vector_startType; + + OutP->emulation_vectorType = emulation_vectorType; + + OutP->emulation_vectorType.msgtl_number = emulation_vectorCnt; + OutP->Head.msgh_size = 52 + (4 * emulation_vectorCnt); +} + +/* Routine xxx_task_set_emulation_vector */ +mig_internal void _Xxxx_task_set_emulation_vector + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t vector_startType; + int vector_start; + mach_msg_type_long_t emulation_vectorType; + vm_offset_t emulation_vector[1024]; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_xxx_task_set_emulation_vector + (mach_port_t task, int vector_start, emulation_vector_t emulation_vector, mach_msg_type_number_t emulation_vectorCnt); + + unsigned int msgh_size; + + auto const mach_msg_type_t vector_startCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + msgh_size = In0P->Head.msgh_size; + if ((msgh_size < 44) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->vector_startType, &vector_startCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if ((In0P->emulation_vectorType.msgtl_header.msgt_inline != TRUE) || + (In0P->emulation_vectorType.msgtl_header.msgt_longform != TRUE) || + (In0P->emulation_vectorType.msgtl_name != 2) || + (In0P->emulation_vectorType.msgtl_size != 32)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (msgh_size != 44 + (4 * In0P->emulation_vectorType.msgtl_number)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_xxx_task_set_emulation_vector(In0P->Head.msgh_request_port, In0P->vector_start, In0P->emulation_vector, In0P->emulation_vectorType.msgtl_number); +} + +/* Routine xxx_host_info */ +mig_internal void _Xxxx_host_info + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t infoType; + machine_info_data_t info; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_xxx_host_info + (mach_port_t target_task, machine_info_data_t *info); + + auto const mach_msg_type_t infoType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 5, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_xxx_host_info(In0P->Head.msgh_request_port, &OutP->info); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_size = 56; + + OutP->infoType = infoType; +} + +/* Routine xxx_slot_info */ +mig_internal void _Xxxx_slot_info + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t slotType; + int slot; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t infoType; + machine_slot_data_t info; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_xxx_slot_info + (mach_port_t target_task, int slot, machine_slot_data_t *info); + + auto const mach_msg_type_t slotCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t infoType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 8, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->slotType, &slotCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_xxx_slot_info(In0P->Head.msgh_request_port, In0P->slot, &OutP->info); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_size = 68; + + OutP->infoType = infoType; +} + +/* Routine xxx_cpu_control */ +mig_internal void _Xxxx_cpu_control + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t cpuType; + int cpu; + mach_msg_type_t runningType; + boolean_t running; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_xxx_cpu_control + (mach_port_t target_task, int cpu, boolean_t running); + + auto const mach_msg_type_t cpuCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t runningCheck = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->cpuType, &cpuCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->runningType, &runningCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_xxx_cpu_control(In0P->Head.msgh_request_port, In0P->cpu, In0P->running); +} + +/* Routine task_suspend */ +mig_internal void _Xtask_suspend + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_task_suspend + (mach_port_t target_task); + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_task_suspend(In0P->Head.msgh_request_port); +} + +/* Routine task_resume */ +mig_internal void _Xtask_resume + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_task_resume + (mach_port_t target_task); + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_task_resume(In0P->Head.msgh_request_port); +} + +/* Routine task_get_special_port */ +mig_internal void _Xtask_get_special_port + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t which_portType; + int which_port; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t special_portType; + mach_port_t special_port; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_task_get_special_port + (mach_port_t task, int which_port, mach_port_t *special_port, mach_msg_type_name_t *special_portPoly); + + boolean_t msgh_simple; + auto const mach_msg_type_t which_portCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t special_portType = { + /* msgt_name = */ -1, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + mach_msg_type_name_t special_portPoly; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->which_portType, &which_portCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_task_get_special_port(In0P->Head.msgh_request_port, In0P->which_port, &OutP->special_port, &special_portPoly); + if (OutP->RetCode != KERN_SUCCESS) + return; + + msgh_simple = TRUE; + OutP->Head.msgh_size = 40; + + OutP->special_portType = special_portType; + + if (MACH_MSG_TYPE_PORT_ANY(special_portPoly)) + msgh_simple = FALSE; + + OutP->special_portType.msgt_name = special_portPoly; + + if (!msgh_simple) + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; +} + +/* Routine task_set_special_port */ +mig_internal void _Xtask_set_special_port + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t which_portType; + int which_port; + mach_msg_type_t special_portType; + mach_port_t special_port; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_task_set_special_port + (mach_port_t task, int which_port, mach_port_t special_port); + + auto const mach_msg_type_t which_portCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t special_portCheck = { + /* msgt_name = */ 17, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->which_portType, &which_portCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->special_portType, &special_portCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_task_set_special_port(In0P->Head.msgh_request_port, In0P->which_port, In0P->special_port); +} + +/* Routine xxx_task_info */ +mig_internal void _Xxxx_task_info + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t flavorType; + int flavor; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_long_t task_info_outType; + natural_t task_info_out[1024]; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_xxx_task_info + (mach_port_t target_task, int flavor, task_info_t task_info_out, mach_msg_type_number_t *task_info_outCnt); + + auto const mach_msg_type_t flavorCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_long_t task_info_outType = { + { + /* msgt_name = */ 0, + /* msgt_size = */ 0, + /* msgt_number = */ 0, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ TRUE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }, + /* msgtl_name = */ 2, + /* msgtl_size = */ 32, + /* msgtl_number = */ 1024, + }; + + mach_msg_type_number_t task_info_outCnt; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->flavorType, &flavorCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + task_info_outCnt = 1024; + + OutP->RetCode = S_xxx_task_info(In0P->Head.msgh_request_port, In0P->flavor, OutP->task_info_out, &task_info_outCnt); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->task_info_outType = task_info_outType; + + OutP->task_info_outType.msgtl_number = task_info_outCnt; + OutP->Head.msgh_size = 44 + (4 * task_info_outCnt); +} + +/* Routine thread_create */ +mig_internal void _Xthread_create + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t child_threadType; + mach_port_t child_thread; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_thread_create + (mach_port_t parent_task, mach_port_t *child_thread, mach_msg_type_name_t *child_threadPoly); + + boolean_t msgh_simple; + auto const mach_msg_type_t child_threadType = { + /* msgt_name = */ -1, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + mach_msg_type_name_t child_threadPoly; + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_thread_create(In0P->Head.msgh_request_port, &OutP->child_thread, &child_threadPoly); + if (OutP->RetCode != KERN_SUCCESS) + return; + + msgh_simple = TRUE; + OutP->Head.msgh_size = 40; + + OutP->child_threadType = child_threadType; + + if (MACH_MSG_TYPE_PORT_ANY(child_threadPoly)) + msgh_simple = FALSE; + + OutP->child_threadType.msgt_name = child_threadPoly; + + if (!msgh_simple) + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; +} + +/* Routine thread_suspend */ +mig_internal void _Xthread_suspend + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_thread_suspend + (mach_port_t target_thread); + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_thread_suspend(In0P->Head.msgh_request_port); +} + +/* Routine thread_resume */ +mig_internal void _Xthread_resume + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_thread_resume + (mach_port_t target_thread); + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_thread_resume(In0P->Head.msgh_request_port); +} + +/* Routine thread_abort */ +mig_internal void _Xthread_abort + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_thread_abort + (mach_port_t target_thread); + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_thread_abort(In0P->Head.msgh_request_port); +} + +/* Routine xxx_thread_get_state */ +mig_internal void _Xxxx_thread_get_state + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t flavorType; + int flavor; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_long_t old_stateType; + natural_t old_state[1024]; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_xxx_thread_get_state + (mach_port_t target_thread, int flavor, thread_state_t old_state, mach_msg_type_number_t *old_stateCnt); + + auto const mach_msg_type_t flavorCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_long_t old_stateType = { + { + /* msgt_name = */ 0, + /* msgt_size = */ 0, + /* msgt_number = */ 0, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ TRUE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }, + /* msgtl_name = */ 2, + /* msgtl_size = */ 32, + /* msgtl_number = */ 1024, + }; + + mach_msg_type_number_t old_stateCnt; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->flavorType, &flavorCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + old_stateCnt = 1024; + + OutP->RetCode = S_xxx_thread_get_state(In0P->Head.msgh_request_port, In0P->flavor, OutP->old_state, &old_stateCnt); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->old_stateType = old_stateType; + + OutP->old_stateType.msgtl_number = old_stateCnt; + OutP->Head.msgh_size = 44 + (4 * old_stateCnt); +} + +/* Routine xxx_thread_set_state */ +mig_internal void _Xxxx_thread_set_state + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t flavorType; + int flavor; + mach_msg_type_long_t new_stateType; + natural_t new_state[1024]; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_xxx_thread_set_state + (mach_port_t target_thread, int flavor, thread_state_t new_state, mach_msg_type_number_t new_stateCnt); + + unsigned int msgh_size; + + auto const mach_msg_type_t flavorCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + msgh_size = In0P->Head.msgh_size; + if ((msgh_size < 44) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->flavorType, &flavorCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if ((In0P->new_stateType.msgtl_header.msgt_inline != TRUE) || + (In0P->new_stateType.msgtl_header.msgt_longform != TRUE) || + (In0P->new_stateType.msgtl_name != 2) || + (In0P->new_stateType.msgtl_size != 32)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (msgh_size != 44 + (4 * In0P->new_stateType.msgtl_number)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_xxx_thread_set_state(In0P->Head.msgh_request_port, In0P->flavor, In0P->new_state, In0P->new_stateType.msgtl_number); +} + +/* Routine thread_get_special_port */ +mig_internal void _Xthread_get_special_port + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t which_portType; + int which_port; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t special_portType; + mach_port_t special_port; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_thread_get_special_port + (mach_port_t thread, int which_port, mach_port_t *special_port); + + auto const mach_msg_type_t which_portCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t special_portType = { + /* msgt_name = */ 19, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->which_portType, &which_portCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_thread_get_special_port(In0P->Head.msgh_request_port, In0P->which_port, &OutP->special_port); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; + OutP->Head.msgh_size = 40; + + OutP->special_portType = special_portType; +} + +/* Routine thread_set_special_port */ +mig_internal void _Xthread_set_special_port + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t which_portType; + int which_port; + mach_msg_type_t special_portType; + mach_port_t special_port; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_thread_set_special_port + (mach_port_t thread, int which_port, mach_port_t special_port); + + auto const mach_msg_type_t which_portCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t special_portCheck = { + /* msgt_name = */ 17, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->which_portType, &which_portCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->special_portType, &special_portCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_thread_set_special_port(In0P->Head.msgh_request_port, In0P->which_port, In0P->special_port); +} + +/* Routine xxx_thread_info */ +mig_internal void _Xxxx_thread_info + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t flavorType; + int flavor; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_long_t thread_info_outType; + natural_t thread_info_out[1024]; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_xxx_thread_info + (mach_port_t target_thread, int flavor, thread_info_t thread_info_out, mach_msg_type_number_t *thread_info_outCnt); + + auto const mach_msg_type_t flavorCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_long_t thread_info_outType = { + { + /* msgt_name = */ 0, + /* msgt_size = */ 0, + /* msgt_number = */ 0, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ TRUE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }, + /* msgtl_name = */ 2, + /* msgtl_size = */ 32, + /* msgtl_number = */ 1024, + }; + + mach_msg_type_number_t thread_info_outCnt; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->flavorType, &flavorCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + thread_info_outCnt = 1024; + + OutP->RetCode = S_xxx_thread_info(In0P->Head.msgh_request_port, In0P->flavor, OutP->thread_info_out, &thread_info_outCnt); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->thread_info_outType = thread_info_outType; + + OutP->thread_info_outType.msgtl_number = thread_info_outCnt; + OutP->Head.msgh_size = 44 + (4 * thread_info_outCnt); +} + +/* Routine task_set_emulation */ +mig_internal void _Xtask_set_emulation + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t routine_entry_ptType; + vm_address_t routine_entry_pt; + mach_msg_type_t routine_numberType; + int routine_number; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_task_set_emulation + (mach_port_t target_port, vm_address_t routine_entry_pt, int routine_number); + + auto const mach_msg_type_t routine_entry_ptCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t routine_numberCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->routine_entry_ptType, &routine_entry_ptCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->routine_numberType, &routine_numberCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_task_set_emulation(In0P->Head.msgh_request_port, In0P->routine_entry_pt, In0P->routine_number); +} + +/* Routine task_ras_control */ +mig_internal void _Xtask_ras_control + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t basepcType; + vm_address_t basepc; + mach_msg_type_t boundspcType; + vm_address_t boundspc; + mach_msg_type_t flavorType; + int flavor; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_task_ras_control + (mach_port_t target_task, vm_address_t basepc, vm_address_t boundspc, int flavor); + + auto const mach_msg_type_t basepcCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t boundspcCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t flavorCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 48) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->basepcType, &basepcCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->boundspcType, &boundspcCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->flavorType, &flavorCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_task_ras_control(In0P->Head.msgh_request_port, In0P->basepc, In0P->boundspc, In0P->flavor); +} + +/* Routine vm_map */ +mig_internal void _Xvm_map + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t addressType; + vm_address_t address; + mach_msg_type_t sizeType; + vm_size_t size; + mach_msg_type_t maskType; + vm_address_t mask; + mach_msg_type_t anywhereType; + boolean_t anywhere; + mach_msg_type_t memory_objectType; + mach_port_t memory_object; + mach_msg_type_t offsetType; + vm_offset_t offset; + mach_msg_type_t copyType; + boolean_t copy; + mach_msg_type_t cur_protectionType; + vm_prot_t cur_protection; + mach_msg_type_t max_protectionType; + vm_prot_t max_protection; + mach_msg_type_t inheritanceType; + vm_inherit_t inheritance; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t addressType; + vm_address_t address; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_vm_map + (mach_port_t target_task, vm_address_t *address, vm_size_t size, vm_address_t mask, boolean_t anywhere, mach_port_t memory_object, vm_offset_t offset, boolean_t copy, vm_prot_t cur_protection, vm_prot_t max_protection, vm_inherit_t inheritance); + + auto const mach_msg_type_t addressCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t sizeCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t maskCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t anywhereCheck = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t memory_objectCheck = { + /* msgt_name = */ 17, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t offsetCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t copyCheck = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t cur_protectionCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t max_protectionCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t inheritanceCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t addressType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 104) || + !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->addressType, &addressCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->sizeType, &sizeCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->maskType, &maskCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->anywhereType, &anywhereCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->memory_objectType, &memory_objectCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->offsetType, &offsetCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->copyType, ©Check)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->cur_protectionType, &cur_protectionCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->max_protectionType, &max_protectionCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->inheritanceType, &inheritanceCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_vm_map(In0P->Head.msgh_request_port, &In0P->address, In0P->size, In0P->mask, In0P->anywhere, In0P->memory_object, In0P->offset, In0P->copy, In0P->cur_protection, In0P->max_protection, In0P->inheritance); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_size = 40; + + OutP->addressType = addressType; + + OutP->address = In0P->address; +} + +/* SimpleRoutine memory_object_data_error */ +mig_internal void _Xmemory_object_data_error + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t offsetType; + vm_offset_t offset; + mach_msg_type_t sizeType; + vm_size_t size; + mach_msg_type_t error_valueType; + kern_return_t error_value; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_memory_object_data_error + (mach_port_t memory_control, vm_offset_t offset, vm_size_t size, kern_return_t error_value); + + auto const mach_msg_type_t offsetCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t sizeCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t error_valueCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 48) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->offsetType, &offsetCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->sizeType, &sizeCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->error_valueType, &error_valueCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_memory_object_data_error(In0P->Head.msgh_request_port, In0P->offset, In0P->size, In0P->error_value); +} + +/* SimpleRoutine memory_object_set_attributes */ +mig_internal void _Xmemory_object_set_attributes + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t object_readyType; + boolean_t object_ready; + mach_msg_type_t may_cacheType; + boolean_t may_cache; + mach_msg_type_t copy_strategyType; + memory_object_copy_strategy_t copy_strategy; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_memory_object_set_attributes + (mach_port_t memory_control, boolean_t object_ready, boolean_t may_cache, memory_object_copy_strategy_t copy_strategy); + + auto const mach_msg_type_t object_readyCheck = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t may_cacheCheck = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t copy_strategyCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 48) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->object_readyType, &object_readyCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->may_cacheType, &may_cacheCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->copy_strategyType, ©_strategyCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_memory_object_set_attributes(In0P->Head.msgh_request_port, In0P->object_ready, In0P->may_cache, In0P->copy_strategy); +} + +/* SimpleRoutine memory_object_destroy */ +mig_internal void _Xmemory_object_destroy + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t reasonType; + kern_return_t reason; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_memory_object_destroy + (mach_port_t memory_control, kern_return_t reason); + + auto const mach_msg_type_t reasonCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->reasonType, &reasonCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_memory_object_destroy(In0P->Head.msgh_request_port, In0P->reason); +} + +/* SimpleRoutine memory_object_data_supply */ +mig_internal void _Xmemory_object_data_supply + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t offsetType; + vm_offset_t offset; + mach_msg_type_long_t dataType; + vm_offset_t data; + mach_msg_type_t lock_valueType; + vm_prot_t lock_value; + mach_msg_type_t preciousType; + boolean_t precious; + mach_msg_type_t reply_toType; + mach_port_t reply_to; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_memory_object_data_supply + (mach_port_t memory_control, vm_offset_t offset, vm_offset_t data, mach_msg_type_number_t dataCnt, vm_prot_t lock_value, boolean_t precious, mach_port_t reply_to, mach_msg_type_name_t reply_toPoly); + + auto const mach_msg_type_t offsetCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t lock_valueCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t preciousCheck = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 72) || + !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->offsetType, &offsetCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if ((In0P->dataType.msgtl_header.msgt_inline != FALSE) || + (In0P->dataType.msgtl_header.msgt_longform != TRUE) || + (In0P->dataType.msgtl_name != 9) || + (In0P->dataType.msgtl_size != 8)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->lock_valueType, &lock_valueCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->preciousType, &preciousCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if ((In0P->reply_toType.msgt_inline != TRUE) || + (In0P->reply_toType.msgt_longform != FALSE) || + (In0P->reply_toType.msgt_number != 1) || + (In0P->reply_toType.msgt_size != 32)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_memory_object_data_supply(In0P->Head.msgh_request_port, In0P->offset, In0P->data, In0P->dataType.msgtl_number, In0P->lock_value, In0P->precious, In0P->reply_to, In0P->reply_toType.msgt_name); +} + +/* SimpleRoutine memory_object_ready */ +mig_internal void _Xmemory_object_ready + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t may_cacheType; + boolean_t may_cache; + mach_msg_type_t copy_strategyType; + memory_object_copy_strategy_t copy_strategy; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_memory_object_ready + (mach_port_t memory_control, boolean_t may_cache, memory_object_copy_strategy_t copy_strategy); + + auto const mach_msg_type_t may_cacheCheck = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t copy_strategyCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->may_cacheType, &may_cacheCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->copy_strategyType, ©_strategyCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_memory_object_ready(In0P->Head.msgh_request_port, In0P->may_cache, In0P->copy_strategy); +} + +/* SimpleRoutine memory_object_change_attributes */ +mig_internal void _Xmemory_object_change_attributes + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t may_cacheType; + boolean_t may_cache; + mach_msg_type_t copy_strategyType; + memory_object_copy_strategy_t copy_strategy; + mach_msg_type_t reply_toType; + mach_port_t reply_to; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_memory_object_change_attributes + (mach_port_t memory_control, boolean_t may_cache, memory_object_copy_strategy_t copy_strategy, mach_port_t reply_to, mach_msg_type_name_t reply_toPoly); + +#if TypeCheck + boolean_t msgh_simple; +#endif /* TypeCheck */ + + auto const mach_msg_type_t may_cacheCheck = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t copy_strategyCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + msgh_simple = !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX); + if ((In0P->Head.msgh_size != 48)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->may_cacheType, &may_cacheCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->copy_strategyType, ©_strategyCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if ((In0P->reply_toType.msgt_inline != TRUE) || + (In0P->reply_toType.msgt_longform != FALSE) || + (MACH_MSG_TYPE_PORT_ANY(In0P->reply_toType.msgt_name) && msgh_simple) || + (In0P->reply_toType.msgt_number != 1) || + (In0P->reply_toType.msgt_size != 32)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_memory_object_change_attributes(In0P->Head.msgh_request_port, In0P->may_cache, In0P->copy_strategy, In0P->reply_to, In0P->reply_toType.msgt_name); +} + +/* Routine vm_machine_attribute */ +mig_internal void _Xvm_machine_attribute + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t addressType; + vm_address_t address; + mach_msg_type_t sizeType; + vm_size_t size; + mach_msg_type_t attributeType; + vm_machine_attribute_t attribute; + mach_msg_type_t valueType; + vm_machine_attribute_val_t value; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t valueType; + vm_machine_attribute_val_t value; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_vm_machine_attribute + (mach_port_t target_task, vm_address_t address, vm_size_t size, vm_machine_attribute_t attribute, vm_machine_attribute_val_t *value); + + auto const mach_msg_type_t addressCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t sizeCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t attributeCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t valueCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t valueType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 56) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->addressType, &addressCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->sizeType, &sizeCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->attributeType, &attributeCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->valueType, &valueCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_vm_machine_attribute(In0P->Head.msgh_request_port, In0P->address, In0P->size, In0P->attribute, &In0P->value); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_size = 40; + + OutP->valueType = valueType; + + OutP->value = In0P->value; +} + +static mig_routine_t mach_server_routines[] = { + 0, + 0, + 0, + 0, + 0, + 0, + 0, + _Xtask_create, + _Xtask_terminate, + _Xtask_get_emulation_vector, + _Xtask_set_emulation_vector, + _Xtask_threads, + _Xtask_info, + 0, + 0, + 0, + _Xthread_terminate, + _Xthread_get_state, + _Xthread_set_state, + _Xthread_info, + 0, + _Xvm_allocate, + 0, + _Xvm_deallocate, + _Xvm_protect, + _Xvm_inherit, + _Xvm_read, + _Xvm_write, + _Xvm_copy, + _Xvm_region, + _Xvm_statistics, + 0, + 0, + _Xmach_ports_register, + _Xmach_ports_lookup, + 0, + 0, + 0, + _Xmemory_object_data_provided, + _Xmemory_object_data_unavailable, + _Xmemory_object_get_attributes, + _Xvm_set_default_memory_manager, + 0, + _Xxxx_memory_object_lock_request, + _Xmemory_object_lock_request, + _Xxxx_task_get_emulation_vector, + _Xxxx_task_set_emulation_vector, + _Xxxx_host_info, + _Xxxx_slot_info, + _Xxxx_cpu_control, + 0, + 0, + 0, + 0, + 0, + 0, + _Xtask_suspend, + _Xtask_resume, + _Xtask_get_special_port, + _Xtask_set_special_port, + _Xxxx_task_info, + _Xthread_create, + _Xthread_suspend, + _Xthread_resume, + _Xthread_abort, + _Xxxx_thread_get_state, + _Xxxx_thread_set_state, + _Xthread_get_special_port, + _Xthread_set_special_port, + _Xxxx_thread_info, + _Xtask_set_emulation, + _Xtask_ras_control, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + _Xvm_map, + _Xmemory_object_data_error, + _Xmemory_object_set_attributes, + _Xmemory_object_destroy, + _Xmemory_object_data_supply, + _Xmemory_object_ready, + _Xmemory_object_change_attributes, + 0, + 0, + 0, + _Xvm_machine_attribute, + 0, +}; + +mig_external boolean_t mach_server + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + register mach_msg_header_t *InP = InHeadP; + register mig_reply_header_t *OutP = (mig_reply_header_t *) OutHeadP; + + auto const mach_msg_type_t RetCodeType = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + register mig_routine_t routine; + + OutP->Head.msgh_bits = MACH_MSGH_BITS(MACH_MSGH_BITS_REPLY(InP->msgh_bits), 0); + OutP->Head.msgh_size = sizeof *OutP; + OutP->Head.msgh_remote_port = InP->msgh_reply_port; + OutP->Head.msgh_local_port = MACH_PORT_NULL; + OutP->Head.msgh_seqno = 0; + OutP->Head.msgh_id = InP->msgh_id + 100; + + OutP->RetCodeType = RetCodeType; + + if ((InP->msgh_id > 2100) || (InP->msgh_id < 2000) || + ((routine = mach_server_routines[InP->msgh_id - 2000]) == 0)) { + OutP->RetCode = MIG_BAD_ID; + return FALSE; + } + (*routine) (InP, &OutP->Head); + return TRUE; +} + +mig_external mig_routine_t mach_server_routine + (const mach_msg_header_t *InHeadP) +{ + register int msgh_id; + + msgh_id = InHeadP->msgh_id - 2000; + + if ((msgh_id > 100) || (msgh_id < 0)) + return 0; + + return mach_server_routines[msgh_id]; +} + diff --git a/boot-proxy-exc/ourmachServer.d b/boot-proxy-exc/ourmachServer.d new file mode 100644 index 00000000..c439ab9e --- /dev/null +++ b/boot-proxy-exc/ourmachServer.d @@ -0,0 +1,44 @@ +ourmachServer.o ourmachServer_pic.o ourmachServer_p.o ourmachServer.d: ourmachServer.c /usr/local/include/mach/boolean.h \ + /usr/local/include/mach/machine/boolean.h \ + /usr/local/include/mach/kern_return.h \ + /usr/local/include/mach/machine/kern_return.h \ + /usr/local/include/mach/message.h /usr/local/include/mach/port.h \ + /usr/local/include/mach/machine/vm_types.h \ + /usr/local/include/mach/mig_errors.h /usr/include/mach/mig_support.h \ + /usr/local/include/mach/std_types.h /usr/include/sys/types.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h /usr/include/gnu/stubs-pthread.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/time.h /usr/lib/gcc/i486-gnu/4.2.4/include/stddef.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/bits/byteswap.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/pthread/pthreadtypes.h \ + /usr/include/xlocale.h /usr/include/bits/pthread.h \ + /usr/include/bits/thread-attr.h /usr/include/sched.h \ + /usr/include/bits/sched.h /usr/include/bits/mutex-attr.h \ + /usr/include/bits/mutex.h /usr/include/bits/spin-lock.h \ + /usr/include/bits/condition-attr.h /usr/include/bits/condition.h \ + /usr/include/bits/rwlock-attr.h /usr/include/bits/rwlock.h \ + /usr/include/bits/barrier-attr.h /usr/include/bits/barrier.h \ + /usr/include/bits/thread-specific.h /usr/include/bits/once.h \ + /usr/include/string.h /usr/include/bits/string.h \ + /usr/include/bits/string2.h /usr/include/stdlib.h \ + /usr/local/include/mach/mach_types.h \ + /usr/local/include/mach/host_info.h /usr/local/include/mach/machine.h \ + /usr/local/include/mach/memory_object.h \ + /usr/local/include/mach/pc_sample.h \ + /usr/local/include/mach/processor_info.h \ + /usr/local/include/mach/task_info.h \ + /usr/local/include/mach/time_value.h \ + /usr/local/include/mach/task_special_ports.h \ + /usr/local/include/mach/thread_info.h /usr/local/include/mach/policy.h \ + /usr/local/include/mach/thread_special_ports.h \ + /usr/local/include/mach/thread_status.h \ + /usr/local/include/mach/machine/thread_status.h \ + /usr/local/include/mach/machine/fp_reg.h \ + /usr/local/include/mach/vm_attributes.h \ + /usr/local/include/mach/vm_inherit.h /usr/local/include/mach/vm_prot.h \ + /usr/local/include/mach/vm_statistics.h diff --git a/boot-proxy-exc/ourmachServer.o b/boot-proxy-exc/ourmachServer.o Binary files differnew file mode 100644 index 00000000..ca7ba26b --- /dev/null +++ b/boot-proxy-exc/ourmachServer.o diff --git a/boot-proxy-exc/ourmach_S.h b/boot-proxy-exc/ourmach_S.h new file mode 100644 index 00000000..9d5bd776 --- /dev/null +++ b/boot-proxy-exc/ourmach_S.h @@ -0,0 +1,1275 @@ +#ifndef _mach_server_ +#define _mach_server_ + +/* Module mach */ + +#include <mach/kern_return.h> +#include <mach/port.h> +#include <mach/message.h> + +#include <mach/std_types.h> +#include <mach/mach_types.h> + +/* Routine task_create */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_task_create +#if defined(LINTLIBRARY) + (target_task, inherit_memory, child_task, child_taskPoly) + mach_port_t target_task; + boolean_t inherit_memory; + mach_port_t *child_task; + mach_msg_type_name_t *child_taskPoly; +{ return S_task_create(target_task, inherit_memory, child_task, child_taskPoly); } +#else +( + mach_port_t target_task, + boolean_t inherit_memory, + mach_port_t *child_task, + mach_msg_type_name_t *child_taskPoly +); +#endif + +/* Routine task_terminate */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_task_terminate +#if defined(LINTLIBRARY) + (target_task) + mach_port_t target_task; +{ return S_task_terminate(target_task); } +#else +( + mach_port_t target_task +); +#endif + +/* Routine task_get_emulation_vector */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_task_get_emulation_vector +#if defined(LINTLIBRARY) + (task, vector_start, emulation_vector, emulation_vectorCnt) + mach_port_t task; + int *vector_start; + emulation_vector_t *emulation_vector; + mach_msg_type_number_t *emulation_vectorCnt; +{ return S_task_get_emulation_vector(task, vector_start, emulation_vector, emulation_vectorCnt); } +#else +( + mach_port_t task, + int *vector_start, + emulation_vector_t *emulation_vector, + mach_msg_type_number_t *emulation_vectorCnt +); +#endif + +/* Routine task_set_emulation_vector */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_task_set_emulation_vector +#if defined(LINTLIBRARY) + (task, vector_start, emulation_vector, emulation_vectorCnt) + mach_port_t task; + int vector_start; + emulation_vector_t emulation_vector; + mach_msg_type_number_t emulation_vectorCnt; +{ return S_task_set_emulation_vector(task, vector_start, emulation_vector, emulation_vectorCnt); } +#else +( + mach_port_t task, + int vector_start, + emulation_vector_t emulation_vector, + mach_msg_type_number_t emulation_vectorCnt +); +#endif + +/* Routine task_threads */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_task_threads +#if defined(LINTLIBRARY) + (target_task, thread_list, thread_listCnt) + mach_port_t target_task; + thread_array_t *thread_list; + mach_msg_type_number_t *thread_listCnt; +{ return S_task_threads(target_task, thread_list, thread_listCnt); } +#else +( + mach_port_t target_task, + thread_array_t *thread_list, + mach_msg_type_number_t *thread_listCnt +); +#endif + +/* Routine task_info */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_task_info +#if defined(LINTLIBRARY) + (target_task, flavor, task_info_out, task_info_outCnt) + mach_port_t target_task; + int flavor; + task_info_t task_info_out; + mach_msg_type_number_t *task_info_outCnt; +{ return S_task_info(target_task, flavor, task_info_out, task_info_outCnt); } +#else +( + mach_port_t target_task, + int flavor, + task_info_t task_info_out, + mach_msg_type_number_t *task_info_outCnt +); +#endif + +/* Routine thread_terminate */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_thread_terminate +#if defined(LINTLIBRARY) + (target_thread) + mach_port_t target_thread; +{ return S_thread_terminate(target_thread); } +#else +( + mach_port_t target_thread +); +#endif + +/* Routine thread_get_state */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_thread_get_state +#if defined(LINTLIBRARY) + (target_thread, flavor, old_state, old_stateCnt) + mach_port_t target_thread; + int flavor; + thread_state_t old_state; + mach_msg_type_number_t *old_stateCnt; +{ return S_thread_get_state(target_thread, flavor, old_state, old_stateCnt); } +#else +( + mach_port_t target_thread, + int flavor, + thread_state_t old_state, + mach_msg_type_number_t *old_stateCnt +); +#endif + +/* Routine thread_set_state */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_thread_set_state +#if defined(LINTLIBRARY) + (target_thread, flavor, new_state, new_stateCnt) + mach_port_t target_thread; + int flavor; + thread_state_t new_state; + mach_msg_type_number_t new_stateCnt; +{ return S_thread_set_state(target_thread, flavor, new_state, new_stateCnt); } +#else +( + mach_port_t target_thread, + int flavor, + thread_state_t new_state, + mach_msg_type_number_t new_stateCnt +); +#endif + +/* Routine thread_info */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_thread_info +#if defined(LINTLIBRARY) + (target_thread, flavor, thread_info_out, thread_info_outCnt) + mach_port_t target_thread; + int flavor; + thread_info_t thread_info_out; + mach_msg_type_number_t *thread_info_outCnt; +{ return S_thread_info(target_thread, flavor, thread_info_out, thread_info_outCnt); } +#else +( + mach_port_t target_thread, + int flavor, + thread_info_t thread_info_out, + mach_msg_type_number_t *thread_info_outCnt +); +#endif + +/* Routine vm_allocate */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_vm_allocate +#if defined(LINTLIBRARY) + (target_task, address, size, anywhere) + mach_port_t target_task; + vm_address_t *address; + vm_size_t size; + boolean_t anywhere; +{ return S_vm_allocate(target_task, address, size, anywhere); } +#else +( + mach_port_t target_task, + vm_address_t *address, + vm_size_t size, + boolean_t anywhere +); +#endif + +/* Routine vm_deallocate */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_vm_deallocate +#if defined(LINTLIBRARY) + (target_task, address, size) + mach_port_t target_task; + vm_address_t address; + vm_size_t size; +{ return S_vm_deallocate(target_task, address, size); } +#else +( + mach_port_t target_task, + vm_address_t address, + vm_size_t size +); +#endif + +/* Routine vm_protect */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_vm_protect +#if defined(LINTLIBRARY) + (target_task, address, size, set_maximum, new_protection) + mach_port_t target_task; + vm_address_t address; + vm_size_t size; + boolean_t set_maximum; + vm_prot_t new_protection; +{ return S_vm_protect(target_task, address, size, set_maximum, new_protection); } +#else +( + mach_port_t target_task, + vm_address_t address, + vm_size_t size, + boolean_t set_maximum, + vm_prot_t new_protection +); +#endif + +/* Routine vm_inherit */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_vm_inherit +#if defined(LINTLIBRARY) + (target_task, address, size, new_inheritance) + mach_port_t target_task; + vm_address_t address; + vm_size_t size; + vm_inherit_t new_inheritance; +{ return S_vm_inherit(target_task, address, size, new_inheritance); } +#else +( + mach_port_t target_task, + vm_address_t address, + vm_size_t size, + vm_inherit_t new_inheritance +); +#endif + +/* Routine vm_read */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_vm_read +#if defined(LINTLIBRARY) + (target_task, address, size, data, dataCnt) + mach_port_t target_task; + vm_address_t address; + vm_size_t size; + vm_offset_t *data; + mach_msg_type_number_t *dataCnt; +{ return S_vm_read(target_task, address, size, data, dataCnt); } +#else +( + mach_port_t target_task, + vm_address_t address, + vm_size_t size, + vm_offset_t *data, + mach_msg_type_number_t *dataCnt +); +#endif + +/* Routine vm_write */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_vm_write +#if defined(LINTLIBRARY) + (target_task, address, data, dataCnt) + mach_port_t target_task; + vm_address_t address; + vm_offset_t data; + mach_msg_type_number_t dataCnt; +{ return S_vm_write(target_task, address, data, dataCnt); } +#else +( + mach_port_t target_task, + vm_address_t address, + vm_offset_t data, + mach_msg_type_number_t dataCnt +); +#endif + +/* Routine vm_copy */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_vm_copy +#if defined(LINTLIBRARY) + (target_task, source_address, size, dest_address) + mach_port_t target_task; + vm_address_t source_address; + vm_size_t size; + vm_address_t dest_address; +{ return S_vm_copy(target_task, source_address, size, dest_address); } +#else +( + mach_port_t target_task, + vm_address_t source_address, + vm_size_t size, + vm_address_t dest_address +); +#endif + +/* Routine vm_region */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_vm_region +#if defined(LINTLIBRARY) + (target_task, address, size, protection, max_protection, inheritance, is_shared, object_name, offset) + mach_port_t target_task; + vm_address_t *address; + vm_size_t *size; + vm_prot_t *protection; + vm_prot_t *max_protection; + vm_inherit_t *inheritance; + boolean_t *is_shared; + mach_port_t *object_name; + vm_offset_t *offset; +{ return S_vm_region(target_task, address, size, protection, max_protection, inheritance, is_shared, object_name, offset); } +#else +( + mach_port_t target_task, + vm_address_t *address, + vm_size_t *size, + vm_prot_t *protection, + vm_prot_t *max_protection, + vm_inherit_t *inheritance, + boolean_t *is_shared, + mach_port_t *object_name, + vm_offset_t *offset +); +#endif + +/* Routine vm_statistics */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_vm_statistics +#if defined(LINTLIBRARY) + (target_task, vm_stats) + mach_port_t target_task; + vm_statistics_data_t *vm_stats; +{ return S_vm_statistics(target_task, vm_stats); } +#else +( + mach_port_t target_task, + vm_statistics_data_t *vm_stats +); +#endif + +/* Routine mach_ports_register */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_mach_ports_register +#if defined(LINTLIBRARY) + (target_task, init_port_set, init_port_setCnt) + mach_port_t target_task; + mach_port_array_t init_port_set; + mach_msg_type_number_t init_port_setCnt; +{ return S_mach_ports_register(target_task, init_port_set, init_port_setCnt); } +#else +( + mach_port_t target_task, + mach_port_array_t init_port_set, + mach_msg_type_number_t init_port_setCnt +); +#endif + +/* Routine mach_ports_lookup */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_mach_ports_lookup +#if defined(LINTLIBRARY) + (target_task, init_port_set, init_port_setCnt) + mach_port_t target_task; + mach_port_array_t *init_port_set; + mach_msg_type_number_t *init_port_setCnt; +{ return S_mach_ports_lookup(target_task, init_port_set, init_port_setCnt); } +#else +( + mach_port_t target_task, + mach_port_array_t *init_port_set, + mach_msg_type_number_t *init_port_setCnt +); +#endif + +/* SimpleRoutine memory_object_data_provided */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_memory_object_data_provided +#if defined(LINTLIBRARY) + (memory_control, offset, data, dataCnt, lock_value) + mach_port_t memory_control; + vm_offset_t offset; + vm_offset_t data; + mach_msg_type_number_t dataCnt; + vm_prot_t lock_value; +{ return S_memory_object_data_provided(memory_control, offset, data, dataCnt, lock_value); } +#else +( + mach_port_t memory_control, + vm_offset_t offset, + vm_offset_t data, + mach_msg_type_number_t dataCnt, + vm_prot_t lock_value +); +#endif + +/* SimpleRoutine memory_object_data_unavailable */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_memory_object_data_unavailable +#if defined(LINTLIBRARY) + (memory_control, offset, size) + mach_port_t memory_control; + vm_offset_t offset; + vm_size_t size; +{ return S_memory_object_data_unavailable(memory_control, offset, size); } +#else +( + mach_port_t memory_control, + vm_offset_t offset, + vm_size_t size +); +#endif + +/* Routine memory_object_get_attributes */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_memory_object_get_attributes +#if defined(LINTLIBRARY) + (memory_control, object_ready, may_cache, copy_strategy) + mach_port_t memory_control; + boolean_t *object_ready; + boolean_t *may_cache; + memory_object_copy_strategy_t *copy_strategy; +{ return S_memory_object_get_attributes(memory_control, object_ready, may_cache, copy_strategy); } +#else +( + mach_port_t memory_control, + boolean_t *object_ready, + boolean_t *may_cache, + memory_object_copy_strategy_t *copy_strategy +); +#endif + +/* Routine vm_set_default_memory_manager */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_vm_set_default_memory_manager +#if defined(LINTLIBRARY) + (host_priv, default_manager) + mach_port_t host_priv; + mach_port_t *default_manager; +{ return S_vm_set_default_memory_manager(host_priv, default_manager); } +#else +( + mach_port_t host_priv, + mach_port_t *default_manager +); +#endif + +/* SimpleRoutine xxx_memory_object_lock_request */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_xxx_memory_object_lock_request +#if defined(LINTLIBRARY) + (memory_control, offset, size, should_clean, should_flush, lock_value, reply_to, reply_toPoly) + mach_port_t memory_control; + vm_offset_t offset; + vm_size_t size; + boolean_t should_clean; + boolean_t should_flush; + vm_prot_t lock_value; + mach_port_t reply_to; + mach_msg_type_name_t reply_toPoly; +{ return S_xxx_memory_object_lock_request(memory_control, offset, size, should_clean, should_flush, lock_value, reply_to, reply_toPoly); } +#else +( + mach_port_t memory_control, + vm_offset_t offset, + vm_size_t size, + boolean_t should_clean, + boolean_t should_flush, + vm_prot_t lock_value, + mach_port_t reply_to, + mach_msg_type_name_t reply_toPoly +); +#endif + +/* SimpleRoutine memory_object_lock_request */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_memory_object_lock_request +#if defined(LINTLIBRARY) + (memory_control, offset, size, should_return, should_flush, lock_value, reply_to, reply_toPoly) + mach_port_t memory_control; + vm_offset_t offset; + vm_size_t size; + memory_object_return_t should_return; + boolean_t should_flush; + vm_prot_t lock_value; + mach_port_t reply_to; + mach_msg_type_name_t reply_toPoly; +{ return S_memory_object_lock_request(memory_control, offset, size, should_return, should_flush, lock_value, reply_to, reply_toPoly); } +#else +( + mach_port_t memory_control, + vm_offset_t offset, + vm_size_t size, + memory_object_return_t should_return, + boolean_t should_flush, + vm_prot_t lock_value, + mach_port_t reply_to, + mach_msg_type_name_t reply_toPoly +); +#endif + +/* Routine xxx_task_get_emulation_vector */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_xxx_task_get_emulation_vector +#if defined(LINTLIBRARY) + (task, vector_start, emulation_vector, emulation_vectorCnt) + mach_port_t task; + int *vector_start; + emulation_vector_t emulation_vector; + mach_msg_type_number_t *emulation_vectorCnt; +{ return S_xxx_task_get_emulation_vector(task, vector_start, emulation_vector, emulation_vectorCnt); } +#else +( + mach_port_t task, + int *vector_start, + emulation_vector_t emulation_vector, + mach_msg_type_number_t *emulation_vectorCnt +); +#endif + +/* Routine xxx_task_set_emulation_vector */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_xxx_task_set_emulation_vector +#if defined(LINTLIBRARY) + (task, vector_start, emulation_vector, emulation_vectorCnt) + mach_port_t task; + int vector_start; + emulation_vector_t emulation_vector; + mach_msg_type_number_t emulation_vectorCnt; +{ return S_xxx_task_set_emulation_vector(task, vector_start, emulation_vector, emulation_vectorCnt); } +#else +( + mach_port_t task, + int vector_start, + emulation_vector_t emulation_vector, + mach_msg_type_number_t emulation_vectorCnt +); +#endif + +/* Routine xxx_host_info */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_xxx_host_info +#if defined(LINTLIBRARY) + (target_task, info) + mach_port_t target_task; + machine_info_data_t *info; +{ return S_xxx_host_info(target_task, info); } +#else +( + mach_port_t target_task, + machine_info_data_t *info +); +#endif + +/* Routine xxx_slot_info */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_xxx_slot_info +#if defined(LINTLIBRARY) + (target_task, slot, info) + mach_port_t target_task; + int slot; + machine_slot_data_t *info; +{ return S_xxx_slot_info(target_task, slot, info); } +#else +( + mach_port_t target_task, + int slot, + machine_slot_data_t *info +); +#endif + +/* Routine xxx_cpu_control */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_xxx_cpu_control +#if defined(LINTLIBRARY) + (target_task, cpu, running) + mach_port_t target_task; + int cpu; + boolean_t running; +{ return S_xxx_cpu_control(target_task, cpu, running); } +#else +( + mach_port_t target_task, + int cpu, + boolean_t running +); +#endif + +/* Routine task_suspend */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_task_suspend +#if defined(LINTLIBRARY) + (target_task) + mach_port_t target_task; +{ return S_task_suspend(target_task); } +#else +( + mach_port_t target_task +); +#endif + +/* Routine task_resume */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_task_resume +#if defined(LINTLIBRARY) + (target_task) + mach_port_t target_task; +{ return S_task_resume(target_task); } +#else +( + mach_port_t target_task +); +#endif + +/* Routine task_get_special_port */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_task_get_special_port +#if defined(LINTLIBRARY) + (task, which_port, special_port, special_portPoly) + mach_port_t task; + int which_port; + mach_port_t *special_port; + mach_msg_type_name_t *special_portPoly; +{ return S_task_get_special_port(task, which_port, special_port, special_portPoly); } +#else +( + mach_port_t task, + int which_port, + mach_port_t *special_port, + mach_msg_type_name_t *special_portPoly +); +#endif + +/* Routine task_set_special_port */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_task_set_special_port +#if defined(LINTLIBRARY) + (task, which_port, special_port) + mach_port_t task; + int which_port; + mach_port_t special_port; +{ return S_task_set_special_port(task, which_port, special_port); } +#else +( + mach_port_t task, + int which_port, + mach_port_t special_port +); +#endif + +/* Routine xxx_task_info */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_xxx_task_info +#if defined(LINTLIBRARY) + (target_task, flavor, task_info_out, task_info_outCnt) + mach_port_t target_task; + int flavor; + task_info_t task_info_out; + mach_msg_type_number_t *task_info_outCnt; +{ return S_xxx_task_info(target_task, flavor, task_info_out, task_info_outCnt); } +#else +( + mach_port_t target_task, + int flavor, + task_info_t task_info_out, + mach_msg_type_number_t *task_info_outCnt +); +#endif + +/* Routine thread_create */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_thread_create +#if defined(LINTLIBRARY) + (parent_task, child_thread, child_threadPoly) + mach_port_t parent_task; + mach_port_t *child_thread; + mach_msg_type_name_t *child_threadPoly; +{ return S_thread_create(parent_task, child_thread, child_threadPoly); } +#else +( + mach_port_t parent_task, + mach_port_t *child_thread, + mach_msg_type_name_t *child_threadPoly +); +#endif + +/* Routine thread_suspend */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_thread_suspend +#if defined(LINTLIBRARY) + (target_thread) + mach_port_t target_thread; +{ return S_thread_suspend(target_thread); } +#else +( + mach_port_t target_thread +); +#endif + +/* Routine thread_resume */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_thread_resume +#if defined(LINTLIBRARY) + (target_thread) + mach_port_t target_thread; +{ return S_thread_resume(target_thread); } +#else +( + mach_port_t target_thread +); +#endif + +/* Routine thread_abort */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_thread_abort +#if defined(LINTLIBRARY) + (target_thread) + mach_port_t target_thread; +{ return S_thread_abort(target_thread); } +#else +( + mach_port_t target_thread +); +#endif + +/* Routine xxx_thread_get_state */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_xxx_thread_get_state +#if defined(LINTLIBRARY) + (target_thread, flavor, old_state, old_stateCnt) + mach_port_t target_thread; + int flavor; + thread_state_t old_state; + mach_msg_type_number_t *old_stateCnt; +{ return S_xxx_thread_get_state(target_thread, flavor, old_state, old_stateCnt); } +#else +( + mach_port_t target_thread, + int flavor, + thread_state_t old_state, + mach_msg_type_number_t *old_stateCnt +); +#endif + +/* Routine xxx_thread_set_state */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_xxx_thread_set_state +#if defined(LINTLIBRARY) + (target_thread, flavor, new_state, new_stateCnt) + mach_port_t target_thread; + int flavor; + thread_state_t new_state; + mach_msg_type_number_t new_stateCnt; +{ return S_xxx_thread_set_state(target_thread, flavor, new_state, new_stateCnt); } +#else +( + mach_port_t target_thread, + int flavor, + thread_state_t new_state, + mach_msg_type_number_t new_stateCnt +); +#endif + +/* Routine thread_get_special_port */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_thread_get_special_port +#if defined(LINTLIBRARY) + (thread, which_port, special_port) + mach_port_t thread; + int which_port; + mach_port_t *special_port; +{ return S_thread_get_special_port(thread, which_port, special_port); } +#else +( + mach_port_t thread, + int which_port, + mach_port_t *special_port +); +#endif + +/* Routine thread_set_special_port */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_thread_set_special_port +#if defined(LINTLIBRARY) + (thread, which_port, special_port) + mach_port_t thread; + int which_port; + mach_port_t special_port; +{ return S_thread_set_special_port(thread, which_port, special_port); } +#else +( + mach_port_t thread, + int which_port, + mach_port_t special_port +); +#endif + +/* Routine xxx_thread_info */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_xxx_thread_info +#if defined(LINTLIBRARY) + (target_thread, flavor, thread_info_out, thread_info_outCnt) + mach_port_t target_thread; + int flavor; + thread_info_t thread_info_out; + mach_msg_type_number_t *thread_info_outCnt; +{ return S_xxx_thread_info(target_thread, flavor, thread_info_out, thread_info_outCnt); } +#else +( + mach_port_t target_thread, + int flavor, + thread_info_t thread_info_out, + mach_msg_type_number_t *thread_info_outCnt +); +#endif + +/* Routine task_set_emulation */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_task_set_emulation +#if defined(LINTLIBRARY) + (target_port, routine_entry_pt, routine_number) + mach_port_t target_port; + vm_address_t routine_entry_pt; + int routine_number; +{ return S_task_set_emulation(target_port, routine_entry_pt, routine_number); } +#else +( + mach_port_t target_port, + vm_address_t routine_entry_pt, + int routine_number +); +#endif + +/* Routine task_ras_control */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_task_ras_control +#if defined(LINTLIBRARY) + (target_task, basepc, boundspc, flavor) + mach_port_t target_task; + vm_address_t basepc; + vm_address_t boundspc; + int flavor; +{ return S_task_ras_control(target_task, basepc, boundspc, flavor); } +#else +( + mach_port_t target_task, + vm_address_t basepc, + vm_address_t boundspc, + int flavor +); +#endif + +/* Routine vm_map */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_vm_map +#if defined(LINTLIBRARY) + (target_task, address, size, mask, anywhere, memory_object, offset, copy, cur_protection, max_protection, inheritance) + mach_port_t target_task; + vm_address_t *address; + vm_size_t size; + vm_address_t mask; + boolean_t anywhere; + mach_port_t memory_object; + vm_offset_t offset; + boolean_t copy; + vm_prot_t cur_protection; + vm_prot_t max_protection; + vm_inherit_t inheritance; +{ return S_vm_map(target_task, address, size, mask, anywhere, memory_object, offset, copy, cur_protection, max_protection, inheritance); } +#else +( + mach_port_t target_task, + vm_address_t *address, + vm_size_t size, + vm_address_t mask, + boolean_t anywhere, + mach_port_t memory_object, + vm_offset_t offset, + boolean_t copy, + vm_prot_t cur_protection, + vm_prot_t max_protection, + vm_inherit_t inheritance +); +#endif + +/* SimpleRoutine memory_object_data_error */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_memory_object_data_error +#if defined(LINTLIBRARY) + (memory_control, offset, size, error_value) + mach_port_t memory_control; + vm_offset_t offset; + vm_size_t size; + kern_return_t error_value; +{ return S_memory_object_data_error(memory_control, offset, size, error_value); } +#else +( + mach_port_t memory_control, + vm_offset_t offset, + vm_size_t size, + kern_return_t error_value +); +#endif + +/* SimpleRoutine memory_object_set_attributes */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_memory_object_set_attributes +#if defined(LINTLIBRARY) + (memory_control, object_ready, may_cache, copy_strategy) + mach_port_t memory_control; + boolean_t object_ready; + boolean_t may_cache; + memory_object_copy_strategy_t copy_strategy; +{ return S_memory_object_set_attributes(memory_control, object_ready, may_cache, copy_strategy); } +#else +( + mach_port_t memory_control, + boolean_t object_ready, + boolean_t may_cache, + memory_object_copy_strategy_t copy_strategy +); +#endif + +/* SimpleRoutine memory_object_destroy */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_memory_object_destroy +#if defined(LINTLIBRARY) + (memory_control, reason) + mach_port_t memory_control; + kern_return_t reason; +{ return S_memory_object_destroy(memory_control, reason); } +#else +( + mach_port_t memory_control, + kern_return_t reason +); +#endif + +/* SimpleRoutine memory_object_data_supply */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_memory_object_data_supply +#if defined(LINTLIBRARY) + (memory_control, offset, data, dataCnt, lock_value, precious, reply_to, reply_toPoly) + mach_port_t memory_control; + vm_offset_t offset; + vm_offset_t data; + mach_msg_type_number_t dataCnt; + vm_prot_t lock_value; + boolean_t precious; + mach_port_t reply_to; + mach_msg_type_name_t reply_toPoly; +{ return S_memory_object_data_supply(memory_control, offset, data, dataCnt, lock_value, precious, reply_to, reply_toPoly); } +#else +( + mach_port_t memory_control, + vm_offset_t offset, + vm_offset_t data, + mach_msg_type_number_t dataCnt, + vm_prot_t lock_value, + boolean_t precious, + mach_port_t reply_to, + mach_msg_type_name_t reply_toPoly +); +#endif + +/* SimpleRoutine memory_object_ready */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_memory_object_ready +#if defined(LINTLIBRARY) + (memory_control, may_cache, copy_strategy) + mach_port_t memory_control; + boolean_t may_cache; + memory_object_copy_strategy_t copy_strategy; +{ return S_memory_object_ready(memory_control, may_cache, copy_strategy); } +#else +( + mach_port_t memory_control, + boolean_t may_cache, + memory_object_copy_strategy_t copy_strategy +); +#endif + +/* SimpleRoutine memory_object_change_attributes */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_memory_object_change_attributes +#if defined(LINTLIBRARY) + (memory_control, may_cache, copy_strategy, reply_to, reply_toPoly) + mach_port_t memory_control; + boolean_t may_cache; + memory_object_copy_strategy_t copy_strategy; + mach_port_t reply_to; + mach_msg_type_name_t reply_toPoly; +{ return S_memory_object_change_attributes(memory_control, may_cache, copy_strategy, reply_to, reply_toPoly); } +#else +( + mach_port_t memory_control, + boolean_t may_cache, + memory_object_copy_strategy_t copy_strategy, + mach_port_t reply_to, + mach_msg_type_name_t reply_toPoly +); +#endif + +/* Routine vm_machine_attribute */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_vm_machine_attribute +#if defined(LINTLIBRARY) + (target_task, address, size, attribute, value) + mach_port_t target_task; + vm_address_t address; + vm_size_t size; + vm_machine_attribute_t attribute; + vm_machine_attribute_val_t *value; +{ return S_vm_machine_attribute(target_task, address, size, attribute, value); } +#else +( + mach_port_t target_task, + vm_address_t address, + vm_size_t size, + vm_machine_attribute_t attribute, + vm_machine_attribute_val_t *value +); +#endif + +#endif /* not defined(_mach_server_) */ diff --git a/boot-proxy-exc/ourmach_host.defs b/boot-proxy-exc/ourmach_host.defs new file mode 100644 index 00000000..c8576ddb --- /dev/null +++ b/boot-proxy-exc/ourmach_host.defs @@ -0,0 +1,381 @@ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989 Carnegie Mellon University. + * Copyright (c) 1993,1994 The University of Utah and + * the Computer Systems Laboratory (CSL). + * 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, THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF + * THIS SOFTWARE IN ITS "AS IS" CONDITION, AND DISCLAIM 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. + */ +/* + * File: mach/mach_host.defs + * + * Abstract: + * Mach host operations support. Includes processor allocation and + * control. + */ + +#ifdef MACH_KERNEL +simport <kern/compat_xxx_defs.h>; /* for obsolete routines */ +#endif + +subsystem +#if KERNEL_SERVER + KernelServer +#endif + mach_host 2600; + +serverprefix S_; + +/* + * Basic types + */ + +#include <mach/std_types.defs> +#include <mach/mach_types.defs> + +/* + * Get list of processors on this host. + */ + +routine host_processors( + host_priv : host_priv_t; + out processor_list : processor_array_t); + +/* obsolete */ +routine yyy_host_info( + host : host_t; + flavor : int; + out host_info_out : host_info_t, IsLong); + + +/* obsolete */ +routine yyy_processor_info( + processor : processor_t; + flavor : int; + out host : host_t; + out processor_info_out: processor_info_t, IsLong); + +/* + * Start processor. + */ + +routine processor_start( + processor : processor_t); + +/* + * Exit processor -- may not be restartable. + */ + +routine processor_exit( + processor : processor_t); + +/* obsolete */ +routine yyy_processor_control( + processor : processor_t; + processor_cmd : processor_info_t, IsLong); + +/* + * Get default processor set for host. + */ +routine processor_set_default( + host : host_t; + out default_set : processor_set_name_t); + +/* + * Get rights to default processor set for host. + * Replaced by host_processor_set_priv. + */ +routine xxx_processor_set_default_priv( + host : host_priv_t; + out default_set : processor_set_t); + +/* + * Create new processor set. Returns real port for manipulations, + * and name port for obtaining information. + */ +routine processor_set_create( + host : host_t; + out new_set : processor_set_t; + out new_name : processor_set_name_t); + +/* + * Destroy processor set. + */ +routine processor_set_destroy( + set : processor_set_t); + +/* obsolete */ +routine yyy_processor_set_info( + set_name : processor_set_name_t; + flavor : int; + out host : host_t; + out info_out : processor_set_info_t, IsLong); + +/* + * Assign processor to processor set. + */ +routine processor_assign( + processor : processor_t; + new_set : processor_set_t; + wait : boolean_t); + +/* + * Get current assignment for processor. + */ + +routine processor_get_assignment( + processor : processor_t; + out assigned_set : processor_set_name_t); + +/* + * Assign thread to processor set. + */ +routine thread_assign( + thread : thread_t; + new_set : processor_set_t); + +/* + * Assign thread to default set. + */ +routine thread_assign_default( + thread : thread_t); + +/* + * Get current assignment for thread. + */ +routine thread_get_assignment( + thread : thread_t; + out assigned_set : processor_set_name_t); + +/* + * Assign task to processor set. + */ +routine task_assign( + task : task_t; + new_set : processor_set_t; + assign_threads : boolean_t); +/* + * Assign task to default set. + */ +routine task_assign_default( + task : task_t; + assign_threads : boolean_t); + +/* + * Get current assignment for task. + */ +routine task_get_assignment( + task : task_t; + out assigned_set : processor_set_name_t); + +/* + * Get string describing current kernel version. + */ +routine host_kernel_version( + host : host_t; + out kernel_version : kernel_version_t); + +/* + * Set priority for thread. + */ +routine thread_priority( + thread : thread_t; + priority : int; + set_max : boolean_t); + +/* + * Set max priority for thread. + */ +routine thread_max_priority( + thread : thread_t; + processor_set : processor_set_t; + max_priority : int); + +/* + * Set task priority. + */ +routine task_priority( + task : task_t; + priority : int; + change_threads : boolean_t); + +/* + * Set max priority for processor_set. + */ +routine processor_set_max_priority( + processor_set : processor_set_t; + max_priority : int; + change_threads : boolean_t); + +/* + * Set policy for thread + */ +routine thread_policy( + thread : thread_t; + policy : int; + data : int); + +/* + * Enable policy for processor set + */ +routine processor_set_policy_enable( + processor_set : processor_set_t; + policy : int); + +/* + * Disable policy for processor set + */ +routine processor_set_policy_disable( + processor_set : processor_set_t; + policy : int; + change_threads : boolean_t); +/* + * List all tasks in processor set. + */ +routine processor_set_tasks( + processor_set : processor_set_t; + out task_list : task_array_t, dealloc); + +/* + * List all threads in processor set. + */ +routine processor_set_threads( + processor_set : processor_set_t; + out thread_list : thread_array_t); + +/* + * List all processor sets on host. + */ +routine host_processor_sets( + host : host_t; + out processor_sets : processor_set_name_array_t); + +/* + * Get control port for a processor set. + */ +routine host_processor_set_priv( + host_priv : host_priv_t; + set_name : processor_set_name_t; + out set : mach_port_send_t); + +routine thread_depress_abort( + thread : thread_t); + +/* + * Set the time on this host. + * Only available to privileged users. + */ +routine host_set_time( + host_priv : host_priv_t; + new_time : time_value_t); + +/* + * Arrange for the time on this host to be gradually changed + * by an adjustment value, and return the old value. + * Only available to privileged users. + */ +routine host_adjust_time( + host_priv : host_priv_t; + in new_adjustment : time_value_t; + out old_adjustment : time_value_t); + +/* + * Get the time on this host. + * Available to all. + */ +routine host_get_time( + host : host_t; + out current_time : time_value_t); + +/* + * Reboot this host. + * Only available to privileged users. + */ +routine host_reboot( + host_priv : host_priv_t; + options : int); + +/* + * Specify that the range of the virtual address space + * of the target task must not cause page faults for + * the indicated accesses. + * + * [ To unwire the pages, specify VM_PROT_NONE. ] + */ +routine vm_wire( + host_priv : host_priv_t; + task : vm_task_t; + address : vm_address_t; + size : vm_size_t; + access : vm_prot_t); + +/* + * Specify that the target thread must always be able + * to run and to allocate memory. + */ +routine thread_wire( + host_priv : host_priv_t; + thread : thread_t; + wired : boolean_t); + +/* + * Return information about this host. + */ + +routine host_info( + host : host_t; + flavor : int; + out host_info_out : host_info_t, CountInOut); + + +/* + * Return information about this processor. + */ +routine processor_info( + processor : processor_t; + flavor : int; + out host : host_t; + out processor_info_out: processor_info_t, CountInOut); + +/* + * Get information about processor set. + */ +routine processor_set_info( + set_name : processor_set_name_t; + flavor : int; + out host : host_t; + out info_out : processor_set_info_t, CountInOut); + +/* + * Do something machine-dependent to processor. + */ +routine processor_control( + processor : processor_t; + processor_cmd : processor_info_t); + +/* + * Get boot configuration information from kernel. + */ +routine host_get_boot_info( + host_priv : host_priv_t; + out boot_info : kernel_boot_info_t); diff --git a/boot-proxy-exc/ourmach_host.sdefs.d b/boot-proxy-exc/ourmach_host.sdefs.d new file mode 100644 index 00000000..250b3700 --- /dev/null +++ b/boot-proxy-exc/ourmach_host.sdefs.d @@ -0,0 +1,3 @@ +ourmach_hostServer.c ourmach_host_S.h: ourmach_host.defs /usr/local/include/mach/std_types.defs \ + /usr/local/include/mach/machine/machine_types.defs \ + /usr/local/include/mach/mach_types.defs diff --git a/boot-proxy-exc/ourmach_hostServer.c b/boot-proxy-exc/ourmach_hostServer.c new file mode 100644 index 00000000..4ede0429 --- /dev/null +++ b/boot-proxy-exc/ourmach_hostServer.c @@ -0,0 +1,2596 @@ +/* Module mach_host */ + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE 1 +#endif + +#define EXPORT_BOOLEAN +#include <mach/boolean.h> +#include <mach/kern_return.h> +#include <mach/message.h> +#include <mach/mig_errors.h> +#include <mach/mig_support.h> + +#ifndef mig_internal +#define mig_internal static +#endif + +#ifndef mig_external +#define mig_external +#endif + +#ifndef TypeCheck +#define TypeCheck 1 +#endif + +#ifndef UseExternRCSId +#define UseExternRCSId 1 +#endif + +#define BAD_TYPECHECK(type, check) ({\ + union { mach_msg_type_t t; unsigned32_t w; } _t, _c;\ + _t.t = *(type); _c.t = *(check); _t.w != _c.w; }) +#define msgh_request_port msgh_local_port +#define MACH_MSGH_BITS_REQUEST(bits) MACH_MSGH_BITS_LOCAL(bits) +#define msgh_reply_port msgh_remote_port +#define MACH_MSGH_BITS_REPLY(bits) MACH_MSGH_BITS_REMOTE(bits) + +#include <mach/std_types.h> +#include <mach/mach_types.h> + +/* Routine host_processors */ +mig_internal void _Xhost_processors + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_long_t processor_listType; + processor_array_t processor_list; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_host_processors + (mach_port_t host_priv, processor_array_t *processor_list, mach_msg_type_number_t *processor_listCnt); + + auto const mach_msg_type_long_t processor_listType = { + { + /* msgt_name = */ 0, + /* msgt_size = */ 0, + /* msgt_number = */ 0, + /* msgt_inline = */ FALSE, + /* msgt_longform = */ TRUE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }, + /* msgtl_name = */ 19, + /* msgtl_size = */ 32, + /* msgtl_number = */ 0, + }; + + mach_msg_type_number_t processor_listCnt; + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_host_processors(In0P->Head.msgh_request_port, &OutP->processor_list, &processor_listCnt); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; + OutP->Head.msgh_size = 48; + + OutP->processor_listType = processor_listType; + + OutP->processor_listType.msgtl_number = processor_listCnt; +} + +/* Routine yyy_host_info */ +mig_internal void _Xyyy_host_info + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t flavorType; + int flavor; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_long_t host_info_outType; + natural_t host_info_out[1024]; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_yyy_host_info + (mach_port_t host, int flavor, host_info_t host_info_out, mach_msg_type_number_t *host_info_outCnt); + + auto const mach_msg_type_t flavorCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_long_t host_info_outType = { + { + /* msgt_name = */ 0, + /* msgt_size = */ 0, + /* msgt_number = */ 0, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ TRUE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }, + /* msgtl_name = */ 2, + /* msgtl_size = */ 32, + /* msgtl_number = */ 1024, + }; + + mach_msg_type_number_t host_info_outCnt; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->flavorType, &flavorCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + host_info_outCnt = 1024; + + OutP->RetCode = S_yyy_host_info(In0P->Head.msgh_request_port, In0P->flavor, OutP->host_info_out, &host_info_outCnt); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->host_info_outType = host_info_outType; + + OutP->host_info_outType.msgtl_number = host_info_outCnt; + OutP->Head.msgh_size = 44 + (4 * host_info_outCnt); +} + +/* Routine yyy_processor_info */ +mig_internal void _Xyyy_processor_info + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t flavorType; + int flavor; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t hostType; + mach_port_t host; + mach_msg_type_long_t processor_info_outType; + natural_t processor_info_out[1024]; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_yyy_processor_info + (mach_port_t processor, int flavor, mach_port_t *host, processor_info_t processor_info_out, mach_msg_type_number_t *processor_info_outCnt); + + auto const mach_msg_type_t flavorCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t hostType = { + /* msgt_name = */ 19, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_long_t processor_info_outType = { + { + /* msgt_name = */ 0, + /* msgt_size = */ 0, + /* msgt_number = */ 0, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ TRUE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }, + /* msgtl_name = */ 2, + /* msgtl_size = */ 32, + /* msgtl_number = */ 1024, + }; + + mach_msg_type_number_t processor_info_outCnt; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->flavorType, &flavorCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + processor_info_outCnt = 1024; + + OutP->RetCode = S_yyy_processor_info(In0P->Head.msgh_request_port, In0P->flavor, &OutP->host, OutP->processor_info_out, &processor_info_outCnt); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; + + OutP->hostType = hostType; + + OutP->processor_info_outType = processor_info_outType; + + OutP->processor_info_outType.msgtl_number = processor_info_outCnt; + OutP->Head.msgh_size = 52 + (4 * processor_info_outCnt); +} + +/* Routine processor_start */ +mig_internal void _Xprocessor_start + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_processor_start + (mach_port_t processor); + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_processor_start(In0P->Head.msgh_request_port); +} + +/* Routine processor_exit */ +mig_internal void _Xprocessor_exit + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_processor_exit + (mach_port_t processor); + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_processor_exit(In0P->Head.msgh_request_port); +} + +/* Routine yyy_processor_control */ +mig_internal void _Xyyy_processor_control + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_long_t processor_cmdType; + natural_t processor_cmd[1024]; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_yyy_processor_control + (mach_port_t processor, processor_info_t processor_cmd, mach_msg_type_number_t processor_cmdCnt); + + unsigned int msgh_size; + +#if TypeCheck + msgh_size = In0P->Head.msgh_size; + if ((msgh_size < 36) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if ((In0P->processor_cmdType.msgtl_header.msgt_inline != TRUE) || + (In0P->processor_cmdType.msgtl_header.msgt_longform != TRUE) || + (In0P->processor_cmdType.msgtl_name != 2) || + (In0P->processor_cmdType.msgtl_size != 32)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (msgh_size != 36 + (4 * In0P->processor_cmdType.msgtl_number)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_yyy_processor_control(In0P->Head.msgh_request_port, In0P->processor_cmd, In0P->processor_cmdType.msgtl_number); +} + +/* Routine processor_set_default */ +mig_internal void _Xprocessor_set_default + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t default_setType; + mach_port_t default_set; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_processor_set_default + (mach_port_t host, mach_port_t *default_set); + + auto const mach_msg_type_t default_setType = { + /* msgt_name = */ 19, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_processor_set_default(In0P->Head.msgh_request_port, &OutP->default_set); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; + OutP->Head.msgh_size = 40; + + OutP->default_setType = default_setType; +} + +/* Routine xxx_processor_set_default_priv */ +mig_internal void _Xxxx_processor_set_default_priv + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t default_setType; + mach_port_t default_set; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_xxx_processor_set_default_priv + (mach_port_t host, mach_port_t *default_set); + + auto const mach_msg_type_t default_setType = { + /* msgt_name = */ 19, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_xxx_processor_set_default_priv(In0P->Head.msgh_request_port, &OutP->default_set); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; + OutP->Head.msgh_size = 40; + + OutP->default_setType = default_setType; +} + +/* Routine processor_set_create */ +mig_internal void _Xprocessor_set_create + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t new_setType; + mach_port_t new_set; + mach_msg_type_t new_nameType; + mach_port_t new_name; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_processor_set_create + (mach_port_t host, mach_port_t *new_set, mach_port_t *new_name); + + auto const mach_msg_type_t new_setType = { + /* msgt_name = */ 19, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t new_nameType = { + /* msgt_name = */ 19, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_processor_set_create(In0P->Head.msgh_request_port, &OutP->new_set, &OutP->new_name); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; + OutP->Head.msgh_size = 48; + + OutP->new_setType = new_setType; + + OutP->new_nameType = new_nameType; +} + +/* Routine processor_set_destroy */ +mig_internal void _Xprocessor_set_destroy + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_processor_set_destroy + (mach_port_t set); + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_processor_set_destroy(In0P->Head.msgh_request_port); +} + +/* Routine yyy_processor_set_info */ +mig_internal void _Xyyy_processor_set_info + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t flavorType; + int flavor; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t hostType; + mach_port_t host; + mach_msg_type_long_t info_outType; + natural_t info_out[1024]; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_yyy_processor_set_info + (mach_port_t set_name, int flavor, mach_port_t *host, processor_set_info_t info_out, mach_msg_type_number_t *info_outCnt); + + auto const mach_msg_type_t flavorCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t hostType = { + /* msgt_name = */ 19, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_long_t info_outType = { + { + /* msgt_name = */ 0, + /* msgt_size = */ 0, + /* msgt_number = */ 0, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ TRUE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }, + /* msgtl_name = */ 2, + /* msgtl_size = */ 32, + /* msgtl_number = */ 1024, + }; + + mach_msg_type_number_t info_outCnt; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->flavorType, &flavorCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + info_outCnt = 1024; + + OutP->RetCode = S_yyy_processor_set_info(In0P->Head.msgh_request_port, In0P->flavor, &OutP->host, OutP->info_out, &info_outCnt); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; + + OutP->hostType = hostType; + + OutP->info_outType = info_outType; + + OutP->info_outType.msgtl_number = info_outCnt; + OutP->Head.msgh_size = 52 + (4 * info_outCnt); +} + +/* Routine processor_assign */ +mig_internal void _Xprocessor_assign + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t new_setType; + mach_port_t new_set; + mach_msg_type_t waitType; + boolean_t wait; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_processor_assign + (mach_port_t processor, mach_port_t new_set, boolean_t wait); + + auto const mach_msg_type_t new_setCheck = { + /* msgt_name = */ 17, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t waitCheck = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->new_setType, &new_setCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->waitType, &waitCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_processor_assign(In0P->Head.msgh_request_port, In0P->new_set, In0P->wait); +} + +/* Routine processor_get_assignment */ +mig_internal void _Xprocessor_get_assignment + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t assigned_setType; + mach_port_t assigned_set; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_processor_get_assignment + (mach_port_t processor, mach_port_t *assigned_set); + + auto const mach_msg_type_t assigned_setType = { + /* msgt_name = */ 19, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_processor_get_assignment(In0P->Head.msgh_request_port, &OutP->assigned_set); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; + OutP->Head.msgh_size = 40; + + OutP->assigned_setType = assigned_setType; +} + +/* Routine thread_assign */ +mig_internal void _Xthread_assign + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t new_setType; + mach_port_t new_set; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_thread_assign + (mach_port_t thread, mach_port_t new_set); + + auto const mach_msg_type_t new_setCheck = { + /* msgt_name = */ 17, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->new_setType, &new_setCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_thread_assign(In0P->Head.msgh_request_port, In0P->new_set); +} + +/* Routine thread_assign_default */ +mig_internal void _Xthread_assign_default + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_thread_assign_default + (mach_port_t thread); + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_thread_assign_default(In0P->Head.msgh_request_port); +} + +/* Routine thread_get_assignment */ +mig_internal void _Xthread_get_assignment + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t assigned_setType; + mach_port_t assigned_set; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_thread_get_assignment + (mach_port_t thread, mach_port_t *assigned_set); + + auto const mach_msg_type_t assigned_setType = { + /* msgt_name = */ 19, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_thread_get_assignment(In0P->Head.msgh_request_port, &OutP->assigned_set); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; + OutP->Head.msgh_size = 40; + + OutP->assigned_setType = assigned_setType; +} + +/* Routine task_assign */ +mig_internal void _Xtask_assign + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t new_setType; + mach_port_t new_set; + mach_msg_type_t assign_threadsType; + boolean_t assign_threads; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_task_assign + (mach_port_t task, mach_port_t new_set, boolean_t assign_threads); + + auto const mach_msg_type_t new_setCheck = { + /* msgt_name = */ 17, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t assign_threadsCheck = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->new_setType, &new_setCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->assign_threadsType, &assign_threadsCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_task_assign(In0P->Head.msgh_request_port, In0P->new_set, In0P->assign_threads); +} + +/* Routine task_assign_default */ +mig_internal void _Xtask_assign_default + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t assign_threadsType; + boolean_t assign_threads; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_task_assign_default + (mach_port_t task, boolean_t assign_threads); + + auto const mach_msg_type_t assign_threadsCheck = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->assign_threadsType, &assign_threadsCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_task_assign_default(In0P->Head.msgh_request_port, In0P->assign_threads); +} + +/* Routine task_get_assignment */ +mig_internal void _Xtask_get_assignment + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t assigned_setType; + mach_port_t assigned_set; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_task_get_assignment + (mach_port_t task, mach_port_t *assigned_set); + + auto const mach_msg_type_t assigned_setType = { + /* msgt_name = */ 19, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_task_get_assignment(In0P->Head.msgh_request_port, &OutP->assigned_set); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; + OutP->Head.msgh_size = 40; + + OutP->assigned_setType = assigned_setType; +} + +/* Routine host_kernel_version */ +mig_internal void _Xhost_kernel_version + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_long_t kernel_versionType; + kernel_version_t kernel_version; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_host_kernel_version + (mach_port_t host, kernel_version_t kernel_version); + + auto const mach_msg_type_long_t kernel_versionType = { + { + /* msgt_name = */ 0, + /* msgt_size = */ 0, + /* msgt_number = */ 0, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ TRUE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }, + /* msgtl_name = */ 12, + /* msgtl_size = */ 4096, + /* msgtl_number = */ 1, + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_host_kernel_version(In0P->Head.msgh_request_port, OutP->kernel_version); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_size = 556; + + OutP->kernel_versionType = kernel_versionType; +} + +/* Routine thread_priority */ +mig_internal void _Xthread_priority + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t priorityType; + int priority; + mach_msg_type_t set_maxType; + boolean_t set_max; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_thread_priority + (mach_port_t thread, int priority, boolean_t set_max); + + auto const mach_msg_type_t priorityCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t set_maxCheck = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->priorityType, &priorityCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->set_maxType, &set_maxCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_thread_priority(In0P->Head.msgh_request_port, In0P->priority, In0P->set_max); +} + +/* Routine thread_max_priority */ +mig_internal void _Xthread_max_priority + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t processor_setType; + mach_port_t processor_set; + mach_msg_type_t max_priorityType; + int max_priority; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_thread_max_priority + (mach_port_t thread, mach_port_t processor_set, int max_priority); + + auto const mach_msg_type_t processor_setCheck = { + /* msgt_name = */ 17, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t max_priorityCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->processor_setType, &processor_setCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->max_priorityType, &max_priorityCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_thread_max_priority(In0P->Head.msgh_request_port, In0P->processor_set, In0P->max_priority); +} + +/* Routine task_priority */ +mig_internal void _Xtask_priority + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t priorityType; + int priority; + mach_msg_type_t change_threadsType; + boolean_t change_threads; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_task_priority + (mach_port_t task, int priority, boolean_t change_threads); + + auto const mach_msg_type_t priorityCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t change_threadsCheck = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->priorityType, &priorityCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->change_threadsType, &change_threadsCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_task_priority(In0P->Head.msgh_request_port, In0P->priority, In0P->change_threads); +} + +/* Routine processor_set_max_priority */ +mig_internal void _Xprocessor_set_max_priority + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t max_priorityType; + int max_priority; + mach_msg_type_t change_threadsType; + boolean_t change_threads; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_processor_set_max_priority + (mach_port_t processor_set, int max_priority, boolean_t change_threads); + + auto const mach_msg_type_t max_priorityCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t change_threadsCheck = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->max_priorityType, &max_priorityCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->change_threadsType, &change_threadsCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_processor_set_max_priority(In0P->Head.msgh_request_port, In0P->max_priority, In0P->change_threads); +} + +/* Routine thread_policy */ +mig_internal void _Xthread_policy + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t policyType; + int policy; + mach_msg_type_t dataType; + int data; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_thread_policy + (mach_port_t thread, int policy, int data); + + auto const mach_msg_type_t policyCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t dataCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->policyType, &policyCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->dataType, &dataCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_thread_policy(In0P->Head.msgh_request_port, In0P->policy, In0P->data); +} + +/* Routine processor_set_policy_enable */ +mig_internal void _Xprocessor_set_policy_enable + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t policyType; + int policy; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_processor_set_policy_enable + (mach_port_t processor_set, int policy); + + auto const mach_msg_type_t policyCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->policyType, &policyCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_processor_set_policy_enable(In0P->Head.msgh_request_port, In0P->policy); +} + +/* Routine processor_set_policy_disable */ +mig_internal void _Xprocessor_set_policy_disable + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t policyType; + int policy; + mach_msg_type_t change_threadsType; + boolean_t change_threads; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_processor_set_policy_disable + (mach_port_t processor_set, int policy, boolean_t change_threads); + + auto const mach_msg_type_t policyCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t change_threadsCheck = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->policyType, &policyCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->change_threadsType, &change_threadsCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_processor_set_policy_disable(In0P->Head.msgh_request_port, In0P->policy, In0P->change_threads); +} + +/* Routine processor_set_tasks */ +mig_internal void _Xprocessor_set_tasks + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_long_t task_listType; + task_array_t task_list; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_processor_set_tasks + (mach_port_t processor_set, task_array_t *task_list, mach_msg_type_number_t *task_listCnt); + + auto const mach_msg_type_long_t task_listType = { + { + /* msgt_name = */ 0, + /* msgt_size = */ 0, + /* msgt_number = */ 0, + /* msgt_inline = */ FALSE, + /* msgt_longform = */ TRUE, + /* msgt_deallocate = */ TRUE, + /* msgt_unused = */ 0 + }, + /* msgtl_name = */ 19, + /* msgtl_size = */ 32, + /* msgtl_number = */ 0, + }; + + mach_msg_type_number_t task_listCnt; + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_processor_set_tasks(In0P->Head.msgh_request_port, &OutP->task_list, &task_listCnt); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; + OutP->Head.msgh_size = 48; + + OutP->task_listType = task_listType; + + OutP->task_listType.msgtl_number = task_listCnt; +} + +/* Routine processor_set_threads */ +mig_internal void _Xprocessor_set_threads + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_long_t thread_listType; + thread_array_t thread_list; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_processor_set_threads + (mach_port_t processor_set, thread_array_t *thread_list, mach_msg_type_number_t *thread_listCnt); + + auto const mach_msg_type_long_t thread_listType = { + { + /* msgt_name = */ 0, + /* msgt_size = */ 0, + /* msgt_number = */ 0, + /* msgt_inline = */ FALSE, + /* msgt_longform = */ TRUE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }, + /* msgtl_name = */ 19, + /* msgtl_size = */ 32, + /* msgtl_number = */ 0, + }; + + mach_msg_type_number_t thread_listCnt; + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_processor_set_threads(In0P->Head.msgh_request_port, &OutP->thread_list, &thread_listCnt); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; + OutP->Head.msgh_size = 48; + + OutP->thread_listType = thread_listType; + + OutP->thread_listType.msgtl_number = thread_listCnt; +} + +/* Routine host_processor_sets */ +mig_internal void _Xhost_processor_sets + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_long_t processor_setsType; + processor_set_name_array_t processor_sets; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_host_processor_sets + (mach_port_t host, processor_set_name_array_t *processor_sets, mach_msg_type_number_t *processor_setsCnt); + + auto const mach_msg_type_long_t processor_setsType = { + { + /* msgt_name = */ 0, + /* msgt_size = */ 0, + /* msgt_number = */ 0, + /* msgt_inline = */ FALSE, + /* msgt_longform = */ TRUE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }, + /* msgtl_name = */ 19, + /* msgtl_size = */ 32, + /* msgtl_number = */ 0, + }; + + mach_msg_type_number_t processor_setsCnt; + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_host_processor_sets(In0P->Head.msgh_request_port, &OutP->processor_sets, &processor_setsCnt); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; + OutP->Head.msgh_size = 48; + + OutP->processor_setsType = processor_setsType; + + OutP->processor_setsType.msgtl_number = processor_setsCnt; +} + +/* Routine host_processor_set_priv */ +mig_internal void _Xhost_processor_set_priv + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t set_nameType; + mach_port_t set_name; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t setType; + mach_port_t set; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_host_processor_set_priv + (mach_port_t host_priv, mach_port_t set_name, mach_port_t *set, mach_msg_type_name_t *setPoly); + + boolean_t msgh_simple; + auto const mach_msg_type_t set_nameCheck = { + /* msgt_name = */ 17, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t setType = { + /* msgt_name = */ -1, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + mach_msg_type_name_t setPoly; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->set_nameType, &set_nameCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_host_processor_set_priv(In0P->Head.msgh_request_port, In0P->set_name, &OutP->set, &setPoly); + if (OutP->RetCode != KERN_SUCCESS) + return; + + msgh_simple = TRUE; + OutP->Head.msgh_size = 40; + + OutP->setType = setType; + + if (MACH_MSG_TYPE_PORT_ANY(setPoly)) + msgh_simple = FALSE; + + OutP->setType.msgt_name = setPoly; + + if (!msgh_simple) + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; +} + +/* Routine thread_depress_abort */ +mig_internal void _Xthread_depress_abort + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_thread_depress_abort + (mach_port_t thread); + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_thread_depress_abort(In0P->Head.msgh_request_port); +} + +/* Routine host_set_time */ +mig_internal void _Xhost_set_time + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t new_timeType; + time_value_t new_time; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_host_set_time + (mach_port_t host_priv, time_value_t new_time); + + auto const mach_msg_type_t new_timeCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 2, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 36) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->new_timeType, &new_timeCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_host_set_time(In0P->Head.msgh_request_port, In0P->new_time); +} + +/* Routine host_adjust_time */ +mig_internal void _Xhost_adjust_time + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t new_adjustmentType; + time_value_t new_adjustment; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t old_adjustmentType; + time_value_t old_adjustment; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_host_adjust_time + (mach_port_t host_priv, time_value_t new_adjustment, time_value_t *old_adjustment); + + auto const mach_msg_type_t new_adjustmentCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 2, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t old_adjustmentType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 2, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 36) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->new_adjustmentType, &new_adjustmentCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_host_adjust_time(In0P->Head.msgh_request_port, In0P->new_adjustment, &OutP->old_adjustment); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_size = 44; + + OutP->old_adjustmentType = old_adjustmentType; +} + +/* Routine host_get_time */ +mig_internal void _Xhost_get_time + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t current_timeType; + time_value_t current_time; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_host_get_time + (mach_port_t host, time_value_t *current_time); + + auto const mach_msg_type_t current_timeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 2, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_host_get_time(In0P->Head.msgh_request_port, &OutP->current_time); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_size = 44; + + OutP->current_timeType = current_timeType; +} + +/* Routine host_reboot */ +mig_internal void _Xhost_reboot + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t optionsType; + int options; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_host_reboot + (mach_port_t host_priv, int options); + + auto const mach_msg_type_t optionsCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->optionsType, &optionsCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_host_reboot(In0P->Head.msgh_request_port, In0P->options); +} + +/* Routine vm_wire */ +mig_internal void _Xvm_wire + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t taskType; + mach_port_t task; + mach_msg_type_t addressType; + vm_address_t address; + mach_msg_type_t sizeType; + vm_size_t size; + mach_msg_type_t accessType; + vm_prot_t access; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_vm_wire + (mach_port_t host_priv, mach_port_t task, vm_address_t address, vm_size_t size, vm_prot_t access); + + auto const mach_msg_type_t taskCheck = { + /* msgt_name = */ 17, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t addressCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t sizeCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t accessCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 56) || + !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->taskType, &taskCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->addressType, &addressCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->sizeType, &sizeCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->accessType, &accessCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_vm_wire(In0P->Head.msgh_request_port, In0P->task, In0P->address, In0P->size, In0P->access); +} + +/* Routine thread_wire */ +mig_internal void _Xthread_wire + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t threadType; + mach_port_t thread; + mach_msg_type_t wiredType; + boolean_t wired; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_thread_wire + (mach_port_t host_priv, mach_port_t thread, boolean_t wired); + + auto const mach_msg_type_t threadCheck = { + /* msgt_name = */ 17, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t wiredCheck = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->threadType, &threadCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->wiredType, &wiredCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_thread_wire(In0P->Head.msgh_request_port, In0P->thread, In0P->wired); +} + +/* Routine host_info */ +mig_internal void _Xhost_info + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t flavorType; + int flavor; + mach_msg_type_t host_info_outCntType; + mach_msg_type_number_t host_info_outCnt; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t host_info_outType; + natural_t host_info_out[1024]; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_host_info + (mach_port_t host, int flavor, host_info_t host_info_out, mach_msg_type_number_t *host_info_outCnt); + + auto const mach_msg_type_t flavorCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t host_info_outCntCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t host_info_outType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1024, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + mach_msg_type_number_t host_info_outCnt; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->flavorType, &flavorCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->host_info_outCntType, &host_info_outCntCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + host_info_outCnt = 1024; + if (In0P->host_info_outCnt < host_info_outCnt) + host_info_outCnt = In0P->host_info_outCnt; + + OutP->RetCode = S_host_info(In0P->Head.msgh_request_port, In0P->flavor, OutP->host_info_out, &host_info_outCnt); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->host_info_outType = host_info_outType; + + OutP->host_info_outType.msgt_number = host_info_outCnt; + OutP->Head.msgh_size = 36 + (4 * host_info_outCnt); +} + +/* Routine processor_info */ +mig_internal void _Xprocessor_info + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t flavorType; + int flavor; + mach_msg_type_t processor_info_outCntType; + mach_msg_type_number_t processor_info_outCnt; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t hostType; + mach_port_t host; + mach_msg_type_t processor_info_outType; + natural_t processor_info_out[1024]; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_processor_info + (mach_port_t processor, int flavor, mach_port_t *host, processor_info_t processor_info_out, mach_msg_type_number_t *processor_info_outCnt); + + auto const mach_msg_type_t flavorCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t processor_info_outCntCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t hostType = { + /* msgt_name = */ 19, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t processor_info_outType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1024, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + mach_msg_type_number_t processor_info_outCnt; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->flavorType, &flavorCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->processor_info_outCntType, &processor_info_outCntCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + processor_info_outCnt = 1024; + if (In0P->processor_info_outCnt < processor_info_outCnt) + processor_info_outCnt = In0P->processor_info_outCnt; + + OutP->RetCode = S_processor_info(In0P->Head.msgh_request_port, In0P->flavor, &OutP->host, OutP->processor_info_out, &processor_info_outCnt); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; + + OutP->hostType = hostType; + + OutP->processor_info_outType = processor_info_outType; + + OutP->processor_info_outType.msgt_number = processor_info_outCnt; + OutP->Head.msgh_size = 44 + (4 * processor_info_outCnt); +} + +/* Routine processor_set_info */ +mig_internal void _Xprocessor_set_info + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t flavorType; + int flavor; + mach_msg_type_t info_outCntType; + mach_msg_type_number_t info_outCnt; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t hostType; + mach_port_t host; + mach_msg_type_t info_outType; + natural_t info_out[1024]; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_processor_set_info + (mach_port_t set_name, int flavor, mach_port_t *host, processor_set_info_t info_out, mach_msg_type_number_t *info_outCnt); + + auto const mach_msg_type_t flavorCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t info_outCntCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t hostType = { + /* msgt_name = */ 19, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t info_outType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1024, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + mach_msg_type_number_t info_outCnt; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->flavorType, &flavorCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->info_outCntType, &info_outCntCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + info_outCnt = 1024; + if (In0P->info_outCnt < info_outCnt) + info_outCnt = In0P->info_outCnt; + + OutP->RetCode = S_processor_set_info(In0P->Head.msgh_request_port, In0P->flavor, &OutP->host, OutP->info_out, &info_outCnt); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; + + OutP->hostType = hostType; + + OutP->info_outType = info_outType; + + OutP->info_outType.msgt_number = info_outCnt; + OutP->Head.msgh_size = 44 + (4 * info_outCnt); +} + +/* Routine processor_control */ +mig_internal void _Xprocessor_control + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t processor_cmdType; + natural_t processor_cmd[1024]; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_processor_control + (mach_port_t processor, processor_info_t processor_cmd, mach_msg_type_number_t processor_cmdCnt); + + unsigned int msgh_size; + +#if TypeCheck + msgh_size = In0P->Head.msgh_size; + if ((msgh_size < 28) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if ((In0P->processor_cmdType.msgt_inline != TRUE) || + (In0P->processor_cmdType.msgt_longform != FALSE) || + (In0P->processor_cmdType.msgt_name != 2) || + (In0P->processor_cmdType.msgt_size != 32)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (msgh_size != 28 + (4 * In0P->processor_cmdType.msgt_number)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_processor_control(In0P->Head.msgh_request_port, In0P->processor_cmd, In0P->processor_cmdType.msgt_number); +} + +/* Routine host_get_boot_info */ +mig_internal void _Xhost_get_boot_info + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_long_t boot_infoType; + kernel_boot_info_t boot_info; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_host_get_boot_info + (mach_port_t host_priv, kernel_boot_info_t boot_info); + + auto const mach_msg_type_long_t boot_infoType = { + { + /* msgt_name = */ 0, + /* msgt_size = */ 0, + /* msgt_number = */ 0, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ TRUE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }, + /* msgtl_name = */ 12, + /* msgtl_size = */ 32768, + /* msgtl_number = */ 1, + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_host_get_boot_info(In0P->Head.msgh_request_port, OutP->boot_info); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_size = 4140; + + OutP->boot_infoType = boot_infoType; +} + +static mig_routine_t mach_host_server_routines[] = { + _Xhost_processors, + _Xyyy_host_info, + _Xyyy_processor_info, + _Xprocessor_start, + _Xprocessor_exit, + _Xyyy_processor_control, + _Xprocessor_set_default, + _Xxxx_processor_set_default_priv, + _Xprocessor_set_create, + _Xprocessor_set_destroy, + _Xyyy_processor_set_info, + _Xprocessor_assign, + _Xprocessor_get_assignment, + _Xthread_assign, + _Xthread_assign_default, + _Xthread_get_assignment, + _Xtask_assign, + _Xtask_assign_default, + _Xtask_get_assignment, + _Xhost_kernel_version, + _Xthread_priority, + _Xthread_max_priority, + _Xtask_priority, + _Xprocessor_set_max_priority, + _Xthread_policy, + _Xprocessor_set_policy_enable, + _Xprocessor_set_policy_disable, + _Xprocessor_set_tasks, + _Xprocessor_set_threads, + _Xhost_processor_sets, + _Xhost_processor_set_priv, + _Xthread_depress_abort, + _Xhost_set_time, + _Xhost_adjust_time, + _Xhost_get_time, + _Xhost_reboot, + _Xvm_wire, + _Xthread_wire, + _Xhost_info, + _Xprocessor_info, + _Xprocessor_set_info, + _Xprocessor_control, + _Xhost_get_boot_info, +}; + +mig_external boolean_t mach_host_server + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + register mach_msg_header_t *InP = InHeadP; + register mig_reply_header_t *OutP = (mig_reply_header_t *) OutHeadP; + + auto const mach_msg_type_t RetCodeType = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + register mig_routine_t routine; + + OutP->Head.msgh_bits = MACH_MSGH_BITS(MACH_MSGH_BITS_REPLY(InP->msgh_bits), 0); + OutP->Head.msgh_size = sizeof *OutP; + OutP->Head.msgh_remote_port = InP->msgh_reply_port; + OutP->Head.msgh_local_port = MACH_PORT_NULL; + OutP->Head.msgh_seqno = 0; + OutP->Head.msgh_id = InP->msgh_id + 100; + + OutP->RetCodeType = RetCodeType; + + if ((InP->msgh_id > 2642) || (InP->msgh_id < 2600) || + ((routine = mach_host_server_routines[InP->msgh_id - 2600]) == 0)) { + OutP->RetCode = MIG_BAD_ID; + return FALSE; + } + (*routine) (InP, &OutP->Head); + return TRUE; +} + +mig_external mig_routine_t mach_host_server_routine + (const mach_msg_header_t *InHeadP) +{ + register int msgh_id; + + msgh_id = InHeadP->msgh_id - 2600; + + if ((msgh_id > 42) || (msgh_id < 0)) + return 0; + + return mach_host_server_routines[msgh_id]; +} + diff --git a/boot-proxy-exc/ourmach_hostServer.d b/boot-proxy-exc/ourmach_hostServer.d new file mode 100644 index 00000000..d4224670 --- /dev/null +++ b/boot-proxy-exc/ourmach_hostServer.d @@ -0,0 +1,45 @@ +ourmach_hostServer.o ourmach_hostServer_pic.o ourmach_hostServer_p.o ourmach_hostServer.d: ourmach_hostServer.c \ + /usr/local/include/mach/boolean.h \ + /usr/local/include/mach/machine/boolean.h \ + /usr/local/include/mach/kern_return.h \ + /usr/local/include/mach/machine/kern_return.h \ + /usr/local/include/mach/message.h /usr/local/include/mach/port.h \ + /usr/local/include/mach/machine/vm_types.h \ + /usr/local/include/mach/mig_errors.h /usr/include/mach/mig_support.h \ + /usr/local/include/mach/std_types.h /usr/include/sys/types.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h /usr/include/gnu/stubs-pthread.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/time.h /usr/lib/gcc/i486-gnu/4.2.4/include/stddef.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/bits/byteswap.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/pthread/pthreadtypes.h \ + /usr/include/xlocale.h /usr/include/bits/pthread.h \ + /usr/include/bits/thread-attr.h /usr/include/sched.h \ + /usr/include/bits/sched.h /usr/include/bits/mutex-attr.h \ + /usr/include/bits/mutex.h /usr/include/bits/spin-lock.h \ + /usr/include/bits/condition-attr.h /usr/include/bits/condition.h \ + /usr/include/bits/rwlock-attr.h /usr/include/bits/rwlock.h \ + /usr/include/bits/barrier-attr.h /usr/include/bits/barrier.h \ + /usr/include/bits/thread-specific.h /usr/include/bits/once.h \ + /usr/include/string.h /usr/include/bits/string.h \ + /usr/include/bits/string2.h /usr/include/stdlib.h \ + /usr/local/include/mach/mach_types.h \ + /usr/local/include/mach/host_info.h /usr/local/include/mach/machine.h \ + /usr/local/include/mach/memory_object.h \ + /usr/local/include/mach/pc_sample.h \ + /usr/local/include/mach/processor_info.h \ + /usr/local/include/mach/task_info.h \ + /usr/local/include/mach/time_value.h \ + /usr/local/include/mach/task_special_ports.h \ + /usr/local/include/mach/thread_info.h /usr/local/include/mach/policy.h \ + /usr/local/include/mach/thread_special_ports.h \ + /usr/local/include/mach/thread_status.h \ + /usr/local/include/mach/machine/thread_status.h \ + /usr/local/include/mach/machine/fp_reg.h \ + /usr/local/include/mach/vm_attributes.h \ + /usr/local/include/mach/vm_inherit.h /usr/local/include/mach/vm_prot.h \ + /usr/local/include/mach/vm_statistics.h diff --git a/boot-proxy-exc/ourmach_hostServer.o b/boot-proxy-exc/ourmach_hostServer.o Binary files differnew file mode 100644 index 00000000..2cc768aa --- /dev/null +++ b/boot-proxy-exc/ourmach_hostServer.o diff --git a/boot-proxy-exc/ourmach_host_S.h b/boot-proxy-exc/ourmach_host_S.h new file mode 100644 index 00000000..7c962cbb --- /dev/null +++ b/boot-proxy-exc/ourmach_host_S.h @@ -0,0 +1,896 @@ +#ifndef _mach_host_server_ +#define _mach_host_server_ + +/* Module mach_host */ + +#include <mach/kern_return.h> +#include <mach/port.h> +#include <mach/message.h> + +#include <mach/std_types.h> +#include <mach/mach_types.h> + +/* Routine host_processors */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_host_processors +#if defined(LINTLIBRARY) + (host_priv, processor_list, processor_listCnt) + mach_port_t host_priv; + processor_array_t *processor_list; + mach_msg_type_number_t *processor_listCnt; +{ return S_host_processors(host_priv, processor_list, processor_listCnt); } +#else +( + mach_port_t host_priv, + processor_array_t *processor_list, + mach_msg_type_number_t *processor_listCnt +); +#endif + +/* Routine yyy_host_info */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_yyy_host_info +#if defined(LINTLIBRARY) + (host, flavor, host_info_out, host_info_outCnt) + mach_port_t host; + int flavor; + host_info_t host_info_out; + mach_msg_type_number_t *host_info_outCnt; +{ return S_yyy_host_info(host, flavor, host_info_out, host_info_outCnt); } +#else +( + mach_port_t host, + int flavor, + host_info_t host_info_out, + mach_msg_type_number_t *host_info_outCnt +); +#endif + +/* Routine yyy_processor_info */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_yyy_processor_info +#if defined(LINTLIBRARY) + (processor, flavor, host, processor_info_out, processor_info_outCnt) + mach_port_t processor; + int flavor; + mach_port_t *host; + processor_info_t processor_info_out; + mach_msg_type_number_t *processor_info_outCnt; +{ return S_yyy_processor_info(processor, flavor, host, processor_info_out, processor_info_outCnt); } +#else +( + mach_port_t processor, + int flavor, + mach_port_t *host, + processor_info_t processor_info_out, + mach_msg_type_number_t *processor_info_outCnt +); +#endif + +/* Routine processor_start */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_processor_start +#if defined(LINTLIBRARY) + (processor) + mach_port_t processor; +{ return S_processor_start(processor); } +#else +( + mach_port_t processor +); +#endif + +/* Routine processor_exit */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_processor_exit +#if defined(LINTLIBRARY) + (processor) + mach_port_t processor; +{ return S_processor_exit(processor); } +#else +( + mach_port_t processor +); +#endif + +/* Routine yyy_processor_control */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_yyy_processor_control +#if defined(LINTLIBRARY) + (processor, processor_cmd, processor_cmdCnt) + mach_port_t processor; + processor_info_t processor_cmd; + mach_msg_type_number_t processor_cmdCnt; +{ return S_yyy_processor_control(processor, processor_cmd, processor_cmdCnt); } +#else +( + mach_port_t processor, + processor_info_t processor_cmd, + mach_msg_type_number_t processor_cmdCnt +); +#endif + +/* Routine processor_set_default */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_processor_set_default +#if defined(LINTLIBRARY) + (host, default_set) + mach_port_t host; + mach_port_t *default_set; +{ return S_processor_set_default(host, default_set); } +#else +( + mach_port_t host, + mach_port_t *default_set +); +#endif + +/* Routine xxx_processor_set_default_priv */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_xxx_processor_set_default_priv +#if defined(LINTLIBRARY) + (host, default_set) + mach_port_t host; + mach_port_t *default_set; +{ return S_xxx_processor_set_default_priv(host, default_set); } +#else +( + mach_port_t host, + mach_port_t *default_set +); +#endif + +/* Routine processor_set_create */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_processor_set_create +#if defined(LINTLIBRARY) + (host, new_set, new_name) + mach_port_t host; + mach_port_t *new_set; + mach_port_t *new_name; +{ return S_processor_set_create(host, new_set, new_name); } +#else +( + mach_port_t host, + mach_port_t *new_set, + mach_port_t *new_name +); +#endif + +/* Routine processor_set_destroy */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_processor_set_destroy +#if defined(LINTLIBRARY) + (set) + mach_port_t set; +{ return S_processor_set_destroy(set); } +#else +( + mach_port_t set +); +#endif + +/* Routine yyy_processor_set_info */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_yyy_processor_set_info +#if defined(LINTLIBRARY) + (set_name, flavor, host, info_out, info_outCnt) + mach_port_t set_name; + int flavor; + mach_port_t *host; + processor_set_info_t info_out; + mach_msg_type_number_t *info_outCnt; +{ return S_yyy_processor_set_info(set_name, flavor, host, info_out, info_outCnt); } +#else +( + mach_port_t set_name, + int flavor, + mach_port_t *host, + processor_set_info_t info_out, + mach_msg_type_number_t *info_outCnt +); +#endif + +/* Routine processor_assign */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_processor_assign +#if defined(LINTLIBRARY) + (processor, new_set, wait) + mach_port_t processor; + mach_port_t new_set; + boolean_t wait; +{ return S_processor_assign(processor, new_set, wait); } +#else +( + mach_port_t processor, + mach_port_t new_set, + boolean_t wait +); +#endif + +/* Routine processor_get_assignment */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_processor_get_assignment +#if defined(LINTLIBRARY) + (processor, assigned_set) + mach_port_t processor; + mach_port_t *assigned_set; +{ return S_processor_get_assignment(processor, assigned_set); } +#else +( + mach_port_t processor, + mach_port_t *assigned_set +); +#endif + +/* Routine thread_assign */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_thread_assign +#if defined(LINTLIBRARY) + (thread, new_set) + mach_port_t thread; + mach_port_t new_set; +{ return S_thread_assign(thread, new_set); } +#else +( + mach_port_t thread, + mach_port_t new_set +); +#endif + +/* Routine thread_assign_default */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_thread_assign_default +#if defined(LINTLIBRARY) + (thread) + mach_port_t thread; +{ return S_thread_assign_default(thread); } +#else +( + mach_port_t thread +); +#endif + +/* Routine thread_get_assignment */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_thread_get_assignment +#if defined(LINTLIBRARY) + (thread, assigned_set) + mach_port_t thread; + mach_port_t *assigned_set; +{ return S_thread_get_assignment(thread, assigned_set); } +#else +( + mach_port_t thread, + mach_port_t *assigned_set +); +#endif + +/* Routine task_assign */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_task_assign +#if defined(LINTLIBRARY) + (task, new_set, assign_threads) + mach_port_t task; + mach_port_t new_set; + boolean_t assign_threads; +{ return S_task_assign(task, new_set, assign_threads); } +#else +( + mach_port_t task, + mach_port_t new_set, + boolean_t assign_threads +); +#endif + +/* Routine task_assign_default */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_task_assign_default +#if defined(LINTLIBRARY) + (task, assign_threads) + mach_port_t task; + boolean_t assign_threads; +{ return S_task_assign_default(task, assign_threads); } +#else +( + mach_port_t task, + boolean_t assign_threads +); +#endif + +/* Routine task_get_assignment */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_task_get_assignment +#if defined(LINTLIBRARY) + (task, assigned_set) + mach_port_t task; + mach_port_t *assigned_set; +{ return S_task_get_assignment(task, assigned_set); } +#else +( + mach_port_t task, + mach_port_t *assigned_set +); +#endif + +/* Routine host_kernel_version */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_host_kernel_version +#if defined(LINTLIBRARY) + (host, kernel_version) + mach_port_t host; + kernel_version_t kernel_version; +{ return S_host_kernel_version(host, kernel_version); } +#else +( + mach_port_t host, + kernel_version_t kernel_version +); +#endif + +/* Routine thread_priority */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_thread_priority +#if defined(LINTLIBRARY) + (thread, priority, set_max) + mach_port_t thread; + int priority; + boolean_t set_max; +{ return S_thread_priority(thread, priority, set_max); } +#else +( + mach_port_t thread, + int priority, + boolean_t set_max +); +#endif + +/* Routine thread_max_priority */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_thread_max_priority +#if defined(LINTLIBRARY) + (thread, processor_set, max_priority) + mach_port_t thread; + mach_port_t processor_set; + int max_priority; +{ return S_thread_max_priority(thread, processor_set, max_priority); } +#else +( + mach_port_t thread, + mach_port_t processor_set, + int max_priority +); +#endif + +/* Routine task_priority */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_task_priority +#if defined(LINTLIBRARY) + (task, priority, change_threads) + mach_port_t task; + int priority; + boolean_t change_threads; +{ return S_task_priority(task, priority, change_threads); } +#else +( + mach_port_t task, + int priority, + boolean_t change_threads +); +#endif + +/* Routine processor_set_max_priority */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_processor_set_max_priority +#if defined(LINTLIBRARY) + (processor_set, max_priority, change_threads) + mach_port_t processor_set; + int max_priority; + boolean_t change_threads; +{ return S_processor_set_max_priority(processor_set, max_priority, change_threads); } +#else +( + mach_port_t processor_set, + int max_priority, + boolean_t change_threads +); +#endif + +/* Routine thread_policy */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_thread_policy +#if defined(LINTLIBRARY) + (thread, policy, data) + mach_port_t thread; + int policy; + int data; +{ return S_thread_policy(thread, policy, data); } +#else +( + mach_port_t thread, + int policy, + int data +); +#endif + +/* Routine processor_set_policy_enable */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_processor_set_policy_enable +#if defined(LINTLIBRARY) + (processor_set, policy) + mach_port_t processor_set; + int policy; +{ return S_processor_set_policy_enable(processor_set, policy); } +#else +( + mach_port_t processor_set, + int policy +); +#endif + +/* Routine processor_set_policy_disable */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_processor_set_policy_disable +#if defined(LINTLIBRARY) + (processor_set, policy, change_threads) + mach_port_t processor_set; + int policy; + boolean_t change_threads; +{ return S_processor_set_policy_disable(processor_set, policy, change_threads); } +#else +( + mach_port_t processor_set, + int policy, + boolean_t change_threads +); +#endif + +/* Routine processor_set_tasks */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_processor_set_tasks +#if defined(LINTLIBRARY) + (processor_set, task_list, task_listCnt) + mach_port_t processor_set; + task_array_t *task_list; + mach_msg_type_number_t *task_listCnt; +{ return S_processor_set_tasks(processor_set, task_list, task_listCnt); } +#else +( + mach_port_t processor_set, + task_array_t *task_list, + mach_msg_type_number_t *task_listCnt +); +#endif + +/* Routine processor_set_threads */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_processor_set_threads +#if defined(LINTLIBRARY) + (processor_set, thread_list, thread_listCnt) + mach_port_t processor_set; + thread_array_t *thread_list; + mach_msg_type_number_t *thread_listCnt; +{ return S_processor_set_threads(processor_set, thread_list, thread_listCnt); } +#else +( + mach_port_t processor_set, + thread_array_t *thread_list, + mach_msg_type_number_t *thread_listCnt +); +#endif + +/* Routine host_processor_sets */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_host_processor_sets +#if defined(LINTLIBRARY) + (host, processor_sets, processor_setsCnt) + mach_port_t host; + processor_set_name_array_t *processor_sets; + mach_msg_type_number_t *processor_setsCnt; +{ return S_host_processor_sets(host, processor_sets, processor_setsCnt); } +#else +( + mach_port_t host, + processor_set_name_array_t *processor_sets, + mach_msg_type_number_t *processor_setsCnt +); +#endif + +/* Routine host_processor_set_priv */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_host_processor_set_priv +#if defined(LINTLIBRARY) + (host_priv, set_name, set, setPoly) + mach_port_t host_priv; + mach_port_t set_name; + mach_port_t *set; + mach_msg_type_name_t *setPoly; +{ return S_host_processor_set_priv(host_priv, set_name, set, setPoly); } +#else +( + mach_port_t host_priv, + mach_port_t set_name, + mach_port_t *set, + mach_msg_type_name_t *setPoly +); +#endif + +/* Routine thread_depress_abort */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_thread_depress_abort +#if defined(LINTLIBRARY) + (thread) + mach_port_t thread; +{ return S_thread_depress_abort(thread); } +#else +( + mach_port_t thread +); +#endif + +/* Routine host_set_time */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_host_set_time +#if defined(LINTLIBRARY) + (host_priv, new_time) + mach_port_t host_priv; + time_value_t new_time; +{ return S_host_set_time(host_priv, new_time); } +#else +( + mach_port_t host_priv, + time_value_t new_time +); +#endif + +/* Routine host_adjust_time */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_host_adjust_time +#if defined(LINTLIBRARY) + (host_priv, new_adjustment, old_adjustment) + mach_port_t host_priv; + time_value_t new_adjustment; + time_value_t *old_adjustment; +{ return S_host_adjust_time(host_priv, new_adjustment, old_adjustment); } +#else +( + mach_port_t host_priv, + time_value_t new_adjustment, + time_value_t *old_adjustment +); +#endif + +/* Routine host_get_time */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_host_get_time +#if defined(LINTLIBRARY) + (host, current_time) + mach_port_t host; + time_value_t *current_time; +{ return S_host_get_time(host, current_time); } +#else +( + mach_port_t host, + time_value_t *current_time +); +#endif + +/* Routine host_reboot */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_host_reboot +#if defined(LINTLIBRARY) + (host_priv, options) + mach_port_t host_priv; + int options; +{ return S_host_reboot(host_priv, options); } +#else +( + mach_port_t host_priv, + int options +); +#endif + +/* Routine vm_wire */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_vm_wire +#if defined(LINTLIBRARY) + (host_priv, task, address, size, access) + mach_port_t host_priv; + mach_port_t task; + vm_address_t address; + vm_size_t size; + vm_prot_t access; +{ return S_vm_wire(host_priv, task, address, size, access); } +#else +( + mach_port_t host_priv, + mach_port_t task, + vm_address_t address, + vm_size_t size, + vm_prot_t access +); +#endif + +/* Routine thread_wire */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_thread_wire +#if defined(LINTLIBRARY) + (host_priv, thread, wired) + mach_port_t host_priv; + mach_port_t thread; + boolean_t wired; +{ return S_thread_wire(host_priv, thread, wired); } +#else +( + mach_port_t host_priv, + mach_port_t thread, + boolean_t wired +); +#endif + +/* Routine host_info */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_host_info +#if defined(LINTLIBRARY) + (host, flavor, host_info_out, host_info_outCnt) + mach_port_t host; + int flavor; + host_info_t host_info_out; + mach_msg_type_number_t *host_info_outCnt; +{ return S_host_info(host, flavor, host_info_out, host_info_outCnt); } +#else +( + mach_port_t host, + int flavor, + host_info_t host_info_out, + mach_msg_type_number_t *host_info_outCnt +); +#endif + +/* Routine processor_info */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_processor_info +#if defined(LINTLIBRARY) + (processor, flavor, host, processor_info_out, processor_info_outCnt) + mach_port_t processor; + int flavor; + mach_port_t *host; + processor_info_t processor_info_out; + mach_msg_type_number_t *processor_info_outCnt; +{ return S_processor_info(processor, flavor, host, processor_info_out, processor_info_outCnt); } +#else +( + mach_port_t processor, + int flavor, + mach_port_t *host, + processor_info_t processor_info_out, + mach_msg_type_number_t *processor_info_outCnt +); +#endif + +/* Routine processor_set_info */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_processor_set_info +#if defined(LINTLIBRARY) + (set_name, flavor, host, info_out, info_outCnt) + mach_port_t set_name; + int flavor; + mach_port_t *host; + processor_set_info_t info_out; + mach_msg_type_number_t *info_outCnt; +{ return S_processor_set_info(set_name, flavor, host, info_out, info_outCnt); } +#else +( + mach_port_t set_name, + int flavor, + mach_port_t *host, + processor_set_info_t info_out, + mach_msg_type_number_t *info_outCnt +); +#endif + +/* Routine processor_control */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_processor_control +#if defined(LINTLIBRARY) + (processor, processor_cmd, processor_cmdCnt) + mach_port_t processor; + processor_info_t processor_cmd; + mach_msg_type_number_t processor_cmdCnt; +{ return S_processor_control(processor, processor_cmd, processor_cmdCnt); } +#else +( + mach_port_t processor, + processor_info_t processor_cmd, + mach_msg_type_number_t processor_cmdCnt +); +#endif + +/* Routine host_get_boot_info */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_host_get_boot_info +#if defined(LINTLIBRARY) + (host_priv, boot_info) + mach_port_t host_priv; + kernel_boot_info_t boot_info; +{ return S_host_get_boot_info(host_priv, boot_info); } +#else +( + mach_port_t host_priv, + kernel_boot_info_t boot_info +); +#endif + +#endif /* not defined(_mach_host_server_) */ diff --git a/boot-proxy-exc/ourmach_port.defs b/boot-proxy-exc/ourmach_port.defs new file mode 100644 index 00000000..4f131bb2 --- /dev/null +++ b/boot-proxy-exc/ourmach_port.defs @@ -0,0 +1,349 @@ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989 Carnegie Mellon University. + * Copyright (c) 1993,1994 The University of Utah and + * the Computer Systems Laboratory (CSL). + * 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, THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF + * THIS SOFTWARE IN ITS "AS IS" CONDITION, AND DISCLAIM 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. + */ +/* + * File: mach/mach_port.defs + * Author: Rich Draves + * + * Copyright (c) 1989 Richard P. Draves, Jr. + * + * Exported kernel calls. + */ + +subsystem +#if KERNEL_SERVER + KernelServer +#endif + mach_port 3200; + +#include <mach/std_types.defs> +#include <mach/mach_types.defs> + +/* + * Returns the set of port and port set names + * to which the target task has access, along with + * the type (set or port) for each name. + */ + +routine mach_port_names( + task : ipc_space_t; + out names : mach_port_name_array_t = + ^array[] of mach_port_name_t + ctype: mach_port_array_t, + dealloc; + out types : mach_port_type_array_t = + ^array[] of mach_port_type_t, + dealloc); + +/* + * Returns the type (set or port) for the port name + * within the target task. Also indicates whether + * there is a dead-name request for the name. + */ + +routine mach_port_type( + task : ipc_space_t; + name : mach_port_name_t; + out ptype : mach_port_type_t); + +/* + * Changes the name by which a port (or port set) is known to + * the target task. The new name can't be in use. The + * old name becomes available for recycling. + */ + +routine mach_port_rename( + task : ipc_space_t; + old_name : mach_port_name_t; + new_name : mach_port_name_t); + +/* + * Allocates the specified kind of object, with the given name. + * The right must be one of + * MACH_PORT_RIGHT_RECEIVE + * MACH_PORT_RIGHT_PORT_SET + * MACH_PORT_RIGHT_DEAD_NAME + * New port sets are empty. New ports don't have any + * send/send-once rights or queued messages. The make-send + * count is zero and their queue limit is MACH_PORT_QLIMIT_DEFAULT. + * New sets, ports, and dead names have one user reference. + */ + +routine mach_port_allocate_name( + task : ipc_space_t; + right : mach_port_right_t; + name : mach_port_name_t); + +/* + * Allocates the specified kind of object. + * The right must be one of + * MACH_PORT_RIGHT_RECEIVE + * MACH_PORT_RIGHT_PORT_SET + * MACH_PORT_RIGHT_DEAD_NAME + * Like port_allocate_name, but the kernel picks a name. + * It can use any name not associated with a right. + */ + +routine mach_port_allocate( + task : ipc_space_t; + right : mach_port_right_t; + out name : mach_port_name_t); + +/* + * Destroys all rights associated with the name and makes it + * available for recycling immediately. The name can be a + * port (possibly with multiple user refs), a port set, or + * a dead name (again, with multiple user refs). + */ + +routine mach_port_destroy( + task : ipc_space_t; + name : mach_port_name_t); + +/* + * Releases one send/send-once/dead-name user ref. + * Just like mach_port_mod_refs -1, but deduces the + * correct type of right. This allows a user task + * to release a ref for a port without worrying + * about whether the port has died or not. + */ + +routine mach_port_deallocate( + task : ipc_space_t; + name : mach_port_name_t); + +/* + * A port set always has one user ref. + * A send-once right always has one user ref. + * A dead name always has one or more user refs. + * A send right always has one or more user refs. + * A receive right always has one user ref. + * The right must be one of + * MACH_PORT_RIGHT_RECEIVE + * MACH_PORT_RIGHT_PORT_SET + * MACH_PORT_RIGHT_DEAD_NAME + * MACH_PORT_RIGHT_SEND + * MACH_PORT_RIGHT_SEND_ONCE + */ + +routine mach_port_get_refs( + task : ipc_space_t; + name : mach_port_name_t; + right : mach_port_right_t; + out refs : mach_port_urefs_t); + +/* + * The delta is a signed change to the task's + * user ref count for the right. Only dead names + * and send rights can have a positive delta. + * The resulting user ref count can't be negative. + * If it is zero, the right is deallocated. + * If the name isn't a composite right, it becomes + * available for recycling. The right must be one of + * MACH_PORT_RIGHT_RECEIVE + * MACH_PORT_RIGHT_PORT_SET + * MACH_PORT_RIGHT_DEAD_NAME + * MACH_PORT_RIGHT_SEND + * MACH_PORT_RIGHT_SEND_ONCE + */ + +routine mach_port_mod_refs( + task : ipc_space_t; + name : mach_port_name_t; + right : mach_port_right_t; + delta : mach_port_delta_t); + +/* + * Temporary compatibility call. + */ + +routine old_mach_port_get_receive_status( + task : ipc_space_t; + name : mach_port_name_t; + out status : old_mach_port_status_t); + +/* + * Only valid for receive rights. + * Sets the queue-limit for the port. + * The limit must be + * 1 <= qlimit <= MACH_PORT_QLIMIT_MAX + */ + +routine mach_port_set_qlimit( + task : ipc_space_t; + name : mach_port_name_t; + qlimit : mach_port_msgcount_t); + +/* + * Only valid for receive rights. + * Sets the make-send count for the port. + */ + +routine mach_port_set_mscount( + task : ipc_space_t; + name : mach_port_name_t; + mscount : mach_port_mscount_t); + +/* + * Only valid for port sets. Returns a list of + * the members. + */ + +routine mach_port_get_set_status( + task : ipc_space_t; + name : mach_port_name_t; + out members : mach_port_name_array_t = + ^array[] of mach_port_name_t + ctype: mach_port_array_t, + dealloc); + +/* + * Puts the member port (the task must have receive rights) + * into the after port set. (Or removes it from any port set + * if after is MACH_PORT_NULL.) If the port is already in + * a set, does an atomic move. + */ + +routine mach_port_move_member( + task : ipc_space_t; + member : mach_port_name_t; + after : mach_port_name_t); + +/* + * Requests a notification from the kernel. The request + * must supply the send-once right which is used for + * the notification. If a send-once right was previously + * registered, it is returned. The msg_id must be one of + * MACH_NOTIFY_PORT_DESTROYED (receive rights) + * MACH_NOTIFY_DEAD_NAME (send/receive/send-once rights) + * MACH_NOTIFY_NO_SENDERS (receive rights) + * + * The sync value specifies whether a notification should + * get sent immediately, if appropriate. The exact meaning + * depends on the notification: + * MACH_NOTIFY_PORT_DESTROYED: must be zero. + * MACH_NOTIFY_DEAD_NAME: if non-zero, then name can be dead, + * and the notification gets sent immediately. + * If zero, then name can't be dead. + * MACH_NOTIFY_NO_SENDERS: the notification gets sent + * immediately if the current mscount is greater + * than or equal to the sync value and there are no + * extant send rights. + */ + +routine mach_port_request_notification( + task : ipc_space_t; + name : mach_port_name_t; + id : mach_msg_id_t; + sync : mach_port_mscount_t; + notify : mach_port_send_once_t; + out previous : mach_port_send_once_t); + +/* + * Inserts the specified rights into the target task, + * using the specified name. If inserting send/receive + * rights and the task already has send/receive rights + * for the port, then the names must agree. In any case, + * the task gains a user ref for the port. + */ + +routine mach_port_insert_right( + task : ipc_space_t; + name : mach_port_name_t; + poly : mach_port_poly_t); + +/* + * Returns the specified right for the named port + * in the target task, extracting that right from + * the target task. The target task loses a user + * ref and the name may be available for recycling. + * msgt_name must be one of + * MACH_MSG_TYPE_MOVE_RECEIVE + * MACH_MSG_TYPE_COPY_SEND + * MACH_MSG_TYPE_MAKE_SEND + * MACH_MSG_TYPE_MOVE_SEND + * MACH_MSG_TYPE_MAKE_SEND_ONCE + * MACH_MSG_TYPE_MOVE_SEND_ONCE + */ + +routine mach_port_extract_right( + task : ipc_space_t; + name : mach_port_name_t; + msgt_name : mach_msg_type_name_t; + out poly : mach_port_poly_t); + +/* + * The task must have receive rights for the named port. + * Returns a status structure (see mach/port.h). + */ + +routine mach_port_get_receive_status( + task : ipc_space_t; + name : mach_port_name_t; + out status : mach_port_status_t); + +/* + * Only valid for receive rights. + * Sets the sequence number for the port. + */ + +routine mach_port_set_seqno( + task : ipc_space_t; + name : mach_port_name_t; + seqno : mach_port_seqno_t); + +#ifdef MIGRATING_THREADS +/* + * Only valid for receive rights. + * Set the user-mode entry info for RPCs coming through this port. + * Do this BEFORE attaching an ActPool to this port, + * unless you can be sure no RPCs will be coming through it yet. + */ + +routine mach_port_set_rpcinfo( + task : ipc_space_t; + name : mach_port_name_t; + rpc_info : thread_info_t); /* XXX */ + +/* + * Only valid for receive rights. + * Create a new activation for migrating RPC, and attach it to the port's ActPool. + * Create an ActPool for the port if it doesn't already have one. + * Supply a stack and receive memory buffer. + */ + +routine mach_port_create_act( + task : task_t; + name : mach_port_name_t; + user_stack : vm_offset_t; + user_rbuf : vm_offset_t; + user_rbuf_size : vm_size_t; + out new_act : thread_t); + +#endif /* MIGRATING_THREADS */ + diff --git a/boot-proxy-exc/ourmach_port.sdefs.d b/boot-proxy-exc/ourmach_port.sdefs.d new file mode 100644 index 00000000..a2d3085f --- /dev/null +++ b/boot-proxy-exc/ourmach_port.sdefs.d @@ -0,0 +1,3 @@ +ourmach_portServer.c ourmach_port_S.h: ourmach_port.defs /usr/local/include/mach/std_types.defs \ + /usr/local/include/mach/machine/machine_types.defs \ + /usr/local/include/mach/mach_types.defs diff --git a/boot-proxy-exc/ourmach_portServer.c b/boot-proxy-exc/ourmach_portServer.c new file mode 100644 index 00000000..202f2511 --- /dev/null +++ b/boot-proxy-exc/ourmach_portServer.c @@ -0,0 +1,1413 @@ +/* Module mach_port */ + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE 1 +#endif + +#define EXPORT_BOOLEAN +#include <mach/boolean.h> +#include <mach/kern_return.h> +#include <mach/message.h> +#include <mach/mig_errors.h> +#include <mach/mig_support.h> + +#ifndef mig_internal +#define mig_internal static +#endif + +#ifndef mig_external +#define mig_external +#endif + +#ifndef TypeCheck +#define TypeCheck 1 +#endif + +#ifndef UseExternRCSId +#define UseExternRCSId 1 +#endif + +#define BAD_TYPECHECK(type, check) ({\ + union { mach_msg_type_t t; unsigned32_t w; } _t, _c;\ + _t.t = *(type); _c.t = *(check); _t.w != _c.w; }) +#define msgh_request_port msgh_local_port +#define MACH_MSGH_BITS_REQUEST(bits) MACH_MSGH_BITS_LOCAL(bits) +#define msgh_reply_port msgh_remote_port +#define MACH_MSGH_BITS_REPLY(bits) MACH_MSGH_BITS_REMOTE(bits) + +#include <mach/std_types.h> +#include <mach/mach_types.h> + +/* Routine mach_port_names */ +mig_internal void _Xmach_port_names + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_long_t namesType; + mach_port_array_t names; + mach_msg_type_long_t typesType; + mach_port_type_array_t types; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_mach_port_names + (mach_port_t task, mach_port_array_t *names, mach_msg_type_number_t *namesCnt, mach_port_type_array_t *types, mach_msg_type_number_t *typesCnt); + + auto const mach_msg_type_long_t namesType = { + { + /* msgt_name = */ 0, + /* msgt_size = */ 0, + /* msgt_number = */ 0, + /* msgt_inline = */ FALSE, + /* msgt_longform = */ TRUE, + /* msgt_deallocate = */ TRUE, + /* msgt_unused = */ 0 + }, + /* msgtl_name = */ 15, + /* msgtl_size = */ 32, + /* msgtl_number = */ 0, + }; + + auto const mach_msg_type_long_t typesType = { + { + /* msgt_name = */ 0, + /* msgt_size = */ 0, + /* msgt_number = */ 0, + /* msgt_inline = */ FALSE, + /* msgt_longform = */ TRUE, + /* msgt_deallocate = */ TRUE, + /* msgt_unused = */ 0 + }, + /* msgtl_name = */ 2, + /* msgtl_size = */ 32, + /* msgtl_number = */ 0, + }; + + mach_msg_type_number_t namesCnt; + mach_msg_type_number_t typesCnt; + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_mach_port_names(In0P->Head.msgh_request_port, &OutP->names, &namesCnt, &OutP->types, &typesCnt); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; + OutP->Head.msgh_size = 64; + + OutP->namesType = namesType; + + OutP->namesType.msgtl_number = namesCnt; + + OutP->typesType = typesType; + + OutP->typesType.msgtl_number = typesCnt; +} + +/* Routine mach_port_type */ +mig_internal void _Xmach_port_type + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t nameType; + mach_port_t name; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t ptypeType; + mach_port_type_t ptype; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_mach_port_type + (mach_port_t task, mach_port_t name, mach_port_type_t *ptype); + + auto const mach_msg_type_t nameCheck = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t ptypeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->nameType, &nameCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_mach_port_type(In0P->Head.msgh_request_port, In0P->name, &OutP->ptype); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_size = 40; + + OutP->ptypeType = ptypeType; +} + +/* Routine mach_port_rename */ +mig_internal void _Xmach_port_rename + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t old_nameType; + mach_port_t old_name; + mach_msg_type_t new_nameType; + mach_port_t new_name; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_mach_port_rename + (mach_port_t task, mach_port_t old_name, mach_port_t new_name); + + auto const mach_msg_type_t old_nameCheck = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t new_nameCheck = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->old_nameType, &old_nameCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->new_nameType, &new_nameCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_mach_port_rename(In0P->Head.msgh_request_port, In0P->old_name, In0P->new_name); +} + +/* Routine mach_port_allocate_name */ +mig_internal void _Xmach_port_allocate_name + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t rightType; + mach_port_right_t right; + mach_msg_type_t nameType; + mach_port_t name; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_mach_port_allocate_name + (mach_port_t task, mach_port_right_t right, mach_port_t name); + + auto const mach_msg_type_t rightCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t nameCheck = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->rightType, &rightCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->nameType, &nameCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_mach_port_allocate_name(In0P->Head.msgh_request_port, In0P->right, In0P->name); +} + +/* Routine mach_port_allocate */ +mig_internal void _Xmach_port_allocate + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t rightType; + mach_port_right_t right; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t nameType; + mach_port_t name; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_mach_port_allocate + (mach_port_t task, mach_port_right_t right, mach_port_t *name); + + auto const mach_msg_type_t rightCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t nameType = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->rightType, &rightCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_mach_port_allocate(In0P->Head.msgh_request_port, In0P->right, &OutP->name); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_size = 40; + + OutP->nameType = nameType; +} + +/* Routine mach_port_destroy */ +mig_internal void _Xmach_port_destroy + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t nameType; + mach_port_t name; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_mach_port_destroy + (mach_port_t task, mach_port_t name); + + auto const mach_msg_type_t nameCheck = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->nameType, &nameCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_mach_port_destroy(In0P->Head.msgh_request_port, In0P->name); +} + +/* Routine mach_port_deallocate */ +mig_internal void _Xmach_port_deallocate + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t nameType; + mach_port_t name; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_mach_port_deallocate + (mach_port_t task, mach_port_t name); + + auto const mach_msg_type_t nameCheck = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->nameType, &nameCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_mach_port_deallocate(In0P->Head.msgh_request_port, In0P->name); +} + +/* Routine mach_port_get_refs */ +mig_internal void _Xmach_port_get_refs + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t nameType; + mach_port_t name; + mach_msg_type_t rightType; + mach_port_right_t right; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t refsType; + mach_port_urefs_t refs; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_mach_port_get_refs + (mach_port_t task, mach_port_t name, mach_port_right_t right, mach_port_urefs_t *refs); + + auto const mach_msg_type_t nameCheck = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t rightCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t refsType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->nameType, &nameCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->rightType, &rightCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_mach_port_get_refs(In0P->Head.msgh_request_port, In0P->name, In0P->right, &OutP->refs); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_size = 40; + + OutP->refsType = refsType; +} + +/* Routine mach_port_mod_refs */ +mig_internal void _Xmach_port_mod_refs + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t nameType; + mach_port_t name; + mach_msg_type_t rightType; + mach_port_right_t right; + mach_msg_type_t deltaType; + mach_port_delta_t delta; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_mach_port_mod_refs + (mach_port_t task, mach_port_t name, mach_port_right_t right, mach_port_delta_t delta); + + auto const mach_msg_type_t nameCheck = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t rightCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t deltaCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 48) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->nameType, &nameCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->rightType, &rightCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->deltaType, &deltaCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_mach_port_mod_refs(In0P->Head.msgh_request_port, In0P->name, In0P->right, In0P->delta); +} + +/* Routine old_mach_port_get_receive_status */ +mig_internal void _Xold_mach_port_get_receive_status + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t nameType; + mach_port_t name; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t statusType; + old_mach_port_status_t status; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_old_mach_port_get_receive_status + (mach_port_t task, mach_port_t name, old_mach_port_status_t *status); + + auto const mach_msg_type_t nameCheck = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t statusType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 8, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->nameType, &nameCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_old_mach_port_get_receive_status(In0P->Head.msgh_request_port, In0P->name, &OutP->status); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_size = 68; + + OutP->statusType = statusType; +} + +/* Routine mach_port_set_qlimit */ +mig_internal void _Xmach_port_set_qlimit + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t nameType; + mach_port_t name; + mach_msg_type_t qlimitType; + mach_port_msgcount_t qlimit; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_mach_port_set_qlimit + (mach_port_t task, mach_port_t name, mach_port_msgcount_t qlimit); + + auto const mach_msg_type_t nameCheck = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t qlimitCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->nameType, &nameCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->qlimitType, &qlimitCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_mach_port_set_qlimit(In0P->Head.msgh_request_port, In0P->name, In0P->qlimit); +} + +/* Routine mach_port_set_mscount */ +mig_internal void _Xmach_port_set_mscount + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t nameType; + mach_port_t name; + mach_msg_type_t mscountType; + mach_port_mscount_t mscount; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_mach_port_set_mscount + (mach_port_t task, mach_port_t name, mach_port_mscount_t mscount); + + auto const mach_msg_type_t nameCheck = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t mscountCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->nameType, &nameCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->mscountType, &mscountCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_mach_port_set_mscount(In0P->Head.msgh_request_port, In0P->name, In0P->mscount); +} + +/* Routine mach_port_get_set_status */ +mig_internal void _Xmach_port_get_set_status + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t nameType; + mach_port_t name; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_long_t membersType; + mach_port_array_t members; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_mach_port_get_set_status + (mach_port_t task, mach_port_t name, mach_port_array_t *members, mach_msg_type_number_t *membersCnt); + + auto const mach_msg_type_t nameCheck = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_long_t membersType = { + { + /* msgt_name = */ 0, + /* msgt_size = */ 0, + /* msgt_number = */ 0, + /* msgt_inline = */ FALSE, + /* msgt_longform = */ TRUE, + /* msgt_deallocate = */ TRUE, + /* msgt_unused = */ 0 + }, + /* msgtl_name = */ 15, + /* msgtl_size = */ 32, + /* msgtl_number = */ 0, + }; + + mach_msg_type_number_t membersCnt; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->nameType, &nameCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_mach_port_get_set_status(In0P->Head.msgh_request_port, In0P->name, &OutP->members, &membersCnt); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; + OutP->Head.msgh_size = 48; + + OutP->membersType = membersType; + + OutP->membersType.msgtl_number = membersCnt; +} + +/* Routine mach_port_move_member */ +mig_internal void _Xmach_port_move_member + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t memberType; + mach_port_t member; + mach_msg_type_t afterType; + mach_port_t after; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_mach_port_move_member + (mach_port_t task, mach_port_t member, mach_port_t after); + + auto const mach_msg_type_t memberCheck = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t afterCheck = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->memberType, &memberCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->afterType, &afterCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_mach_port_move_member(In0P->Head.msgh_request_port, In0P->member, In0P->after); +} + +/* Routine mach_port_request_notification */ +mig_internal void _Xmach_port_request_notification + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t nameType; + mach_port_t name; + mach_msg_type_t idType; + mach_msg_id_t id; + mach_msg_type_t syncType; + mach_port_mscount_t sync; + mach_msg_type_t notifyType; + mach_port_t notify; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t previousType; + mach_port_t previous; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_mach_port_request_notification + (mach_port_t task, mach_port_t name, mach_msg_id_t id, mach_port_mscount_t sync, mach_port_t notify, mach_port_t *previous, mach_msg_type_name_t *previousPoly); + + boolean_t msgh_simple; + auto const mach_msg_type_t nameCheck = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t idCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t syncCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t notifyCheck = { + /* msgt_name = */ 18, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t previousType = { + /* msgt_name = */ -1, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + mach_msg_type_name_t previousPoly; + +#if TypeCheck + if ((In0P->Head.msgh_size != 56) || + !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->nameType, &nameCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->idType, &idCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->syncType, &syncCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->notifyType, ¬ifyCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_mach_port_request_notification(In0P->Head.msgh_request_port, In0P->name, In0P->id, In0P->sync, In0P->notify, &OutP->previous, &previousPoly); + if (OutP->RetCode != KERN_SUCCESS) + return; + + msgh_simple = TRUE; + OutP->Head.msgh_size = 40; + + OutP->previousType = previousType; + + if (MACH_MSG_TYPE_PORT_ANY(previousPoly)) + msgh_simple = FALSE; + + OutP->previousType.msgt_name = previousPoly; + + if (!msgh_simple) + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; +} + +/* Routine mach_port_insert_right */ +mig_internal void _Xmach_port_insert_right + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t nameType; + mach_port_t name; + mach_msg_type_t polyType; + mach_port_t poly; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_mach_port_insert_right + (mach_port_t task, mach_port_t name, mach_port_t poly, mach_msg_type_name_t polyPoly); + +#if TypeCheck + boolean_t msgh_simple; +#endif /* TypeCheck */ + + auto const mach_msg_type_t nameCheck = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + msgh_simple = !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX); + if ((In0P->Head.msgh_size != 40)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->nameType, &nameCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if ((In0P->polyType.msgt_inline != TRUE) || + (In0P->polyType.msgt_longform != FALSE) || + (MACH_MSG_TYPE_PORT_ANY(In0P->polyType.msgt_name) && msgh_simple) || + (In0P->polyType.msgt_number != 1) || + (In0P->polyType.msgt_size != 32)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_mach_port_insert_right(In0P->Head.msgh_request_port, In0P->name, In0P->poly, In0P->polyType.msgt_name); +} + +/* Routine mach_port_extract_right */ +mig_internal void _Xmach_port_extract_right + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t nameType; + mach_port_t name; + mach_msg_type_t msgt_nameType; + mach_msg_type_name_t msgt_name; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t polyType; + mach_port_t poly; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_mach_port_extract_right + (mach_port_t task, mach_port_t name, mach_msg_type_name_t msgt_name, mach_port_t *poly, mach_msg_type_name_t *polyPoly); + + boolean_t msgh_simple; + auto const mach_msg_type_t nameCheck = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t msgt_nameCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t polyType = { + /* msgt_name = */ -1, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + mach_msg_type_name_t polyPoly; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->nameType, &nameCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->msgt_nameType, &msgt_nameCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_mach_port_extract_right(In0P->Head.msgh_request_port, In0P->name, In0P->msgt_name, &OutP->poly, &polyPoly); + if (OutP->RetCode != KERN_SUCCESS) + return; + + msgh_simple = TRUE; + OutP->Head.msgh_size = 40; + + OutP->polyType = polyType; + + if (MACH_MSG_TYPE_PORT_ANY(polyPoly)) + msgh_simple = FALSE; + + OutP->polyType.msgt_name = polyPoly; + + if (!msgh_simple) + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; +} + +/* Routine mach_port_get_receive_status */ +mig_internal void _Xmach_port_get_receive_status + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t nameType; + mach_port_t name; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t statusType; + mach_port_status_t status; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_mach_port_get_receive_status + (mach_port_t task, mach_port_t name, mach_port_status_t *status); + + auto const mach_msg_type_t nameCheck = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t statusType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 9, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->nameType, &nameCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_mach_port_get_receive_status(In0P->Head.msgh_request_port, In0P->name, &OutP->status); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_size = 72; + + OutP->statusType = statusType; +} + +/* Routine mach_port_set_seqno */ +mig_internal void _Xmach_port_set_seqno + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t nameType; + mach_port_t name; + mach_msg_type_t seqnoType; + mach_port_seqno_t seqno; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_mach_port_set_seqno + (mach_port_t task, mach_port_t name, mach_port_seqno_t seqno); + + auto const mach_msg_type_t nameCheck = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t seqnoCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->nameType, &nameCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->seqnoType, &seqnoCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_mach_port_set_seqno(In0P->Head.msgh_request_port, In0P->name, In0P->seqno); +} + +static mig_routine_t mach_port_server_routines[] = { + _Xmach_port_names, + _Xmach_port_type, + _Xmach_port_rename, + _Xmach_port_allocate_name, + _Xmach_port_allocate, + _Xmach_port_destroy, + _Xmach_port_deallocate, + _Xmach_port_get_refs, + _Xmach_port_mod_refs, + _Xold_mach_port_get_receive_status, + _Xmach_port_set_qlimit, + _Xmach_port_set_mscount, + _Xmach_port_get_set_status, + _Xmach_port_move_member, + _Xmach_port_request_notification, + _Xmach_port_insert_right, + _Xmach_port_extract_right, + _Xmach_port_get_receive_status, + _Xmach_port_set_seqno, +}; + +mig_external boolean_t mach_port_server + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + register mach_msg_header_t *InP = InHeadP; + register mig_reply_header_t *OutP = (mig_reply_header_t *) OutHeadP; + + auto const mach_msg_type_t RetCodeType = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + register mig_routine_t routine; + + OutP->Head.msgh_bits = MACH_MSGH_BITS(MACH_MSGH_BITS_REPLY(InP->msgh_bits), 0); + OutP->Head.msgh_size = sizeof *OutP; + OutP->Head.msgh_remote_port = InP->msgh_reply_port; + OutP->Head.msgh_local_port = MACH_PORT_NULL; + OutP->Head.msgh_seqno = 0; + OutP->Head.msgh_id = InP->msgh_id + 100; + + OutP->RetCodeType = RetCodeType; + + if ((InP->msgh_id > 3218) || (InP->msgh_id < 3200) || + ((routine = mach_port_server_routines[InP->msgh_id - 3200]) == 0)) { + OutP->RetCode = MIG_BAD_ID; + return FALSE; + } + (*routine) (InP, &OutP->Head); + return TRUE; +} + +mig_external mig_routine_t mach_port_server_routine + (const mach_msg_header_t *InHeadP) +{ + register int msgh_id; + + msgh_id = InHeadP->msgh_id - 3200; + + if ((msgh_id > 18) || (msgh_id < 0)) + return 0; + + return mach_port_server_routines[msgh_id]; +} + diff --git a/boot-proxy-exc/ourmach_portServer.d b/boot-proxy-exc/ourmach_portServer.d new file mode 100644 index 00000000..d2092ed1 --- /dev/null +++ b/boot-proxy-exc/ourmach_portServer.d @@ -0,0 +1,45 @@ +ourmach_portServer.o ourmach_portServer_pic.o ourmach_portServer_p.o ourmach_portServer.d: ourmach_portServer.c \ + /usr/local/include/mach/boolean.h \ + /usr/local/include/mach/machine/boolean.h \ + /usr/local/include/mach/kern_return.h \ + /usr/local/include/mach/machine/kern_return.h \ + /usr/local/include/mach/message.h /usr/local/include/mach/port.h \ + /usr/local/include/mach/machine/vm_types.h \ + /usr/local/include/mach/mig_errors.h /usr/include/mach/mig_support.h \ + /usr/local/include/mach/std_types.h /usr/include/sys/types.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h /usr/include/gnu/stubs-pthread.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/time.h /usr/lib/gcc/i486-gnu/4.2.4/include/stddef.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/bits/byteswap.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/pthread/pthreadtypes.h \ + /usr/include/xlocale.h /usr/include/bits/pthread.h \ + /usr/include/bits/thread-attr.h /usr/include/sched.h \ + /usr/include/bits/sched.h /usr/include/bits/mutex-attr.h \ + /usr/include/bits/mutex.h /usr/include/bits/spin-lock.h \ + /usr/include/bits/condition-attr.h /usr/include/bits/condition.h \ + /usr/include/bits/rwlock-attr.h /usr/include/bits/rwlock.h \ + /usr/include/bits/barrier-attr.h /usr/include/bits/barrier.h \ + /usr/include/bits/thread-specific.h /usr/include/bits/once.h \ + /usr/include/string.h /usr/include/bits/string.h \ + /usr/include/bits/string2.h /usr/include/stdlib.h \ + /usr/local/include/mach/mach_types.h \ + /usr/local/include/mach/host_info.h /usr/local/include/mach/machine.h \ + /usr/local/include/mach/memory_object.h \ + /usr/local/include/mach/pc_sample.h \ + /usr/local/include/mach/processor_info.h \ + /usr/local/include/mach/task_info.h \ + /usr/local/include/mach/time_value.h \ + /usr/local/include/mach/task_special_ports.h \ + /usr/local/include/mach/thread_info.h /usr/local/include/mach/policy.h \ + /usr/local/include/mach/thread_special_ports.h \ + /usr/local/include/mach/thread_status.h \ + /usr/local/include/mach/machine/thread_status.h \ + /usr/local/include/mach/machine/fp_reg.h \ + /usr/local/include/mach/vm_attributes.h \ + /usr/local/include/mach/vm_inherit.h /usr/local/include/mach/vm_prot.h \ + /usr/local/include/mach/vm_statistics.h diff --git a/boot-proxy-exc/ourmach_portServer.o b/boot-proxy-exc/ourmach_portServer.o Binary files differnew file mode 100644 index 00000000..39c31ec7 --- /dev/null +++ b/boot-proxy-exc/ourmach_portServer.o diff --git a/boot-proxy-exc/ourmach_port_S.h b/boot-proxy-exc/ourmach_port_S.h new file mode 100644 index 00000000..df473c50 --- /dev/null +++ b/boot-proxy-exc/ourmach_port_S.h @@ -0,0 +1,432 @@ +#ifndef _mach_port_server_ +#define _mach_port_server_ + +/* Module mach_port */ + +#include <mach/kern_return.h> +#include <mach/port.h> +#include <mach/message.h> + +#include <mach/std_types.h> +#include <mach/mach_types.h> + +/* Routine mach_port_names */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_mach_port_names +#if defined(LINTLIBRARY) + (task, names, namesCnt, types, typesCnt) + mach_port_t task; + mach_port_array_t *names; + mach_msg_type_number_t *namesCnt; + mach_port_type_array_t *types; + mach_msg_type_number_t *typesCnt; +{ return S_mach_port_names(task, names, namesCnt, types, typesCnt); } +#else +( + mach_port_t task, + mach_port_array_t *names, + mach_msg_type_number_t *namesCnt, + mach_port_type_array_t *types, + mach_msg_type_number_t *typesCnt +); +#endif + +/* Routine mach_port_type */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_mach_port_type +#if defined(LINTLIBRARY) + (task, name, ptype) + mach_port_t task; + mach_port_t name; + mach_port_type_t *ptype; +{ return S_mach_port_type(task, name, ptype); } +#else +( + mach_port_t task, + mach_port_t name, + mach_port_type_t *ptype +); +#endif + +/* Routine mach_port_rename */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_mach_port_rename +#if defined(LINTLIBRARY) + (task, old_name, new_name) + mach_port_t task; + mach_port_t old_name; + mach_port_t new_name; +{ return S_mach_port_rename(task, old_name, new_name); } +#else +( + mach_port_t task, + mach_port_t old_name, + mach_port_t new_name +); +#endif + +/* Routine mach_port_allocate_name */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_mach_port_allocate_name +#if defined(LINTLIBRARY) + (task, right, name) + mach_port_t task; + mach_port_right_t right; + mach_port_t name; +{ return S_mach_port_allocate_name(task, right, name); } +#else +( + mach_port_t task, + mach_port_right_t right, + mach_port_t name +); +#endif + +/* Routine mach_port_allocate */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_mach_port_allocate +#if defined(LINTLIBRARY) + (task, right, name) + mach_port_t task; + mach_port_right_t right; + mach_port_t *name; +{ return S_mach_port_allocate(task, right, name); } +#else +( + mach_port_t task, + mach_port_right_t right, + mach_port_t *name +); +#endif + +/* Routine mach_port_destroy */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_mach_port_destroy +#if defined(LINTLIBRARY) + (task, name) + mach_port_t task; + mach_port_t name; +{ return S_mach_port_destroy(task, name); } +#else +( + mach_port_t task, + mach_port_t name +); +#endif + +/* Routine mach_port_deallocate */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_mach_port_deallocate +#if defined(LINTLIBRARY) + (task, name) + mach_port_t task; + mach_port_t name; +{ return S_mach_port_deallocate(task, name); } +#else +( + mach_port_t task, + mach_port_t name +); +#endif + +/* Routine mach_port_get_refs */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_mach_port_get_refs +#if defined(LINTLIBRARY) + (task, name, right, refs) + mach_port_t task; + mach_port_t name; + mach_port_right_t right; + mach_port_urefs_t *refs; +{ return S_mach_port_get_refs(task, name, right, refs); } +#else +( + mach_port_t task, + mach_port_t name, + mach_port_right_t right, + mach_port_urefs_t *refs +); +#endif + +/* Routine mach_port_mod_refs */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_mach_port_mod_refs +#if defined(LINTLIBRARY) + (task, name, right, delta) + mach_port_t task; + mach_port_t name; + mach_port_right_t right; + mach_port_delta_t delta; +{ return S_mach_port_mod_refs(task, name, right, delta); } +#else +( + mach_port_t task, + mach_port_t name, + mach_port_right_t right, + mach_port_delta_t delta +); +#endif + +/* Routine old_mach_port_get_receive_status */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_old_mach_port_get_receive_status +#if defined(LINTLIBRARY) + (task, name, status) + mach_port_t task; + mach_port_t name; + old_mach_port_status_t *status; +{ return S_old_mach_port_get_receive_status(task, name, status); } +#else +( + mach_port_t task, + mach_port_t name, + old_mach_port_status_t *status +); +#endif + +/* Routine mach_port_set_qlimit */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_mach_port_set_qlimit +#if defined(LINTLIBRARY) + (task, name, qlimit) + mach_port_t task; + mach_port_t name; + mach_port_msgcount_t qlimit; +{ return S_mach_port_set_qlimit(task, name, qlimit); } +#else +( + mach_port_t task, + mach_port_t name, + mach_port_msgcount_t qlimit +); +#endif + +/* Routine mach_port_set_mscount */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_mach_port_set_mscount +#if defined(LINTLIBRARY) + (task, name, mscount) + mach_port_t task; + mach_port_t name; + mach_port_mscount_t mscount; +{ return S_mach_port_set_mscount(task, name, mscount); } +#else +( + mach_port_t task, + mach_port_t name, + mach_port_mscount_t mscount +); +#endif + +/* Routine mach_port_get_set_status */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_mach_port_get_set_status +#if defined(LINTLIBRARY) + (task, name, members, membersCnt) + mach_port_t task; + mach_port_t name; + mach_port_array_t *members; + mach_msg_type_number_t *membersCnt; +{ return S_mach_port_get_set_status(task, name, members, membersCnt); } +#else +( + mach_port_t task, + mach_port_t name, + mach_port_array_t *members, + mach_msg_type_number_t *membersCnt +); +#endif + +/* Routine mach_port_move_member */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_mach_port_move_member +#if defined(LINTLIBRARY) + (task, member, after) + mach_port_t task; + mach_port_t member; + mach_port_t after; +{ return S_mach_port_move_member(task, member, after); } +#else +( + mach_port_t task, + mach_port_t member, + mach_port_t after +); +#endif + +/* Routine mach_port_request_notification */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_mach_port_request_notification +#if defined(LINTLIBRARY) + (task, name, id, sync, notify, previous, previousPoly) + mach_port_t task; + mach_port_t name; + mach_msg_id_t id; + mach_port_mscount_t sync; + mach_port_t notify; + mach_port_t *previous; + mach_msg_type_name_t *previousPoly; +{ return S_mach_port_request_notification(task, name, id, sync, notify, previous, previousPoly); } +#else +( + mach_port_t task, + mach_port_t name, + mach_msg_id_t id, + mach_port_mscount_t sync, + mach_port_t notify, + mach_port_t *previous, + mach_msg_type_name_t *previousPoly +); +#endif + +/* Routine mach_port_insert_right */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_mach_port_insert_right +#if defined(LINTLIBRARY) + (task, name, poly, polyPoly) + mach_port_t task; + mach_port_t name; + mach_port_t poly; + mach_msg_type_name_t polyPoly; +{ return S_mach_port_insert_right(task, name, poly, polyPoly); } +#else +( + mach_port_t task, + mach_port_t name, + mach_port_t poly, + mach_msg_type_name_t polyPoly +); +#endif + +/* Routine mach_port_extract_right */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_mach_port_extract_right +#if defined(LINTLIBRARY) + (task, name, msgt_name, poly, polyPoly) + mach_port_t task; + mach_port_t name; + mach_msg_type_name_t msgt_name; + mach_port_t *poly; + mach_msg_type_name_t *polyPoly; +{ return S_mach_port_extract_right(task, name, msgt_name, poly, polyPoly); } +#else +( + mach_port_t task, + mach_port_t name, + mach_msg_type_name_t msgt_name, + mach_port_t *poly, + mach_msg_type_name_t *polyPoly +); +#endif + +/* Routine mach_port_get_receive_status */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_mach_port_get_receive_status +#if defined(LINTLIBRARY) + (task, name, status) + mach_port_t task; + mach_port_t name; + mach_port_status_t *status; +{ return S_mach_port_get_receive_status(task, name, status); } +#else +( + mach_port_t task, + mach_port_t name, + mach_port_status_t *status +); +#endif + +/* Routine mach_port_set_seqno */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_mach_port_set_seqno +#if defined(LINTLIBRARY) + (task, name, seqno) + mach_port_t task; + mach_port_t name; + mach_port_seqno_t seqno; +{ return S_mach_port_set_seqno(task, name, seqno); } +#else +( + mach_port_t task, + mach_port_t name, + mach_port_seqno_t seqno +); +#endif + +#endif /* not defined(_mach_port_server_) */ diff --git a/boot-proxy-exc/sigvec.S b/boot-proxy-exc/sigvec.S new file mode 100644 index 00000000..cc7bb94e --- /dev/null +++ b/boot-proxy-exc/sigvec.S @@ -0,0 +1,23 @@ +#include <i386/asm.h> + +.text +ENTRY(sigreturn) + movl $0x67,%eax + lcall $0x7,$0x0 + jb error + ret +ENTRY(_sigreturn) + addl $0xc,%esp + call EXT(sigreturn) + ret +ENTRY(sigvec) + movl $0x6c,%eax + movl $EXT(_sigreturn),%edx + orl $0x80000000,%edx + lcall $0x7,$0x0 + jb error + ret +error: + movl %eax,EXT(errno) + movl $-1,%eax + ret diff --git a/boot-proxy-exc/syscall.S b/boot-proxy-exc/syscall.S new file mode 100644 index 00000000..a04ab28d --- /dev/null +++ b/boot-proxy-exc/syscall.S @@ -0,0 +1,35 @@ +/* Temporary.... + Copyright (C) 1993, 1995 Free Software Foundation + +This file is part of the GNU Hurd. + +The GNU Hurd is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +The GNU Hurd 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with the GNU Hurd; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include <i386/asm.h> + +/* .globl EXT(errno)*/ +.text +ENTRY(syscall) + pop %ecx + pop %eax + push %ecx + lcall $7, $0 + push %ecx /* Restore stack position. */ + jb error + ret +error: + movl %eax,EXT(errno) + movl $-1,%eax + ret diff --git a/boot-proxy-exc/term.sdefs.d b/boot-proxy-exc/term.sdefs.d new file mode 100644 index 00000000..962519f1 --- /dev/null +++ b/boot-proxy-exc/term.sdefs.d @@ -0,0 +1,5 @@ +termServer.c term_S.h: ../hurd/term.defs ../hurd/hurd_types.defs \ + /usr/local/include/mach/std_types.defs \ + /usr/local/include/mach/machine/machine_types.defs \ + /usr/local/include/mach/mach_types.defs \ + /usr/local/include/device/device_types.defs /usr/include/bits/utsname.h diff --git a/boot-proxy-exc/termServer.c b/boot-proxy-exc/termServer.c new file mode 100644 index 00000000..b24b3157 --- /dev/null +++ b/boot-proxy-exc/termServer.c @@ -0,0 +1,701 @@ +/* Module term */ + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE 1 +#endif + +#define EXPORT_BOOLEAN +#include <mach/boolean.h> +#include <mach/kern_return.h> +#include <mach/message.h> +#include <mach/mig_errors.h> +#include <mach/mig_support.h> + +#ifndef mig_internal +#define mig_internal static +#endif + +#ifndef mig_external +#define mig_external +#endif + +#ifndef TypeCheck +#define TypeCheck 1 +#endif + +#ifndef UseExternRCSId +#define UseExternRCSId 1 +#endif + +#define BAD_TYPECHECK(type, check) ({\ + union { mach_msg_type_t t; unsigned32_t w; } _t, _c;\ + _t.t = *(type); _c.t = *(check); _t.w != _c.w; }) +#define msgh_request_port msgh_local_port +#define MACH_MSGH_BITS_REQUEST(bits) MACH_MSGH_BITS_LOCAL(bits) +#define msgh_reply_port msgh_remote_port +#define MACH_MSGH_BITS_REPLY(bits) MACH_MSGH_BITS_REMOTE(bits) + +#include <mach/std_types.h> +#include <mach/mach_types.h> +#include <device/device_types.h> +#include <device/net_status.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/statfs.h> +#include <sys/resource.h> +#include <sys/utsname.h> +#include <hurd/hurd_types.h> + +/* Routine term_getctty */ +mig_internal void _Xterm_getctty + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t cttyType; + mach_port_t ctty; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_term_getctty + (io_t terminal, mach_port_t *ctty, mach_msg_type_name_t *cttyPoly); + + boolean_t msgh_simple; + auto const mach_msg_type_t cttyType = { + /* msgt_name = */ -1, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + mach_msg_type_name_t cttyPoly; + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_term_getctty(In0P->Head.msgh_request_port, &OutP->ctty, &cttyPoly); + if (OutP->RetCode != KERN_SUCCESS) + return; + + msgh_simple = TRUE; + OutP->Head.msgh_size = 40; + + OutP->cttyType = cttyType; + + if (MACH_MSG_TYPE_PORT_ANY(cttyPoly)) + msgh_simple = FALSE; + + OutP->cttyType.msgt_name = cttyPoly; + + if (!msgh_simple) + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; +} + +/* Routine term_open_ctty */ +mig_internal void _Xterm_open_ctty + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t pidType; + pid_t pid; + mach_msg_type_t pgrpType; + pid_t pgrp; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t newttyType; + mach_port_t newtty; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_term_open_ctty + (io_t terminal, pid_t pid, pid_t pgrp, mach_port_t *newtty, mach_msg_type_name_t *newttyPoly); + + boolean_t msgh_simple; + auto const mach_msg_type_t pidCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t pgrpCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t newttyType = { + /* msgt_name = */ -1, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + mach_msg_type_name_t newttyPoly; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->pidType, &pidCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->pgrpType, &pgrpCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_term_open_ctty(In0P->Head.msgh_request_port, In0P->pid, In0P->pgrp, &OutP->newtty, &newttyPoly); + if (OutP->RetCode != KERN_SUCCESS) + return; + + msgh_simple = TRUE; + OutP->Head.msgh_size = 40; + + OutP->newttyType = newttyType; + + if (MACH_MSG_TYPE_PORT_ANY(newttyPoly)) + msgh_simple = FALSE; + + OutP->newttyType.msgt_name = newttyPoly; + + if (!msgh_simple) + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; +} + +/* Routine term_set_nodename */ +mig_internal void _Xterm_set_nodename + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t nameType; + string_t name; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_term_set_nodename + (io_t terminal, string_t name); + + auto const mach_msg_type_t nameCheck = { + /* msgt_name = */ MACH_MSG_TYPE_STRING_C, + /* msgt_size = */ 8, + /* msgt_number = */ 1024, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 1052) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->nameType, &nameCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_term_set_nodename(In0P->Head.msgh_request_port, In0P->name); +} + +/* Routine term_get_nodename */ +mig_internal void _Xterm_get_nodename + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t nameType; + string_t name; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_term_get_nodename + (io_t terminal, string_t name); + + auto const mach_msg_type_t nameType = { + /* msgt_name = */ MACH_MSG_TYPE_STRING_C, + /* msgt_size = */ 8, + /* msgt_number = */ 1024, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_term_get_nodename(In0P->Head.msgh_request_port, OutP->name); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_size = 1060; + + OutP->nameType = nameType; +} + +/* Routine term_set_filenode */ +mig_internal void _Xterm_set_filenode + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t filenodeType; + file_t filenode; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_term_set_filenode + (io_t terminal, file_t filenode); + + auto const mach_msg_type_t filenodeCheck = { + /* msgt_name = */ 17, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->filenodeType, &filenodeCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_term_set_filenode(In0P->Head.msgh_request_port, In0P->filenode); +} + +/* Routine term_get_bottom_type */ +mig_internal void _Xterm_get_bottom_type + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t ttypeType; + int ttype; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_term_get_bottom_type + (io_t terminal, int *ttype); + + auto const mach_msg_type_t ttypeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_term_get_bottom_type(In0P->Head.msgh_request_port, &OutP->ttype); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_size = 40; + + OutP->ttypeType = ttypeType; +} + +/* Routine term_on_machdev */ +mig_internal void _Xterm_on_machdev + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t machdevType; + mach_port_t machdev; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_term_on_machdev + (io_t terminal, mach_port_t machdev); + + auto const mach_msg_type_t machdevCheck = { + /* msgt_name = */ 17, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->machdevType, &machdevCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_term_on_machdev(In0P->Head.msgh_request_port, In0P->machdev); +} + +/* Routine term_on_hurddev */ +mig_internal void _Xterm_on_hurddev + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t hurddevType; + io_t hurddev; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_term_on_hurddev + (io_t terminal, io_t hurddev); + + auto const mach_msg_type_t hurddevCheck = { + /* msgt_name = */ 17, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->hurddevType, &hurddevCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_term_on_hurddev(In0P->Head.msgh_request_port, In0P->hurddev); +} + +/* Routine term_on_pty */ +mig_internal void _Xterm_on_pty + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t ptymasterType; + io_t ptymaster; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_term_on_pty + (io_t terminal, io_t *ptymaster); + + auto const mach_msg_type_t ptymasterType = { + /* msgt_name = */ 19, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_term_on_pty(In0P->Head.msgh_request_port, &OutP->ptymaster); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; + OutP->Head.msgh_size = 40; + + OutP->ptymasterType = ptymasterType; +} + +/* Routine termctty_open_terminal */ +mig_internal void _Xtermctty_open_terminal + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t flagsType; + int flags; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t terminalType; + mach_port_t terminal; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_termctty_open_terminal + (mach_port_t ctty, int flags, mach_port_t *terminal, mach_msg_type_name_t *terminalPoly); + + boolean_t msgh_simple; + auto const mach_msg_type_t flagsCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t terminalType = { + /* msgt_name = */ -1, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + mach_msg_type_name_t terminalPoly; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->flagsType, &flagsCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_termctty_open_terminal(In0P->Head.msgh_request_port, In0P->flags, &OutP->terminal, &terminalPoly); + if (OutP->RetCode != KERN_SUCCESS) + return; + + msgh_simple = TRUE; + OutP->Head.msgh_size = 40; + + OutP->terminalType = terminalType; + + if (MACH_MSG_TYPE_PORT_ANY(terminalPoly)) + msgh_simple = FALSE; + + OutP->terminalType.msgt_name = terminalPoly; + + if (!msgh_simple) + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; +} + +/* Routine term_get_peername */ +mig_internal void _Xterm_get_peername + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t nameType; + string_t name; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_term_get_peername + (io_t terminal, string_t name); + + auto const mach_msg_type_t nameType = { + /* msgt_name = */ MACH_MSG_TYPE_STRING_C, + /* msgt_size = */ 8, + /* msgt_number = */ 1024, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_term_get_peername(In0P->Head.msgh_request_port, OutP->name); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_size = 1060; + + OutP->nameType = nameType; +} + +static mig_routine_t term_server_routines[] = { + _Xterm_getctty, + _Xterm_open_ctty, + _Xterm_set_nodename, + _Xterm_get_nodename, + _Xterm_set_filenode, + _Xterm_get_bottom_type, + _Xterm_on_machdev, + _Xterm_on_hurddev, + _Xterm_on_pty, + _Xtermctty_open_terminal, + _Xterm_get_peername, +}; + +mig_external boolean_t term_server + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + register mach_msg_header_t *InP = InHeadP; + register mig_reply_header_t *OutP = (mig_reply_header_t *) OutHeadP; + + auto const mach_msg_type_t RetCodeType = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + register mig_routine_t routine; + + OutP->Head.msgh_bits = MACH_MSGH_BITS(MACH_MSGH_BITS_REPLY(InP->msgh_bits), 0); + OutP->Head.msgh_size = sizeof *OutP; + OutP->Head.msgh_remote_port = InP->msgh_reply_port; + OutP->Head.msgh_local_port = MACH_PORT_NULL; + OutP->Head.msgh_seqno = 0; + OutP->Head.msgh_id = InP->msgh_id + 100; + + OutP->RetCodeType = RetCodeType; + + if ((InP->msgh_id > 28010) || (InP->msgh_id < 28000) || + ((routine = term_server_routines[InP->msgh_id - 28000]) == 0)) { + OutP->RetCode = MIG_BAD_ID; + return FALSE; + } + (*routine) (InP, &OutP->Head); + return TRUE; +} + +mig_external mig_routine_t term_server_routine + (const mach_msg_header_t *InHeadP) +{ + register int msgh_id; + + msgh_id = InHeadP->msgh_id - 28000; + + if ((msgh_id > 10) || (msgh_id < 0)) + return 0; + + return term_server_routines[msgh_id]; +} + diff --git a/boot-proxy-exc/termServer.d b/boot-proxy-exc/termServer.d new file mode 100644 index 00000000..c6b0503f --- /dev/null +++ b/boot-proxy-exc/termServer.d @@ -0,0 +1,51 @@ +termServer.o termServer_pic.o termServer_p.o termServer.d: termServer.c /usr/local/include/mach/boolean.h \ + /usr/local/include/mach/machine/boolean.h \ + /usr/local/include/mach/kern_return.h \ + /usr/local/include/mach/machine/kern_return.h \ + /usr/local/include/mach/message.h /usr/local/include/mach/port.h \ + /usr/local/include/mach/machine/vm_types.h \ + /usr/local/include/mach/mig_errors.h /usr/include/mach/mig_support.h \ + /usr/local/include/mach/std_types.h /usr/include/sys/types.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h /usr/include/gnu/stubs-pthread.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/time.h /usr/lib/gcc/i486-gnu/4.2.4/include/stddef.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/bits/byteswap.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/pthread/pthreadtypes.h \ + /usr/include/xlocale.h /usr/include/bits/pthread.h \ + /usr/include/bits/thread-attr.h /usr/include/sched.h \ + /usr/include/bits/sched.h /usr/include/bits/mutex-attr.h \ + /usr/include/bits/mutex.h /usr/include/bits/spin-lock.h \ + /usr/include/bits/condition-attr.h /usr/include/bits/condition.h \ + /usr/include/bits/rwlock-attr.h /usr/include/bits/rwlock.h \ + /usr/include/bits/barrier-attr.h /usr/include/bits/barrier.h \ + /usr/include/bits/thread-specific.h /usr/include/bits/once.h \ + /usr/include/string.h /usr/include/bits/string.h \ + /usr/include/bits/string2.h /usr/include/stdlib.h \ + /usr/local/include/mach/mach_types.h \ + /usr/local/include/mach/host_info.h /usr/local/include/mach/machine.h \ + /usr/local/include/mach/memory_object.h \ + /usr/local/include/mach/pc_sample.h \ + /usr/local/include/mach/processor_info.h \ + /usr/local/include/mach/task_info.h \ + /usr/local/include/mach/time_value.h \ + /usr/local/include/mach/task_special_ports.h \ + /usr/local/include/mach/thread_info.h /usr/local/include/mach/policy.h \ + /usr/local/include/mach/thread_special_ports.h \ + /usr/local/include/mach/thread_status.h \ + /usr/local/include/mach/machine/thread_status.h \ + /usr/local/include/mach/machine/fp_reg.h \ + /usr/local/include/mach/vm_attributes.h \ + /usr/local/include/mach/vm_inherit.h /usr/local/include/mach/vm_prot.h \ + /usr/local/include/mach/vm_statistics.h \ + /usr/local/include/device/device_types.h \ + /usr/local/include/device/net_status.h /usr/local/include/device/bpf.h \ + /usr/include/sys/stat.h /usr/include/bits/stat.h \ + /usr/include/sys/statfs.h /usr/include/bits/statfs.h \ + /usr/include/sys/resource.h /usr/include/bits/resource.h \ + /usr/include/sys/utsname.h /usr/include/bits/utsname.h \ + ../hurd/hurd_types.h /usr/include/errno.h /usr/include/bits/errno.h diff --git a/boot-proxy-exc/termServer.o b/boot-proxy-exc/termServer.o Binary files differnew file mode 100644 index 00000000..757ae7e4 --- /dev/null +++ b/boot-proxy-exc/termServer.o diff --git a/boot-proxy-exc/term_S.h b/boot-proxy-exc/term_S.h new file mode 100644 index 00000000..95b385f8 --- /dev/null +++ b/boot-proxy-exc/term_S.h @@ -0,0 +1,242 @@ +#ifndef _term_server_ +#define _term_server_ + +/* Module term */ + +#include <mach/kern_return.h> +#include <mach/port.h> +#include <mach/message.h> + +#include <mach/std_types.h> +#include <mach/mach_types.h> +#include <device/device_types.h> +#include <device/net_status.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/statfs.h> +#include <sys/resource.h> +#include <sys/utsname.h> +#include <hurd/hurd_types.h> + +/* Routine term_getctty */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_term_getctty +#if defined(LINTLIBRARY) + (terminal, ctty, cttyPoly) + io_t terminal; + mach_port_t *ctty; + mach_msg_type_name_t *cttyPoly; +{ return S_term_getctty(terminal, ctty, cttyPoly); } +#else +( + io_t terminal, + mach_port_t *ctty, + mach_msg_type_name_t *cttyPoly +); +#endif + +/* Routine term_open_ctty */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_term_open_ctty +#if defined(LINTLIBRARY) + (terminal, pid, pgrp, newtty, newttyPoly) + io_t terminal; + pid_t pid; + pid_t pgrp; + mach_port_t *newtty; + mach_msg_type_name_t *newttyPoly; +{ return S_term_open_ctty(terminal, pid, pgrp, newtty, newttyPoly); } +#else +( + io_t terminal, + pid_t pid, + pid_t pgrp, + mach_port_t *newtty, + mach_msg_type_name_t *newttyPoly +); +#endif + +/* Routine term_set_nodename */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_term_set_nodename +#if defined(LINTLIBRARY) + (terminal, name) + io_t terminal; + string_t name; +{ return S_term_set_nodename(terminal, name); } +#else +( + io_t terminal, + string_t name +); +#endif + +/* Routine term_get_nodename */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_term_get_nodename +#if defined(LINTLIBRARY) + (terminal, name) + io_t terminal; + string_t name; +{ return S_term_get_nodename(terminal, name); } +#else +( + io_t terminal, + string_t name +); +#endif + +/* Routine term_set_filenode */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_term_set_filenode +#if defined(LINTLIBRARY) + (terminal, filenode) + io_t terminal; + file_t filenode; +{ return S_term_set_filenode(terminal, filenode); } +#else +( + io_t terminal, + file_t filenode +); +#endif + +/* Routine term_get_bottom_type */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_term_get_bottom_type +#if defined(LINTLIBRARY) + (terminal, ttype) + io_t terminal; + int *ttype; +{ return S_term_get_bottom_type(terminal, ttype); } +#else +( + io_t terminal, + int *ttype +); +#endif + +/* Routine term_on_machdev */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_term_on_machdev +#if defined(LINTLIBRARY) + (terminal, machdev) + io_t terminal; + mach_port_t machdev; +{ return S_term_on_machdev(terminal, machdev); } +#else +( + io_t terminal, + mach_port_t machdev +); +#endif + +/* Routine term_on_hurddev */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_term_on_hurddev +#if defined(LINTLIBRARY) + (terminal, hurddev) + io_t terminal; + io_t hurddev; +{ return S_term_on_hurddev(terminal, hurddev); } +#else +( + io_t terminal, + io_t hurddev +); +#endif + +/* Routine term_on_pty */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_term_on_pty +#if defined(LINTLIBRARY) + (terminal, ptymaster) + io_t terminal; + io_t *ptymaster; +{ return S_term_on_pty(terminal, ptymaster); } +#else +( + io_t terminal, + io_t *ptymaster +); +#endif + +/* Routine termctty_open_terminal */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_termctty_open_terminal +#if defined(LINTLIBRARY) + (ctty, flags, terminal, terminalPoly) + mach_port_t ctty; + int flags; + mach_port_t *terminal; + mach_msg_type_name_t *terminalPoly; +{ return S_termctty_open_terminal(ctty, flags, terminal, terminalPoly); } +#else +( + mach_port_t ctty, + int flags, + mach_port_t *terminal, + mach_msg_type_name_t *terminalPoly +); +#endif + +/* Routine term_get_peername */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t S_term_get_peername +#if defined(LINTLIBRARY) + (terminal, name) + io_t terminal; + string_t name; +{ return S_term_get_peername(terminal, name); } +#else +( + io_t terminal, + string_t name +); +#endif + +#endif /* not defined(_term_server_) */ diff --git a/boot-proxy-exc/userland-boot.c b/boot-proxy-exc/userland-boot.c new file mode 100644 index 00000000..20c818ff --- /dev/null +++ b/boot-proxy-exc/userland-boot.c @@ -0,0 +1,122 @@ +/* boot_script.c support functions for running in a Mach user task. + Copyright (C) 2001 Free Software Foundation, Inc. + + This file is part of the GNU Hurd. + + The GNU Hurd is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + The GNU Hurd 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 + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include <mach.h> +#include <stdlib.h> +#include <stdio.h> +#include <errno.h> +#include <error.h> +#include "boot_script.h" +#include "mach_proxy.h" +#include "util.h" + +extern boolean_t is_user; + +void * +boot_script_malloc (unsigned int size) +{ + return malloc (size); +} + +void +boot_script_free (void *ptr, unsigned int size) +{ + free (ptr); +} + +int +boot_script_task_create (struct cmd *cmd) +{ + error_t err = task_create (mach_task_self (), 0, &cmd->task); + if (err) + { + error (0, err, "%s: task_create", cmd->path); + return BOOT_SCRIPT_MACH_ERROR; + } + debug ("creating task: %s, task port: %d", cmd->path, cmd->task); + if (is_user) + { + task_t pseudo_task = 0; + create_pseudo_task (cmd->task, &pseudo_task); + /* now it is the pseudo task port. */ + cmd->task = pseudo_task; + } + err = task_suspend (cmd->task); + if (err) + { + error (0, err, "%s: task_suspend", cmd->path); + return BOOT_SCRIPT_MACH_ERROR; + } + return 0; +} + +int +boot_script_task_resume (struct cmd *cmd) +{ + debug ("resume task %s: %d", cmd->path, cmd->task); + error_t err = task_resume (cmd->task); + if (err) + { + error (0, err, "%s: task_resume", cmd->path); + return BOOT_SCRIPT_MACH_ERROR; + } + return 0; +} + +int +boot_script_prompt_task_resume (struct cmd *cmd) +{ + char xx[5]; + + printf ("Hit return to resume %s...", cmd->path); + fgets (xx, sizeof xx, stdin); + + return boot_script_task_resume (cmd); +} + +void +boot_script_free_task (task_t task, int aborting) +{ + if (aborting) + task_terminate (task); + else if (!is_user) + mach_port_deallocate (mach_task_self (), task); + /* For the normal user, the task port will still be used, + * so we cannot deallocate the task port here.*/ +} + +int +boot_script_insert_right (struct cmd *cmd, mach_port_t port, mach_port_t *name) +{ + error_t err = mach_port_insert_right (cmd->task, + port, port, MACH_MSG_TYPE_COPY_SEND); + if (err) + { + error (0, err, "%s: mach_port_insert_right", cmd->path); + return BOOT_SCRIPT_MACH_ERROR; + } + *name = port; + return 0; +} + +int +boot_script_insert_task_port (struct cmd *cmd, task_t task, mach_port_t *name) +{ + return boot_script_insert_right (cmd, task, name); +} diff --git a/boot-proxy-exc/userland-boot.d b/boot-proxy-exc/userland-boot.d new file mode 100644 index 00000000..34a8b5e2 --- /dev/null +++ b/boot-proxy-exc/userland-boot.d @@ -0,0 +1,89 @@ +userland-boot.o userland-boot_pic.o userland-boot_p.o userland-boot.d: userland-boot.c /usr/include/mach.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h /usr/include/gnu/stubs-pthread.h \ + /usr/local/include/mach/mach_types.h \ + /usr/local/include/mach/host_info.h /usr/local/include/mach/machine.h \ + /usr/local/include/mach/machine/vm_types.h \ + /usr/local/include/mach/boolean.h \ + /usr/local/include/mach/machine/boolean.h \ + /usr/local/include/mach/memory_object.h /usr/local/include/mach/port.h \ + /usr/local/include/mach/pc_sample.h \ + /usr/local/include/mach/processor_info.h \ + /usr/local/include/mach/task_info.h \ + /usr/local/include/mach/time_value.h \ + /usr/local/include/mach/task_special_ports.h \ + /usr/local/include/mach/thread_info.h /usr/local/include/mach/policy.h \ + /usr/local/include/mach/thread_special_ports.h \ + /usr/local/include/mach/thread_status.h \ + /usr/local/include/mach/machine/thread_status.h \ + /usr/local/include/mach/machine/fp_reg.h \ + /usr/local/include/mach/vm_attributes.h \ + /usr/local/include/mach/vm_inherit.h /usr/local/include/mach/vm_prot.h \ + /usr/local/include/mach/vm_statistics.h \ + /usr/local/include/mach/std_types.h \ + /usr/local/include/mach/kern_return.h \ + /usr/local/include/mach/machine/kern_return.h /usr/include/mach_init.h \ + /usr/include/mach/mach_traps.h /usr/local/include/mach/message.h \ + /usr/include/mach/mach_interface.h /usr/include/mach/mach_port.h \ + /usr/include/mach/mach_host.h /usr/include/mach-shortcuts.h \ + /usr/include/stdio.h /usr/include/stdlib.h \ + /usr/lib/gcc/i486-gnu/4.2.4/include/stddef.h \ + /usr/include/bits/waitflags.h /usr/include/bits/waitstatus.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/bits/byteswap.h /usr/include/xlocale.h \ + /usr/include/sys/types.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/pthread/pthreadtypes.h /usr/include/bits/pthread.h \ + /usr/include/bits/thread-attr.h /usr/include/sched.h \ + /usr/include/bits/sched.h /usr/include/bits/mutex-attr.h \ + /usr/include/bits/mutex.h /usr/include/bits/spin-lock.h \ + /usr/include/bits/condition-attr.h /usr/include/bits/condition.h \ + /usr/include/bits/rwlock-attr.h /usr/include/bits/rwlock.h \ + /usr/include/bits/barrier-attr.h /usr/include/bits/barrier.h \ + /usr/include/bits/thread-specific.h /usr/include/bits/once.h \ + /usr/include/alloca.h /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/wchar.h /usr/lib/gcc/i486-gnu/4.2.4/include/stdarg.h \ + /usr/include/bits/stdio-lock.h /usr/include/bits/libc-lock.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/bits/stdio.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/error.h boot_script.h \ + mach_proxy.h /usr/include/hurd.h /usr/local/include/mach/mig_errors.h \ + ../hurd/hurd_types.h /usr/include/hurd/auth.h \ + /usr/local/include/device/device_types.h \ + /usr/local/include/device/net_status.h /usr/local/include/device/bpf.h \ + /usr/include/sys/stat.h /usr/include/bits/stat.h \ + /usr/include/sys/statfs.h /usr/include/bits/statfs.h \ + /usr/include/sys/resource.h /usr/include/bits/resource.h \ + /usr/include/sys/utsname.h /usr/include/bits/utsname.h \ + /usr/include/hurd/process.h /usr/include/hurd/fs.h \ + /usr/include/hurd/io.h /usr/include/hurd/port.h \ + /usr/include/hurd/userlink.h /usr/include/hurd/signal.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/sys/ucontext.h /usr/include/bits/sigthread.h \ + /usr/include/hurd/msg.h ../include/cthreads.h \ + ../include/../libthreads/cthreads.h \ + /usr/local/include/mach/machine/vm_param.h /usr/include/machine-sp.h \ + /usr/include/spin-lock.h /usr/include/lock-intern.h \ + /usr/include/machine-lock.h /usr/include/setjmp.h \ + /usr/include/bits/setjmp.h /usr/include/hurd/threadvar.h \ + ../hurd/ports.h ../hurd/../libports/ports.h ../hurd/ihash.h \ + ../hurd/../libihash/ihash.h \ + /usr/lib/gcc/i486-gnu/4.2.4/include/limits.h \ + /usr/lib/gcc/i486-gnu/4.2.4/include/syslimits.h /usr/include/limits.h \ + /usr/include/bits/posix1_lim.h /usr/include/bits/local_lim.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/xopen_lim.h \ + /usr/include/stdint.h /usr/include/bits/wchar.h \ + /usr/local/include/mach/notify.h list.h util.h /usr/include/string.h \ + /usr/include/bits/string.h /usr/include/bits/string2.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/arpa/inet.h \ + /usr/include/netinet/in.h /usr/include/bits/in.h \ + /usr/include/netinet/ip.h /usr/include/syslog.h \ + /usr/include/sys/syslog.h /usr/include/bits/syslog-path.h diff --git a/boot-proxy-exc/userland-boot.o b/boot-proxy-exc/userland-boot.o Binary files differnew file mode 100644 index 00000000..024396ce --- /dev/null +++ b/boot-proxy-exc/userland-boot.o diff --git a/boot-proxy-exc/util.h b/boot-proxy-exc/util.h new file mode 100644 index 00000000..e82a8626 --- /dev/null +++ b/boot-proxy-exc/util.h @@ -0,0 +1,113 @@ +/* + Copyright (C) 2008 Free Software Foundation, Inc. + Written by Zheng Da. + + This file is part of the GNU Hurd. + + The GNU Hurd is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + The GNU Hurd 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with the GNU Hurd; see the file COPYING. If not, write to + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef UTIL_H +#define UTIL_H + +#include <stdio.h> +#include <string.h> + +#include <sys/types.h> +#include <sys/socket.h> +#include <arpa/inet.h> +#include <netinet/ip.h> +#include <syslog.h> + +#include <mach.h> +#include <hurd.h> + +#define DEBUG 0 +#define INFO 1 +#define LOGLEVEL DEBUG + +extern FILE *logfile; + +#define LOG_START() do \ +{ \ + logfile = fopen("boot.log", "a"); \ + assert (logfile != NULL); \ +} while (0) + +#define LOG_END() fclose (logfile) + +#define output(format, ...) do \ +{ \ + char buf[1024]; \ + snprintf (buf, 1024, "boot: %s: %s\r\n", __func__, format); \ + fprintf (stderr , buf, ## __VA_ARGS__); \ + fflush (stderr); \ +} while (0) + +#if DEBUG >= LOGLEVEL +#define debug(format, ...) do \ +{ \ + char buf[1024]; \ + snprintf (buf, 1024, "boot: %s: %s\r\n", __func__, format); \ + fprintf (logfile , buf, ## __VA_ARGS__); \ + fflush (logfile); \ +} while (0) +#else +#define debug(format, ...) do {} while (0) +#endif + +#if INFO >= LOGLEVEL +#define info output +#else +#define info(format, ...) do {} while (0) +#endif + +#if ERROR >= LOGLEVEL +#define logerror(format, ...) do \ +{ \ + char buf[1024]; \ + snprintf (buf, 1024, "boot ERROR: %s: %s\r\n", __func__, format); \ + fprintf (stderr , buf, ## __VA_ARGS__); \ + fflush (stderr); \ +} while (0) +#else +#define logerror(format, ...) do {} while (0) +#endif + +#define print_port_type(port) do \ +{ \ + mach_port_type_t ptype; \ + error_t err = mach_port_type (mach_task_self (), port, &ptype); \ + if (err) \ + debug ("mach_port_type: %s", strerror (err)); \ + else if (ptype & MACH_PORT_TYPE_SEND) \ + debug ("port %d has send right", port); \ + else if (ptype & MACH_PORT_TYPE_RECEIVE) \ + debug ("port %d has receive right", port); \ + else if (ptype & MACH_PORT_TYPE_SEND_ONCE) \ + debug ("port %d has send once right", port); \ + else if (ptype & MACH_PORT_TYPE_PORT_SET) \ + debug ("port %d is port set", port); \ + else if (ptype & MACH_PORT_TYPE_DEAD_NAME) \ + debug ("port %d is a dead name", port); \ + else \ + debug ("the type of port %d is %d", port, ptype); \ + mach_port_urefs_t refs; \ + err = mach_port_get_refs (mach_task_self (), port, \ + MACH_PORT_RIGHT_SEND, &refs); \ + if (!err) \ + debug ("port send right references: %d", refs); \ +} while (0) + +#endif diff --git a/boot-proxy-exc/util.h~ b/boot-proxy-exc/util.h~ new file mode 100644 index 00000000..7073cdd2 --- /dev/null +++ b/boot-proxy-exc/util.h~ @@ -0,0 +1,113 @@ +/* + Copyright (C) 2008 Free Software Foundation, Inc. + Written by Zheng Da. + + This file is part of the GNU Hurd. + + The GNU Hurd is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + The GNU Hurd 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with the GNU Hurd; see the file COPYING. If not, write to + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef UTIL_H +#define UTIL_H + +#include <stdio.h> +#include <string.h> + +#include <sys/types.h> +#include <sys/socket.h> +#include <arpa/inet.h> +#include <netinet/ip.h> +#include <syslog.h> + +#include <mach.h> +#include <hurd.h> + +#define DEBUG 0 +#define INFO 1 +#define LOGLEVEL INFO + +extern FILE *logfile; + +#define LOG_START() do \ +{ \ + logfile = fopen("boot.log", "a"); \ + assert (logfile != NULL); \ +} while (0) + +#define LOG_END() fclose (logfile) + +#define output(format, ...) do \ +{ \ + char buf[1024]; \ + snprintf (buf, 1024, "boot: %s: %s\r\n", __func__, format); \ + fprintf (stderr , buf, ## __VA_ARGS__); \ + fflush (stderr); \ +} while (0) + +#if DEBUG >= LOGLEVEL +#define debug(format, ...) do \ +{ \ + char buf[1024]; \ + snprintf (buf, 1024, "boot: %s: %s\r\n", __func__, format); \ + fprintf (logfile , buf, ## __VA_ARGS__); \ + fflush (logfile); \ +} while (0) +#else +#define debug(format, ...) do {} while (0) +#endif + +#if INFO >= LOGLEVEL +#define info output +#else +#define info(format, ...) do {} while (0) +#endif + +#if ERROR >= LOGLEVEL +#define logerror(format, ...) do \ +{ \ + char buf[1024]; \ + snprintf (buf, 1024, "boot ERROR: %s: %s\r\n", __func__, format); \ + fprintf (stderr , buf, ## __VA_ARGS__); \ + fflush (stderr); \ +} while (0) +#else +#define logerror(format, ...) do {} while (0) +#endif + +#define print_port_type(port) do \ +{ \ + mach_port_type_t ptype; \ + error_t err = mach_port_type (mach_task_self (), port, &ptype); \ + if (err) \ + debug ("mach_port_type: %s", strerror (err)); \ + else if (ptype & MACH_PORT_TYPE_SEND) \ + debug ("port %d has send right", port); \ + else if (ptype & MACH_PORT_TYPE_RECEIVE) \ + debug ("port %d has receive right", port); \ + else if (ptype & MACH_PORT_TYPE_SEND_ONCE) \ + debug ("port %d has send once right", port); \ + else if (ptype & MACH_PORT_TYPE_PORT_SET) \ + debug ("port %d is port set", port); \ + else if (ptype & MACH_PORT_TYPE_DEAD_NAME) \ + debug ("port %d is a dead name", port); \ + else \ + debug ("the type of port %d is %d", port, ptype); \ + mach_port_urefs_t refs; \ + err = mach_port_get_refs (mach_task_self (), port, \ + MACH_PORT_RIGHT_SEND, &refs); \ + if (!err) \ + debug ("port send right references: %d", refs); \ +} while (0) + +#endif diff --git a/boot-proxy-exc/ux.c b/boot-proxy-exc/ux.c new file mode 100644 index 00000000..b532f19e --- /dev/null +++ b/boot-proxy-exc/ux.c @@ -0,0 +1,303 @@ +/* Hacks to make boot work under UX + + Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation, Inc. + + This file is part of the GNU Hurd. + + The GNU Hurd is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + The GNU Hurd 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with the GNU Hurd; see the file COPYING. If not, write to + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include <mach.h> +#include <sys/types.h> +#include <stdio.h> +#include <stdlib.h> +#include <stdarg.h> +#include <string.h> +#include <cthreads.h> + +#include "ux.h" + +#if 0 +static int (* const _sc)(int, ...) = &syscall; +int _sc_print = 1; + +#define syscall(num, args...) \ + ({ int _rv, _num = (num), _pr = _sc_print; \ + _sc_print = 0; \ + if (_pr) printf ("syscall (%d) start\r\n", _num); \ + _rv = (*_sc) (_num , ##args); \ + if (_pr) printf ("syscall (%d) end\r\n", _num); \ + _sc_print = _pr; \ + _rv; \ + }) +#endif + +extern void __mach_init (); +void (*mach_init_routine)() = __mach_init; + +/* These will prevent the Hurd-ish versions from being used */ + +struct free_reply_port +{ + mach_port_t port; + struct free_reply_port *next; +}; +static struct free_reply_port *free_reply_ports = NULL; +static spin_lock_t free_reply_ports_lock = SPIN_LOCK_INITIALIZER; + +mach_port_t __mig_get_reply_port () +{ + spin_lock (&free_reply_ports_lock); + if (free_reply_ports == NULL) + { + spin_unlock (&free_reply_ports_lock); + return __mach_reply_port (); + } + else + { + struct free_reply_port *frp = free_reply_ports; + mach_port_t reply_port = frp->port; + free_reply_ports = free_reply_ports->next; + spin_unlock (&free_reply_ports_lock); + free (frp); + return reply_port; + } +} +mach_port_t mig_get_reply_port () +{ + return __mig_get_reply_port (); +} +void __mig_put_reply_port (mach_port_t port) +{ + struct free_reply_port *frp = malloc (sizeof (struct free_reply_port)); + frp->port = port; + spin_lock (&free_reply_ports_lock); + frp->next = free_reply_ports; + free_reply_ports = frp; + spin_unlock (&free_reply_ports_lock); +} +void mig_put_reply_port (mach_port_t port) +{ + __mig_put_reply_port (port); +} +void __mig_dealloc_reply_port (mach_port_t port) +{ + mach_port_mod_refs (__mach_task_self (), port, + MACH_PORT_RIGHT_RECEIVE, -1); +} +void mig_dealloc_reply_port (mach_port_t port) +{ + __mig_dealloc_reply_port (port); +} +void __mig_init (void *stack) {} +void mig_init (void *stack) {} + +int +task_by_pid (int pid) +{ + return syscall (-33, pid); +} + +int +write (int fd, + const void *buf, + int buflen) +{ + return syscall (4, fd, buf, buflen); +} + +int +read (int fd, + void *buf, + int buflen) +{ + return syscall (3, fd, buf, buflen); +} + +int +open (const char *name, + int flags, + int mode) +{ + return syscall (5, name, flags, mode); +} + +int +uxfstat (int fd, struct uxstat *buf) +{ + return syscall (62, fd, buf); +} + +int +close (int fd) +{ + return syscall (6, fd); +} + +int +lseek (int fd, + int off, + int whence) +{ + return syscall (19, fd, off, whence); +} + +int +uxexit (int code) +{ + return syscall (1, code); +} + +int +getpid () +{ + return syscall (20); +} + +int +ioctl (int fd, int code, void *buf) +{ + return syscall (54, fd, code, buf); +} + +int +sigblock (int mask) +{ + return syscall (109, mask); +} + +int +sigsetmask (int mask) +{ + return syscall (110, mask); +} + +int +sigpause (int mask) +{ + return syscall (111, mask); +} + + +#if 0 +void +sigreturn () +{ + asm volatile ("movl $0x67,%eax\n" + "lcall $0x7, $0x0\n" + "ret"); +} + +void +_sigreturn () +{ + asm volatile ("addl $0xc, %%esp\n" + "call %0\n" + "ret"::"m" (sigreturn)); +} + +int +sigvec (int sig, struct sigvec *vec, struct sigvec *ovec) +{ + asm volatile ("movl $0x6c,%%eax\n" + "movl %0, %%edx\n" + "orl $0x80000000, %%edx\n" + "lcall $0x7,$0x0\n" + "ret"::"g" (_sigreturn)); +} +#else +int sigvec (); +#endif + +void get_privileged_ports (mach_port_t *host_port, mach_port_t *device_port) +{ + *host_port = task_by_pid (-1); + *device_port = task_by_pid (-2); +} + +/* A *really* stupid printf that only understands %s & %d. */ +int +printf (const char *fmt, ...) +{ + va_list ap; + const char *p = fmt, *q = p; + + void flush (const char *new) + { + if (p > q) + write (1, q, p - q); + q = p = new; + } + + va_start (ap, fmt); + while (*p) + if (*p == '%' && p[1] == 's') + { + char *str = va_arg (ap, char *); + flush (p + 2); + write (1, str, strlen (str)); + } + else if (*p == '%' && p[1] == 'd') + { + int i = va_arg (ap, int); + char rbuf[20], *e = rbuf + sizeof (rbuf), *b = e; + + if (i == 0) + *--b = '0'; + else + while (i) + { + *--b = i % 10 + '0'; + i /= 10; + } + + flush (p + 2); + write (1, b, e - b); + } + else + p++; + va_end (ap); + + flush (0); + + return 0; +} + +static struct sgttyb term_sgb; +static int localbits; + +void +init_termstate () +{ + struct sgttyb sgb; + int bits; + ioctl (0, TIOCGETP, &term_sgb); + ioctl (0, TIOCLGET, &localbits); + /* Enter raw made. Rather than try and interpret these bits, + we just do what emacs does in .../emacs/src/sysdep.c for + an old style terminal driver. */ + bits = localbits | LDECCTQ | LLITOUT | LPASS8 | LNOFLSH; + ioctl (0, TIOCLSET, &bits); + sgb = term_sgb; + sgb.sg_flags &= ~ECHO; + sgb.sg_flags |= RAW | ANYP; + ioctl (0, TIOCSETN, &sgb); +} + +void +restore_termstate () +{ + ioctl (0, TIOCLSET, &localbits); + ioctl (0, TIOCSETN, &term_sgb); +} diff --git a/boot-proxy-exc/ux.h b/boot-proxy-exc/ux.h new file mode 100644 index 00000000..d3787c54 --- /dev/null +++ b/boot-proxy-exc/ux.h @@ -0,0 +1,114 @@ +/* Hacks to make boot work under UX + + Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation, Inc. + + This file is part of the GNU Hurd. + + The GNU Hurd is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + The GNU Hurd 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with the GNU Hurd; see the file COPYING. If not, write to + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#define sigmask(m) (1 << ((m)-1)) + +#define IOCPARM_MASK 0x7f +#define IOC_OUT 0x40000000 +#define IOC_IN 0x80000000 +#define _IOR(x,y,t) (IOC_OUT|((sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y) +#define _IOW(x,y,t) (IOC_IN|((sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y) +#define FIONREAD _IOR('f', 127, int) +#define FIOASYNC _IOW('f', 125, int) +#define TIOCGETP _IOR('t', 8, struct sgttyb) +#define TIOCLGET _IOR('t', 124, int) +#define TIOCLSET _IOW('t', 125, int) +#define TIOCSETN _IOW('t', 10, struct sgttyb) +#define LDECCTQ 0x4000 +#define LLITOUT 0x0020 +#define LPASS8 0x0800 +#define LNOFLSH 0x8000 +#define RAW 0x0020 +#define ANYP 0x00c0 +#define ECHO 8 + + +struct sgttyb +{ + char unused[4]; + short sg_flags; +}; + +#define SIGIO 23 + +struct sigvec +{ + void (*sv_handler)(); + int sv_mask; + int sv_flags; +}; + +struct uxstat + { + short int st_dev; /* Device containing the file. */ + __ino_t st_ino; /* File serial number. */ + unsigned short int st_mode; /* File mode. */ + __nlink_t st_nlink; /* Link count. */ + unsigned short int st_uid; /* User ID of the file's owner. */ + unsigned short int st_gid; /* Group ID of the file's group.*/ + short int st_rdev; /* Device number, if device. */ + __off_t st_size; /* Size of file, in bytes. */ + __time_t st_atime; /* Time of last access. */ + unsigned long int st_atime_usec; + __time_t st_mtime; /* Time of last modification. */ + unsigned long int st_mtime_usec; + __time_t st_ctime; /* Time of last status change. */ + unsigned long int st_ctime_usec; + unsigned long int st_blksize; /* Optimal block size for I/O. */ + unsigned long int st_blocks; /* Number of 512-byte blocks allocated. */ + long int st_spare[2]; + }; + +void get_privileged_ports (mach_port_t *host_port, mach_port_t *device_port); + +/* We can't include <unistd.h> for this, because that will fight witho + our definitions of syscalls below. */ +int syscall (int, ...); + +int open (const char *name, int flags, int mode); +int write (int fd, const void *buf, int len); +int read (int fd, void *buf, int len); +int uxfstat (int fd, struct uxstat *buf); +int close (int fd); +int lseek (int fd, int off, int whence); +int uxexit (int code); +int getpid (); +int ioctl (int fd, int code, void *buf); +int sigblock (int mask); +int sigsetmask (int mask); +int sigpause (int mask); +int sigvec (int sig, struct sigvec *vec, struct sigvec *ovec); + +#undef O_RDONLY +#undef O_WRONLY +#undef O_RDWR +#define O_RDONLY 0 +#define O_WRONLY 1 +#define O_RDWR 2 + +#define host_exit(c) uxexit(c) + +typedef struct uxstat host_stat_t; +#define host_fstat(fd, st) uxfstat (fd, st) + +void init_stdio (); + +#undef errno +int errno; |