The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/compat/mach/mach_port.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: mach_port.h,v 1.40 2008/04/28 20:23:44 martin Exp $ */
    2 
    3 /*-
    4  * Copyright (c) 2002-2003 The NetBSD Foundation, Inc.
    5  * All rights reserved.
    6  *
    7  * This code is derived from software contributed to The NetBSD Foundation
    8  * by Emmanuel Dreyfus
    9  *
   10  * Redistribution and use in source and binary forms, with or without
   11  * modification, are permitted provided that the following conditions
   12  * are met:
   13  * 1. Redistributions of source code must retain the above copyright
   14  *    notice, this list of conditions and the following disclaimer.
   15  * 2. Redistributions in binary form must reproduce the above copyright
   16  *    notice, this list of conditions and the following disclaimer in the
   17  *    documentation and/or other materials provided with the distribution.
   18  *
   19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
   20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
   23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   29  * POSSIBILITY OF SUCH DAMAGE.
   30  */
   31 
   32 #ifndef _MACH_PORT_H_
   33 #define _MACH_PORT_H_
   34 
   35 #define MACH_PORT_REF(mp)       (mp)->mp_refcount++
   36 #define MACH_PORT_UNREF(mp)     if (--(mp)->mp_refcount <= 0) mach_port_put(mp)
   37 
   38 #define MACH_PORT_NULL                  (struct mach_right *)0
   39 #define MACH_PORT_DEAD                  (struct mach_right *)-1
   40 
   41 #define MACH_PORT_RIGHT_SEND            0
   42 #define MACH_PORT_RIGHT_RECEIVE         1
   43 #define MACH_PORT_RIGHT_SEND_ONCE       2
   44 #define MACH_PORT_RIGHT_PORT_SET        3
   45 #define MACH_PORT_RIGHT_DEAD_NAME       4
   46 #define MACH_PORT_RIGHT_NUMBER          5
   47 
   48 #define MACH_PORT_TYPE_SEND             (1 << (MACH_PORT_RIGHT_SEND + 16))
   49 #define MACH_PORT_TYPE_RECEIVE          (1 << (MACH_PORT_RIGHT_RECEIVE + 16))
   50 #define MACH_PORT_TYPE_SEND_ONCE        (1 << (MACH_PORT_RIGHT_SEND_ONCE + 16))
   51 #define MACH_PORT_TYPE_PORT_SET         (1 << (MACH_PORT_RIGHT_PORT_SET + 16))
   52 #define MACH_PORT_TYPE_DEAD_NAME        (1 << (MACH_PORT_RIGHT_DEAD_NAME + 16))
   53 #define MACH_PORT_TYPE_PORT_RIGHTS \
   54     (MACH_PORT_TYPE_SEND | MACH_PORT_TYPE_RECEIVE | MACH_PORT_TYPE_SEND_ONCE)
   55 #define MACH_PORT_TYPE_PORT_OR_DEAD \
   56     (MACH_PORT_TYPE_PORT_RIGHTS | MACH_PORT_TYPE_DEAD_NAME)
   57 #define MACH_PORT_TYPE_ALL_RIGHTS \
   58     (MACH_PORT_TYPE_PORT_OR_DEAD|MACH_PORT_TYPE_PORT_SET)
   59 #define MACH_PORT_TYPE_REF_RIGHTS \
   60     (MACH_PORT_TYPE_SEND | MACH_PORT_TYPE_SEND_ONCE | MACH_PORT_TYPE_DEAD_NAME)
   61 
   62 /* port_deallocate */
   63 
   64 typedef struct {
   65         mach_msg_header_t req_msgh;
   66         mach_ndr_record_t req_ndr;
   67         mach_port_name_t req_name;
   68 } mach_port_deallocate_request_t;
   69 
   70 typedef struct {
   71         mach_msg_header_t rep_msgh;
   72         mach_ndr_record_t rep_ndr;
   73         mach_kern_return_t rep_retval;
   74         mach_msg_trailer_t rep_trailer;
   75 } mach_port_deallocate_reply_t;
   76 
   77 /* port_allocate */
   78 
   79 typedef struct {
   80         mach_msg_header_t req_msgh;
   81         mach_ndr_record_t req_ndr;
   82         mach_port_right_t req_right;
   83 } mach_port_allocate_request_t;
   84 
   85 typedef struct {
   86         mach_msg_header_t rep_msgh;
   87         mach_ndr_record_t rep_ndr;
   88         mach_kern_return_t rep_retval;
   89         mach_port_name_t rep_name;
   90         mach_msg_trailer_t rep_trailer;
   91 } mach_port_allocate_reply_t;
   92 
   93 /* port_insert_right */
   94 
   95 typedef struct {
   96         mach_msg_header_t req_msgh;
   97         mach_msg_body_t req_body;
   98         mach_msg_port_descriptor_t req_poly;
   99         mach_ndr_record_t req_ndr;
  100         mach_port_name_t req_name;
  101 } mach_port_insert_right_request_t;
  102 
  103 typedef struct {
  104         mach_msg_header_t rep_msgh;
  105         mach_ndr_record_t rep_ndr;
  106         mach_kern_return_t rep_retval;
  107         mach_msg_trailer_t rep_trailer;
  108 } mach_port_insert_right_reply_t;
  109 
  110 /* port_type */
  111 
  112 typedef struct {
  113         mach_msg_header_t req_msgh;
  114         mach_ndr_record_t req_ndr;
  115         mach_port_name_t req_name;
  116 } mach_port_type_request_t;
  117 
  118 typedef struct {
  119         mach_msg_header_t rep_msgh;
  120         mach_ndr_record_t rep_ndr;
  121         mach_kern_return_t rep_retval;
  122         mach_port_type_t rep_ptype;
  123         mach_msg_trailer_t rep_trailer;
  124 } mach_port_type_reply_t;
  125 
  126 /* port_set_attributes */
  127 
  128 #define MACH_PORT_LIMITS_INFO 1
  129 #define MACH_PORT_RECEIVE_STATUS 2
  130 #define MACH_PORT_DNREQUESTS_SIZE 3
  131 
  132 typedef struct mach_port_status {
  133         mach_port_name_t        mps_pset;
  134         mach_port_seqno_t       mps_seqno;
  135         mach_port_mscount_t     mps_mscount;
  136         mach_port_msgcount_t    mps_qlimit;
  137         mach_port_msgcount_t    mps_msgcount;
  138         mach_port_rights_t      mps_sorights;
  139         mach_boolean_t          mps_srights;
  140         mach_boolean_t          mps_pdrequest;
  141         mach_boolean_t          mps_nsrequest;
  142         unsigned int            mps_flags;
  143 } mach_port_status_t;
  144 
  145 typedef struct mach_port_limits {
  146         mach_port_msgcount_t    mpl_qlimit;
  147 } mach_port_limits_t;
  148 
  149 typedef struct {
  150         mach_msg_header_t req_msgh;
  151         mach_ndr_record_t req_ndr;
  152         mach_port_name_t req_name;
  153         mach_port_flavor_t req_flavor;
  154         mach_msg_type_number_t req_count;
  155         mach_integer_t req_port_info[0];
  156 } mach_port_set_attributes_request_t;
  157 
  158 typedef struct {
  159         mach_msg_header_t rep_msgh;
  160         mach_ndr_record_t rep_ndr;
  161         mach_kern_return_t rep_retval;
  162         mach_msg_trailer_t rep_trailer;
  163 } mach_port_set_attributes_reply_t;
  164 
  165 /* port_get_attributes */
  166 
  167 #define MACH_PORT_QLIMIT_DEFAULT ((mach_port_msgcount_t) 5)
  168 #define MACH_PORT_QLIMIT_MAX ((mach_port_msgcount_t) 16)
  169 
  170 typedef struct {
  171         mach_msg_header_t req_msgh;
  172         mach_ndr_record_t req_ndr;
  173         mach_port_name_t req_name;
  174         mach_port_flavor_t req_flavor;
  175         mach_msg_type_number_t req_count;
  176 } mach_port_get_attributes_request_t;
  177 
  178 typedef struct {
  179         mach_msg_header_t rep_msgh;
  180         mach_ndr_record_t rep_ndr;
  181         mach_kern_return_t rep_retval;
  182         mach_msg_type_number_t rep_count;
  183         mach_integer_t rep_info[10];
  184         mach_msg_trailer_t rep_trailer;
  185 } mach_port_get_attributes_reply_t;
  186 
  187 /* port_insert_member */
  188 
  189 typedef struct {
  190         mach_msg_header_t req_msgh;
  191         mach_ndr_record_t req_ndr;
  192         mach_port_name_t req_name;
  193         mach_port_name_t req_pset;
  194 } mach_port_insert_member_request_t;
  195 
  196 typedef struct {
  197         mach_msg_header_t rep_msgh;
  198         mach_ndr_record_t rep_ndr;
  199         mach_kern_return_t rep_retval;
  200         mach_msg_trailer_t rep_trailer;
  201 } mach_port_insert_member_reply_t;
  202 
  203 /* port_move_member */
  204 
  205 typedef struct {
  206         mach_msg_header_t req_msgh;
  207         mach_ndr_record_t req_ndr;
  208         mach_port_name_t req_member;
  209         mach_port_name_t req_after;
  210 } mach_port_move_member_request_t;
  211 
  212 typedef struct {
  213         mach_msg_header_t rep_msgh;
  214         mach_ndr_record_t rep_ndr;
  215         mach_kern_return_t rep_retval;
  216         mach_msg_trailer_t rep_trailer;
  217 } mach_port_move_member_reply_t;
  218 
  219 /* port_destroy */
  220 
  221 typedef struct {
  222         mach_msg_header_t req_msgh;
  223         mach_ndr_record_t req_ndr;
  224         mach_port_name_t req_name;
  225 } mach_port_destroy_request_t;
  226 
  227 typedef struct {
  228         mach_msg_header_t rep_msgh;
  229         mach_ndr_record_t rep_ndr;
  230         mach_kern_return_t rep_retval;
  231         mach_msg_trailer_t rep_trailer;
  232 } mach_port_destroy_reply_t;
  233 
  234 /* port_request_notification */
  235 
  236 typedef struct {
  237         mach_msg_header_t req_msgh;
  238         mach_msg_body_t req_body;
  239         mach_msg_port_descriptor_t req_notify;
  240         mach_ndr_record_t req_ndr;
  241         mach_port_name_t req_name;
  242         mach_msg_id_t req_msgid;
  243         mach_port_mscount_t req_count;
  244 } mach_port_request_notification_request_t;
  245 
  246 typedef struct {
  247         mach_msg_header_t rep_msgh;
  248         mach_msg_body_t rep_body;
  249         mach_msg_port_descriptor_t rep_previous;
  250         mach_msg_trailer_t rep_trailer;
  251 } mach_port_request_notification_reply_t;
  252 
  253 /* port_get_refs */
  254 
  255 typedef struct {
  256         mach_msg_header_t req_msgh;
  257         mach_ndr_record_t req_ndr;
  258         mach_port_name_t req_name;
  259         mach_port_right_t req_right;
  260 } mach_port_get_refs_request_t;
  261 
  262 typedef struct {
  263         mach_msg_header_t rep_msgh;
  264         mach_ndr_record_t rep_ndr;
  265         mach_kern_return_t rep_retval;
  266         mach_port_urefs_t rep_refs;
  267         mach_msg_trailer_t rep_trailer;
  268 } mach_port_get_refs_reply_t;
  269 
  270 /* port_mod_refs */
  271 
  272 typedef struct {
  273         mach_msg_header_t req_msgh;
  274         mach_ndr_record_t req_ndr;
  275         mach_port_name_t req_name;
  276         mach_port_right_t req_right;
  277         mach_port_delta_t req_delta;
  278 } mach_port_mod_refs_request_t;
  279 
  280 typedef struct {
  281         mach_msg_header_t rep_msgh;
  282         mach_ndr_record_t rep_ndr;
  283         mach_kern_return_t rep_retval;
  284         mach_msg_trailer_t rep_trailer;
  285 } mach_port_mod_refs_reply_t;
  286 
  287 /* Kernel-private structures */
  288 
  289 extern struct mach_port *mach_clock_port;
  290 extern struct mach_port *mach_io_master_port;
  291 extern struct mach_port *mach_bootstrap_port;
  292 extern struct mach_port *mach_saved_bootstrap_port;
  293 
  294 /* In-kernel Mach port right description */
  295 struct mach_right {
  296         mach_port_t mr_name;            /* The right name */
  297         struct lwp *mr_lwp;             /* points back to struct lwp */
  298         int mr_type;                    /* right type (recv, send, sendonce) */
  299         LIST_ENTRY(mach_right) mr_list; /* Right list for a process */
  300         int mr_refcount;                /* Reference count */
  301         struct mach_right *mr_notify_destroyed;         /* notify destroyed */
  302         struct mach_right *mr_notify_dead_name;         /* notify dead name */
  303         struct mach_right *mr_notify_no_senders;        /* notify no senders */
  304 
  305         /* Revelant only if the right is on a port set */
  306         LIST_HEAD(mr_set, mach_right) mr_set;
  307                                         /* The right set list */
  308 
  309         /* Revelant only if the right is not on a port set */
  310         struct mach_port *mr_port;      /* Port we have the right on */
  311         LIST_ENTRY(mach_right) mr_setlist; /* Set list */
  312 
  313         /* Revelant only if the right is part of a port set */
  314         struct mach_right *mr_sethead;  /* Points back to right set */
  315 };
  316 
  317 mach_port_t mach_right_newname(struct lwp *, mach_port_t);
  318 struct mach_right *mach_right_get(struct mach_port *,
  319     struct lwp *, int, mach_port_t);
  320 void mach_right_put(struct mach_right *, int);
  321 void mach_right_put_shlocked(struct mach_right *, int);
  322 void mach_right_put_exclocked(struct mach_right *, int);
  323 struct mach_right *mach_right_check(mach_port_t, struct lwp *, int);
  324 
  325 /* In-kernel Mach port description */
  326 struct mach_port {
  327         struct mach_right *mp_recv;     /* The receive right on this port */
  328         int mp_count;                   /* Count of queued messages */
  329         TAILQ_HEAD(mp_msglist,          /* Queue pending messages */
  330             mach_message) mp_msglist;
  331         krwlock_t mp_msglock;           /* Lock for the queue */
  332         int mp_refcount;                /* Reference count */
  333         int mp_flags;                   /* Flags, see below */
  334         int mp_datatype;                /* Type of field mp_data, see below */
  335         void *mp_data;                  /* Data attached to the port */
  336 };
  337 
  338 /* mp_flags for struct mach_port */
  339 #define MACH_MP_INKERNEL        0x01    /* Receiver is inside the kernel */
  340 #define MACH_MP_DATA_ALLOCATED  0x02    /* mp_data was malloc'ed */
  341 
  342 /* mp_datatype for struct mach_port */
  343 #define MACH_MP_NONE            0x0     /* No data */
  344 #define MACH_MP_LWP             0x1     /* (struct lwp *) */
  345 #define MACH_MP_DEVICE_ITERATOR 0x2     /* (struct mach_device_iterator *) */
  346 #define MACH_MP_IOKIT_DEVCLASS  0x3     /* (struct mach_iokit_devclass *) */
  347 #define MACH_MP_PROC            0x4     /* (struct proc *) */
  348 #define MACH_MP_NOTIFY_SYNC     0x5     /* int */
  349 #define MACH_MP_MEMORY_ENTRY    0x6     /* (struct mach_memory_entry *) */
  350 #define MACH_MP_EXC_INFO        0x7     /* (struct mach_exc_info *) */
  351 #define MACH_MP_SEMAPHORE       0x8     /* (struct mach_semaphore *) */
  352 
  353 void mach_port_init(void);
  354 struct mach_port *mach_port_get(void);
  355 void mach_port_put(struct mach_port *);
  356 void mach_remove_recvport(struct mach_port *);
  357 void mach_add_recvport(struct mach_port *, struct lwp *);
  358 int mach_port_check(struct mach_port *);
  359 #ifdef DEBUG_MACH
  360 void mach_debug_port(void);
  361 #endif
  362 
  363 #endif /* _MACH_PORT_H_ */

Cache object: 7a6d03fbee14c0b2f04e71b548f17337


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.