26.02.2014 Views

Getting Started with QNX Neutrino - QNX Software Systems

Getting Started with QNX Neutrino - QNX Software Systems

Getting Started with QNX Neutrino - QNX Software Systems

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Alphabetical listing of connect and I/O functions<br />

© 2009, <strong>QNX</strong> <strong>Software</strong> <strong>Systems</strong> GmbH & Co. KG.<br />

member; the driver is to set the outgoing structure’s nbytes member to the number of<br />

bytes transferred.<br />

Note that the input and output data structures are zero-padded so that they align <strong>with</strong><br />

each other. This means that the implicit data area begins at the same address in the<br />

input and output structures.<br />

If using the helper routine iofunc_devctl(), beware that it’ll return the constant<br />

_RESMGR_DEFAULT in the case where it can’t do anything <strong>with</strong> the devctl() message.<br />

This return value is there to decouple legitimate errno return values from an<br />

“unrecognized command” return value. Upon receiving a _RESMGR_DEFAULT, the<br />

base-layer library will respond <strong>with</strong> an errno of ENOSYS, which the client’s devctl()<br />

library function will translate into ENOTTY (which is the “correct” POSIX value).<br />

It’s up to your function to check the open mode against the operation; no checking is<br />

done anywhere in either the client’s devctl() library or in the resource manager library.<br />

For example, it’s possible to open a resource manager “read-only” and then issue a<br />

devctl() to it telling it to “format the hard disk” (which is very much a “write”<br />

operation). It would be prudent to verify the open mode first before proceeding <strong>with</strong><br />

the operation.<br />

Note that the range of dcmd values you can use is limited (0x0000 through 0x0FFF<br />

inclusive is reserved for QSS). Other values may be in use; take a look through the<br />

include files that have the name .<br />

Returns: The status via the helper macro _RESMGR_STATUS and the reply buffer<br />

(<strong>with</strong> reply data, if required).<br />

For an example, take a look at “A simple io_devctl() example,” below.<br />

io_dup()<br />

int io_dup (resmgr_context_t *ctp, io_dup_t *msg, RESMGR_OCB_T<br />

*ocb)<br />

Classification: I/O<br />

Default handler: NULL — handled by base layer<br />

Helper functions: none<br />

Client functions: dup(), dup2(), fcntl(), fork(), spawn*(), vfork()<br />

Messages: _IO_DUP<br />

Data structure:<br />

struct _io_dup {<br />

uint16_t<br />

type;<br />

uint16_t<br />

combine_len;<br />

struct _msg_info info;<br />

uint32_t<br />

reserved;<br />

uint32_t<br />

key;<br />

};<br />

typedef union {<br />

234 Chapter 5 • Resource Managers April 30, 2009

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!