Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought



     COPYIO(K)                 UNIX System V                 COPYIO(K)



     Name
          copyio - copies bytes to and from a physical address

     Syntax
          #include "sys/user.h"

          int
          copyio(paddr, caddr, bytes, mapping)
          paddr_t paddr;
          caddr_t caddr;
          int bytes, mapping;

     Description
          The copyio routine copies bytes between kernel virtual
          addresses, and between kernel addresses and user addresses.
          This routine has little purpose other than to call bcopy(K)
          for tranfers between kernel addresses, copyin(K) for
          transfers from user space to the kernel, and copyout(K) for
          transfers from the kernel to user space.

          After completion of calls to copyio with the U_RUD or U_WUD
          mappings, increase u.u_base by the number of bytes
          transferred, and decrease u.u_count by the number of bytes
          transferred.  If an error code is returned, call
          seterror(EFAULT) to return EFAULT to the user process that
          is calling your driver.  Address values need not be word-
          aligned.

     Parameters
          The argument paddr is a pointer to a virtual address to
          which or from which data is to be transferred.

          The argument caddr is a virtual address to which or from
          which data is to be transferred.

          The argument bytes is an integer that specifies the number
          of bytes of data to transfer.

          The value of mapping is an integer that designates the
          direction of the transfer. The following possible mapping
          values are defined in sys/user.h.  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

     Warning
          Always include user.h and select a correct mapping value.
          Otherwise, a panic occurs with the message, "bad mapping in
          copyio."  Be sure to specify kernel addresses only for U_RKD
          and U_WKD.  If a user address is specified, the system will
          panic.  The copyio routine called with the U_RUD and U_WUD
          mappings cannot be used from an interrupt or initialization
          routine.

     Return Value
          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:

           +   a page fault occurred between a transfer to user space

           +   the address in user space is invalid

           +   an address was specified that would have resulted in
               data being copied into the user block

          If U_RUD or U_WUD is set in mapping and -1 is returned, call
          seterror to return EFAULT to the caller in user space.

     See Also
          bcopy(K), copyin(K), copyout(K), seterror(K)

                                                      (printed 7/6/89)



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026