Print this page
8368 remove warlock leftovers from usr/src/uts
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/io/1394/nx1394.c
+++ new/usr/src/uts/common/io/1394/nx1394.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License, Version 1.0 only
6 6 * (the "License"). You may not use this file except in compliance
7 7 * with the License.
8 8 *
9 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 * or http://www.opensolaris.org/os/licensing.
11 11 * See the License for the specific language governing permissions
12 12 * and limitations under the License.
13 13 *
14 14 * When distributing Covered Code, include this CDDL HEADER in each
15 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 16 * If applicable, add the following below this CDDL HEADER, with the
17 17 * fields enclosed by brackets "[]" replaced with your own identifying
18 18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 19 *
20 20 * CDDL HEADER END
21 21 */
22 22 /*
23 23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24 24 * Use is subject to license terms.
25 25 */
26 26 /*
27 27 * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
28 28 */
29 29
30 30 /*
31 31 * nx1394.c
32 32 * 1394 Services Layer Nexus Support Routines
33 33 * Routines in this file implement nexus bus_ops.
34 34 */
35 35
36 36 #include <sys/conf.h>
37 37 #include <sys/ddi.h>
38 38 #include <sys/modctl.h>
39 39 #include <sys/sunddi.h>
40 40 #include <sys/cmn_err.h>
41 41 #include <sys/types.h>
42 42 #include <sys/ddi_impldefs.h>
43 43
44 44 #include <sys/tnf_probe.h>
45 45
46 46 #include <sys/1394/t1394.h>
47 47 #include <sys/1394/s1394.h>
48 48 #include <sys/1394/h1394.h>
49 49
50 50 static int nx1394_dma_allochdl(dev_info_t *dip, dev_info_t *rdip,
51 51 ddi_dma_attr_t *attr, int (*waitfnp)(caddr_t), caddr_t arg,
52 52 ddi_dma_handle_t *handlep);
53 53
54 54 static int nx1394_bus_ctl(dev_info_t *dip, dev_info_t *rdip, ddi_ctl_enum_t op,
55 55 void *arg, void *result);
56 56
57 57 static int nx1394_get_event_cookie(dev_info_t *dip, dev_info_t *rdip,
58 58 char *name, ddi_eventcookie_t *event_cookiep);
59 59
60 60 static int nx1394_add_eventcall(dev_info_t *dip, dev_info_t *rdip,
61 61 ddi_eventcookie_t eventhdl, void (*callback)(), void *arg,
62 62 ddi_callback_id_t *cb_id);
63 63
64 64 static int nx1394_remove_eventcall(dev_info_t *dip, ddi_callback_id_t cb_id);
65 65
66 66 static int nx1394_post_event(dev_info_t *dip, dev_info_t *rdip,
67 67 ddi_eventcookie_t eventhdl, void *impl_data);
68 68
69 69 struct bus_ops nx1394_busops = {
70 70 BUSO_REV,
71 71 nullbusmap, /* bus_map */
72 72 NULL, /* bus_get_intrspec */
73 73 NULL, /* bus_add_intrspec */
74 74 NULL, /* bus_remove_intrspec */
75 75 i_ddi_map_fault, /* XXXX bus_map_fault */
76 76 NULL, /* bus_dma_map */
77 77 nx1394_dma_allochdl,
78 78 ddi_dma_freehdl,
79 79 ddi_dma_bindhdl,
80 80 ddi_dma_unbindhdl,
81 81 ddi_dma_flush,
82 82 ddi_dma_win,
83 83 ddi_dma_mctl, /* bus_dma_ctl */
84 84 nx1394_bus_ctl, /* bus_ctl */
85 85 ddi_bus_prop_op, /* bus_prop_op */
86 86 nx1394_get_event_cookie, /* (*bus_get_eventcookie() */
87 87 nx1394_add_eventcall, /* (*bus_add_eventcall)(); */
88 88 nx1394_remove_eventcall, /* (*bus_remove_eventcall)(); */
89 89 nx1394_post_event, /* (*bus_post_event)(); */
90 90 0, /* (*interrupt control)(); */
91 91 0, /* (*bus_config)(); */
92 92 0, /* (*bus_unconfig)(); */
93 93 0, /* (*bus_fm_init)(); */
94 94 0, /* (*bus_fm_fini)(); */
95 95 0, /* (*bus_fm_access_enter)(); */
96 96 0, /* (*bus_fm_access_exit)(); */
97 97 0, /* (*bus_power)(); */
98 98 i_ddi_intr_ops /* (*bus_intr_op)(); */
99 99 };
100 100
101 101 /*
102 102 * removal/insertion/reset events
103 103 */
104 104 #define NX1394_EVENT_TAG_HOT_REMOVAL 0
105 105 #define NX1394_EVENT_TAG_HOT_INSERTION 1
106 106 #define NX1394_EVENT_TAG_BUS_RESET 2
107 107
108 108 static ndi_event_definition_t nx1394_event_defs[] = {
109 109 {NX1394_EVENT_TAG_HOT_REMOVAL, DDI_DEVI_REMOVE_EVENT, EPL_KERNEL,
110 110 NDI_EVENT_POST_TO_TGT},
111 111 {NX1394_EVENT_TAG_HOT_INSERTION, DDI_DEVI_INSERT_EVENT, EPL_KERNEL,
112 112 NDI_EVENT_POST_TO_TGT},
113 113 {NX1394_EVENT_TAG_BUS_RESET, DDI_DEVI_BUS_RESET_EVENT, EPL_KERNEL,
114 114 NDI_EVENT_POST_TO_ALL},
115 115 };
116 116
117 117 #define NX1394_N_EVENTS \
118 118 (sizeof (nx1394_event_defs) / sizeof (ndi_event_definition_t))
119 119
120 120 static ndi_event_set_t nx1394_events = {
121 121 NDI_EVENTS_REV1, NX1394_N_EVENTS, nx1394_event_defs
122 122 };
123 123
124 124 /*
125 125 * nx1394_bus_ctl()
126 126 * This routine implements nexus bus ctl operations. Of importance are
127 127 * DDI_CTLOPS_REPORTDEV, DDI_CTLOPS_INITCHILD, DDI_CTLOPS_UNINITCHILD
128 128 * and DDI_CTLOPS_POWER. For DDI_CTLOPS_INITCHILD, it tries to lookup
129 129 * reg property on the child node and builds and sets the name
130 130 * (name is of the form GGGGGGGGGGGGGGGG[,AAAAAAAAAAAA], where
131 131 * GGGGGGGGGGGGGGGG is the GUID and AAAAAAAAAAAA is the optional unit
132 132 * address).
133 133 */
134 134 static int
135 135 nx1394_bus_ctl(dev_info_t *dip, dev_info_t *rdip, ddi_ctl_enum_t op, void *arg,
136 136 void *result)
137 137 {
138 138 int status;
139 139
140 140 TNF_PROBE_0_DEBUG(nx1394_bus_ctl_enter, S1394_TNF_SL_NEXUS_STACK, "");
141 141
142 142 switch (op) {
143 143 case DDI_CTLOPS_REPORTDEV: {
144 144 dev_info_t *pdip = ddi_get_parent(rdip);
145 145 cmn_err(CE_CONT, "?%s%d at %s%d",
146 146 ddi_node_name(rdip), ddi_get_instance(rdip),
147 147 ddi_node_name(pdip), ddi_get_instance(pdip));
148 148 TNF_PROBE_0_DEBUG(nx1394_bus_ctl_exit, S1394_TNF_SL_NEXUS_STACK,
149 149 "");
150 150 return (DDI_SUCCESS);
151 151 }
152 152
153 153 case DDI_CTLOPS_INITCHILD: {
154 154 dev_info_t *ocdip, *cdip = (dev_info_t *)arg;
155 155 dev_info_t *pdip = ddi_get_parent(cdip);
156 156 int reglen, i;
157 157 uint32_t *regptr;
158 158 char addr[MAXNAMELEN];
159 159
160 160 TNF_PROBE_1(nx1394_bus_ctl_init_child,
161 161 S1394_TNF_SL_HOTPLUG_STACK, "", tnf_opaque, dip, cdip);
162 162
163 163 i = ddi_prop_lookup_int_array(DDI_DEV_T_ANY, cdip,
164 164 DDI_PROP_DONTPASS, "reg", (int **)®ptr,
165 165 (uint_t *)®len);
166 166
167 167 if (i != DDI_PROP_SUCCESS) {
168 168 cmn_err(CE_NOTE, "!%s(%d): \"reg\" property not found",
169 169 ddi_node_name(cdip), ddi_get_instance(cdip));
170 170 TNF_PROBE_2(nx1394_bus_ctl,
171 171 S1394_TNF_SL_NEXUS_ERROR, "", tnf_string, msg,
172 172 "Reg property not found", tnf_int, reason, i);
173 173 TNF_PROBE_1_DEBUG(nx1394_bus_ctl_exit,
174 174 S1394_TNF_SL_NEXUS_STACK, "", tnf_string, op,
175 175 "initchild");
176 176 return (DDI_NOT_WELL_FORMED);
177 177 }
178 178
179 179 ASSERT(reglen != 0);
180 180
181 181 /*
182 182 * addr is of the format GGGGGGGGGGGGGGGG[,AAAAAAAAAAAA]
183 183 */
184 184 if (regptr[2] || regptr[3]) {
185 185 (void) sprintf(addr, "%08x%08x,%04x%08x", regptr[0],
186 186 regptr[1], regptr[2], regptr[3]);
187 187 } else {
188 188 (void) sprintf(addr, "%08x%08x", regptr[0], regptr[1]);
189 189 }
190 190 ddi_prop_free(regptr);
191 191 ddi_set_name_addr(cdip, addr);
192 192
193 193 /*
194 194 * Check for a node with the same name & addr as the current
195 195 * node. If such a node exists, return failure.
196 196 */
197 197 if ((ocdip = ndi_devi_find(pdip, ddi_node_name(cdip), addr)) !=
198 198 NULL && ocdip != cdip) {
199 199 cmn_err(CE_NOTE,
200 200 "!%s(%d): Duplicate dev_info node found %s@%s",
201 201 ddi_node_name(cdip), ddi_get_instance(cdip),
202 202 ddi_node_name(ocdip), addr);
203 203 TNF_PROBE_1(nx1394_bus_ctl,
204 204 S1394_TNF_SL_NEXUS_ERROR, "", tnf_string, msg,
205 205 "Duplicate nodes");
206 206 TNF_PROBE_1_DEBUG(nx1394_bus_ctl_exit,
207 207 S1394_TNF_SL_NEXUS_STACK, "", tnf_string, op,
208 208 "initchild");
209 209 ddi_set_name_addr(cdip, NULL);
210 210 return (DDI_NOT_WELL_FORMED);
211 211 }
212 212
213 213 /*
214 214 * If HAL (parent dip) has "active-dma-flush" property, then
215 215 * add property to child as well. Workaround for active
216 216 * context flushing bug in Schizo rev 2.1 and 2.2.
217 217 */
218 218 if (ddi_prop_exists(DDI_DEV_T_ANY, pdip, DDI_PROP_DONTPASS,
219 219 "active-dma-flush") != 0) {
220 220 status = ndi_prop_update_int(DDI_DEV_T_NONE, cdip,
221 221 "active-dma-flush", 1);
222 222 if (status != NDI_SUCCESS) {
223 223 cmn_err(CE_NOTE, "!%s(%d): Unable to add "
224 224 "\"active-dma-flush\" property",
225 225 ddi_node_name(cdip),
226 226 ddi_get_instance(cdip));
227 227 TNF_PROBE_1(nx1394_bus_ctl,
228 228 S1394_TNF_SL_NEXUS_ERROR, "", tnf_string,
229 229 msg, "Unable to add \"active-dma-flush\" "
230 230 "property");
231 231 TNF_PROBE_1_DEBUG(nx1394_bus_ctl_exit,
232 232 S1394_TNF_SL_NEXUS_STACK, "", tnf_string,
233 233 op, "initchild");
234 234 ddi_set_name_addr(cdip, NULL);
235 235 return (DDI_NOT_WELL_FORMED);
236 236 }
237 237 }
238 238
239 239 TNF_PROBE_1_DEBUG(nx1394_bus_ctl_exit,
240 240 S1394_TNF_SL_NEXUS_STACK, "", tnf_string, op, "initchild");
241 241 return (DDI_SUCCESS);
242 242 }
243 243
244 244 case DDI_CTLOPS_UNINITCHILD: {
245 245 ddi_prop_remove_all((dev_info_t *)arg);
246 246 ddi_set_name_addr((dev_info_t *)arg, NULL);
247 247 TNF_PROBE_1_DEBUG(nx1394_bus_ctl_exit, S1394_TNF_SL_NEXUS_STACK,
248 248 "", tnf_string, op, "uninitchild");
249 249 return (DDI_SUCCESS);
250 250 }
251 251
252 252 case DDI_CTLOPS_IOMIN: {
253 253 status = ddi_ctlops(dip, rdip, op, arg, result);
254 254 TNF_PROBE_1_DEBUG(nx1394_bus_ctl_exit, S1394_TNF_SL_NEXUS_STACK,
255 255 "", tnf_string, op, "iomin");
256 256 return (status);
257 257 }
258 258
259 259 case DDI_CTLOPS_POWER: {
260 260 return (DDI_SUCCESS);
261 261 }
262 262
263 263 /*
264 264 * These ops correspond to functions that "shouldn't" be called
265 265 * by a 1394 client driver.
266 266 */
267 267 case DDI_CTLOPS_DMAPMAPC:
268 268 case DDI_CTLOPS_REPORTINT:
269 269 case DDI_CTLOPS_REGSIZE:
270 270 case DDI_CTLOPS_NREGS:
271 271 case DDI_CTLOPS_SIDDEV:
272 272 case DDI_CTLOPS_SLAVEONLY:
273 273 case DDI_CTLOPS_AFFINITY:
274 274 case DDI_CTLOPS_POKE:
275 275 case DDI_CTLOPS_PEEK: {
276 276 cmn_err(CE_CONT, "!%s(%d): invalid op (%d) from %s(%d)",
277 277 ddi_node_name(dip), ddi_get_instance(dip),
278 278 op, ddi_node_name(rdip), ddi_get_instance(rdip));
279 279 TNF_PROBE_2(nx1394_bus_ctl, S1394_TNF_SL_NEXUS_ERROR, "",
280 280 tnf_string, msg, "invalid op", tnf_int, op, op);
281 281 TNF_PROBE_0_DEBUG(nx1394_bus_ctl_exit, S1394_TNF_SL_NEXUS_STACK,
282 282 "");
283 283 return (DDI_FAILURE);
284 284 }
285 285
286 286 /*
287 287 * Everything else (e.g. PTOB/BTOP/BTOPR requests) we pass up
288 288 */
289 289 default: {
290 290 status = ddi_ctlops(dip, rdip, op, arg, result);
291 291 TNF_PROBE_0_DEBUG(nx1394_bus_ctl_exit, S1394_TNF_SL_NEXUS_STACK,
292 292 "");
293 293 return (status);
294 294 }
295 295 }
296 296 }
297 297
298 298 /*
299 299 * nx1394_dma_allochdl()
300 300 * Merges the ddi_dma_attr_t passed in by the target (using
301 301 * ddi_dma_alloc_handle() call) with that of the hal and passes the alloc
↓ open down ↓ |
301 lines elided |
↑ open up ↑ |
302 302 * handle request up the device by calling ddi_dma_allochdl().
303 303 */
304 304 static int
305 305 nx1394_dma_allochdl(dev_info_t *dip, dev_info_t *rdip, ddi_dma_attr_t *attr,
306 306 int (*waitfnp)(caddr_t), caddr_t arg, ddi_dma_handle_t *handlep)
307 307 {
308 308 s1394_hal_t *hal;
309 309 ddi_dma_attr_t *hal_attr;
310 310 int status;
311 311
312 - _NOTE(SCHEME_PROTECTS_DATA("unique (per thread)", ddi_dma_attr_t))
313 -
314 312 TNF_PROBE_0_DEBUG(nx1394_dma_allochdl_enter, S1394_TNF_SL_NEXUS_STACK,
315 313 "");
316 314
317 315 /*
318 316 * If hal calls ddi_dma_alloc_handle, dip == rdip == hal dip.
319 317 * Unfortunately, we cannot verify this (by way of looking up for hal
320 318 * dip) here because h1394_attach() may happen much later.
321 319 */
322 320 if (dip != rdip) {
323 321 hal = s1394_dip_to_hal(ddi_get_parent(rdip));
324 322 ASSERT(hal);
325 323 hal_attr = &hal->halinfo.dma_attr;
326 324 ASSERT(hal_attr);
327 325 ddi_dma_attr_merge(attr, hal_attr);
328 326 }
329 327 status = ddi_dma_allochdl(dip, rdip, attr, waitfnp, arg, handlep);
330 328 TNF_PROBE_1_DEBUG(nx1394_dma_allochdl_exit, S1394_TNF_SL_NEXUS_STACK,
331 329 "", tnf_int, status, status);
332 330 return (status);
333 331 }
334 332
335 333 /*
336 334 * nx1394_get_event_cookie()
337 335 * Called when a child node calls ddi_get_eventcookie().
338 336 * Returns event cookie corresponding to event "name".
339 337 */
340 338 static int
341 339 nx1394_get_event_cookie(dev_info_t *dip, dev_info_t *rdip, char *name,
342 340 ddi_eventcookie_t *event_cookiep)
343 341 {
344 342 int ret;
345 343 s1394_hal_t *hal;
346 344
347 345 TNF_PROBE_1_DEBUG(nx1394_get_event_cookie_enter,
348 346 S1394_TNF_SL_NEXUS_STACK, "", tnf_string, name, name);
349 347
350 348 hal = s1394_dip_to_hal(dip);
351 349 ASSERT(hal);
352 350
353 351 ret = ndi_event_retrieve_cookie(hal->hal_ndi_event_hdl,
354 352 rdip, name, event_cookiep, 0);
355 353
356 354 TNF_PROBE_4_DEBUG(nx1394_get_event_cookie_exit,
357 355 S1394_TNF_SL_NEXUS_STACK, "", tnf_opaque, parent_dip, (void *)dip,
358 356 tnf_opaque, requestor_dip, (void *)rdip, tnf_string, event_name,
359 357 name, tnf_int, request_status, ret);
360 358
361 359 return (ret);
362 360
363 361 }
364 362
365 363 /*
366 364 * nx1394_add_eventcall()
367 365 * This gets called when a child node calls ddi_add_eventcall(). Registers
368 366 * the specified callback for the requested event cookie with the ndi
369 367 * event framework.
370 368 * dip is the hal dip. This routine calls ndi_event_add_callback(),
371 369 * allowing requests for events we don't generate to pass up the tree.
372 370 */
373 371 static int
374 372 nx1394_add_eventcall(dev_info_t *dip, dev_info_t *rdip,
375 373 ddi_eventcookie_t cookie, void (*callback)(), void *arg,
376 374 ddi_callback_id_t *cb_id)
377 375 {
378 376 int ret;
379 377 s1394_hal_t *hal;
380 378 #if defined(DEBUG)
381 379 char *event_name = NULL;
382 380 #endif
383 381
384 382 hal = s1394_dip_to_hal(dip);
385 383 ASSERT(hal);
386 384
387 385 TNF_PROBE_0_DEBUG(nx1394_add_eventcall_enter, S1394_TNF_SL_NEXUS_STACK,
388 386 "");
389 387
390 388 ret = ndi_event_add_callback(hal->hal_ndi_event_hdl, rdip, cookie,
391 389 callback, arg, NDI_NOSLEEP, cb_id);
392 390 #if defined(DEBUG)
393 391 event_name = ndi_event_cookie_to_name(hal->hal_ndi_event_hdl, cookie);
394 392 if (event_name == NULL)
395 393 event_name = "";
396 394 #endif
397 395 TNF_PROBE_4_DEBUG(nx1394_add_eventcall_exit, S1394_TNF_SL_NEXUS_STACK,
398 396 "", tnf_opaque, parent_dip, (void *)dip, tnf_opaque, requestor_dip,
399 397 (void *)rdip, tnf_string, event_name, event_name, tnf_int,
400 398 request_status, ret);
401 399
402 400 return (ret);
403 401 }
404 402
405 403 /*
406 404 * nx1394_remove_eventcall()
407 405 * Called as a result of a child node calling ddi_remove_eventcall().
408 406 * Unregisters the callback corresponding to the callback id passed in.
409 407 */
410 408 static int
411 409 nx1394_remove_eventcall(dev_info_t *dip, ddi_callback_id_t cb_id)
412 410 {
413 411 int ret;
414 412 s1394_hal_t *hal;
415 413 ddi_eventcookie_t cookie;
416 414 #if defined(DEBUG)
417 415 char *event_name = NULL;
418 416 #endif
419 417
420 418 ASSERT(cb_id);
421 419 cookie = ((ndi_event_callbacks_t *)cb_id)->ndi_evtcb_cookie;
422 420
423 421 hal = s1394_dip_to_hal(dip);
424 422 ASSERT(hal);
425 423
426 424 TNF_PROBE_0_DEBUG(nx1394_remove_eventcall_enter,
427 425 S1394_TNF_SL_NEXUS_STACK, "");
428 426
429 427 ret = ndi_event_remove_callback(hal->hal_ndi_event_hdl, cb_id);
430 428
431 429 #if defined(DEBUG)
432 430 event_name = ndi_event_cookie_to_name(hal->hal_ndi_event_hdl, cookie);
433 431 if (event_name == NULL)
434 432 event_name = "";
435 433
436 434 TNF_PROBE_4_DEBUG(nx1394_remove_eventcall_exit,
437 435 S1394_TNF_SL_NEXUS_STACK, "", tnf_opaque, parent_dip, (void *)dip,
438 436 tnf_opaque, callback_id, (void *)cb_id, tnf_string, event_name,
439 437 event_name, tnf_int, request_status, ret);
440 438 #endif
441 439
442 440 return (ret);
443 441 }
444 442
445 443 /*
446 444 * nx1394_post_event()
447 445 * Called when a child node calls ddi_post_event. If the event is one of
448 446 * the events supported by us (bus reset/insert/remove, for now), builds
449 447 * a t1394_localinfo_t structure and calls ndi_event_run_callbacks(). This
450 448 * will result in all registered callbacks being invoked with
451 449 * t1394_localinfo_t as the impl_data. (see ddi_add_eventcall for callback
452 450 * arguments.) If the event is not defined by us, the request is
453 451 * propagated up the device tree by calling ndi_post_event().
454 452 */
455 453 static int
456 454 nx1394_post_event(dev_info_t *dip, dev_info_t *rdip, ddi_eventcookie_t cookie,
457 455 void *impl_data)
458 456 {
459 457 int ret;
460 458 char *name;
461 459 s1394_hal_t *hal;
462 460 t1394_localinfo_t localinfo;
463 461
464 462 hal = s1394_dip_to_hal(dip);
465 463 ASSERT(hal);
466 464
467 465 TNF_PROBE_0_DEBUG(nx1394_post_event_enter, S1394_TNF_SL_NEXUS_STACK,
468 466 "");
469 467
470 468 name = ndi_event_cookie_to_name(hal->hal_ndi_event_hdl, cookie);
471 469 /* name is NULL if we don't generate the event */
472 470 if (name != NULL) {
473 471
474 472 mutex_enter(&hal->topology_tree_mutex);
475 473 localinfo.bus_generation = hal->generation_count;
476 474 localinfo.local_nodeID = hal->node_id;
477 475 mutex_exit(&hal->topology_tree_mutex);
478 476 impl_data = &localinfo;
479 477
480 478 ret = ndi_event_run_callbacks(hal->hal_ndi_event_hdl,
481 479 rdip, cookie, impl_data);
482 480
483 481 TNF_PROBE_4_DEBUG(nx1394_post_event_exit,
484 482 S1394_TNF_SL_NEXUS_STACK, "", tnf_opaque, parent_dip,
485 483 (void *)dip, tnf_opaque, requestor_dip, (void *)rdip,
486 484 tnf_string, event_name, name, tnf_int, request_status, ret);
487 485 return (ret);
488 486
489 487 } else {
490 488 ret = ndi_post_event(ddi_get_parent(dip), rdip, cookie,
491 489 impl_data);
492 490 TNF_PROBE_2_DEBUG(nx1394_post_event_exit,
493 491 S1394_TNF_SL_NEXUS_STACK, "", tnf_string, msg,
494 492 "Not our event", tnf_int, ret, ret);
495 493 return (ret);
496 494 }
497 495 }
498 496
499 497 /*
500 498 * nx1394_define_events()
501 499 * Allocates event handle for the hal dip and binds event set to it.
502 500 */
503 501 int
504 502 nx1394_define_events(s1394_hal_t *hal)
505 503 {
506 504 int ret;
507 505
508 506 TNF_PROBE_0_DEBUG(nx1394_define_events_enter, S1394_TNF_SL_NEXUS_STACK,
509 507 "");
510 508
511 509 /* get event handle */
512 510 ret = ndi_event_alloc_hdl(hal->halinfo.dip, hal->halinfo.hw_interrupt,
513 511 &hal->hal_ndi_event_hdl, NDI_SLEEP);
514 512 if (ret != NDI_SUCCESS) {
515 513 TNF_PROBE_1(nx1394_define_events_alloc_fail,
516 514 S1394_TNF_SL_NEXUS_ERROR, "", tnf_int, ret, ret);
517 515 } else {
518 516 /* and bind to it */
519 517 ret = ndi_event_bind_set(hal->hal_ndi_event_hdl, &nx1394_events,
520 518 NDI_SLEEP);
521 519 if (ret != NDI_SUCCESS) {
522 520 TNF_PROBE_1(nx1394_define_events_bind_fail,
523 521 S1394_TNF_SL_NEXUS_ERROR, "", tnf_int, ret, ret);
524 522 (void) ndi_event_free_hdl(hal->hal_ndi_event_hdl);
525 523 TNF_PROBE_0_DEBUG(nx1394_define_events_exit,
526 524 S1394_TNF_SL_NEXUS_STACK, "");
527 525 return (DDI_FAILURE);
528 526 }
529 527 }
530 528
531 529 TNF_PROBE_0_DEBUG(nx1394_define_events_exit, S1394_TNF_SL_NEXUS_STACK,
532 530 "");
533 531
534 532 return (DDI_SUCCESS);
535 533 }
536 534
537 535 /*
538 536 * nx1394_undefine_events()
539 537 * Unbinds event set bound to the hal and frees the event handle.
540 538 */
541 539 void
542 540 nx1394_undefine_events(s1394_hal_t *hal)
543 541 {
544 542 int ret;
545 543
546 544 TNF_PROBE_0_DEBUG(nx1394_undefine_events_enter,
547 545 S1394_TNF_SL_NEXUS_STACK, "");
548 546
549 547 ret = ndi_event_unbind_set(hal->hal_ndi_event_hdl, &nx1394_events,
550 548 NDI_SLEEP);
551 549 if (ret != NDI_SUCCESS) {
552 550 TNF_PROBE_1(nx1394_undefine_events_unbind_fail,
553 551 S1394_TNF_SL_NEXUS_ERROR, "", tnf_int, ret, ret);
554 552 } else {
555 553 ret = ndi_event_free_hdl(hal->hal_ndi_event_hdl);
556 554 if (ret != NDI_SUCCESS) {
557 555 TNF_PROBE_1(nx1394_undefine_events_free_hdl_fail,
558 556 S1394_TNF_SL_NEXUS_ERROR, "", tnf_int, ret, ret);
559 557 }
560 558 }
561 559
562 560 TNF_PROBE_0_DEBUG(nx1394_undefine_events_exit,
563 561 S1394_TNF_SL_NEXUS_STACK, "");
564 562 }
↓ open down ↓ |
241 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX