Back to Darwin Xnu

Device Open

osfmk/man/device_open.html

latest2.1 KB
Original Source

device_open


Function - Establish a connection to a device.

SYNOPSIS

**#include&ltdevice/device.h&gt**** kern\_return\_t device\_open****(mach\_port\_t**master\_port, **mach\_port\_t** ledger, **dev\_mode\_t** mode, **security\_token\_t** security\_id, **dev\_name\_t** name, **mach\_port\_t** device**);****#include&ltdevice/device\_request.h&gt ****kern\_return\_t device\_open\_request**** (mach\_port\_t **master\_port,** mach\_port\_t **reply\_port,** mach\_port\_t **ledger,** dev\_mode\_t **mode,** security\_token\_t **security\_id,** dev\_name\_t **name** ); ****kern\_return\_t ds\_device\_open\_reply**** (mach\_port\_t **reply\_port,** kern\_return\_t **return\_code,** mach\_port\_t **device** );**

PARAMETERS

master_port[in device-master send right] The master device port. This port is provided to the bootstrap task.

reply_port[in reply receive (to be converted to send-once) right] The port to which a reply is to be sent when the device is open.

ledger[pointer to a ledger send right] Resource ledger from which the device will draw its resources.

mode[in scalar] Opening mode. This is the bit-wise OR of the following values:

D_READ Read access

D_WRITE Write access

D_NODELAY Do not delay on open

security_id[in scalar] The security ID that tasks attempting to use this device port must have. A zero value indicates all identities.

name[pointer to in array of char] Name of the device to open.

return_code[in scalar] Status of the open.

device[out device send right, in for asynchronous form] The returned device port.

DESCRIPTION

The device_open function opens a device object. The open operation of the device is invoked, if the device is not already open. The open count for the device is incremented. Each open for a device returns a port, the allowed operations upon which being governed by mode. The port is not distinct.

RETURN VALUES

Only generic errors apply.

Functions: device_close, device_reply_server.