Merge commit '9276b3991ba20d5a5660887ba81b0bc7bed25a0c'
[unleashed.git] / share / man / man9f / pci_save_config_regs.9f
blob49d2d2ff9c77c986e6be3fcd63ab617d43ea1795
1 '\" te
2 .\" Copyright (c) 2002, 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 PCI_SAVE_CONFIG_REGS 9F "Jun 02, 2000"
7 .SH NAME
8 pci_save_config_regs, pci_restore_config_regs \- save and restore the PCI
9 configuration registers
10 .SH SYNOPSIS
11 .LP
12 .nf
13 \fB#include <sys/ddi.h>\fR
14 \fB#include <sys/sunddi.h>\fR
18 \fBint\fR \fBpci_save_config_regs\fR(\fBdev_info_t *\fR\fIdip\fR);
19 .fi
21 .LP
22 .nf
23 \fBint\fR \fBpci_restore_config_regs\fR(\fBdev_info_t *\fR\fIdip\fR);
24 .fi
26 .SH INTERFACE LEVEL
27 .sp
28 .LP
29 Solaris DDI-specific (Solaris DDI).
30 .SH ARGUMENTS
31 .sp
32 .ne 2
33 .na
34 \fB\fIdip\fR\fR
35 .ad
36 .RS 7n
37 Pointer to the device's \fBdev_info\fR structure.
38 .RE
40 .SH DESCRIPTION
41 .sp
42 .LP
43 \fBpci_save_config_regs()\fR saves the current configuration registers on
44 persistent system memory. \fBpci_restore_config_regs()\fR restores
45 configuration registers previously saved by \fBpci_save_config_regs()\fR.
46 .sp
47 .LP
48 \fBpci_save_config_regs()\fR should be called by the driver's \fBpower()\fR
49 entry point before powering a device off (to PCI state D3). Likewise,
50 \fBpci_restore_config_regs()\fR should be called after powering a device on
51 (from PCI state D3), but before accessing the device. See \fBpower\fR(9E).
52 .SH RETURN VALUES
53 .sp
54 .LP
55 \fBpci_save_config_regs()\fR and \fBpci_restore_config_regs()\fR return:
56 .sp
57 .ne 2
58 .na
59 \fB\fBDDI_SUCCESS\fR\fR
60 .ad
61 .RS 15n
62 Operation completed successfully.
63 .RE
65 .sp
66 .ne 2
67 .na
68 \fB\fBDDI_FAILURE\fR\fR
69 .ad
70 .RS 15n
71 Operation failed to complete successfully.
72 .RE
74 .SH CONTEXT
75 .sp
76 .LP
77 Both these functions can be called from user or kernel context.
78 .SH EXAMPLES
79 .LP
80 \fBExample 1 \fRInvoking the save and restore functions
81 .sp
82 .in +2
83 .nf
84 static int
85 xx_power(dev_info_t *dip, int component, int level) {
86    struct xx *xx;
87    int rval = DDI_SUCCESS;
89    xx = ddi_get_soft_state(xx_softstate, ddi_get_instance(dip));
90    if (xx == NULL) {
91        return (DDI_FAILURE);
92    }
94    mutex_enter(&xx\(mi>x_mutex);
96    switch (level) {
97    case PM_LEVEL_D0:
98        XX_POWER_ON(xx);
99        if (pci_restore_config_regs(dip) == DDI_FAILURE) {
100            /*
101             * appropriate error path handling here
102             */
103            ...
104            rval = DDI_FAILURE;
105            }
106        break;
108    case PM_LEVEL_D3:
109        if (pci_save_config_regs(dip) == DDI_FAILURE) {
110             /*
111              * appropriate error path handling here
112              */
113             ...
114             rval = DDI_FAILURE;
115             }
116         else {
117             XX_POWER_OFF(xx);
118         }
119         break;
121     default:
122           rval = DDI_FAILURE;
123           break;
124     }
126     mutex_exit(&xx\(mi>x_mutex);
127     return (rval);
130 .in -2
132 .SH ATTRIBUTES
135 See \fBattributes\fR(5) for descriptions of the following attributes:
140 box;
141 c | c
142 l | l .
143 ATTRIBUTE TYPE  ATTRIBUTE VALUE
145 Interface Stability     Committed
148 .SH SEE ALSO
151 \fBattributes\fR(5), \fBpower\fR(9E)
154 \fIWriting Device Drivers\fR
157 \fIPCI Bus Power Management Interface Specification Version 1.1\fR
160 \fIPCI Bus Specification Revision 2.1\fR