2 * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
32 * Mach Operating System
33 * Copyright (c) 1991,1990 Carnegie Mellon University
34 * All Rights Reserved.
36 * Permission to use, copy, modify and distribute this software and its
37 * documentation is hereby granted, provided that both the copyright
38 * notice and this permission notice appear in all copies of the
39 * software, derivative works or modified versions, and any portions
40 * thereof, and that both notices appear in supporting documentation.
42 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
43 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
44 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
46 * Carnegie Mellon requests users of this software to return to
48 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
49 * School of Computer Science
50 * Carnegie Mellon University
51 * Pittsburgh PA 15213-3890
53 * any improvements or extensions that they make and grant Carnegie Mellon
54 * the rights to redistribute these changes.
59 #include <mach/boolean.h>
60 #include <mach/port.h>
62 #include <mach/mig_errors.h>
63 #include <mach/mach_types.h>
64 #include <mach/mach_traps.h>
66 #include <kern/ipc_tt.h>
67 #include <kern/ipc_mig.h>
68 #include <kern/kalloc.h>
69 #include <kern/task.h>
70 #include <kern/thread.h>
71 #include <kern/ipc_kobject.h>
72 #include <kern/misc_protos.h>
75 #include <ipc/ipc_kmsg.h>
76 #include <ipc/ipc_entry.h>
77 #include <ipc/ipc_object.h>
78 #include <ipc/ipc_mqueue.h>
79 #include <ipc/ipc_space.h>
80 #include <ipc/ipc_port.h>
81 #include <ipc/ipc_pset.h>
82 #include <ipc/ipc_notify.h>
83 #include <vm/vm_map.h>
85 #include <libkern/OSAtomic.h>
88 * Routine: mach_msg_send_from_kernel
90 * Send a message from the kernel.
92 * This is used by the client side of KernelUser interfaces
93 * to implement SimpleRoutines. Currently, this includes
94 * memory_object messages.
98 * MACH_MSG_SUCCESS Sent the message.
99 * MACH_SEND_INVALID_DEST Bad destination port.
100 * MACH_MSG_SEND_NO_BUFFER Destination port had inuse fixed bufer
101 * or destination is above kernel limit
104 #if IKM_SUPPORT_LEGACY
106 #undef mach_msg_send_from_kernel
107 mach_msg_return_t
mach_msg_send_from_kernel(
108 mach_msg_header_t
*msg
,
109 mach_msg_size_t send_size
);
112 mach_msg_send_from_kernel(
113 mach_msg_header_t
*msg
,
114 mach_msg_size_t send_size
)
117 mach_msg_return_t mr
;
119 mr
= ipc_kmsg_get_from_kernel(msg
, send_size
, &kmsg
);
120 if (mr
!= MACH_MSG_SUCCESS
)
123 mr
= ipc_kmsg_copyin_from_kernel_legacy(kmsg
);
124 if (mr
!= MACH_MSG_SUCCESS
) {
129 mr
= ipc_kmsg_send(kmsg
,
130 MACH_SEND_KERNEL_DEFAULT
,
131 MACH_MSG_TIMEOUT_NONE
);
132 if (mr
!= MACH_MSG_SUCCESS
) {
133 ipc_kmsg_destroy(kmsg
);
139 #endif /* IKM_SUPPORT_LEGACY */
142 mach_msg_send_from_kernel_proper(
143 mach_msg_header_t
*msg
,
144 mach_msg_size_t send_size
)
147 mach_msg_return_t mr
;
149 mr
= ipc_kmsg_get_from_kernel(msg
, send_size
, &kmsg
);
150 if (mr
!= MACH_MSG_SUCCESS
)
153 mr
= ipc_kmsg_copyin_from_kernel(kmsg
);
154 if (mr
!= MACH_MSG_SUCCESS
) {
159 mr
= ipc_kmsg_send(kmsg
,
160 MACH_SEND_KERNEL_DEFAULT
,
161 MACH_MSG_TIMEOUT_NONE
);
162 if (mr
!= MACH_MSG_SUCCESS
) {
163 ipc_kmsg_destroy(kmsg
);
170 mach_msg_send_from_kernel_with_options(
171 mach_msg_header_t
*msg
,
172 mach_msg_size_t send_size
,
173 mach_msg_option_t option
,
174 mach_msg_timeout_t timeout_val
)
177 mach_msg_return_t mr
;
179 mr
= ipc_kmsg_get_from_kernel(msg
, send_size
, &kmsg
);
180 if (mr
!= MACH_MSG_SUCCESS
)
183 mr
= ipc_kmsg_copyin_from_kernel(kmsg
);
184 if (mr
!= MACH_MSG_SUCCESS
) {
191 * Until we are sure of its effects, we are disabling
192 * importance donation from the kernel-side of user
193 * threads in importance-donating tasks - unless the
194 * option to force importance donation is passed in.
196 if ((option
& MACH_SEND_IMPORTANCE
) == 0)
197 option
|= MACH_SEND_NOIMPORTANCE
;
199 mr
= ipc_kmsg_send(kmsg
, option
, timeout_val
);
201 if (mr
!= MACH_MSG_SUCCESS
) {
202 ipc_kmsg_destroy(kmsg
);
209 #if IKM_SUPPORT_LEGACY
212 mach_msg_send_from_kernel_with_options_legacy(
213 mach_msg_header_t
*msg
,
214 mach_msg_size_t send_size
,
215 mach_msg_option_t option
,
216 mach_msg_timeout_t timeout_val
)
219 mach_msg_return_t mr
;
221 mr
= ipc_kmsg_get_from_kernel(msg
, send_size
, &kmsg
);
222 if (mr
!= MACH_MSG_SUCCESS
)
225 mr
= ipc_kmsg_copyin_from_kernel_legacy(kmsg
);
226 if (mr
!= MACH_MSG_SUCCESS
) {
233 * Until we are sure of its effects, we are disabling
234 * importance donation from the kernel-side of user
235 * threads in importance-donating tasks.
237 option
|= MACH_SEND_NOIMPORTANCE
;
239 mr
= ipc_kmsg_send(kmsg
, option
, timeout_val
);
241 if (mr
!= MACH_MSG_SUCCESS
) {
242 ipc_kmsg_destroy(kmsg
);
248 #endif /* IKM_SUPPORT_LEGACY */
251 * Routine: mach_msg_rpc_from_kernel
253 * Send a message from the kernel and receive a reply.
254 * Uses ith_rpc_reply for the reply port.
256 * This is used by the client side of KernelUser interfaces
257 * to implement Routines.
261 * MACH_MSG_SUCCESS Sent the message.
262 * MACH_RCV_PORT_DIED The reply port was deallocated.
265 mach_msg_return_t
mach_msg_rpc_from_kernel_body(mach_msg_header_t
*msg
,
266 mach_msg_size_t send_size
, mach_msg_size_t rcv_size
, boolean_t legacy
);
268 #if IKM_SUPPORT_LEGACY
270 #undef mach_msg_rpc_from_kernel
272 mach_msg_rpc_from_kernel(
273 mach_msg_header_t
*msg
,
274 mach_msg_size_t send_size
,
275 mach_msg_size_t rcv_size
);
278 mach_msg_rpc_from_kernel(
279 mach_msg_header_t
*msg
,
280 mach_msg_size_t send_size
,
281 mach_msg_size_t rcv_size
)
283 return mach_msg_rpc_from_kernel_body(msg
, send_size
, rcv_size
, TRUE
);
286 #endif /* IKM_SUPPORT_LEGACY */
289 mach_msg_rpc_from_kernel_proper(
290 mach_msg_header_t
*msg
,
291 mach_msg_size_t send_size
,
292 mach_msg_size_t rcv_size
)
294 return mach_msg_rpc_from_kernel_body(msg
, send_size
, rcv_size
, FALSE
);
298 mach_msg_rpc_from_kernel_body(
299 mach_msg_header_t
*msg
,
300 mach_msg_size_t send_size
,
301 mach_msg_size_t rcv_size
,
302 #if !IKM_SUPPORT_LEGACY
307 thread_t self
= current_thread();
310 mach_port_seqno_t seqno
;
311 mach_msg_return_t mr
;
313 assert(msg
->msgh_local_port
== MACH_PORT_NULL
);
315 mr
= ipc_kmsg_get_from_kernel(msg
, send_size
, &kmsg
);
316 if (mr
!= MACH_MSG_SUCCESS
)
319 reply
= self
->ith_rpc_reply
;
320 if (reply
== IP_NULL
) {
321 reply
= ipc_port_alloc_reply();
322 if ((reply
== IP_NULL
) ||
323 (self
->ith_rpc_reply
!= IP_NULL
))
324 panic("mach_msg_rpc_from_kernel");
325 self
->ith_rpc_reply
= reply
;
328 /* insert send-once right for the reply port */
329 kmsg
->ikm_header
->msgh_local_port
= reply
;
330 kmsg
->ikm_header
->msgh_bits
|=
331 MACH_MSGH_BITS(0, MACH_MSG_TYPE_MAKE_SEND_ONCE
);
333 #if IKM_SUPPORT_LEGACY
335 mr
= ipc_kmsg_copyin_from_kernel_legacy(kmsg
);
337 mr
= ipc_kmsg_copyin_from_kernel(kmsg
);
339 mr
= ipc_kmsg_copyin_from_kernel(kmsg
);
341 if (mr
!= MACH_MSG_SUCCESS
) {
345 mr
= ipc_kmsg_send(kmsg
,
346 MACH_SEND_KERNEL_DEFAULT
,
347 MACH_MSG_TIMEOUT_NONE
);
348 if (mr
!= MACH_MSG_SUCCESS
) {
349 ipc_kmsg_destroy(kmsg
);
356 assert(reply
->ip_pset_count
== 0);
357 assert(ip_active(reply
));
359 /* JMM - why this check? */
361 ipc_port_dealloc_reply(reply
);
362 self
->ith_rpc_reply
= IP_NULL
;
363 return MACH_RCV_INTERRUPTED
;
366 self
->ith_continuation
= (void (*)(mach_msg_return_t
))0;
368 mqueue
= &reply
->ip_messages
;
369 ipc_mqueue_receive(mqueue
,
370 MACH_MSG_OPTION_NONE
,
372 MACH_MSG_TIMEOUT_NONE
,
373 THREAD_INTERRUPTIBLE
);
375 mr
= self
->ith_state
;
376 kmsg
= self
->ith_kmsg
;
377 seqno
= self
->ith_seqno
;
379 if (mr
== MACH_MSG_SUCCESS
)
384 assert(mr
== MACH_RCV_INTERRUPTED
);
386 assert(reply
== self
->ith_rpc_reply
);
388 if (self
->handlers
) {
389 ipc_port_dealloc_reply(reply
);
390 self
->ith_rpc_reply
= IP_NULL
;
396 * Check to see how much of the message/trailer can be received.
397 * We chose the maximum trailer that will fit, since we don't
398 * have options telling us which trailer elements the caller needed.
400 if (rcv_size
>= kmsg
->ikm_header
->msgh_size
) {
401 mach_msg_format_0_trailer_t
*trailer
= (mach_msg_format_0_trailer_t
*)
402 ((vm_offset_t
)kmsg
->ikm_header
+ kmsg
->ikm_header
->msgh_size
);
404 if (rcv_size
>= kmsg
->ikm_header
->msgh_size
+ MAX_TRAILER_SIZE
) {
405 /* Enough room for a maximum trailer */
406 trailer
->msgh_trailer_size
= MAX_TRAILER_SIZE
;
408 else if (rcv_size
< kmsg
->ikm_header
->msgh_size
+
409 trailer
->msgh_trailer_size
) {
410 /* no room for even the basic (default) trailer */
411 trailer
->msgh_trailer_size
= 0;
413 assert(trailer
->msgh_trailer_type
== MACH_MSG_TRAILER_FORMAT_0
);
414 rcv_size
= kmsg
->ikm_header
->msgh_size
+ trailer
->msgh_trailer_size
;
415 mr
= MACH_MSG_SUCCESS
;
417 mr
= MACH_RCV_TOO_LARGE
;
422 * We want to preserve rights and memory in reply!
423 * We don't have to put them anywhere; just leave them
426 #if IKM_SUPPORT_LEGACY
428 ipc_kmsg_copyout_to_kernel_legacy(kmsg
, ipc_space_reply
);
430 ipc_kmsg_copyout_to_kernel(kmsg
, ipc_space_reply
);
432 ipc_kmsg_copyout_to_kernel(kmsg
, ipc_space_reply
);
434 ipc_kmsg_put_to_kernel(msg
, kmsg
, rcv_size
);
439 /************** These Calls are set up for kernel-loaded tasks/threads **************/
442 * Routine: mach_msg_overwrite
444 * Like mach_msg_overwrite_trap except that message buffers
445 * live in kernel space. Doesn't handle any options.
447 * This is used by in-kernel server threads to make
448 * kernel calls, to receive request messages, and
449 * to send reply messages.
457 mach_msg_header_t
*msg
,
458 mach_msg_option_t option
,
459 mach_msg_size_t send_size
,
460 mach_msg_size_t rcv_size
,
461 mach_port_name_t rcv_name
,
462 __unused mach_msg_timeout_t msg_timeout
,
463 __unused mach_port_name_t notify
,
464 __unused mach_msg_header_t
*rcv_msg
,
465 __unused mach_msg_size_t rcv_msg_size
)
467 ipc_space_t space
= current_space();
468 vm_map_t map
= current_map();
470 mach_port_seqno_t seqno
;
471 mach_msg_return_t mr
;
472 mach_msg_trailer_size_t trailer_size
;
474 if (option
& MACH_SEND_MSG
) {
475 mach_msg_size_t msg_and_trailer_size
;
476 mach_msg_max_trailer_t
*max_trailer
;
478 if ((send_size
< sizeof(mach_msg_header_t
)) || (send_size
& 3))
479 return MACH_SEND_MSG_TOO_SMALL
;
481 if (send_size
> MACH_MSG_SIZE_MAX
- MAX_TRAILER_SIZE
)
482 return MACH_SEND_TOO_LARGE
;
484 msg_and_trailer_size
= send_size
+ MAX_TRAILER_SIZE
;
485 kmsg
= ipc_kmsg_alloc(msg_and_trailer_size
);
487 if (kmsg
== IKM_NULL
)
488 return MACH_SEND_NO_BUFFER
;
490 (void) memcpy((void *) kmsg
->ikm_header
, (const void *) msg
, send_size
);
492 kmsg
->ikm_header
->msgh_size
= send_size
;
495 * Reserve for the trailer the largest space (MAX_TRAILER_SIZE)
496 * However, the internal size field of the trailer (msgh_trailer_size)
497 * is initialized to the minimum (sizeof(mach_msg_trailer_t)), to optimize
498 * the cases where no implicit data is requested.
500 max_trailer
= (mach_msg_max_trailer_t
*) ((vm_offset_t
)kmsg
->ikm_header
+ send_size
);
501 max_trailer
->msgh_sender
= current_thread()->task
->sec_token
;
502 max_trailer
->msgh_audit
= current_thread()->task
->audit_token
;
503 max_trailer
->msgh_trailer_type
= MACH_MSG_TRAILER_FORMAT_0
;
504 max_trailer
->msgh_trailer_size
= MACH_MSG_TRAILER_MINIMUM_SIZE
;
506 mr
= ipc_kmsg_copyin(kmsg
, space
, map
, &option
);
508 if (mr
!= MACH_MSG_SUCCESS
) {
514 mr
= ipc_kmsg_send(kmsg
, MACH_MSG_OPTION_NONE
, MACH_MSG_TIMEOUT_NONE
);
515 } while (mr
== MACH_SEND_INTERRUPTED
);
517 assert(mr
== MACH_MSG_SUCCESS
);
520 if (option
& MACH_RCV_MSG
) {
521 thread_t self
= current_thread();
527 mr
= ipc_mqueue_copyin(space
, rcv_name
,
529 if (mr
!= MACH_MSG_SUCCESS
)
531 /* hold ref for object */
533 self
->ith_continuation
= (void (*)(mach_msg_return_t
))0;
534 ipc_mqueue_receive(mqueue
,
535 MACH_MSG_OPTION_NONE
,
537 MACH_MSG_TIMEOUT_NONE
,
539 mr
= self
->ith_state
;
540 kmsg
= self
->ith_kmsg
;
541 seqno
= self
->ith_seqno
;
545 } while (mr
== MACH_RCV_INTERRUPTED
);
546 if (mr
!= MACH_MSG_SUCCESS
)
550 trailer_size
= ipc_kmsg_add_trailer(kmsg
, space
, option
, current_thread(), seqno
, TRUE
,
551 kmsg
->ikm_header
->msgh_remote_port
->ip_context
);
553 if (rcv_size
< (kmsg
->ikm_header
->msgh_size
+ trailer_size
)) {
554 ipc_kmsg_copyout_dest(kmsg
, space
);
555 (void) memcpy((void *) msg
, (const void *) kmsg
->ikm_header
, sizeof *msg
);
557 return MACH_RCV_TOO_LARGE
;
560 mr
= ipc_kmsg_copyout(kmsg
, space
, map
, MACH_MSG_BODY_NULL
, option
);
561 if (mr
!= MACH_MSG_SUCCESS
) {
562 if ((mr
&~ MACH_MSG_MASK
) == MACH_RCV_BODY_ERROR
) {
563 ipc_kmsg_put_to_kernel(msg
, kmsg
,
564 kmsg
->ikm_header
->msgh_size
+ trailer_size
);
566 ipc_kmsg_copyout_dest(kmsg
, space
);
567 (void) memcpy((void *) msg
, (const void *) kmsg
->ikm_header
, sizeof *msg
);
574 (void) memcpy((void *) msg
, (const void *) kmsg
->ikm_header
,
575 kmsg
->ikm_header
->msgh_size
+ trailer_size
);
579 return MACH_MSG_SUCCESS
;
583 * Routine: mig_get_reply_port
585 * Called by client side interfaces living in the kernel
586 * to get a reply port.
589 mig_get_reply_port(void)
591 return (MACH_PORT_NULL
);
595 * Routine: mig_dealloc_reply_port
597 * Called by client side interfaces to get rid of a reply port.
601 mig_dealloc_reply_port(
602 __unused mach_port_t reply_port
)
607 * Routine: mig_put_reply_port
609 * Called by client side interfaces after each RPC to
610 * let the client recycle the reply port if it wishes.
614 __unused mach_port_t reply_port
)
619 * mig_strncpy.c - by Joshua Block
621 * mig_strncp -- Bounded string copy. Does what the library routine strncpy
622 * OUGHT to do: Copies the (null terminated) string in src into dest, a
623 * buffer of length len. Assures that the copy is still null terminated
624 * and doesn't overflow the buffer, truncating the copy if necessary.
628 * dest - Pointer to destination buffer.
630 * src - Pointer to source string.
632 * len - Length of destination buffer.
645 for (i
=1; i
<len
; i
++)
646 if (! (*dest
++ = *src
++))
657 return (char *)kalloc(size
);
669 * Routine: mig_object_init
671 * Initialize the base class portion of a MIG object. We
672 * will lazy init the port, so just clear it for now.
676 mig_object_t mig_object
,
677 const IMIGObject
*interface
)
679 if (mig_object
== MIG_OBJECT_NULL
)
680 return KERN_INVALID_ARGUMENT
;
681 mig_object
->pVtbl
= (const IMIGObjectVtbl
*)interface
;
682 mig_object
->port
= MACH_PORT_NULL
;
687 * Routine: mig_object_destroy
689 * The object is being freed. This call lets us clean
690 * up any state we have have built up over the object's
693 * Since notifications and the port hold references on
694 * on the object, neither can exist when this is called.
695 * This is a good place to assert() that condition.
699 __assert_only mig_object_t mig_object
)
701 assert(mig_object
->port
== MACH_PORT_NULL
);
706 * Routine: mig_object_reference
708 * Pure virtual helper to invoke the MIG object's AddRef
711 * MIG object port may be locked.
714 mig_object_reference(
715 mig_object_t mig_object
)
717 assert(mig_object
!= MIG_OBJECT_NULL
);
718 mig_object
->pVtbl
->AddRef((IMIGObject
*)mig_object
);
722 * Routine: mig_object_deallocate
724 * Pure virtual helper to invoke the MIG object's Release
730 mig_object_deallocate(
731 mig_object_t mig_object
)
733 assert(mig_object
!= MIG_OBJECT_NULL
);
734 mig_object
->pVtbl
->Release((IMIGObject
*)mig_object
);
738 * Routine: convert_mig_object_to_port [interface]
740 * Base implementation of MIG outtrans routine to convert from
741 * a mig object reference to a new send right on the object's
742 * port. The object reference is consumed.
744 * IP_NULL - Null MIG object supplied
745 * Otherwise, a newly made send right for the port
750 convert_mig_object_to_port(
751 mig_object_t mig_object
)
754 boolean_t deallocate
= TRUE
;
756 if (mig_object
== MIG_OBJECT_NULL
)
759 port
= mig_object
->port
;
760 while ((port
== IP_NULL
) ||
761 ((port
= ipc_port_make_send(port
)) == IP_NULL
)) {
765 * Either the port was never set up, or it was just
766 * deallocated out from under us by the no-senders
767 * processing. In either case, we must:
768 * Attempt to make one
769 * Arrange for no senders
770 * Try to atomically register it with the object
771 * Destroy it if we are raced.
773 port
= ipc_port_alloc_kernel();
775 ipc_kobject_set_atomically(port
,
776 (ipc_kobject_t
) mig_object
,
779 /* make a sonce right for the notification */
783 ipc_port_nsrequest(port
, 1, port
, &previous
);
786 assert(previous
== IP_NULL
);
788 if (OSCompareAndSwapPtr((void *)IP_NULL
, (void *)port
,
789 (void * volatile *)&mig_object
->port
)) {
792 ipc_port_dealloc_kernel(port
);
793 port
= mig_object
->port
;
798 mig_object
->pVtbl
->Release((IMIGObject
*)mig_object
);
805 * Routine: convert_port_to_mig_object [interface]
807 * Base implementation of MIG intrans routine to convert from
808 * an incoming port reference to a new reference on the
809 * underlying object. A new reference must be created, because
810 * the port's reference could go away asynchronously.
812 * NULL - Not an active MIG object port or iid not supported
813 * Otherwise, a reference to the underlying MIG interface
818 convert_port_to_mig_object(
822 mig_object_t mig_object
;
829 if (!ip_active(port
) || (ip_kotype(port
) != IKOT_MIG
)) {
835 * Our port points to some MIG object interface. Now
836 * query it to get a reference to the desired interface.
839 mig_object
= (mig_object_t
)port
->ip_kobject
;
840 mig_object
->pVtbl
->QueryInterface((IMIGObject
*)mig_object
, iid
, &ppv
);
842 return (mig_object_t
)ppv
;
846 * Routine: mig_object_no_senders [interface]
848 * Base implementation of a no-senders notification handler
849 * for MIG objects. If there truly are no more senders, must
850 * destroy the port and drop its reference on the object.
852 * TRUE - port deallocate and reference dropped
853 * FALSE - more senders arrived, re-registered for notification
859 mig_object_no_senders(
861 mach_port_mscount_t mscount
)
863 mig_object_t mig_object
;
866 if (port
->ip_mscount
> mscount
) {
870 * Somebody created new send rights while the
871 * notification was in-flight. Just create a
872 * new send-once right and re-register with
873 * the new (higher) mscount threshold.
875 /* make a sonce right for the notification */
878 ipc_port_nsrequest(port
, mscount
, port
, &previous
);
881 assert(previous
== IP_NULL
);
886 * Clear the port pointer while we have it locked.
888 mig_object
= (mig_object_t
)port
->ip_kobject
;
889 mig_object
->port
= IP_NULL
;
892 * Bring the sequence number and mscount in
893 * line with ipc_port_destroy assertion.
895 port
->ip_mscount
= 0;
896 port
->ip_messages
.imq_seqno
= 0;
897 ipc_port_destroy(port
); /* releases lock */
900 * Release the port's reference on the object.
902 mig_object
->pVtbl
->Release((IMIGObject
*)mig_object
);
907 * Kernel implementation of the notification chain for MIG object
908 * is kept separate from the actual objects, since there are expected
909 * to be much fewer of them than actual objects.
911 * The implementation of this part of MIG objects is coming
912 * "Real Soon Now"(TM).