xref: /xnu-10002.1.13/osfmk/man/device_open.html (revision 1031c584a5e37aff177559b9f69dbd3c8c3fd30a)
1*1031c584SApple OSS Distributions<h2>device_open</h2>
2*1031c584SApple OSS Distributions<hr>
3*1031c584SApple OSS Distributions<p>
4*1031c584SApple OSS Distributions<strong>Function</strong> - Establish a connection to a device.
5*1031c584SApple OSS Distributions<h3>SYNOPSIS</h3>
6*1031c584SApple OSS Distributions<pre>
7*1031c584SApple OSS Distributions<strong>#include&ltdevice/device.h&gt</strong>
8*1031c584SApple OSS Distributions
9*1031c584SApple OSS Distributions<strong>kern_return_t   device_open</strong>
10*1031c584SApple OSS Distributions                <strong>(mach_port_t</strong>                        <var>master_port</var>,
11*1031c584SApple OSS Distributions                 <strong>mach_port_t</strong>                             <var>ledger</var>,
12*1031c584SApple OSS Distributions                 <strong>dev_mode_t</strong>                                <var>mode</var>,
13*1031c584SApple OSS Distributions                 <strong>security_token_t</strong>                   <var>security_id</var>,
14*1031c584SApple OSS Distributions                 <strong>dev_name_t</strong>                                <var>name</var>,
15*1031c584SApple OSS Distributions                 <strong>mach_port_t</strong>                             <var>device</var><strong>);</strong>
16*1031c584SApple OSS Distributions
17*1031c584SApple OSS Distributions
18*1031c584SApple OSS Distributions<strong>#include&ltdevice/device_request.h&gt</strong>
19*1031c584SApple OSS Distributions
20*1031c584SApple OSS Distributions<strong>kern_return_t   device_open_request</strong>
21*1031c584SApple OSS Distributions                <strong>(mach_port_t</strong>                        <var>master_port</var>,
22*1031c584SApple OSS Distributions                 <strong>mach_port_t</strong>                         <var>reply_port</var>,
23*1031c584SApple OSS Distributions                 <strong>mach_port_t</strong>                             <var>ledger</var>,
24*1031c584SApple OSS Distributions                 <strong>dev_mode_t</strong>                                <var>mode</var>,
25*1031c584SApple OSS Distributions                 <strong>security_token_t</strong>                   <var>security_id</var>,
26*1031c584SApple OSS Distributions                 <strong>dev_name_t</strong>                                <var>name</var><strong>);</strong>
27*1031c584SApple OSS Distributions
28*1031c584SApple OSS Distributions
29*1031c584SApple OSS Distributions<strong>kern_return_t   ds_device_open_reply</strong>
30*1031c584SApple OSS Distributions                <strong>(mach_port_t</strong>                         <var>reply_port</var>,
31*1031c584SApple OSS Distributions                 <strong>kern_return_t</strong>                      <var>return_code</var>,
32*1031c584SApple OSS Distributions                 <strong>mach_port_t</strong>                             <var>device</var><strong>);</strong>
33*1031c584SApple OSS Distributions</pre>
34*1031c584SApple OSS Distributions<h3>PARAMETERS</h3>
35*1031c584SApple OSS Distributions<dl>
36*1031c584SApple OSS Distributions<p>
37*1031c584SApple OSS Distributions<dt> <var>master_port</var>
38*1031c584SApple OSS Distributions<dd>
39*1031c584SApple OSS Distributions[in device-master send right]
40*1031c584SApple OSS DistributionsThe master device port.  This port is
41*1031c584SApple OSS Distributionsprovided to the bootstrap task.
42*1031c584SApple OSS Distributions<p>
43*1031c584SApple OSS Distributions<dt> <var>reply_port</var>
44*1031c584SApple OSS Distributions<dd>
45*1031c584SApple OSS Distributions[in reply receive (to be converted to send-once) right]
46*1031c584SApple OSS DistributionsThe port to
47*1031c584SApple OSS Distributionswhich a reply is to be sent when the device is open.
48*1031c584SApple OSS Distributions<p>
49*1031c584SApple OSS Distributions<dt> <var>ledger</var>
50*1031c584SApple OSS Distributions<dd>
51*1031c584SApple OSS Distributions[pointer to a ledger send right]
52*1031c584SApple OSS DistributionsResource ledger from which the device will draw its resources.
53*1031c584SApple OSS Distributions<p>
54*1031c584SApple OSS Distributions<dt> <var>mode</var>
55*1031c584SApple OSS Distributions<dd>
56*1031c584SApple OSS Distributions[in scalar]
57*1031c584SApple OSS DistributionsOpening mode.  This is the bit-wise <strong>OR</strong> of the following
58*1031c584SApple OSS Distributionsvalues:
59*1031c584SApple OSS Distributions<dl>
60*1031c584SApple OSS Distributions<p>
61*1031c584SApple OSS Distributions<dt> <strong>D_READ</strong>
62*1031c584SApple OSS Distributions<dd>
63*1031c584SApple OSS DistributionsRead access
64*1031c584SApple OSS Distributions<p>
65*1031c584SApple OSS Distributions<dt> <strong>D_WRITE</strong>
66*1031c584SApple OSS Distributions<dd>
67*1031c584SApple OSS DistributionsWrite access
68*1031c584SApple OSS Distributions<p>
69*1031c584SApple OSS Distributions<dt> <strong>D_NODELAY</strong>
70*1031c584SApple OSS Distributions<dd>
71*1031c584SApple OSS DistributionsDo not delay on open
72*1031c584SApple OSS Distributions</dl>
73*1031c584SApple OSS Distributions<p>
74*1031c584SApple OSS Distributions<dt> <var>security_id</var>
75*1031c584SApple OSS Distributions<dd>
76*1031c584SApple OSS Distributions[in scalar]
77*1031c584SApple OSS DistributionsThe security ID that tasks attempting to use this device port
78*1031c584SApple OSS Distributionsmust have.  A zero value indicates all identities.
79*1031c584SApple OSS Distributions<p>
80*1031c584SApple OSS Distributions<dt> <var>name</var>
81*1031c584SApple OSS Distributions<dd>
82*1031c584SApple OSS Distributions[pointer to in array of <var>char</var>]
83*1031c584SApple OSS DistributionsName of the device to open.
84*1031c584SApple OSS Distributions<p>
85*1031c584SApple OSS Distributions<dt> <var>return_code</var>
86*1031c584SApple OSS Distributions<dd>
87*1031c584SApple OSS Distributions[in scalar]
88*1031c584SApple OSS DistributionsStatus of the open.
89*1031c584SApple OSS Distributions<p>
90*1031c584SApple OSS Distributions<dt> <var>device</var>
91*1031c584SApple OSS Distributions<dd>
92*1031c584SApple OSS Distributions[out device send right, in for asynchronous form]
93*1031c584SApple OSS DistributionsThe returned device
94*1031c584SApple OSS Distributionsport.
95*1031c584SApple OSS Distributions</dl>
96*1031c584SApple OSS Distributions<h3>DESCRIPTION</h3>
97*1031c584SApple OSS Distributions<p>
98*1031c584SApple OSS DistributionsThe <strong>device_open</strong> function opens a device object.  The
99*1031c584SApple OSS Distributionsopen operation of the
100*1031c584SApple OSS Distributionsdevice is invoked, if the device is not already open.  The open
101*1031c584SApple OSS Distributionscount for the device
102*1031c584SApple OSS Distributionsis incremented.  Each open for a device returns a port, the allowed
103*1031c584SApple OSS Distributionsoperations upon which being governed by <var>mode</var>.  The port is not
104*1031c584SApple OSS Distributionsdistinct.
105*1031c584SApple OSS Distributions<h3>RETURN VALUES</h3>
106*1031c584SApple OSS Distributions<p>
107*1031c584SApple OSS DistributionsOnly generic errors apply.
108*1031c584SApple OSS Distributions<h3>RELATED INFORMATION</h3>
109*1031c584SApple OSS Distributions<p>
110*1031c584SApple OSS DistributionsFunctions:
111*1031c584SApple OSS Distributions<a href="device_close.html"><strong>device_close</strong></a>,
112*1031c584SApple OSS Distributions<a href="device_reply_server.html"><strong>device_reply_server</strong></a>.
113