Motorola MCP750 Specifications Page 162

  • Download
  • Add to my manuals
  • Print
  • Page
    / 344
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 161
D
evice Driver Programming
10-16
The Write Routine 10
Specification
#include <sys/types.h>
#include <sys/errno.h>
#include <sys/uio.h>
#include <sys/cred.h>
#include <sys/ddi.h>
int xxwrite (dev, uio_p, crp)
dev_t dev;
uio_t *uio_p;
cred_t *crp;
Return Values
0 if the device write is successful
A nonzero value if the write fails. The number is returned to the user in
errno; it should be an error number as defined in <sys/errno.h>.
The driver’s write(D2) routine is called when the write(2) system call is made to
write data to the device. This entry point is optional.
The dev argument specifies the device major and minor number.
The uio_p argument is a pointer to a uio structure that describes the location and layout of
the user’s I/0 buffers. This structure is defined in <sys/uio.h>; it is described in sec-
tion Chapter 9, “The iovec and uio Structures” on page 9-7.
NOTE
A driver compiled as a large offset driver is passed (and expects to
get) the large offset version of the uio structure for the
write(D2) interface it supplies. The same applies for small off-
set drivers. For details on how this is done, see Chapter 9, the sec-
tion “Small vs. Large Offset Drivers” on page 9-21.
The crp argument is a pointer to the cred structure associated with the user process.
The uio structure contains the number and position of the characters as given by the user.
uio–>uio_resid is the number of characters in the uio structure. The uio structure
contains a pointer to an array of iovec structures in uio->uio_iov. The number of iovec
structures is kept in uio->uio_iovcnt. Each iovec structure contains the base address of
the user’s characters in iovec->iov_base and the number of characters in iovec->iov_len.
The system can call the routine internally, so the flag uio->uio_segflg is supplied that
determines if the iovec structures refer to the system address space instead of the user’s.
Page view 161
1 2 ... 157 158 159 160 161 162 163 164 165 166 167 ... 343 344

Comments to this Manuals

No comments