niocopy(D3DKX) —
.IX \f4niocopy\fP(D3DKX)
NAME
niocopy − copy memory, intercepting bus errors
SYNOPSIS
#include <sys/types.h>
#include <sys/iosystm.h>
int niocopy(u_int access, void ∗saddr, void ∗daddr, size_t size);
ARGUMENTS
accessThe type of memory access to use.
saddrThe address of the buffer to copy from.
daddrThe address of the buffer to copy to.
sizeThe size of the buffers, in bytes.
DESCRIPTION
niocopy is used in driver initialization routines to initialize device memory and check if the memory exists.
Memory is accessed in various different ways, depending on the value of access. The following constants (defined in sys/iosystm.h) are used to define the access type:
| Size flags: | ||
| IOP_BYTE | 0x02 | |
| IOP_SHORT | 0x04 | |
| IOP_LONG | 0x06 | |
| Mapping flags: | ||
| IOP_VIRTUAL | 0x08 | |
| IOP_PHYSICAL | 0x10 | |
| IOP_DVIRTUAL | 0x20 | |
| IOP_DPHYSICAL | 0x40 | |
niocopy is called with an access value that is a combination (bit-wise “or”) of these constants. access must include exactly one of the size flags, whose meanings are as follows:
| IOP_BYTE | Copy bytes from saddr to daddr. |
| IOP_SHORT | Copy shorts from saddr to daddr. |
| IOP_LONG | Copy longs from saddr to daddr. |
access may also include one or more of the mapping flags, whose meanings are described below.
The saddr, daddr and size parameters must be suitable for the type of access requested. For example, if IOP_LONG is specified, then the parameters must be multiples of 4. It is up to the caller to ensure this alignment; the result otherwise is undefined.
niocopy by default reads and writes virtual addresses. However, if access includes the flag IOP_PHYSICAL, then saddr is taken as a physical address. If access includes the flag IOP_DPHYSICAL, then daddr is taken as a physical address. IOP_VIRTUAL and/or IOP_DVIRTUAL can also be “ored” with one of the constants to specify the default behavior of virtual accesses. If both IOP_VIRTUAL and IOP_PHYSICAL are specified, or both IOP_DVIRTUAL and IOP_DPHYSICAL are specified, the result is unspecified.
niocopy is not guaranteed to work when called from interrupt level if IOP_PHYSICAL or IOP_DPHYSICAL is specified.
If any address in the buffers specified by saddr and size or daddr and size is invalid or nonexistent, niocopy returns nonzero.
niocopy assumes that the input and output buffers do not overlap. If they overlap, correct results are not guaranteed.
RETURN VALUES
Zero if the operation succeeds. Nonzero if a specified physical address does not respond, or a specified virtual address is not mapped, or IOP_PHYSICAL or IOP_DPHYSICAL was specified from interrupt context. Nonzero may also be returned if access has an incorrect value or if alignment is not correct, but this is not guaranteed.
LEVEL
Base or Interrupt
SEE ALSO
niofillmem(D3DKX)
DDI/DKI