/* 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 #include #include #include #include #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 (""); // 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 (""); // 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 (""); // 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 (""); // 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 (""); // 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 (""); // 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 (""); // 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 (""); // Hurd currently doesn't use it. return EOPNOTSUPP; } /* Start processor. */ kern_return_t S_processor_start (mach_port_t processor) { debug (""); // 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 (""); // 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 (""); // 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 (""); // Hurd currently doesn't use it. return EOPNOTSUPP; } /* Destroy processor set. */ kern_return_t S_processor_set_destroy (mach_port_t set) { debug (""); // 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 (""); // 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 (""); // 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 (""); // 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 (""); // 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 (""); // 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 (""); // 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 (""); // 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 (""); // 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 (""); // 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 (""); // 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 (""); // 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 (""); // 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 (""); // 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 (""); // 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 (""); // 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 (""); return EOPNOTSUPP; } /* Assign thread to default set. */ kern_return_t S_thread_assign_default (mach_port_t thread) { debug (""); return EOPNOTSUPP; } /* Get current assignment for thread. */ kern_return_t S_thread_get_assignment (mach_port_t thread, mach_port_t *assigned_set) { debug (""); return EOPNOTSUPP; } /* Set priority for thread. */ kern_return_t S_thread_priority (mach_port_t thread, int priority, boolean_t set_max) { debug (""); 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 (""); 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 (""); return EOPNOTSUPP; } /* Set policy for thread */ kern_return_t S_thread_policy (mach_port_t thread, int policy, int data) { debug (""); 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 (""); 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 (""); 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 (""); 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 (""); 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 (""); return EOPNOTSUPP; }