vtop -- convert virtual address to physical address

Synopsis (Not in current DDI version)

   #include <sys/types.h>
   #include <sys/proc.h>
   #include <sys/ddi.h>

paddr_t vtop(caddr_t vaddr, proc_t *p);


vtop( ) converts a virtual address to a physical address.


Virtual address to convert. The only addresses that are safe to pass to vtop( ) are those provided to drivers from the kernel through driver entry points, DDI callable functions, DDI kernel data structures, or statically-allocated global driver variables.

Pointer to the process structure used by To indicate that the address is in kernel virtual space, p must be set to NULL. Block drivers that can transfer data directly in and out of user memory space must set p to the b_proc member of the buf(D4) structure. A pointer to the currently running process can be obtained by calling drv_getparm(D3) with the UPROCP parameter. vtop( ) to locate the information tables used for memory management.

Return values

On success, vtop( ) returns the physical address. Otherwise, if no physical memory is mapped to the virtual address, vtop( ) returns 0.


When a driver receives a memory address from the kernel, that address is virtual. Generally, memory management is performed by the MMU. However, devices that access memory directly using physical DMA deal only with physical memory addresses. In such cases, the driver must provide the device with physical memory addresses.

Drivers should verify the physical properties of the memory by calling functions such as msgpullup_physreq(D3str) before calling vtop( ).

Context and synchronization

All contexts.


If vaddr specifies an invalid kernel address, a system panic will occur.

Hardware applicability


Version applicability

ddi: 1, 2, 3, 4, 5, 5mp, 6, 6mp, 7, 7mp, 7.1, 7.1mp

Differences between versions

vtop( ) is not supported in DDI 8 because paddr is not visible to drivers. See ``Large memory support (DDI 8)'' in HDK Technical Reference. See ``Scatter/gather operations'' in HDK Technical Reference for details about methods for setting up scatter/gather operations for DDI 8 drivers.

The requirement to verify the physical properties of the memory before calling vtop( ) apply only to DDI 6 and 7, and the current implementation does not enforce this requirement. However, drivers that do not verify the physical properties may fail when being ported to future releases.

SCO OpenServer ODDI compatibility

The SCO OpenServer vtop(D3oddi) function is identical to the DDI version in syntax and return values. See ``Scatter/gather operations'' in HDK Technical Reference for information about setting up scatter/gather lists for SCO OpenServer ODDI drivers.


btop(D3), btopr(D3), buf(D4), drv_getparm(D3), kmem_alloc_phys(D3), msgscgth(D3str), msgpullup_physreq(D3str), ptob(D3)

``Scatter/gather operations'' in HDK Technical Reference

19 June 2005
© 2005 The SCO Group, Inc. All rights reserved.
OpenServer 6 and UnixWare (SVR5) HDK - June 2005