Merge commit '9276b3991ba20d5a5660887ba81b0bc7bed25a0c'
[unleashed.git] / share / man / man9f / ddi_btop.9f
blob072f261cc6e10441b7ea9f2a488d5e1486d33c06
1 '\" te
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"
7 .SH NAME
8 ddi_btop, ddi_btopr, ddi_ptob \- page size conversions
9 .SH SYNOPSIS
10 .LP
11 .nf
12 #include <sys/ddi.h>
13 #include <sys/sunddi.h>
17 \fBunsigned long\fR \fBddi_btop\fR(\fBdev_info_t\fR \fI*dip\fR, \fBunsigned long\fR \fIbytes\fR);
18 .fi
20 .LP
21 .nf
22 \fBunsigned long\fR \fBddi_btopr\fR(\fBdev_info_t\fR \fI*dip\fR, \fBunsigned long\fR \fIbytes\fR);
23 .fi
25 .LP
26 .nf
27 \fBunsigned long\fR \fBddi_ptob\fR(\fBdev_info_t\fR \fI*dip\fR, \fBunsigned long\fR \fIpages\fR);
28 .fi
30 .SH INTERFACE LEVEL
31 .sp
32 .LP
33 Solaris DDI specific (Solaris DDI).
34 .SH DESCRIPTION
35 .sp
36 .LP
37 This set of routines use the parent nexus driver to perform conversions in page
38 size units.
39 .sp
40 .LP
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.
44 .sp
45 .LP
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.
49 .sp
50 .LP
51 The \fBddi_ptob()\fR function converts the given number of pages to the number
52 of bytes that it corresponds to.
53 .sp
54 .LP
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.
59 .SH RETURN VALUES
60 .sp
61 .LP
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.
65 .SH CONTEXT
66 .sp
67 .LP
68 This function can be called from user, interrupt, or kernel context.
69 .SH EXAMPLES
70 .LP
71 \fBExample 1 \fRFind the size (in bytes) of one page
72 .sp
73 .in +2
74 .nf
75 pagesize = ddi_ptob(dip, 1L);
76 .fi
77 .in -2
79 .SH SEE ALSO
80 .sp
81 .LP
82 \fBbtop\fR(9F), \fBbtopr\fR(9F), \fBptob\fR(9F)
83 .sp
84 .LP
85 \fIWriting Device Drivers\fR