Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ bcopy(D3DK) — Motorola System V 88k Release 4 Version 4.3

Media Vault

Software Library

Restoration Projects

Artifacts Sought

bcopy(D3DK)  —  

.IX \f4bcopy\fP(D3DK)
.IX kernel, data copy in

NAME

bcopy − copy data between address locations in the kernel

SYNOPSIS

#include <sys/types.h>
void bcopy(caddr_t from, caddr_t to, size_t bcount);

ARGUMENTS

fromSource address from which the copy is made. 

toDestination address to which the copy is made. 

bcountNumber of bytes to be copied. 

DESCRIPTION

bcopy copies bcount bytes from one kernel address to another.  It chooses the best algorithm based on address alignment and number of bytes to copy.  If the input and output addresses overlap, the function executes, but the results are undefined. 

RETURN VALUE

None. 

LEVEL

Base or Interrupt. 

NOTES

Does not sleep. 

Driver-defined basic locks, read/write locks, and sleep locks may be held across calls to this function. 

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 bcopy.  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, copyin(D3DK), copyout(D3DK), uiomove(D3DK), ureadc(D3DK), or uwritec(D3DK)). 

SEE ALSO

copyin(D3DK), copyout(D3DK), uiomove(D3DK), ureadc(D3DK), uwritec(D3DK)

EXAMPLE

.IX \f4buf\fP(D4DK), 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 bcopy function is used since both the RAM disk and the buffer are part of the kernel address space. 

 1  #define RAMDNBLK    1000           /∗ number of blocks in the 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  }

DDI/DKI

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