diff options
Diffstat (limited to 'boot.backup1')
-rw-r--r-- | boot.backup1/Makefile~ | 56 | ||||
-rw-r--r-- | boot.backup1/boot.c~ | 2073 | ||||
-rw-r--r-- | boot.backup1/exc_impl.c~ | 38 | ||||
-rw-r--r-- | boot.backup1/list.h~ | 40 | ||||
-rw-r--r-- | boot.backup1/mach_host_impl.c~ | 551 | ||||
-rw-r--r-- | boot.backup1/mach_impl.c~ | 869 | ||||
-rw-r--r-- | boot.backup1/mach_port_impl.c~ | 378 | ||||
-rw-r--r-- | boot.backup1/mach_proxy.c~ | 68 | ||||
-rw-r--r-- | boot.backup1/mach_proxy.h~ | 54 | ||||
-rw-r--r-- | boot.backup1/ourmach.defs~ | 770 | ||||
-rw-r--r-- | boot.backup1/ourmach_host.defs~ | 381 | ||||
-rw-r--r-- | boot.backup1/ourmach_port.defs~ | 348 | ||||
-rw-r--r-- | boot.backup1/util.h~ | 96 |
13 files changed, 0 insertions, 5722 deletions
diff --git a/boot.backup1/Makefile~ b/boot.backup1/Makefile~ deleted file mode 100644 index 33c475fb..00000000 --- a/boot.backup1/Makefile~ +++ /dev/null @@ -1,56 +0,0 @@ -# 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.backup1/boot.c~ b/boot.backup1/boot.c~ deleted file mode 100644 index 94bcdac5..00000000 --- a/boot.backup1/boot.c~ +++ /dev/null @@ -1,2073 +0,0 @@ -/* 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> - -//task_t kernel_task; -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 *thread_portclass; - -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 pseudo_privileged_host_port; -mach_port_t receive_set; -mach_port_t pseudo_console, pseudo_root; -auth_t authserver; - -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; - - -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) - || mach_host_server (inp, outp) - || mach_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_one_thread (port_bucket, - mach_proxy_demuxer, 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); - - debug ("load the executable file..."); - 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."}, - { 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 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; -} - -void init_kernel_task () -{ - error_t err; - task_t pseudo_task; - task_t kernel_task; - int create_pseudo_task (task_t real_task, task_t *ret_pseudo_task); - - err = proc_pid2task (getproc (), 2, &kernel_task); - if (err) - error (4, err, "cannot get the kernel task port"); - create_pseudo_task (kernel_task, &pseudo_task); -} - -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 }; - -#ifdef UNTESTED - fprintf (stderr, "running untested code\n"); -#else - fprintf (stderr, "running tested code\n"); -#endif - - port_bucket = ports_create_bucket (); - task_portclass = ports_create_class (clean_pseudo_task, 0); - thread_portclass = ports_create_class (0, 0); - init_kernel_task (); - cthread_detach (cthread_fork ((cthread_fn_t) mach_proxy_thread, (any_t) 0)); - - 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); - -// get_privileged_ports (&privileged_host_port, 0 /*&master_device_port*/); -// if (privileged_host_port == MACH_PORT_NULL) -// { -// debug ("Cannot get the privileged host port"); -// exit (4); -// } -// if (master_device_port == MACH_PORT_NULL) -// { -// debug ("Cannot get the master device port"); -// exit (4); -// } - - if (pager_file == NULL) - { - fprintf (stderr, "The default pager must be specified for subhurd."); - exit (4); - } - defpager = file_name_lookup (pager_file, O_EXEC, 0); - if (defpager == MACH_PORT_NULL) - error (4, errno, "file_name_look: %s", pager_file); -// defpager = MACH_PORT_NULL; -// err = vm_set_default_memory_manager (privileged_host_port, &defpager); -// if (err) -// error (4, err, "vm_set_default_memory_manager"); - - 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 privileged host port. */ - mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_RECEIVE, - &pseudo_privileged_host_port); - mach_port_insert_right (mach_task_self (), - pseudo_privileged_host_port, - pseudo_privileged_host_port, - MACH_MSG_TYPE_MAKE_SEND); - mach_port_move_member (mach_task_self (), pseudo_privileged_host_port, - receive_set); - mach_port_request_notification (mach_task_self (), - pseudo_privileged_host_port, - MACH_NOTIFY_NO_SENDERS, 1, - pseudo_privileged_host_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) privileged_host_port) - (int) pseudo_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); - mach_port_deallocate (mach_task_self (), pseudo_privileged_host_port); - - cthread_detach (cthread_fork ((cthread_fn_t) msg_thread, (any_t) 0)); - - debug ("start the select loop..."); - 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"); - } - -/* 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; -{ - *hostp = pseudo_privileged_host_port; -// *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; - - imsg.port_1 = pseudo_privileged_host_port; -// 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; - } - - return D_NO_SUCH_DEVICE; -// *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) - { - debug ("device_write to console: %d", datalen); -#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; - debug ("device_write to pseudo root: %d", datalen); - 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; - debug ("device_write_inband to pseudo root: %d", datalen); - 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; -} - -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; - - err = ports_do_mach_notify_no_senders (notify, mscount); - if (!err) - { - info ("a task die"); - return 0; - } - - if (notify == pseudo_master_device_port) - { - if (no_console && pseudo_privileged_host_port == MACH_PORT_NULL) - goto bye; - pseudo_master_device_port = MACH_PORT_NULL; - return 0; - } - if (notify == pseudo_privileged_host_port) - { - if (no_console && pseudo_master_device_port == MACH_PORT_NULL) - goto bye; - pseudo_privileged_host_port = MACH_PORT_NULL; - return 0; - } - if (notify == pseudo_console) - { - if (mscount == console_mscount && - pseudo_master_device_port == MACH_PORT_NULL && - pseudo_privileged_host_port == MACH_PORT_NULL) - { - bye: - restore_termstate (); - write (2, "bye\n", 4); - host_exit (0); - } - else - { - no_console = (mscount == console_mscount); - - 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); - } - } - - return EOPNOTSUPP; -} - -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.backup1/exc_impl.c~ b/boot.backup1/exc_impl.c~ deleted file mode 100644 index bd48d542..00000000 --- a/boot.backup1/exc_impl.c~ +++ /dev/null @@ -1,38 +0,0 @@ -/* - 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) -{ - debug (""); - assert (0); - return EOPNOTSUPP; -} diff --git a/boot.backup1/list.h~ b/boot.backup1/list.h~ deleted file mode 100644 index c94c0628..00000000 --- a/boot.backup1/list.h~ +++ /dev/null @@ -1,40 +0,0 @@ -/* - 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_INIT() {&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.backup1/mach_host_impl.c~ b/boot.backup1/mach_host_impl.c~ deleted file mode 100644 index 4947751a..00000000 --- a/boot.backup1/mach_host_impl.c~ +++ /dev/null @@ -1,551 +0,0 @@ -/* - 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; - - debug (""); - 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); - 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) -{ -// extern task_t kernel_task; - error_t err = 0; - mach_port_t *subhurd_tasks = NULL; - int size = 0; - struct list *entry; - /* 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; - -// subhurd_tasks[0] = kernel_task; - entry = &tasks_head; - for (entry = tasks_head.next; entry != &tasks_head; entry = entry->next) - { - struct task_info *task_pi = LIST_ENTRY (entry, struct task_info, list); - assert (num < tot_nbtasks); - subhurd_tasks[num++] = ports_get_right (task_pi); - } - 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) -{ - static mach_port_t set_port = MACH_PORT_NULL; - kern_return_t ret = 0; - - // TODO create a port for each processor set - debug (""); - if (set_port == MACH_PORT_NULL) - { - extern mach_port_t receive_set; - // TODO use libports - mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_RECEIVE, - &set_port); - mach_port_move_member (mach_task_self (), set_port, - receive_set); - mach_port_insert_right (mach_task_self (), set_port, - set_port, MACH_MSG_TYPE_MAKE_SEND); - } - *set = set_port; - *setPoly = MACH_MSG_TYPE_COPY_SEND; - 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 0; -} - -/* 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 0; -} - -//////////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); - // TODO change the interface of the function. - // 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.backup1/mach_impl.c~ b/boot.backup1/mach_impl.c~ deleted file mode 100644 index 6e294218..00000000 --- a/boot.backup1/mach_impl.c~ +++ /dev/null @@ -1,869 +0,0 @@ -/* - 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; - debug ("get a request from task %d", target_task_pi->task_port); - err = task_create (target_task_pi->task_port, - inherit_memory, &real_child_task); - 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; - debug ("get request from task %d", target_task_pi->task_port); - err = task_terminate (target_task_pi->task_port); - debug ("task_terminate: %s", 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; - - debug (""); - 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); - 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; - debug ("request is from task %d", target_task_pi->task_port); - - /* This should be enough. */ - err = vm_allocate (target_task_pi->task_port, address, size, anywhere); - debug ("address: %d, size: %d, anywhere: %d, %s", - *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; - debug ("get a request from task %d", target_task_pi->task_port); - err = vm_deallocate (target_task_pi->task_port, address, size); - 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; - debug ("request is from task %d", target_task_pi->task_port); - err = vm_protect (target_task_pi->task_port, address, - size, set_maximum, new_protection); - debug ("vm_protect: %s", 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; - - debug (""); - 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); - 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; - - debug ("get a request from task %d", target_task_pi->task_port); - err = vm_read (target_task_pi->task_port, address, size, data, dataCnt); - 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; - debug ("get a request from task %d", target_task_pi->task_port); - err = vm_write (target_task_pi->task_port, address, data, dataCnt); - 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; - - debug (""); - 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); - 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; - - debug ("get a request from task %d", target_task_pi->task_port); - err = vm_region (target_task_pi->task_port, address, size, protection, - max_protection, inheritance, is_shared, object_name, offset); - debug ("vm_region: %s, object: %d", 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; - - debug ("request is from task %d", target_task_pi->task_port); - err = vm_statistics (target_task_pi->task_port, vm_stats); - ports_port_deref (target_task_pi); - debug ("vm_statistics: %s", strerror (err)); - 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; - debug ("get request from task %d", target_task_pi->task_port); - err = task_suspend (target_task_pi->task_port); - debug ("task_suspend: %s", 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; - - debug ("get request from task %d", target_task_pi->task_port); - err = task_resume (target_task_pi->task_port); - 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; - - debug ("request is from task %d", target_task_pi->task_port); - err = task_get_special_port (target_task_pi->task_port, - which_port, special_port); - debug ("task_get_special_port (%d, %d): %s\n", - 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; - - debug ("get request from task %d", target_task_pi->task_port); - err = task_set_special_port (target_task_pi->task_port, which_port, - special_port); - ports_port_deref (target_task_pi); - debug ("task_set_special_port (%d, %d): %s", - which_port, special_port, strerror (err)); - mach_port_deallocate (mach_task_self (), special_port); - 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; - - debug (""); - 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); - 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; - debug ("request is from task %d", target_task_pi->task_port); - err = vm_map (target_task_pi->task_port, address, size, mask, - anywhere, memory_object, offset, copy, - cur_protection, max_protection, inheritance); - ports_port_deref (target_task_pi); - debug ("vm_map: %s", strerror (err)); - 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; - - debug (""); - 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); - 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; - - debug ("get a request from task %d", target_task_pi->task_port); - // TODO: use move send - err = task_threads (target_task_pi->task_port, - thread_list, thread_listCnt); - 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; - debug ("get a request from task %d", target_task_pi->task_port); - err = thread_create (target_task_pi->task_port, child_thread); - debug ("thread_create: thread port: %d: %s", - *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.backup1/mach_port_impl.c~ b/boot.backup1/mach_port_impl.c~ deleted file mode 100644 index 2933950e..00000000 --- a/boot.backup1/mach_port_impl.c~ +++ /dev/null @@ -1,378 +0,0 @@ -/* - 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; - - debug (""); - 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); - /* 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; - - debug (""); - 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); - 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; - - debug (""); - 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); - 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; - - debug (""); - 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); - 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; - debug ("get a request from task %d", task_pi->task_port); - print_port_type (task_pi->task_port); - err = mach_port_allocate (task_pi->task_port, right, name); - debug ("mach_port_allocate: %s", 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; - debug ("get a request from port %d", task_pi->task_port); - err = mach_port_destroy (task_pi->task_port, name); - 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; - debug ("get a request from task %d", task_pi->task_port); - err = mach_port_deallocate (task_pi->task_port, name); - debug ("mach_port_deallocate port: %d: %s", 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; - - debug (""); - 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); - 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; - debug ("get a request from task %d", task_pi->task_port); - err = mach_port_mod_refs (task_pi->task_port, name, right, delta); - debug ("mach_port_mod_refs: %s, port: %d, delta: %d", - strerror (err), right, delta); - 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 (""); - 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; - - debug (""); - 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); - 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; - - debug (""); - 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); - 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; - - debug (""); - 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); - 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; - - debug (""); - 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); - 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; - error_t err; - - task_pi = ports_lookup_port (port_bucket, task, task_portclass); - if (task_pi == NULL) - return EOPNOTSUPP; - debug ("get a request from task %d", task_pi->task_port); - /* notify is send-once right from the client. */ - err = mach_port_request_notification (task_pi->task_port, name, id, sync, - notify, MACH_MSG_TYPE_MOVE_SEND_ONCE, - previous); - debug ("mach_port_request_notification, id: %d, old port: %d, %s", - id, *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; - debug ("get a request from task %d", task_pi->task_port); - /* 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 ("mach_port_insert_right: %s", 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; - - debug (""); - 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); - 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; - - debug (""); - 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); - 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; - - debug (""); - 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); - ports_port_deref (task_pi); - return err; -} diff --git a/boot.backup1/mach_proxy.c~ b/boot.backup1/mach_proxy.c~ deleted file mode 100644 index 54c84edd..00000000 --- a/boot.backup1/mach_proxy.c~ +++ /dev/null @@ -1,68 +0,0 @@ -/* - 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" - -LIST_HEADER (tasks_head); - -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; - - 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); - - task_pi->task_port = real_task; - entry_init (&task_pi->list); - add_entry_end (&tasks_head, &task_pi->list); - /* 0 is used by kernel task */ - 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)); - // TODO: I hope I destroy it in the right way. - 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"); - remove_entry (&task->list); -} diff --git a/boot.backup1/mach_proxy.h~ b/boot.backup1/mach_proxy.h~ deleted file mode 100644 index 28778402..00000000 --- a/boot.backup1/mach_proxy.h~ +++ /dev/null @@ -1,54 +0,0 @@ -/* - 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; - /* 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; -}; - -extern struct port_bucket *port_bucket; -extern struct port_class *task_portclass; -extern struct port_class *thread_portclass; -extern struct list task_list; - -int create_pseudo_task (task_t real_task, task_t *ret_pseudo_task); -void clean_pseudo_task (void *pi); - -#define UNTESTED - -#endif diff --git a/boot.backup1/ourmach.defs~ b/boot.backup1/ourmach.defs~ deleted file mode 100644 index 5265269f..00000000 --- a/boot.backup1/ourmach.defs~ +++ /dev/null @@ -1,770 +0,0 @@ -/* - * 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_move_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.backup1/ourmach_host.defs~ b/boot.backup1/ourmach_host.defs~ deleted file mode 100644 index 0e7e367e..00000000 --- a/boot.backup1/ourmach_host.defs~ +++ /dev/null @@ -1,381 +0,0 @@ -/* - * 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.backup1/ourmach_port.defs~ b/boot.backup1/ourmach_port.defs~ deleted file mode 100644 index fb3e552c..00000000 --- a/boot.backup1/ourmach_port.defs~ +++ /dev/null @@ -1,348 +0,0 @@ -/* - * 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); - -/* - * 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.backup1/util.h~ b/boot.backup1/util.h~ deleted file mode 100644 index 81a1a671..00000000 --- a/boot.backup1/util.h~ +++ /dev/null @@ -1,96 +0,0 @@ -/* - 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 <mach.h> -#include <hurd.h> - -#define DEBUG 0 -#define INFO 1 -#define LOGLEVEL DEBUG - -#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 output -#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 |