2 .\" Copyright (c) 2006, Sun Microsystems, Inc.
3 .\" 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.
4 .\" 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.
5 .\" 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]
6 .TH DDI_BTOP 9F "Jan 16, 2006"
8 ddi_btop, ddi_btopr, ddi_ptob \- page size conversions
13 #include <sys/sunddi.h>
17 \fBunsigned long\fR \fBddi_btop\fR(\fBdev_info_t\fR \fI*dip\fR, \fBunsigned long\fR \fIbytes\fR);
22 \fBunsigned long\fR \fBddi_btopr\fR(\fBdev_info_t\fR \fI*dip\fR, \fBunsigned long\fR \fIbytes\fR);
27 \fBunsigned long\fR \fBddi_ptob\fR(\fBdev_info_t\fR \fI*dip\fR, \fBunsigned long\fR \fIpages\fR);
33 Solaris DDI specific (Solaris DDI).
37 This set of routines use the parent nexus driver to perform conversions in page
41 The \fBddi_btop()\fR function converts the given number of bytes to the number
42 of memory pages that it corresponds to, rounding down in the case that the byte
43 count is not a page multiple.
46 The \fBddi_btopr()\fR function converts the given number of bytes to the number
47 of memory pages that it corresponds to, rounding up in the case that the byte
48 count is not a page multiple.
51 The \fBddi_ptob()\fR function converts the given number of pages to the number
52 of bytes that it corresponds to.
55 Because bus nexus may possess their own hardware address translation
56 facilities, these routines should be used in preference to the corresponding
57 DDI/DKI routines \fBbtop\fR(9F), \fBbtopr\fR(9F), and \fBptob\fR(9F), which
58 only deal in terms of the pagesize of the main system MMU.
62 The \fBddi_btop()\fR and \fBddi_btopr()\fR functions return the number of
63 corresponding pages. \fBddi_ptob()\fR returns the corresponding number of
64 bytes. There are no error return values.
68 This function can be called from user, interrupt, or kernel context.
71 \fBExample 1 \fRFind the size (in bytes) of one page
75 pagesize = ddi_ptob(dip, 1L);
82 \fBbtop\fR(9F), \fBbtopr\fR(9F), \fBptob\fR(9F)
85 \fIWriting Device Drivers\fR