SCO OpenServer
copyio(D3oddi)
copyio --
copy bytes between a physical and a virtual address
Synopsis
#include <sys/types.h>
#include <sys/user.h>
int copyio(paddr_t paddr, caddr_t caddr, int bytes, int mapping);
Description
The copyio function copies bytes between
physical addresses and kernel virtual addresses,
and between kernel addresses and user addresses.
This routine has little purpose other than to call
bcopy(D3oddi)
for transfers between kernel addresses,
copyin(D3oddi)
for transfers from user space to the kernel, and
copyout(D3oddi)
for transfers from the kernel to user space.
Arguments
paddr-
Pointer to a physical address to which,
or from which, data is to be transferred.
caddr-
Virtual address to which, or from which,
data is to be transferred.
bytes-
integer that specifies the number
of bytes of data to transfer.
mapping-
integer that designates the
direction of the transfer.
The following possible mapping values are
defined in the <sys/user.h> header file.
Use of any other value causes a system panic.
U_RKD-
Kernel-to-kernel transfer from paddr to caddr
using bcopy.
U_WKD-
Kernel-to-kernel transfer from caddr to paddr
using bcopy.
U_RUD-
Kernel-to-user transfer from paddr to caddr
using copyout.
U_WUD-
User-to-kernel transfer from caddr to paddr
using copyin.
Return values
If successful, this routine performs the specified data
transfer. Otherwise, -1 is returned for any mapping setting if the
requested number of bytes to transfer is 0 (zero). The following
errors can also occur only when copyio is called with the
U_RUD or U_WUD mappings:
-
The address in user space is invalid,
causing a page fault to occur
during a transfer to or from user space.
-
An address was specified that would have resulted in
data being copied into priviliged address space
such as the user block.
If U_RUD or U_WUD is set in mapping
and -1 is returned, call seterror to return
EFAULT to the calling process in user space.
Usage
Always include <sys/user.h> and select a correct
mapping value. Otherwise, a panic occurs with the message
``bad mapping in copyio''.
Specify kernel addresses only for mapping set to
U_RKD or U_WKD.
If a user address is specified for these mappings,
the system will panic.
When this function is called from the
read(D2oddi)
or
write(D2oddi)
entry point
with the U_RUD or U_WUD mapping,
the driver code must
increase u.u_base
and u.u_offset
by
the number of bytes transferred,
and decrease u.u_count
by
the number of bytes transferred
after the call completes:
u.u_count -= cnt;
u.u_offset += cnt;
u.u_base += cnt;
The
iomove(D3oddi)
function is similar to
copyio( ),
but it sets the members of the user area
and the driver does not have to.
If an error code is returned, call
seterror(D3oddi)
with argument EFAULT to return EFAULT to the
user process calling your driver. Address values need not be
word-aligned.
Context and synchronization
If mapping is U_RUD or U_WUD-
User
context.
If mapping is U_RKD or U_WKD-
All
contexts.
Hardware applicability
All
Version applicability
oddi:
1, 2, 2mp, 3, 3mp, 4, 4mp, 5, 5mp, 6, 6mp
SVR5 DDI compatibility
This function is not supported in DDI.
This function can be replaced with calls to
bcopy(D3)
for transfers between kernel addresses,
copyin(D3)
for transfers from user space to the kernel,
and
copyout(D3)
for transfers from the kernel to user space.
References
bcopy(D3oddi),
copyin(D3oddi),
copyout(D3oddi),
cpass(D3oddi),
fubyte(D3oddi),
fuword(D3oddi),
iomove(D3oddi),
passc(D3oddi),
seterror(D3oddi),
subyte(D3oddi),
suword(D3oddi)
``Data, copying'' in HDK Technical Reference
19 June 2005
© 2005 The SCO Group, Inc. All rights reserved.
OpenServer 5 HDK - June 2005