Move everything from /var/adm to /var/log
[unleashed.git] / share / man / man9f / bcopy.9f
blobb73276c8c138e8f2f2c923c7250bd4973f10cf20
1 '\" te
2 .\"  Copyright 1989 AT&T
3 .\"  Copyright (c) 2006, Sun Microsystems, Inc.  All Rights Reserved
4 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
5 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
6 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
7 .TH BCOPY 9F "Jan 16, 2006"
8 .SH NAME
9 bcopy \- copy data between address locations in the kernel
10 .SH SYNOPSIS
11 .LP
12 .nf
13 #include <sys/types.h>
14 #include <sys/sunddi.h>
19 \fBvoid\fR \fBbcopy\fR(\fBconst void *\fR\fIfrom\fR, \fBvoid *\fR\fIto\fR, \fBsize_t\fR \fIbcount\fR);
20 .fi
22 .SH INTERFACE LEVEL
23 .sp
24 .LP
25 Architecture independent level 1 (DDI/DKI).
26 .SH PARAMETERS
27 .sp
28 .ne 2
29 .na
30 \fB\fIfrom\fR\fR
31 .ad
32 .RS 10n
33 Source address from which the copy is made.
34 .RE
36 .sp
37 .ne 2
38 .na
39 \fB\fIto\fR\fR
40 .ad
41 .RS 10n
42 Destination address to which copy is made.
43 .RE
45 .sp
46 .ne 2
47 .na
48 \fB\fIbcount\fR\fR
49 .ad
50 .RS 10n
51 The number of bytes moved.
52 .RE
54 .SH DESCRIPTION
55 .sp
56 .LP
57 The \fBbcopy()\fR function copies \fIbcount\fR bytes from one kernel address to
58 another. If the input and output addresses overlap, the command executes, but
59 the results may not be as expected.
60 .sp
61 .LP
62 Note that \fBbcopy()\fR should never be used to move data in or out of a user
63 buffer, because it has no provision for handling page faults. The user address
64 space can be swapped out at any time, and \fBbcopy()\fR always assumes that
65 there will be no paging faults. If \fBbcopy()\fR attempts to access the user
66 buffer when it is swapped out, the system will panic. It is safe to use
67 \fBbcopy()\fR to move data within kernel space, since kernel space is never
68 swapped out.
69 .SH CONTEXT
70 .sp
71 .LP
72 The \fBbcopy()\fR function can be called from user, interrupt, or kernel
73 context.
74 .SH EXAMPLES
75 .LP
76 \fBExample 1 \fRCopying data between address locations in the kernel:
77 .sp
78 .LP
79 An \fBI/O\fR request is made for data stored in a \fBRAM\fR disk. If the \fBI/O
80 \fRoperation is a read request, the data is copied from the \fBRAM\fR disk to a
81 buffer (line 8).  If it is a write request, the data is copied from a buffer to
82 the \fBRAM\fR disk (line 15). \fBbcopy()\fR is used since both the \fBRAM\fR
83 disk and the buffer are part of the kernel address space.
85 .sp
86 .in +2
87 .nf
88  1 #define RAMDNBLK 1000                /* blocks in the RAM disk */
89  2 #define RAMDBSIZ 512                 /* bytes per block */
90  3 char ramdblks[RAMDNBLK][RAMDBSIZ];   /* blocks forming RAM
91                                         /* disk
92         ...
93  4
94  5 if   (bp->b_flags & B_READ)      /* if read request, copy data */
95  6                                  /* from RAM disk data block */
96  7                                  /* to system buffer */
97  8           bcopy(&ramdblks[bp->b_blkno][0], bp->b_un.b_addr,
98  9               bp->b_bcount);
100 11 else                             /* else write request, */
101 12                                  /* copy data from a */
102 13                                  /* system buffer to RAM disk */
103 14                                  /* data block */
104 15           bcopy(bp->b_un.b_addr, &ramdblks[bp->b_blkno][0],
105 16               bp->b_bcount);
107 .in -2
109 .SH SEE ALSO
112 \fBcopyin\fR(9F), \fBcopyout\fR(9F)
115 \fIWriting Device Drivers\fR
116 .SH WARNINGS
119 The \fIfrom\fR and \fIto\fR addresses must be within the kernel space. No range
120 checking is done. If an address outside of the kernel space is selected, the
121 driver may corrupt the system in an unpredictable way.