• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.9.5/xnu-2422.115.4/osfmk/ipc/

Lines Matching refs:port

75 #include <mach/port.h>
103 ipc_port_t port,
114 ipc_port_release(ipc_port_t port)
116 ip_release(port);
120 ipc_port_reference(ipc_port_t port)
122 ip_reference(port);
144 * The port is locked and active.
153 ipc_port_t port,
163 ipc_port_t port,
179 assert(ip_active(port));
183 table = port->ip_requests;
202 if (port->ip_sprequests == 0) {
203 port->ip_sprequests = 1;
205 if (port->ip_impdonation != 0 &&
206 port->ip_spimportant == 0 &&
208 port->ip_spimportant = 1;
225 * Grow a port's table of requests.
227 * The port must be locked and active.
229 * Upon return the port is unlocked.
233 * KERN_SUCCESS The port died.
240 ipc_port_t port,
246 assert(ip_active(port));
248 otable = port->ip_requests;
257 ip_unlock(port);
264 ip_unlock(port);
269 ip_reference(port);
270 ip_unlock(port);
274 ip_release(port);
278 ip_lock(port);
281 * Check that port is still active and that nobody else
287 if (ip_active(port) && (port->ip_requests == otable) &&
324 port->ip_requests = ntable;
325 ip_unlock(port);
326 ip_release(port);
332 ip_unlock(port);
333 ip_release(port);
345 * The port must be locked and active.
354 ipc_port_t port,
361 ipc_port_t port,
369 assert(ip_active(port));
371 table = port->ip_requests;
379 port->ip_sprequests = 1;
382 (port->ip_impdonation != 0) &&
383 (port->ip_spimportant == 0) &&
386 port->ip_spimportant = 1;
400 * Determine the type(s) of port requests enabled for a name.
402 * The port must be locked or inactive (to avoid table growth).
407 ipc_port_t port,
414 table = port->ip_requests;
440 * The port must be locked and active.
446 ipc_port_t port,
453 assert(ip_active(port));
454 table = port->ip_requests;
473 * Make a port-deleted request, returning the
477 * The port is locked and active. It is unlocked.
484 ipc_port_t port,
490 assert(ip_active(port));
492 previous = port->ip_pdrequest;
493 port->ip_pdrequest = notify;
494 ip_unlock(port);
506 * The port is locked and active. It is unlocked.
513 ipc_port_t port,
521 assert(ip_active(port));
523 previous = port->ip_nsrequest;
524 mscount = port->ip_mscount;
526 if ((port->ip_srights == 0) && (sync <= mscount) &&
528 port->ip_nsrequest = IP_NULL;
529 ip_unlock(port);
532 port->ip_nsrequest = notify;
533 ip_unlock(port);
545 * The port is locked and active.
550 ipc_port_t port,
555 assert(ip_active(port));
560 if (port->ip_pset_count != 0) {
561 ipc_pset_remove_from_all(port, links);
562 assert(port->ip_pset_count == 0);
566 * Send anyone waiting on the port's queue directly away.
570 imq_lock(&port->ip_messages);
571 ipc_mqueue_changed(&port->ip_messages);
572 ipc_port_set_mscount(port, 0);
573 port->ip_messages.imq_seqno = 0;
574 port->ip_context = port->ip_guarded = port->ip_strict_guard = 0;
575 imq_unlock(&port->ip_messages);
582 * Initializes a newly-allocated port.
588 ipc_port_t port,
592 /* port->ip_kobject doesn't have to be initialized */
594 port->ip_receiver = space;
595 port->ip_receiver_name = name;
597 port->ip_mscount = 0;
598 port->ip_srights = 0;
599 port->ip_sorights = 0;
601 port->ip_nsrequest = IP_NULL;
602 port->ip_pdrequest = IP_NULL;
603 port->ip_requests = IPR_NULL;
605 port->ip_pset_count = 0;
606 port->ip_premsg = IKM_NULL;
607 port->ip_context = 0;
609 port->ip_sprequests = 0;
610 port->ip_spimportant = 0;
611 port->ip_impdonation = 0;
612 port->ip_tempowner = 0;
613 port->ip_taskptr = 0;
615 port->ip_guarded = 0;
616 port->ip_strict_guard = 0;
617 port->ip_impcount = 0;
619 port->ip_reserved = 0;
621 ipc_mqueue_init(&port->ip_messages, FALSE /* set */);
627 * Allocate a port.
629 * Nothing locked. If successful, the port is returned
632 * KERN_SUCCESS The port is allocated.
644 ipc_port_t port;
655 &name, (ipc_object_t *) &port);
659 /* port and space are locked */
660 ipc_port_init(port, space, name);
663 ipc_port_init_debug(port, &buf[0], IP_CALLSTACK_MAX);
673 &port->ip_label);
678 *portp = port;
686 * Allocate a port, with a specific name.
688 * Nothing locked. If successful, the port is returned
691 * KERN_SUCCESS The port is allocated.
703 ipc_port_t port;
713 name, (ipc_object_t *) &port);
717 /* port is locked */
719 ipc_port_init(port, space, name);
722 ipc_port_init_debug(port, &buf[0], IP_CALLSTACK_MAX);
729 &port->ip_label);
733 *portp = port;
741 * Generate send-possible port notifications.
743 * Nothing locked, reference held on port.
747 ipc_port_t port)
756 * If the port has no send-possible request
757 * armed, don't bother to lock the port.
759 if (port->ip_sprequests == 0)
762 ip_lock(port);
765 if (port->ip_spimportant != 0) {
766 port->ip_spimportant = 0;
767 port->ip_impcount--;
772 if (port->ip_sprequests == 0) {
773 ip_unlock(port);
776 port->ip_sprequests = 0;
779 if (ip_active(port)) {
782 /* table may change each time port unlocked (reload) */
783 requests = port->ip_requests;
803 ip_unlock(port);
807 ip_lock(port);
812 ip_unlock(port);
832 * Reference held on port.
836 ipc_port_t port)
838 ipc_port_request_t requests = port->ip_requests;
840 assert(!ip_active(port));
861 * Destroys a port. Cleans up queued messages.
863 * If the port has a backup, it doesn't get destroyed,
864 * but is sent in a port-destroyed notification to the backup.
866 * The port is locked and alive; nothing else locked.
868 * Afterwards, the port is unlocked and dead.
873 ipc_port_t port)
886 assert(ip_active(port));
887 /* port->ip_receiver_name is garbage */
888 /* port->ip_receiver/port->ip_destination is garbage */
889 assert(port->ip_pset_count == 0);
890 assert(port->ip_mscount == 0);
892 /* check for a backup port */
893 pdrequest = port->ip_pdrequest;
897 if (port->ip_tempowner != 0) {
899 if (port->ip_taskptr != 0) {
900 release_imp_task = port->ip_imp_task;
901 port->ip_imp_task = TASK_NULL;
902 port->ip_taskptr = 0;
903 assertcnt = port->ip_impcount;
907 assert(port->ip_taskptr == 0);
908 assertcnt = port->ip_impcount;
911 port->ip_tempowner = 1;
920 port->ip_pdrequest = IP_NULL;
922 /* make port be in limbo */
923 port->ip_receiver_name = MACH_PORT_NULL;
924 port->ip_destination = IP_NULL;
925 ip_unlock(port);
927 /* consumes our refs for port and pdrequest */
928 ipc_notify_port_destroyed(pdrequest, port);
933 /* once port is dead, we don't need to keep it locked */
935 port->ip_object.io_bits &= ~IO_BITS_ACTIVE;
936 port->ip_timestamp = ipc_port_timestamp();
939 * If the port has a preallocated message buffer and that buffer
944 if (IP_PREALLOC(port)) {
947 kmsg = port->ip_premsg;
950 IP_CLEAR_PREALLOC(port, kmsg);
951 ip_unlock(port);
953 assert(inuse_port == port);
958 ip_unlock(port);
962 nsrequest = port->ip_nsrequest;
967 mqueue = &port->ip_messages;
971 ipc_port_dnnotify(port);
973 ipc_kobject_destroy(port);
975 ip_release(port); /* consume caller's ref */
996 /* the port chain we are enqueued on should cover our assertions */
1006 * Check if queueing "port" in a message for "dest"
1009 * If no circularity (FALSE returned), then "port"
1012 * That is, we want to set port->ip_destination == dest,
1014 * port->ip_destination->ip_destination->... == port
1016 * Additionally, if port was successfully changed to "in transit",
1017 * propagate boost assertions from the "in limbo" port to all
1022 * No ports locked. References held for "port" and "dest".
1027 ipc_port_t port,
1038 assert(port != IP_NULL);
1041 if (port == dest)
1050 ip_lock(port);
1061 ip_unlock(port);
1066 * Search for the end of the chain (a port not in transit),
1083 if (port == base) {
1088 /* port (== base) is in limbo */
1090 assert(ip_active(port));
1091 assert(port->ip_receiver_name == MACH_PORT_NULL);
1092 assert(port->ip_destination == IP_NULL);
1111 * The guarantee: lock port while the entire chain is locked.
1112 * Once port is locked, we can take a reference to dest,
1113 * add port to the chain, and unlock everything.
1116 ip_lock(port);
1121 /* port is in limbo */
1123 assert(ip_active(port));
1124 assert(port->ip_receiver_name == MACH_PORT_NULL);
1125 assert(port->ip_destination == IP_NULL);
1128 port->ip_destination = dest;
1132 assert(port->ip_tempowner != 0);
1134 if (port->ip_taskptr != 0) {
1140 release_task = port->ip_imp_task;
1141 port->ip_imp_task = TASK_NULL;
1142 port->ip_taskptr = 0;
1144 assertcnt = port->ip_impcount;
1146 /* take the port out of limbo w.r.t. assertions */
1147 port->ip_tempowner = 0;
1153 ip_unlock(port);
1158 /* every port along chain track assertions behind it */
1165 /* port is in transit */
1175 port = dest->ip_destination;
1177 dest = port;
1246 * Adjust the importance count through the given port.
1247 * If the port is in transit, apply the delta throughout
1252 * The port is referenced and locked on entry.
1261 ipc_port_t port,
1271 base = port;
1273 /* if port is in transit, have to search for end of chain */
1274 if (ip_active(port) &&
1275 port->ip_destination != IP_NULL &&
1276 port->ip_receiver_name == MACH_PORT_NULL) {
1280 ip_unlock(port);
1296 port->ip_impcount += delta;
1298 if (port == base)
1301 /* port is in transit */
1302 assert(port->ip_tempowner == 0);
1303 next = port->ip_destination;
1304 ip_unlock(port);
1305 port = next;
1354 * Make a send-once notify port from a receive right.
1368 ipc_port_t port;
1379 port = (ipc_port_t) entry->ie_object;
1380 assert(port != IP_NULL);
1382 ip_lock(port);
1383 assert(ip_active(port));
1384 assert(port->ip_receiver_name == name);
1385 assert(port->ip_receiver == space);
1387 ip_reference(port);
1388 port->ip_sorights++;
1389 ip_unlock(port);
1391 return port;
1400 * port locked and active.
1404 ipc_port_t port)
1406 assert(ip_active(port));
1407 port->ip_mscount++;
1408 port->ip_srights++;
1409 ip_reference(port);
1410 return port;
1421 ipc_port_t port)
1424 if (!IP_VALID(port))
1425 return port;
1427 ip_lock(port);
1428 if (ip_active(port)) {
1429 port->ip_mscount++;
1430 port->ip_srights++;
1431 ip_reference(port);
1432 ip_unlock(port);
1433 return port;
1435 ip_unlock(port);
1445 * dead port -> IP_DEAD
1446 * live port -> port + ref
1453 ipc_port_t port)
1457 if (!IP_VALID(port))
1458 return port;
1460 ip_lock(port);
1461 if (ip_active(port)) {
1462 assert(port->ip_srights > 0);
1464 ip_reference(port);
1465 port->ip_srights++;
1466 sright = port;
1469 ip_unlock(port);
1513 * Consumes a ref for the port.
1520 ipc_port_t port)
1525 if (!IP_VALID(port))
1528 ip_lock(port);
1530 if (!ip_active(port)) {
1531 ip_unlock(port);
1532 ip_release(port);
1536 assert(port->ip_srights > 0);
1538 if (--port->ip_srights == 0 &&
1539 port->ip_nsrequest != IP_NULL) {
1540 nsrequest = port->ip_nsrequest;
1541 port->ip_nsrequest = IP_NULL;
1542 mscount = port->ip_mscount;
1543 ip_unlock(port);
1544 ip_release(port);
1547 ip_unlock(port);
1548 ip_release(port);
1557 * The port is locked and active.
1562 ipc_port_t port)
1564 assert(ip_active(port));
1565 port->ip_sorights++;
1566 ip_reference(port);
1567 return port;
1575 * The port is not locked.
1580 ipc_port_t port)
1582 if (!IP_VALID(port))
1583 return port;
1585 ip_lock(port);
1586 if (ip_active(port)) {
1587 port->ip_sorights++;
1588 ip_reference(port);
1589 ip_unlock(port);
1590 return port;
1592 ip_unlock(port);
1600 * Consumes a ref for the port.
1612 ipc_port_t port)
1614 if (!IP_VALID(port))
1617 ip_lock(port);
1619 assert(port->ip_sorights > 0);
1621 port->ip_sorights--;
1623 ip_unlock(port);
1624 ip_release(port);
1631 * Consumes a ref for the port; destroys the port.
1638 ipc_port_t port)
1642 if (!IP_VALID(port))
1645 ip_lock(port);
1646 assert(ip_active(port));
1647 assert(port->ip_receiver_name == MACH_PORT_NULL);
1648 dest = port->ip_destination;
1650 ipc_port_destroy(port); /* consumes ref, unlocks */
1659 * Allocate a port in a special space.
1660 * The new port is returned with one ref.
1670 ipc_port_t port;
1672 port = (ipc_port_t) io_alloc(IOT_PORT);
1673 if (port == IP_NULL)
1681 bzero((char *)port, sizeof(*port));
1682 io_lock_init(&port->ip_object);
1683 port->ip_references = 1;
1684 port->ip_object.io_bits = io_makebits(TRUE, IOT_PORT, 0);
1686 ipc_port_init(port, space, 1);
1689 ipc_port_init_debug(port, &buf[0], IP_CALLSTACK_MAX);
1700 mac_port_label_init(&port->ip_label);
1701 mac_port_label_associate_kernel(&port->ip_label, space == ipc_space_reply);
1704 return port;
1710 * Deallocate a port in a special space.
1711 * Consumes one ref for the port.
1718 ipc_port_t port,
1721 ip_lock(port);
1722 assert(ip_active(port));
1723 // assert(port->ip_receiver_name != MACH_PORT_NULL);
1724 assert(port->ip_receiver == space);
1731 port->ip_receiver_name = MACH_PORT_NULL;
1732 port->ip_receiver = IS_NULL;
1735 ipc_port_set_mscount(port, 0);
1736 port->ip_messages.imq_seqno = 0;
1738 ipc_port_destroy(port);
1746 * port.
1752 ipc_port_t port)
1754 ipc_port_request_t requests = port->ip_requests;
1756 assert(!ip_active(port));
1760 port->ip_requests = IPR_NULL;
1764 ipc_port_track_dealloc(port);
1769 mac_port_label_destroy(&port->ip_label);
1789 ipc_port_t port);
1800 * port debugging.
1818 * Initialize all of the debugging state in a port.
1819 * Insert the port into a global list of all allocated ports.
1823 ipc_port_t port,
1829 port->ip_thread = current_thread();
1830 port->ip_timetrack = port_timestamp++;
1832 port->ip_callstack[i] = callstack[i];
1834 port->ip_spares[i] = 0;
1841 port->ip_spares[0] = proc_pid(proc);
1850 queue_enter(&port_alloc_queue, port, ipc_port_t, ip_port_links);
1880 * Remove a port from the queue of allocated ports.
1882 * deallocating the actual memory occupied by the port.
1887 __unused ipc_port_t port)
1893 ipc_port_t port)
1898 queue_remove(&port_alloc_queue, port, ipc_port_t, ip_port_links);