2 .\" Copyright (c) 2007, 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_FM_HANDLER_REGISTER 9F "May 14, 2007"
8 ddi_fm_handler_register, ddi_fm_handler_unregister \- register or unregister an
9 error handling callback
13 #include <sys/ddifm.h>
15 \fBvoid\fR \fBddi_fm_handler_register\fR(\fBdev_info_t\fR *\fIdip\fR,
16 \fBddi_err_func_t\fR \fIerror_handler\fR, \fBvoid\fR *\fIimpl_data\fR);
21 \fBvoid\fR \fBddi_fm_handler_unregister\fR(\fBdev_info_t\fR *\fIdip\fR);
27 Solaris DDI specific (Solaris DDI)
35 Pointer to the \fBdev_info\fR structure
41 \fB\fIerror_handler\fR\fR
44 Pointer to an error handler callback function
53 Pointer to private data for use by the caller
59 The \fBddi_fm_handler_register()\fR function registers an error handler
60 callback routine with the \fBI/O\fR Fault Management framework. The error
61 handler callback, \fIerror_handler\fR, is called to process error conditions
62 detected by the system. In addition to its device instance, \fIdip\fR, the
63 error handler is called with a pointer to a fault management error status
64 structure, \fBddi_fm_error_t\fR. For example:
68 int (*ddi_err_func_t)(dev_info_t *dip, ddi_fm_error_t *error_status);
74 A driver error handling callback is passed the following arguments:
79 a pointer to the device instance registered for this callback.
85 a data structure containing common fault management data and status for error
90 The primary responsibilities of the error handler include:
95 to check for outstanding hardware or software errors.
101 where possible, to isolate the device that might have caused the errors.
107 to report errors that were detected.
111 During the invocation of an error handler, a device driver might need to
112 quiesce or suspend all \fBI/O\fR activities in order to check for error
113 conditions or status in:
118 hardware control and status registers.
124 outstanding \fBI/O\fR transactions.
130 access or \fBDMA\fR handles.
134 For each error detected, the driver must formulate and post an error report via
135 \fBddi_fm_ereport_post()\fR for problem analysis by the Solaris Fault Manager
139 For a \fBPCI\fR, \fBPCI/X\fR, or \fBPCI Express\fR leaf device, the
140 \fBpci_ereport_post()\fR function is provided to carry out reporting
141 responsibilities on behalf of the driver. In many cases, an error handler
142 callback function of the following form can be used:
146 xxx_err_cb(dev_info_t *dip, ddi_fm_error_t *errp) {
147 pci_ereport_post(dip, errp, NULL);
148 return (errp->fme_status);
155 In addition, the driver might be able to carry out further device specific
156 checks within the error handler.
159 Error handlers can be called from kernel, interrupt, or high-level interrupt
160 context. The interrupt block cookie returned from \fBddi_fm_init()\fR should be
161 used to allocate and initialize any synchronization variables and locks that
162 might be used within the error handler callback function. Such locks may not be
163 held by the driver when a device register is accessed with functions such as
164 \fBddi_get8\fR(9F) and \fBddi_put8\fR(9F).
167 The data structure, \fBddi_fm_error_t\fR, contains an \fBFMA\fR protocol
168 (format 1) \fBENA\fR for the current error propagation chain, the status of the
169 error handler callback, an error expectation flag, and any potential access or
170 \fBDMA\fR handles associated with an error detected by the parent nexus.
173 The \fBddi_fm_handler_unregister()\fR function removes a previously registered
174 error handling callback for the device instance specified by the \fIdip\fR.
178 The \fBddi_fm_handler_register()\fR and \fBddi_fm_handler_unregister()\fR
179 functions must be called from kernel context in an \fBattach\fR(9E) or
180 \fBdetach\fR(9E) entry point. The registered error handler,
181 \fIerror_handler\fR, callback can be called from kernel, interrupt, or high
182 level interrupt context.
186 See \fBattributes\fR(5) for descriptions of the following attributes:
194 ATTRIBUTE TYPE ATTRIBUTE VALUE
196 Interface Stability Committed
202 \fBfmd\fR(8), \fBattributes\fR(5), \fBattach\fR(9E), \fBdetach\fR(9E),
203 \fBddi_fm_ereport_post\fR(9F), \fBddi_fm_init\fR(9F), \fBddi_get8\fR(9F),
204 \fBddi_put8\fR(9F), \fBpci_ereport_post\fR(9F), \fBddi_fm_error\fR(9S)
207 \fIWriting Device Drivers\fR