2 .\" Copyright (c) 2006, Sun Microsystems, Inc. All Rights Reserved
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_PEEK 9F "Jan 16, 2006"
8 ddi_peek, ddi_peek8, ddi_peek16, ddi_peek32, ddi_peek64, ddi_peekc, ddi_peeks,
9 ddi_peekl, ddi_peekd \- read a value from a location
14 #include <sys/sunddi.h>
18 \fBint\fR \fBddi_peek8\fR(\fBdev_info_t\fR \fI*dip\fR, \fBint8_t\fR \fI*addr\fR, \fBint8_t\fR \fI*valuep\fR);
23 \fBint\fR \fBddi_peek16\fR(\fBdev_info_t\fR \fI*dip\fR, \fBint16_t\fR \fI*addr\fR, \fBint16_t\fR \fI*valuep\fR);
28 \fBint\fR \fBddi_peek32\fR(\fBdev_info_t\fR \fI*dip\fR, \fBint32_t\fR \fI*addr\fR, \fBint32_t\fR \fI*valuep\fR);
33 \fBint\fR \fBddi_peek64\fR(\fBdev_info_t\fR \fI*dip\fR, \fBint64_t\fR \fI*addr\fR, \fBint64_t\fR \fI*valuep\fR);
39 Solaris DDI specific (Solaris DDI). The \fBddi_peekc()\fR, \fBddi_peeks()\fR,
40 \fBddi_peekl()\fR, and \fBddi_peekd()\fR functions are obsolete. Use,
41 respectively, \fBddi_peek8()\fR, \fBddi_peek16()\fR, \fBddi_peek32()\fR, and
42 \fBddi_peek64()\fR, instead.
50 A pointer to the device's \fBdev_info\fR structure.
59 Virtual address of the location to be examined.
68 Pointer to a location to hold the result. If a null pointer is specified, then
69 the value read from the location will simply be discarded.
75 These routines cautiously attempt to read a value from a specified virtual
76 address, and return the value to the caller, using the parent nexus driver to
77 assist in the process where necessary.
80 If the address is not valid, or the value cannot be read without an error
81 occurring, an error code is returned.
84 The routines are most useful when first trying to establish the presence of a
85 device on the system in a driver's \fBprobe\fR(9E) or \fBattach\fR(9E)
91 \fB\fBDDI_SUCCESS\fR\fR
94 The value at the given virtual address was successfully read, and if
95 \fIvaluep\fR is non-null, \fI*valuep\fR will have been updated.
101 \fB\fBDDI_FAILURE\fR\fR
104 An error occurred while trying to read the location. \fI*valuep\fR is
111 These functions can be called from user, interrupt, or kernel context.
114 \fBExample 1 \fRChecking to see that the status register of a device is mapped
115 into the kernel address space:
119 if (ddi_peek8(dip, csr, (int8_t *)0) != DDI_SUCCESS) {
120 cmn_err(CE_WARN, "Status register not mapped");
121 return (DDI_FAILURE);
127 \fBExample 2 \fRReading and logging the device type of a particular device:
132 xx_attach(dev_info_t *dip, ddi_attach_cmd_t cmd)
135 /* map device registers */
138 if (ddi_peek32(dip, id_addr, &id_value) != DDI_SUCCESS) {
139 cmn_err(CE_WARN, "%s%d: cannot read device identifier",
140 ddi_get_name(dip), ddi_get_instance(dip));
143 cmn_err(CE_CONT, "!%s%d: device type 0x%x\en",
144 ddi_get_name(dip), ddi_get_instance(dip), id_value);
149 return (DDI_SUCCESS);
152 /* free any resources allocated */
154 return (DDI_FAILURE);
162 \fBattach\fR(9E), \fBprobe\fR(9E), \fBddi_poke\fR(9F)
165 \fIWriting Device Drivers\fR
169 The functions described in this manual page previously used symbolic names
170 which specified their data access size; the function names have been changed so
171 they now specify a fixed-width data size. See the following table for the new
180 \fBPrevious Name\fR \fBNew Name\fR
181 \fBddi_peekc\fR \fBddi_peek8\fR
182 \fBddi_peeks\fR \fBddi_peek16\fR
183 \fBddi_peekl\fR \fBddi_peek32\fR
184 \fBddi_peekd\fR \fBddi_peek64\fR