'\"macro stdmacro
.if n .pH ddi_dki.bcopy @(#)bcopy	40.6 of 10/10/89
.\" Copyright 1989 AT&T
.de IX
.ie '\\n(.z'' .tm .Index: \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9	\\n%
.el \\!.IX \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9
..
.nr X
.if \nX=0 .ds x} bcopy D3DK "" "DDI/DKI" "\&"
.if \nX=1 .ds x} bcopy D3DK "" "DDI/DKI"
.if \nX=2 .ds x} bcopy D3DK "" "\&"
.if \nX=3 .ds x} bcopy "" "" "\&"
.TH \*(x}
.IX "\f4bcopy\fP(D3DK)"
.IX kernel, data copy in
.SH NAME
\f4bcopy\f1 \- copy data between address locations in the kernel
.SH SYNOPSIS
.nf
.na
\f4#include <sys/types.h>
.sp 0.5
int bcopy(\f4caddr_t\f1 \f2from, \f4caddr_t\f1 \f2to, \f4long\f1 \f2bcount\f4);\f1
.ad
.fi
.SH ARGUMENTS
.RS 0n
.IP "\f2from\f1" 10n
Source address from which the copy is made.
.IP "\f2to\f1" 10n
Destination address to which copy is made.
.IP "\f2bcount\f1" 10n
The number of bytes moved.
.RE
.SH DESCRIPTION
\f4bcopy\f1 copies \f2bcount\f1 bytes from one kernel address to
another.  If the input and output addresses overlap, the command
executes, but the results may not be as expected.
.P
\f3CAUTION:\f1
The \f2from\f1 and \f2to\f1 addresses must be within the
kernel space.  No range checking is done.  If an address outside of the
kernel space is selected, the driver may corrupt the system in an
unpredictable way.
.P
Note that \f4bcopy\f1 should never be used
to move data in or out of a user buffer,
because it has no provision for handling page faults.
The user address space can be swapped out at any time,
and \f4bcopy\f1 always assumes that there will be no paging faults.
If \f4bcopy\f1 attempts to access the user buffer
when it is swapped out, the system will panic.
It is safe to use \f4bcopy\f1 to move data
within kernel space, since kernel space is never swapped out.
.SH RETURN VALUE
Under all conditions, \f40\f1 is returned.
.SH LEVEL
Base or Interrupt
.SH SEE ALSO
\f2BCI Driver Development Guide\f1, Chapter 6, ``Input/Output Operations''
.P
.na
\f4copyin\f1(D3DK),
\f4copyout\f1(D3DK)
.ad
.SH EXAMPLE
.IX "\f4buf\fP(D4DK), example"
.P
An I/O request is made for data stored in a RAM disk.
If the I/O operation is a read request, the data is copied from the RAM disk
to a buffer (line 7).  If it is a write request, the data is copied from a
buffer to the RAM disk (line 11).  The \f4bcopy\f1 function is used since both
the RAM disk and the buffer are part of the kernel address space.
.ne 4
.P
.nf
.ft 4
.ps 7
 1  #define RAMDNBLK    1000           /* blocks in the RAM disk      */
 2  #define RAMDBSIZ     512           /* bytes per block             */
 3  char ramdblks[RAMDNBLK][RAMDBSIZ]; /* blocks forming RAM disk     */
       ...
 4
 5  if  (bp->b_flags & B_READ) /* if read request, copy data from RAM  */
 6                             /* disk data block to system buffer     */
 7       bcopy(&ramdblks[bp->b_blkno][0], bp->b_un.b_addr, bp->b_bcount);
 8
 9  else                       /* else write request, copy data from a */
10                             /* system buffer to RAM disk data block */
11       bcopy(bp->b_un.b_addr, &ramdblks[bp->b_blkno][0], bp->b_bcount);
.ps
.ft 1
.fi
.P
.FG "bcopy \- RAM disk read or write"
.ad
.fi
