device_open


Function - Establish a connection to a device.

SYNOPSIS

#include<device/device.h>

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<device/device_request.h>

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.

RELATED INFORMATION

Functions: device_close, device_reply_server.