/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
- * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
- *
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
#include <mach/vm_map.h>
#include <kern/task.h>
#include <kern/counters.h>
-#include <kern/thread_act.h>
+#include <kern/thread.h>
+#include <kern/kalloc.h>
#include <mach/mach_port_server.h>
#include <vm/vm_map.h>
#include <vm/vm_kern.h>
mach_port_name_t name,
mach_port_name_t *names,
mach_port_type_t *types,
- ipc_entry_num_t *actualp,
- ipc_space_t space);
+ ipc_entry_num_t *actualp);
void mach_port_gst_helper(
ipc_pset_t pset,
mach_port_name_t name,
mach_port_name_t *names,
mach_port_type_t *types,
- ipc_entry_num_t *actualp,
- ipc_space_t space)
+ ipc_entry_num_t *actualp)
{
ipc_entry_bits_t bits;
ipc_port_request_index_t request;
mach_port_type_t **typesp,
mach_msg_type_number_t *typesCnt)
{
- ipc_entry_bits_t *capability;
ipc_tree_entry_t tentry;
ipc_entry_t table;
ipc_entry_num_t tsize;
/* upper bound on number of names in the space */
bound = space->is_table_size + space->is_tree_total;
- size_needed = round_page_32(bound * sizeof(mach_port_name_t));
+ size_needed = round_page(bound * sizeof(mach_port_name_t));
if (size_needed <= size)
break;
}
size = size_needed;
- kr = vm_allocate(ipc_kernel_map, &addr1, size, TRUE);
+ kr = vm_allocate(ipc_kernel_map, &addr1, size, VM_FLAGS_ANYWHERE);
if (kr != KERN_SUCCESS)
return KERN_RESOURCE_SHORTAGE;
- kr = vm_allocate(ipc_kernel_map, &addr2, size, TRUE);
+ kr = vm_allocate(ipc_kernel_map, &addr2, size, VM_FLAGS_ANYWHERE);
if (kr != KERN_SUCCESS) {
kmem_free(ipc_kernel_map, addr1, size);
return KERN_RESOURCE_SHORTAGE;
/* can't fault while we hold locks */
- kr = vm_map_wire(ipc_kernel_map, addr1, addr1 + size,
- VM_PROT_READ|VM_PROT_WRITE, FALSE);
+ kr = vm_map_wire(ipc_kernel_map, vm_map_trunc_page(addr1),
+ vm_map_round_page(addr1 + size),
+ VM_PROT_READ|VM_PROT_WRITE, FALSE);
if (kr != KERN_SUCCESS) {
kmem_free(ipc_kernel_map, addr1, size);
kmem_free(ipc_kernel_map, addr2, size);
return KERN_RESOURCE_SHORTAGE;
}
- kr = vm_map_wire(ipc_kernel_map, addr2, addr2 + size,
- VM_PROT_READ|VM_PROT_WRITE, FALSE);
+ kr = vm_map_wire(ipc_kernel_map, vm_map_trunc_page(addr2),
+ vm_map_round_page(addr2 + size),
+ VM_PROT_READ|VM_PROT_WRITE, FALSE);
if (kr != KERN_SUCCESS) {
kmem_free(ipc_kernel_map, addr1, size);
kmem_free(ipc_kernel_map, addr2, size);
name = MACH_PORT_MAKE(index, IE_BITS_GEN(bits));
mach_port_names_helper(timestamp, entry, name, names,
- types, &actual, space);
+ types, &actual);
}
}
assert(IE_BITS_TYPE(tentry->ite_bits) != MACH_PORT_TYPE_NONE);
mach_port_names_helper(timestamp, entry, name, names,
- types, &actual, space);
+ types, &actual);
}
ipc_splay_traverse_finish(&space->is_tree);
is_read_unlock(space);
vm_size_t vm_size_used;
size_used = actual * sizeof(mach_port_name_t);
- vm_size_used = round_page_32(size_used);
+ vm_size_used = round_page(size_used);
/*
* Make used memory pageable and get it into
* copied-in form. Free any unused memory.
*/
- kr = vm_map_unwire(ipc_kernel_map,
- addr1, addr1 + vm_size_used, FALSE);
+ kr = vm_map_unwire(ipc_kernel_map, vm_map_trunc_page(addr1),
+ vm_map_round_page(addr1 + vm_size_used), FALSE);
assert(kr == KERN_SUCCESS);
- kr = vm_map_unwire(ipc_kernel_map,
- addr2, addr2 + vm_size_used, FALSE);
+ kr = vm_map_unwire(ipc_kernel_map, vm_map_trunc_page(addr2),
+ vm_map_round_page(addr2 + vm_size_used), FALSE);
assert(kr == KERN_SUCCESS);
- kr = vm_map_copyin(ipc_kernel_map, addr1, size_used,
- TRUE, &memory1);
+ kr = vm_map_copyin(ipc_kernel_map, (vm_map_address_t)addr1,
+ (vm_map_size_t)size_used, TRUE, &memory1);
assert(kr == KERN_SUCCESS);
- kr = vm_map_copyin(ipc_kernel_map, addr2, size_used,
- TRUE, &memory2);
+ kr = vm_map_copyin(ipc_kernel_map, (vm_map_address_t)addr2,
+ (vm_map_size_t)size_used, TRUE, &memory2);
assert(kr == KERN_SUCCESS);
if (vm_size_used != size) {
mach_port_qos_t *qosp,
mach_port_name_t *namep)
{
- ipc_kmsg_t kmsg;
+ ipc_kmsg_t kmsg = IKM_NULL;
kern_return_t kr;
if (space == IS_NULL)
mach_msg_size_t size = qosp->len + MAX_TRAILER_SIZE;
if (right != MACH_PORT_RIGHT_RECEIVE)
return (KERN_INVALID_VALUE);
- kmsg = (ipc_kmsg_t)kalloc(ikm_plus_overhead(size));
+ kmsg = (ipc_kmsg_t)ipc_kmsg_alloc(size);
if (kmsg == IKM_NULL)
return (KERN_RESOURCE_SHORTAGE);
- ikm_init(kmsg, size);
}
switch (right) {
else
kr = ipc_port_alloc(space, namep, &port);
if (kr == KERN_SUCCESS) {
- if (qosp->prealloc)
+ if (kmsg != IKM_NULL)
ipc_kmsg_set_prealloc(kmsg, port);
ip_unlock(port);
- } else if (qosp->prealloc)
+ } else if (kmsg != IKM_NULL)
ipc_kmsg_free(kmsg);
break;
}
mach_port_name_t *names,
ipc_entry_num_t *actualp)
{
- ipc_pset_t ip_pset;
mach_port_name_t name;
assert(port != IP_NULL);
mach_port_name_t *names;
ipc_pset_t pset;
- kr = vm_allocate(ipc_kernel_map, &addr, size, TRUE);
+ kr = vm_allocate(ipc_kernel_map, &addr, size, VM_FLAGS_ANYWHERE);
if (kr != KERN_SUCCESS)
return KERN_RESOURCE_SHORTAGE;
/* didn't have enough memory; allocate more */
kmem_free(ipc_kernel_map, addr, size);
- size = round_page_32(actual * sizeof(mach_port_name_t)) + PAGE_SIZE;
+ size = round_page(actual * sizeof(mach_port_name_t)) + PAGE_SIZE;
}
if (actual == 0) {
vm_size_t vm_size_used;
size_used = actual * sizeof(mach_port_name_t);
- vm_size_used = round_page_32(size_used);
+ vm_size_used = round_page(size_used);
/*
* Make used memory pageable and get it into
* copied-in form. Free any unused memory.
*/
- kr = vm_map_unwire(ipc_kernel_map,
- addr, addr + vm_size_used, FALSE);
+ kr = vm_map_unwire(ipc_kernel_map, vm_map_trunc_page(addr),
+ vm_map_round_page(addr + vm_size_used), FALSE);
assert(kr == KERN_SUCCESS);
- kr = vm_map_copyin(ipc_kernel_map, addr, size_used,
- TRUE, &memory);
+ kr = vm_map_copyin(ipc_kernel_map, (vm_map_address_t)addr,
+ (vm_map_size_t)size_used, TRUE, &memory);
assert(kr == KERN_SUCCESS);
if (vm_size_used != size)
ipc_port_t *previousp)
{
kern_return_t kr;
- ipc_entry_t entry;
- ipc_port_t port;
-
if (space == IS_NULL)
return KERN_INVALID_TASK;
/*
* Requesting notifications on RPC ports is an error.
*/
- kr = ipc_right_lookup_write(space, name, &entry);
- if (kr != KERN_SUCCESS)
- return kr;
+ {
+ ipc_port_t port;
+ ipc_entry_t entry;
- port = (ipc_port_t) entry->ie_object;
+ kr = ipc_right_lookup_write(space, name, &entry);
+ if (kr != KERN_SUCCESS)
+ return kr;
+
+ port = (ipc_port_t) entry->ie_object;
- if (port->ip_subsystem != NULL) {
+ if (port->ip_subsystem != NULL) {
+ is_write_unlock(space);
+ panic("mach_port_request_notification: on RPC port!!");
+ return KERN_INVALID_CAPABILITY;
+ }
is_write_unlock(space);
- panic("mach_port_request_notification: on RPC port!!");
- return KERN_INVALID_CAPABILITY;
}
- is_write_unlock(space);
#endif /* NOTYET */
mach_port_name_t name,
mach_port_name_t psname)
{
- mach_port_name_t oldname;
ipc_object_t psobj;
ipc_object_t obj;
kern_return_t kr;
return kr;
}
+/*
+ * task_set_port_space:
+ *
+ * Set port name space of task to specified size.
+ */
+kern_return_t
+task_set_port_space(
+ ipc_space_t space,
+ int table_entries)
+{
+ kern_return_t kr;
+
+ is_write_lock(space);
+ kr = ipc_entry_grow_table(space, table_entries);
+ if (kr == KERN_SUCCESS)
+ is_write_unlock(space);
+ return kr;
+}
+