1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
|
'\" te
.\" Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved.
.\" 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.
.\" 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.
.\" 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]
.TH DDI_FM_HANDLER_REGISTER 9F "May 14, 2007"
.SH NAME
ddi_fm_handler_register, ddi_fm_handler_unregister \- register or unregister an
error handling callback
.SH SYNOPSIS
.LP
.nf
#include <sys/ddifm.h>
\fBvoid\fR \fBddi_fm_handler_register\fR(\fBdev_info_t\fR *\fIdip\fR,
\fBddi_err_func_t\fR \fIerror_handler\fR, \fBvoid\fR *\fIimpl_data\fR);
.fi
.LP
.nf
\fBvoid\fR \fBddi_fm_handler_unregister\fR(\fBdev_info_t\fR *\fIdip\fR);
.fi
.SH INTERFACE LEVEL
.sp
.LP
Solaris DDI specific (Solaris DDI)
.SH PARAMETERS
.sp
.ne 2
.na
\fB\fIdip\fR\fR
.ad
.RS 17n
Pointer to the \fBdev_info\fR structure
.RE
.sp
.ne 2
.na
\fB\fIerror_handler\fR\fR
.ad
.RS 17n
Pointer to an error handler callback function
.RE
.sp
.ne 2
.na
\fB\fIimpl_data\fR\fR
.ad
.RS 17n
Pointer to private data for use by the caller
.RE
.SH DESCRIPTION
.sp
.LP
The \fBddi_fm_handler_register()\fR function registers an error handler
callback routine with the \fBI/O\fR Fault Management framework. The error
handler callback, \fIerror_handler\fR, is called to process error conditions
detected by the system. In addition to its device instance, \fIdip\fR, the
error handler is called with a pointer to a fault management error status
structure, \fBddi_fm_error_t\fR. For example:
.sp
.in +2
.nf
int (*ddi_err_func_t)(dev_info_t *dip, ddi_fm_error_t *error_status);
.fi
.in -2
.sp
.LP
A driver error handling callback is passed the following arguments:
.RS +4
.TP
.ie t \(bu
.el o
a pointer to the device instance registered for this callback.
.RE
.RS +4
.TP
.ie t \(bu
.el o
a data structure containing common fault management data and status for error
handling.
.RE
.sp
.LP
The primary responsibilities of the error handler include:
.RS +4
.TP
.ie t \(bu
.el o
to check for outstanding hardware or software errors.
.RE
.RS +4
.TP
.ie t \(bu
.el o
where possible, to isolate the device that might have caused the errors.
.RE
.RS +4
.TP
.ie t \(bu
.el o
to report errors that were detected.
.RE
.sp
.LP
During the invocation of an error handler, a device driver might need to
quiesce or suspend all \fBI/O\fR activities in order to check for error
conditions or status in:
.RS +4
.TP
.ie t \(bu
.el o
hardware control and status registers.
.RE
.RS +4
.TP
.ie t \(bu
.el o
outstanding \fBI/O\fR transactions.
.RE
.RS +4
.TP
.ie t \(bu
.el o
access or \fBDMA\fR handles.
.RE
.sp
.LP
For each error detected, the driver must formulate and post an error report via
\fBddi_fm_ereport_post()\fR for problem analysis by the Solaris Fault Manager
\fBfmd\fR(1M).
.sp
.LP
For a \fBPCI\fR, \fBPCI/X\fR, or \fBPCI Express\fR leaf device, the
\fBpci_ereport_post()\fR function is provided to carry out reporting
responsibilities on behalf of the driver. In many cases, an error handler
callback function of the following form can be used:
.sp
.in +2
.nf
xxx_err_cb(dev_info_t *dip, ddi_fm_error_t *errp) {
pci_ereport_post(dip, errp, NULL);
return (errp->fme_status);
}
.fi
.in -2
.sp
.LP
In addition, the driver might be able to carry out further device specific
checks within the error handler.
.sp
.LP
Error handlers can be called from kernel, interrupt, or high-level interrupt
context. The interrupt block cookie returned from \fBddi_fm_init()\fR should be
used to allocate and initialize any synchronization variables and locks that
might be used within the error handler callback function. Such locks may not be
held by the driver when a device register is accessed with functions such as
\fBddi_get8\fR(9F) and \fBddi_put8\fR(9F).
.sp
.LP
The data structure, \fBddi_fm_error_t\fR, contains an \fBFMA\fR protocol
(format 1) \fBENA\fR for the current error propagation chain, the status of the
error handler callback, an error expectation flag, and any potential access or
\fBDMA\fR handles associated with an error detected by the parent nexus.
.sp
.LP
The \fBddi_fm_handler_unregister()\fR function removes a previously registered
error handling callback for the device instance specified by the \fIdip\fR.
.SH CONTEXT
.sp
.LP
The \fBddi_fm_handler_register()\fR and \fBddi_fm_handler_unregister()\fR
functions must be called from kernel context in an \fBattach\fR(9E) or
\fBdetach\fR(9E) entry point. The registered error handler,
\fIerror_handler\fR, callback can be called from kernel, interrupt, or high
level interrupt context.
.SH ATTRIBUTES
.sp
.LP
See \fBattributes\fR(5) for descriptions of the following attributes:
.sp
.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE ATTRIBUTE VALUE
_
Interface Stability Committed
.TE
.SH SEE ALSO
.sp
.LP
\fBfmd\fR(1M), \fBattributes\fR(5), \fBattach\fR(9E), \fBdetach\fR(9E),
\fBddi_fm_ereport_post\fR(9F), \fBddi_fm_init\fR(9F), \fBddi_get8\fR(9F),
\fBddi_put8\fR(9F), \fBpci_ereport_post\fR(9F), \fBddi_fm_error\fR(9S)
.sp
.LP
\fIWriting Device Drivers\fR
|