'\" te
.\" Copyright (c) 2006, Sun Microsystems, Inc.
.\" 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.
.\" 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.
.\" 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]
.TH DDI_BTOP 9F "Jan 16, 2006"
.SH NAME
ddi_btop, ddi_btopr, ddi_ptob \- page size conversions
.SH SYNOPSIS
.LP
.nf
#include <sys/ddi.h>
#include <sys/sunddi.h>



\fBunsigned long\fR \fBddi_btop\fR(\fBdev_info_t\fR \fI*dip\fR, \fBunsigned long\fR \fIbytes\fR);
.fi

.LP
.nf
\fBunsigned long\fR \fBddi_btopr\fR(\fBdev_info_t\fR \fI*dip\fR, \fBunsigned long\fR \fIbytes\fR);
.fi

.LP
.nf
\fBunsigned long\fR \fBddi_ptob\fR(\fBdev_info_t\fR \fI*dip\fR, \fBunsigned long\fR \fIpages\fR);
.fi

.SH INTERFACE LEVEL
.sp
.LP
Solaris DDI specific (Solaris DDI).
.SH DESCRIPTION
.sp
.LP
This set of routines use the parent nexus driver to perform conversions in page
size units.
.sp
.LP
The \fBddi_btop()\fR function converts the given number of bytes to the number
of memory pages that it corresponds to, rounding down in the case that the byte
count is not a page multiple.
.sp
.LP
The \fBddi_btopr()\fR function converts the given number of bytes to the number
of memory pages that it corresponds to, rounding up in the case that the byte
count is not a page multiple.
.sp
.LP
The \fBddi_ptob()\fR function converts the given number of pages to the number
of bytes that it corresponds to.
.sp
.LP
Because bus nexus may possess their own hardware address translation
facilities, these routines should be used in preference to the corresponding
DDI/DKI routines \fBbtop\fR(9F), \fBbtopr\fR(9F), and \fBptob\fR(9F), which
only deal in terms of the pagesize of the main system MMU.
.SH RETURN VALUES
.sp
.LP
The \fBddi_btop()\fR and \fBddi_btopr()\fR functions return the number of
corresponding pages. \fBddi_ptob()\fR returns the corresponding number of
bytes. There are no error return values.
.SH CONTEXT
.sp
.LP
This function can be called from user, interrupt, or kernel context.
.SH EXAMPLES
.LP
\fBExample 1 \fRFind the size (in bytes) of one page
.sp
.in +2
.nf
pagesize = ddi_ptob(dip, 1L);
.fi
.in -2

.SH SEE ALSO
.sp
.LP
\fBbtop\fR(9F), \fBbtopr\fR(9F), \fBptob\fR(9F)
.sp
.LP
\fIWriting Device Drivers\fR