void ipc_port_init( ipc_port_t port, ipc_space_t space, mach_port_name_t name) { /* port->ip_kobject doesn't have to be initialized */ port->ip_receiver = space; port->ip_receiver_name = name; port->ip_mscount = 0; port->ip_srights = 0; port->ip_sorights = 0; port->ip_nsrequest = IP_NULL; port->ip_pdrequest = IP_NULL; port->ip_dnrequests = IPR_NULL; port->ip_pset_count = 0; port->ip_premsg = IKM_NULL; port->ip_context = 0; #if MACH_ASSERT ipc_port_init_debug(port); #endif /* MACH_ASSERT */ ipc_mqueue_init(&port->ip_messages, FALSE /* set */); }
void ipc_port_init( ipc_port_t port, ipc_space_t space, mach_port_name_t name) { /* port->ip_kobject doesn't have to be initialized */ port->ip_receiver = space; port->ip_receiver_name = name; port->ip_mscount = 0; port->ip_srights = 0; port->ip_sorights = 0; port->ip_nsrequest = IP_NULL; port->ip_pdrequest = IP_NULL; port->ip_dnrequests = IPR_NULL; port->ip_pset = IPS_NULL; port->ip_seqno = 0; port->ip_msgcount = 0; port->ip_qlimit = MACH_PORT_QLIMIT_DEFAULT; port->ip_subsystem = RPC_SUBSYSTEM_NULL; port->ip_flags = 0; port->ip_context = 0; /* * Turn no more senders detection on * for all ports. Eventually, this * default will go away, and nms * detection will be enabled depending * on how the port is allocated. XXX */ IP_SET_NMS(port); #if MACH_ASSERT ipc_port_init_debug(port); #endif /* MACH_ASSERT */ ipc_mqueue_init(&port->ip_messages); thread_pool_init(&port->ip_thread_pool); ipc_thread_queue_init(&port->ip_blocked); }
kern_return_t ipc_port_alloc( ipc_space_t space, mach_port_name_t *namep, ipc_port_t *portp) { ipc_port_t port; mach_port_name_t name; kern_return_t kr; #if MACH_ASSERT uintptr_t buf[IP_CALLSTACK_MAX]; ipc_port_callstack_init_debug(&buf[0], IP_CALLSTACK_MAX); #endif /* MACH_ASSERT */ kr = ipc_object_alloc(space, IOT_PORT, MACH_PORT_TYPE_RECEIVE, 0, &name, (ipc_object_t *) &port); if (kr != KERN_SUCCESS) return kr; /* port and space are locked */ ipc_port_init(port, space, name); #if MACH_ASSERT ipc_port_init_debug(port, &buf[0], IP_CALLSTACK_MAX); #endif /* MACH_ASSERT */ /* unlock space after init */ is_write_unlock(space); #if CONFIG_MACF_MACH task_t issuer = current_task(); tasklabel_lock2 (issuer, space->is_task); mac_port_label_associate(&issuer->maclabel, &space->is_task->maclabel, &port->ip_label); tasklabel_unlock2 (issuer, space->is_task); #endif *namep = name; *portp = port; return KERN_SUCCESS; }
ipc_port_t ipc_port_alloc_special( ipc_space_t space) { ipc_port_t port; port = (ipc_port_t) io_alloc(IOT_PORT); if (port == IP_NULL) return IP_NULL; #if MACH_ASSERT uintptr_t buf[IP_CALLSTACK_MAX]; ipc_port_callstack_init_debug(&buf[0], IP_CALLSTACK_MAX); #endif /* MACH_ASSERT */ bzero((char *)port, sizeof(*port)); io_lock_init(&port->ip_object); port->ip_references = 1; port->ip_object.io_bits = io_makebits(TRUE, IOT_PORT, 0); ipc_port_init(port, space, 1); #if MACH_ASSERT ipc_port_init_debug(port, &buf[0], IP_CALLSTACK_MAX); #endif /* MACH_ASSERT */ #if CONFIG_MACF_MACH /* Currently, ipc_port_alloc_special is used for two things: * - Reply ports for messages from the kernel * - Ports for communication with the kernel (e.g. task ports) * Since both of these would typically be labelled as kernel objects, * we will use a new entry point for this purpose, as current_task() * is often wrong (i.e. not kernel_task) or null. */ mac_port_label_init(&port->ip_label); mac_port_label_associate_kernel(&port->ip_label, space == ipc_space_reply); #endif return port; }