'\"macro stdmacro
.if n .pH ddi_dki.vtop @(#)vtop	40.7 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} vtop D3D "3B2" "DDI" "\&"
.if \nX=1 .ds x} vtop D3D "3B2" "DDI"
.if \nX=2 .ds x} vtop D3D "" "\&"
.if \nX=3 .ds x} vtop "" "" "\&"
.TH \*(x}
.IX "\f4vtop\fP(D3D)"
.SH NAME
\f4vtop\f1 \- convert virtual to physical address
.SH SYNOPSIS
.nf
.na
\f4#include <sys/types.h>
.sp 0.5
paddr_t vtop(\f4long\f1 \f2vaddr, \f4proc_t *\f1\f2p\f4);\f1
.ad
.fi
.SH ARGUMENTS
.RS 0n 10
.IP "\f2vaddr\f1" 10n
Virtual address to convert.
.IP "\f2p\f1" 10n
Pointer to the \f4proc\f1(D4X) structure used by \f4vtop\f1 to
locate the information tables used for memory management.  To indicate
that the address is in kernel virtual space or in the virtual space of
the current process, set \f2p\f1 to \f4NULL\f1.  Block drivers that
can transfer data directly in and out of user memory space must set
\f2p\f1 to the \f4b_proc\f1 member of the \f4buf\f1(D4DK) structure.
.RE
.SH DESCRIPTION
\f4vtop\f1 converts a virtual address to a physical address.  When a
driver receives a memory address from the kernel, that address is
virtual.  Generally, memory management is performed by the \s-1MMU\s0.
However, devices that access memory directly (\s-1DMA\s0) deal only with
physical memory addresses.  In such cases, the driver must provide the
device with physical memory addresses.
.P
The virtual address is the memory address being translated.
The \f4vtop\f1 function returns the translated address.
.P
The same functionality is provided by the \f4kvtophys\f1(D3D)
function.
.SH RETURN VALUE
Under normal conditions, a physical address is returned.  Otherwise, the
following can be returned:
.RS
.TP 4
\f4-1\f1
if the virtual address to be translated is not a valid one
.TP
\f4 0\f1
if there is no physical memory mapped to the virtual address
.RE
.SH LEVEL
Base or Interrupt.
.SH SEE ALSO
\f2BCI Driver Development Guide\f1, Chapter 6, ``Input/Output Operations''
.P
.na
\f4btop\f1(D3DK),
\f4btopr\f1(D3DK),
\f4ptob\f1(D3DK),
\f4kvtophys\f1(D3D)
.ad
