1
0
Files
irix-657m-src/eoe/man/manD/bcopy.d3
2022-09-29 17:59:04 +03:00

113 lines
3.4 KiB
Plaintext

.if n .pH ddi.rm/d3/gen/bcopy @(#)bcopy 43.12 of 12/9/92
.\" Copyright 1992, 1991 UNIX System Laboratories, Inc.
.TH bcopy D3
.IX "\f4bcopy\fP(D3)"
.IX kernel, data copy in
.SH NAME
\f4bcopy\fP \- copy data between address locations in the kernel
.SH SYNOPSIS
.nf
.na
.ft 4
#include <sys/types.h>
#include <sys/ddi.h>
.sp 0.4
void bcopy(caddr_t \f2from\fP, caddr_t \f2to\fP, size_t \f2bcount\fP);
.ft 1
.ad
.fi
.SS Arguments
.RS 0
.IP "\f2from\fP" 10n
Source address from which the copy is made.
.IP "\f2to\fP" 10n
Destination address to which the copy is made.
.IP "\f2bcount\fP" 10n
Number of bytes to be copied.
.RE
.SH DESCRIPTION
\f4bcopy\fP copies \f2bcount\fP bytes
from one kernel address to another.
It chooses the best algorithm based on address alignment
and number of bytes to copy.
.SS "Return Values"
None
.SH USAGE
If the input and output addresses overlap,
the function executes, but the results are undefined.
.P
The source and destination address ranges must both be
within the kernel address space and must be memory resident.
No range checking is done.
Since there is no mechanism by which drivers that conform to the
rules of the DDI/DKI can obtain and use a kernel address which is not
memory resident (an address which is paged out),
DDI/DKI conforming drivers can assume that any address to which they
have access is memory resident and therefore a valid argument to \f4bcopy\fP.
Addresses within user address space are not valid arguments,
and specifying such an address may cause the driver to corrupt the system in an
unpredictable way.
For copying between kernel and user space, drivers must use
an appropriate function defined for that purpose (for example,
\f4copyin\fP(D3), \f4copyout\fP(D3), \f4uiomove\fP(D3),
\f4ureadc\fP(D3), or \f4uwritec\fP(D3)).
.P
Do not use \f4bcopy\fP to copy to or from I/O (hardware) addresses,
because they may not allow accesses of the type used by \f4bcopy\fP;
use it for memory addresses only. Use the \f4hwcpin\fP(D3), or
\f4hwcpout\fP(D3) routines for I/O addresses.
.SS Level
Initialization, Base or Interrupt.
.SS "Synchronization Constraints"
Does not sleep.
.P
Driver-defined basic locks, read/write locks, and sleep locks
may be held across calls to this function.
.SS Examples
.IX "\f4buf\fP(D4), example"
An I/O request is made for data stored in a RAM disk.
If the I/O operation is a read request, data are copied from the RAM disk
to a buffer (line 9).
If it is a write request, data are copied from a
buffer to the RAM disk (line 15).
The \f4bcopy\fP function is used since both
the RAM disk and the buffer are part of the kernel address space.
.br
.ne 3i
.P
.nf
.ft 4
.ps -1
.vs -1
1 #define RAMDNBLK 1000 /* number of blocks in RAM disk */
2 #define RAMDBSIZ NBPSCTR /* bytes per block */
3 char ramdblks[RAMDNBLK][RAMDBSIZ]; /* blocks forming RAM disk */
...
4
5 if (bp->b_flags & B_READ) {
6 /*
7 * read request - copy data from RAM disk to system buffer
8 */
9 bcopy(ramdblks[bp->b_blkno], bp->b_un.b_addr, bp->b_bcount);
10
11 } else {
12 /*
13 * write request - copy data from system buffer to RAM disk
14 */
15 bcopy(bp->b_un.b_addr, ramdblks[bp->b_blkno], bp->b_bcount);
16 }
.ps
.vs
.ft 1
.fi
.SH REFERENCES
.na
\f4copyin\fP(D3),
\f4copyout\fP(D3),
\f4hwcpin\fP(D3),
\f4hwcpout\fP(D3)
\f4uiomove\fP(D3),
\f4ureadc\fP(D3),
\f4uwritec\fP(D3)
.ad