Print this page
8627 want ddi_ffsll, ddi_flsll
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/sys/sunddi.h
+++ new/usr/src/uts/common/sys/sunddi.h
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 (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved.
24 24 * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
25 25 * Copyright (c) 2012 by Delphix. All rights reserved.
26 26 * Copyright 2016 Nexenta Systems, Inc. All rights reserved.
27 27 */
28 28
29 29 #ifndef _SYS_SUNDDI_H
30 30 #define _SYS_SUNDDI_H
31 31
32 32 /*
33 33 * Sun Specific DDI definitions
34 34 */
35 35
36 36 #include <sys/isa_defs.h>
37 37 #include <sys/dditypes.h>
38 38 #include <sys/ddipropdefs.h>
39 39 #include <sys/devops.h>
40 40 #include <sys/time.h>
41 41 #include <sys/cmn_err.h>
42 42 #include <sys/ddidevmap.h>
43 43 #include <sys/ddi_impldefs.h>
44 44 #include <sys/ddi_implfuncs.h>
45 45 #include <sys/ddi_isa.h>
46 46 #include <sys/model.h>
47 47 #include <sys/devctl.h>
48 48 #if defined(__i386) || defined(__amd64)
49 49 #include <sys/dma_engine.h>
50 50 #endif
51 51 #include <sys/sunpm.h>
52 52 #include <sys/nvpair.h>
53 53 #include <sys/sysevent.h>
54 54 #include <sys/thread.h>
55 55 #include <sys/stream.h>
56 56 #if defined(__GNUC__) && defined(_ASM_INLINES) && defined(_KERNEL)
57 57 #include <asm/sunddi.h>
58 58 #endif
59 59 #ifdef _KERNEL
60 60 #include <sys/ddi_obsolete.h>
61 61 #endif
62 62 #include <sys/u8_textprep.h>
63 63 #include <sys/kiconv.h>
64 64
65 65 #ifdef __cplusplus
66 66 extern "C" {
67 67 #endif
68 68
69 69 /*
70 70 * Generic Sun DDI definitions.
71 71 */
72 72
73 73 #define DDI_SUCCESS (0) /* successful return */
74 74 #define DDI_FAILURE (-1) /* unsuccessful return */
75 75 #define DDI_NOT_WELL_FORMED (-2) /* A dev_info node is not valid */
76 76 #define DDI_EAGAIN (-3) /* not enough interrupt resources */
77 77 #define DDI_EINVAL (-4) /* invalid request or arguments */
78 78 #define DDI_ENOTSUP (-5) /* operation is not supported */
79 79 #define DDI_EPENDING (-6) /* operation or an event is pending */
80 80 #define DDI_EALREADY (-7) /* operation already in progress */
81 81
82 82 /*
83 83 * General-purpose DDI error return value definitions
84 84 */
85 85 #define DDI_ENOMEM 1 /* memory not available */
86 86 #define DDI_EBUSY 2 /* busy */
87 87 #define DDI_ETRANSPORT 3 /* transport down */
88 88 #define DDI_ECONTEXT 4 /* context error */
89 89
90 90
91 91 /*
92 92 * General DDI sleep/nosleep allocation flags
93 93 */
94 94 #define DDI_SLEEP 0
95 95 #define DDI_NOSLEEP 1
96 96
97 97 /*
98 98 * The following special nodeid values are reserved for use when creating
99 99 * nodes ONLY. They specify the attributes of the DDI_NC_PSEUDO class node
100 100 * being created:
101 101 *
102 102 * o DEVI_PSEUDO_NODEID specifics a node without persistence.
103 103 * o DEVI_SID_NODEID specifies a node with persistence.
104 104 * o DEVI_SID_HIDDEN_NODEID specifies a hidden node with persistence.
105 105 *
106 106 * A node with the 'hidden' attribute will not show up in devinfo snapshots
107 107 * or in /devices file system.
108 108 *
109 109 * A node with the 'persistent' attribute will not be automatically removed by
110 110 * the framework in the current implementation - driver.conf nodes are without
111 111 * persistence.
112 112 *
113 113 * The actual nodeid value may be assigned by the framework and may be
114 114 * different than these special values. Drivers may not make assumptions
115 115 * about the nodeid value that is actually assigned to the node.
116 116 */
117 117
118 118 #define DEVI_PSEUDO_NODEID ((int)-1)
119 119 #define DEVI_SID_NODEID ((int)-2)
120 120 #define DEVI_SID_HIDDEN_NODEID ((int)-3)
121 121 #define DEVI_SID_HP_NODEID ((int)-4)
122 122 #define DEVI_SID_HP_HIDDEN_NODEID ((int)-5)
123 123
124 124 #define DEVI_PSEUDO_NEXNAME "pseudo"
125 125 #define DEVI_ISA_NEXNAME "isa"
126 126 #define DEVI_EISA_NEXNAME "eisa"
127 127
128 128 /*
129 129 * ddi_create_minor_node flags
130 130 */
131 131 #define CLONE_DEV 1 /* device is a clone device */
132 132 #define PRIVONLY_DEV 0x10 /* policy-based permissions only */
133 133
134 134 /*
135 135 * Historical values used for the flag field in ddi_create_minor_node.
136 136 * Future use of flag bits should avoid these fields to keep binary
137 137 * compatibility
138 138 * #define GLOBAL_DEV 0x2
139 139 * #define NODEBOUND_DEV 0x4
140 140 * #define NODESPECIFIC_DEV 0x6
141 141 * #define ENUMERATED_DEV 0x8
142 142 */
143 143
144 144 /*
145 145 * Device type defines which are used by the 'node_type' element of the
146 146 * ddi_minor_data structure
147 147 */
148 148 #define DDI_NT_SERIAL "ddi_serial" /* Serial port */
149 149 #define DDI_NT_SERIAL_MB "ddi_serial:mb" /* the 'built-in' serial */
150 150 /* ports (the old ttya, b */
151 151 /* (,c ,d)) */
152 152 #define DDI_NT_SERIAL_DO "ddi_serial:dialout" /* dialout ports */
153 153 #define DDI_NT_SERIAL_MB_DO "ddi_serial:dialout,mb" /* dialout for onboard */
154 154 /* ports */
155 155 #define DDI_NT_SERIAL_LOMCON "ddi_serial:lomcon" /* LOMlite2 console port */
156 156
157 157 /*
158 158 * *_CHAN disk type devices have channel numbers or target numbers.
159 159 * (i.e. ipi and scsi devices)
160 160 */
161 161 #define DDI_NT_BLOCK "ddi_block" /* hard disks */
162 162 /*
163 163 * The next define is for block type devices that can possible exist on
164 164 * a sub-bus like the scsi bus or the ipi channel. The 'disks' program
165 165 * will pick up on this and create logical names like c0t0d0s0 instead of
166 166 * c0d0s0
167 167 */
168 168 #define DDI_NT_BLOCK_CHAN "ddi_block:channel"
169 169 #define DDI_NT_BLOCK_WWN "ddi_block:wwn"
170 170 #define DDI_NT_CD "ddi_block:cdrom" /* rom drives (cd-rom) */
171 171 #define DDI_NT_CD_CHAN "ddi_block:cdrom:channel" /* rom drives (scsi type) */
172 172 #define DDI_NT_FD "ddi_block:diskette" /* floppy disks */
173 173
174 174 #define DDI_NT_ENCLOSURE "ddi_enclosure"
175 175 #define DDI_NT_SCSI_ENCLOSURE "ddi_enclosure:scsi"
176 176
177 177 #define DDI_NT_BLOCK_SAS "ddi_block:sas"
178 178 #define DDI_NT_BLOCK_BLKDEV "ddi_block:blkdev"
179 179
180 180 /*
181 181 * xVM virtual block devices
182 182 */
183 183 #define DDI_NT_BLOCK_XVMD "ddi_block:xvmd"
184 184 #define DDI_NT_CD_XVMD "ddi_block:cdrom:xvmd"
185 185
186 186
187 187 #define DDI_NT_TAPE "ddi_byte:tape" /* tape drives */
188 188
189 189 #define DDI_NT_NET "ddi_network" /* DLPI network devices */
190 190
191 191 #define DDI_NT_NET_WIFI "ddi_network:wifi" /* wifi devices */
192 192
193 193 #define DDI_NT_DISPLAY "ddi_display" /* display devices */
194 194
195 195 #define DDI_NT_DISPLAY_DRM "ddi_display:drm" /* drm display devices */
196 196
197 197 #define DDI_PSEUDO "ddi_pseudo" /* general pseudo devices */
198 198
199 199 #define DDI_NT_AUDIO "ddi_audio" /* audio device */
200 200
201 201 #define DDI_NT_MOUSE "ddi_mouse" /* mouse device */
202 202
203 203 #define DDI_NT_KEYBOARD "ddi_keyboard" /* keyboard device */
204 204
205 205 #define DDI_NT_PARALLEL "ddi_parallel" /* parallel port */
206 206
207 207 #define DDI_NT_PRINTER "ddi_printer" /* printer device */
208 208
209 209 #define DDI_NT_UGEN "ddi_generic:usb" /* USB generic drv */
210 210
211 211 #define DDI_NT_SMP "ddi_sas_smp" /* smp devcies */
212 212
213 213 #define DDI_NT_NEXUS "ddi_ctl:devctl" /* nexus drivers */
214 214
215 215 #define DDI_NT_NVME_NEXUS "ddi_ctl:devctl:nvme" /* nexus drivers */
216 216
217 217 #define DDI_NT_SCSI_NEXUS "ddi_ctl:devctl:scsi" /* nexus drivers */
218 218
219 219 #define DDI_NT_SATA_NEXUS "ddi_ctl:devctl:sata" /* nexus drivers */
220 220
221 221 #define DDI_NT_IB_NEXUS "ddi_ctl:devctl:ib" /* nexus drivers */
222 222
223 223 #define DDI_NT_ATTACHMENT_POINT "ddi_ctl:attachment_point" /* attachment pt */
224 224
225 225 #define DDI_NT_NVME_ATTACHMENT_POINT "ddi_ctl:attachment_point:nvme"
226 226 /* nvme attachment pt */
227 227
228 228 #define DDI_NT_SCSI_ATTACHMENT_POINT "ddi_ctl:attachment_point:scsi"
229 229 /* scsi attachment pt */
230 230
231 231 #define DDI_NT_SATA_ATTACHMENT_POINT "ddi_ctl:attachment_point:sata"
232 232 /* sata attachment pt */
233 233
234 234 #define DDI_NT_SDCARD_ATTACHMENT_POINT "ddi_ctl:attachment_point:sdcard"
235 235 /* sdcard attachment pt */
236 236
237 237 #define DDI_NT_PCI_ATTACHMENT_POINT "ddi_ctl:attachment_point:pci"
238 238 /* PCI attachment pt */
239 239 #define DDI_NT_SBD_ATTACHMENT_POINT "ddi_ctl:attachment_point:sbd"
240 240 /* generic bd attachment pt */
241 241 #define DDI_NT_FC_ATTACHMENT_POINT "ddi_ctl:attachment_point:fc"
242 242 /* FC attachment pt */
243 243 #define DDI_NT_USB_ATTACHMENT_POINT "ddi_ctl:attachment_point:usb"
244 244 /* USB devices */
245 245 #define DDI_NT_BLOCK_FABRIC "ddi_block:fabric"
246 246 /* Fabric Devices */
247 247 #define DDI_NT_IB_ATTACHMENT_POINT "ddi_ctl:attachment_point:ib"
248 248 /* IB devices */
249 249
250 250 #define DDI_NT_AV_ASYNC "ddi_av:async" /* asynchronous AV device */
251 251 #define DDI_NT_AV_ISOCH "ddi_av:isoch" /* isochronous AV device */
252 252
253 253 /* Device types used for agpgart driver related devices */
254 254 #define DDI_NT_AGP_PSEUDO "ddi_agp:pseudo" /* agpgart pseudo device */
255 255 #define DDI_NT_AGP_MASTER "ddi_agp:master" /* agp master device */
256 256 #define DDI_NT_AGP_TARGET "ddi_agp:target" /* agp target device */
257 257 #define DDI_NT_AGP_CPUGART "ddi_agp:cpugart" /* amd64 on-cpu gart device */
258 258
259 259 #define DDI_NT_REGACC "ddi_tool_reg" /* tool register access */
260 260 #define DDI_NT_INTRCTL "ddi_tool_intr" /* tool intr access */
261 261
262 262 /*
263 263 * DDI event definitions
264 264 */
265 265 #define EC_DEVFS "EC_devfs" /* Event class devfs */
266 266 #define EC_DDI "EC_ddi" /* Event class ddi */
267 267
268 268 /* Class devfs subclasses */
269 269 #define ESC_DEVFS_MINOR_CREATE "ESC_devfs_minor_create"
270 270 #define ESC_DEVFS_MINOR_REMOVE "ESC_devfs_minor_remove"
271 271 #define ESC_DEVFS_DEVI_ADD "ESC_devfs_devi_add"
272 272 #define ESC_DEVFS_DEVI_REMOVE "ESC_devfs_devi_remove"
273 273 #define ESC_DEVFS_INSTANCE_MOD "ESC_devfs_instance_mod"
274 274 #define ESC_DEVFS_BRANCH_ADD "ESC_devfs_branch_add"
275 275 #define ESC_DEVFS_BRANCH_REMOVE "ESC_devfs_branch_remove"
276 276 #define ESC_DEVFS_START "ESC_devfs_start"
277 277
278 278 /* Class ddi subclasses */
279 279 #define ESC_DDI_INITIATOR_REGISTER "ESC_ddi_initiator_register"
280 280 #define ESC_DDI_INITIATOR_UNREGISTER "ESC_ddi_initiator_unregister"
281 281
282 282 /* DDI/NDI event publisher */
283 283 #define EP_DDI SUNW_KERN_PUB"ddi"
284 284
285 285 /*
286 286 * devfs event class attributes
287 287 *
288 288 * The following attributes are private to EC_DEVFS event data.
289 289 */
290 290 #define DEVFS_DRIVER_NAME "di.driver"
291 291 #define DEVFS_INSTANCE "di.instance"
292 292 #define DEVFS_PATHNAME "di.path"
293 293 #define DEVFS_DEVI_CLASS "di.devi_class"
294 294 #define DEVFS_BRANCH_EVENT "di.branch_event"
295 295 #define DEVFS_MINOR_NAME "mi.name"
296 296 #define DEVFS_MINOR_NODETYPE "mi.nodetype"
297 297 #define DEVFS_MINOR_ISCLONE "mi.isclone"
298 298 #define DEVFS_MINOR_MAJNUM "mi.majorno"
299 299 #define DEVFS_MINOR_MINORNUM "mi.minorno"
300 300
301 301 /*
302 302 * ddi event class payload
303 303 *
304 304 * The following attributes are private to EC_DDI event data.
305 305 */
306 306 #define DDI_DRIVER_NAME "ddi.driver"
307 307 #define DDI_DRIVER_MAJOR "ddi.major"
308 308 #define DDI_INSTANCE "ddi.instance"
309 309 #define DDI_PATHNAME "ddi.path"
310 310 #define DDI_CLASS "ddi.class"
311 311
312 312 /*
313 313 * Fault-related definitions
314 314 *
315 315 * The specific numeric values have been chosen to be ordered, but
316 316 * not consecutive, to allow for future interpolation if required.
317 317 */
318 318 typedef enum {
319 319 DDI_SERVICE_LOST = -32,
320 320 DDI_SERVICE_DEGRADED = -16,
321 321 DDI_SERVICE_UNAFFECTED = 0,
322 322 DDI_SERVICE_RESTORED = 16
323 323 } ddi_fault_impact_t;
324 324
325 325 typedef enum {
326 326 DDI_DATAPATH_FAULT = -32,
327 327 DDI_DEVICE_FAULT = -16,
328 328 DDI_EXTERNAL_FAULT = 0
329 329 } ddi_fault_location_t;
330 330
331 331 typedef enum {
332 332 DDI_DEVSTATE_OFFLINE = -32,
333 333 DDI_DEVSTATE_DOWN = -16,
334 334 DDI_DEVSTATE_QUIESCED = 0,
335 335 DDI_DEVSTATE_DEGRADED = 16,
336 336 DDI_DEVSTATE_UP = 32
337 337 } ddi_devstate_t;
338 338
339 339 #if defined(_KERNEL) || defined(_FAKE_KERNEL)
340 340
341 341 /*
342 342 * Common property definitions
343 343 */
344 344 #define DDI_FORCEATTACH "ddi-forceattach"
345 345 #define DDI_NO_AUTODETACH "ddi-no-autodetach"
346 346 #define DDI_VHCI_CLASS "ddi-vhci-class"
347 347 #define DDI_NO_ROOT_SUPPORT "ddi-no-root-support"
348 348 #define DDI_OPEN_RETURNS_EINTR "ddi-open-returns-eintr"
349 349 #define DDI_DEVID_REGISTRANT "ddi-devid-registrant"
350 350
351 351 /*
352 352 * Values that the function supplied to the dev_info
353 353 * tree traversal functions defined below must return.
354 354 */
355 355
356 356 /*
357 357 * Continue search, if appropriate.
358 358 */
359 359 #define DDI_WALK_CONTINUE 0
360 360
361 361 /*
362 362 * Terminate current depth of traversal. That is, terminate
363 363 * the current traversal of children nodes, but continue
364 364 * traversing sibling nodes and their children (if any).
365 365 */
366 366
367 367 #define DDI_WALK_PRUNECHILD -1
368 368
369 369 /*
370 370 * Terminate current width of traversal. That is, terminate
371 371 * the current traversal of sibling nodes, but continue with
372 372 * traversing children nodes and their siblings (if appropriate).
373 373 */
374 374
375 375 #define DDI_WALK_PRUNESIB -2
376 376
377 377 /*
378 378 * Terminate the entire search.
379 379 */
380 380
381 381 #define DDI_WALK_TERMINATE -3
382 382
383 383 /*
384 384 * Terminate the entire search because an error occurred in function
385 385 */
386 386 #define DDI_WALK_ERROR -4
387 387
388 388 /*
389 389 * Drivers that are prepared to support full driver layering
390 390 * should create and export a null-valued property of the following
391 391 * name.
392 392 *
393 393 * Such drivers should be prepared to be called with FKLYR in
394 394 * the 'flag' argument of their open(9E), close(9E) routines, and
395 395 * with FKIOCTL in the 'mode' argument of their ioctl(9E) routines.
396 396 *
397 397 * See ioctl(9E) and ddi_copyin(9F) for details.
398 398 */
399 399 #define DDI_KERNEL_IOCTL "ddi-kernel-ioctl"
400 400
401 401 /*
402 402 * Model definitions for ddi_mmap_get_model(9F) and ddi_model_convert_from(9F).
403 403 */
404 404 #define DDI_MODEL_MASK DATAMODEL_MASK /* Note: 0x0FF00000 */
405 405 #define DDI_MODEL_ILP32 DATAMODEL_ILP32
406 406 #define DDI_MODEL_LP64 DATAMODEL_LP64
407 407 #define DDI_MODEL_NATIVE DATAMODEL_NATIVE
408 408 #define DDI_MODEL_NONE DATAMODEL_NONE
409 409
410 410 /* if set to B_TRUE is DER_MODE is equivalent to DERE_PANIC */
411 411 extern boolean_t ddi_err_panic;
412 412
413 413 /*
414 414 * Defines for ddi_err().
415 415 */
416 416 typedef enum {
417 417 DER_INVALID = 0, /* must be 0 */
418 418 DER_CONT = 1,
419 419 DER_CONS,
420 420 DER_LOG,
421 421 DER_VERB,
422 422 DER_NOTE,
423 423 DER_WARN,
424 424 DER_PANIC,
425 425 DER_MODE,
426 426 DER_DEBUG
427 427 } ddi_err_t;
428 428
429 429 extern void ddi_err(ddi_err_t de, dev_info_t *rdip, const char *fmt, ...);
430 430
431 431
432 432 extern char *ddi_strdup(const char *str, int flag);
433 433 extern char *strdup(const char *str);
434 434 extern void strfree(char *str);
435 435
436 436 /*
437 437 * Functions and data references which really should be in <sys/ddi.h>
438 438 */
439 439
440 440 extern int maxphys;
441 441 extern void minphys(struct buf *);
442 442 extern int physio(int (*)(struct buf *), struct buf *, dev_t,
443 443 int, void (*)(struct buf *), struct uio *);
444 444 extern void disksort(struct diskhd *, struct buf *);
445 445
446 446 extern size_t strlen(const char *) __PURE;
447 447 extern size_t strnlen(const char *, size_t) __PURE;
448 448 extern char *strcpy(char *, const char *);
449 449 extern char *strncpy(char *, const char *, size_t);
450 450 /* Need to be consistent with <string.h> C++ definition for strchr() */
451 451 #if __cplusplus >= 199711L
452 452 extern const char *strchr(const char *, int);
453 453 #ifndef _STRCHR_INLINE
454 454 #define _STRCHR_INLINE
455 455 extern "C++" {
456 456 inline char *strchr(char *__s, int __c) {
457 457 return (char *)strchr((const char *)__s, __c);
458 458 }
459 459 }
460 460 #endif /* _STRCHR_INLINE */
461 461 #else
462 462 extern char *strchr(const char *, int);
463 463 #endif /* __cplusplus >= 199711L */
464 464 #define DDI_STRSAME(s1, s2) ((*(s1) == *(s2)) && (strcmp((s1), (s2)) == 0))
465 465 extern int strcmp(const char *, const char *) __PURE;
466 466 extern int strncmp(const char *, const char *, size_t) __PURE;
467 467 extern char *strncat(char *, const char *, size_t);
468 468 extern size_t strlcat(char *, const char *, size_t);
469 469 extern size_t strlcpy(char *, const char *, size_t);
470 470 extern size_t strspn(const char *, const char *);
471 471 extern size_t strcspn(const char *, const char *);
472 472 extern char *strsep(char **, const char *);
473 473 extern int bcmp(const void *, const void *, size_t) __PURE;
474 474 extern int stoi(char **);
475 475 extern void numtos(ulong_t, char *);
476 476 extern void bcopy(const void *, void *, size_t);
477 477 extern void bzero(void *, size_t);
478 478
479 479 extern void *memcpy(void *, const void *, size_t);
480 480 extern void *memset(void *, int, size_t);
481 481 extern void *memmove(void *, const void *, size_t);
482 482 extern int memcmp(const void *, const void *, size_t) __PURE;
483 483 /* Need to be consistent with <string.h> C++ definition for memchr() */
484 484 #if __cplusplus >= 199711L
485 485 extern const void *memchr(const void *, int, size_t);
486 486 #ifndef _MEMCHR_INLINE
487 487 #define _MEMCHR_INLINE
488 488 extern "C++" {
489 489 inline void *memchr(void * __s, int __c, size_t __n) {
490 490 return (void *)memchr((const void *)__s, __c, __n);
491 491 }
492 492 }
493 493 #endif /* _MEMCHR_INLINE */
494 494 #else
495 495 extern void *memchr(const void *, int, size_t);
496 496 #endif /* __cplusplus >= 199711L */
497 497
498 498 extern int ddi_strtol(const char *, char **, int, long *);
499 499 extern int ddi_strtoul(const char *, char **, int, unsigned long *);
500 500 extern int ddi_strtoll(const char *, char **, int, longlong_t *);
501 501 extern int ddi_strtoull(const char *, char **, int, u_longlong_t *);
502 502
503 503 /*
504 504 * kiconv functions and their macros.
505 505 */
506 506 #define KICONV_IGNORE_NULL (0x0001)
507 507 #define KICONV_REPLACE_INVALID (0x0002)
508 508
509 509 extern kiconv_t kiconv_open(const char *, const char *);
510 510 extern size_t kiconv(kiconv_t, char **, size_t *, char **, size_t *, int *);
511 511 extern int kiconv_close(kiconv_t);
512 512 extern size_t kiconvstr(const char *, const char *, char *, size_t *, char *,
513 513 size_t *, int, int *);
514 514
515 515 #endif /* _KERNEL || _FAKE_KERNEL */
516 516 #ifdef _KERNEL
517 517
518 518 /*
519 519 * ddi_map_regs
520 520 *
521 521 * Map in the register set given by rnumber.
522 522 * The register number determine which register
523 523 * set will be mapped if more than one exists.
524 524 * The parent driver gets the information
525 525 * from parent private data and sets up the
526 526 * appropriate mappings and returns the kernel
527 527 * virtual address of the register set in *kaddrp.
528 528 * The offset specifies an offset into the register
529 529 * space to start from and len indicates the size
530 530 * of the area to map. If len and offset are 0 then
531 531 * the entire space is mapped. It returns DDI_SUCCESS on
532 532 * success or DDI_FAILURE otherwise.
533 533 *
534 534 */
535 535 int
536 536 ddi_map_regs(dev_info_t *dip, uint_t rnumber, caddr_t *kaddrp,
537 537 off_t offset, off_t len);
538 538
539 539 /*
540 540 * ddi_unmap_regs
541 541 *
542 542 * Undo mappings set up by ddi_map_regs.
543 543 * The register number determines which register
544 544 * set will be unmapped if more than one exists.
545 545 * This is provided for drivers preparing
546 546 * to detach themselves from the system to
547 547 * allow them to release allocated mappings.
548 548 *
549 549 * The kaddrp and len specify the area to be
550 550 * unmapped. *kaddrp was returned from ddi_map_regs
551 551 * and len should match what ddi_map_regs was called
552 552 * with.
553 553 */
554 554
555 555 void
556 556 ddi_unmap_regs(dev_info_t *dip, uint_t rnumber, caddr_t *kaddrp,
557 557 off_t offset, off_t len);
558 558
559 559 int
560 560 ddi_map(dev_info_t *dp, ddi_map_req_t *mp, off_t offset, off_t len,
561 561 caddr_t *addrp);
562 562
563 563 int
564 564 ddi_apply_range(dev_info_t *dip, dev_info_t *rdip, struct regspec *rp);
565 565
566 566 /*
567 567 * ddi_rnumber_to_regspec: Not for use by leaf drivers.
568 568 */
569 569 struct regspec *
570 570 ddi_rnumber_to_regspec(dev_info_t *dip, int rnumber);
571 571
572 572 int
573 573 ddi_bus_map(dev_info_t *dip, dev_info_t *rdip, ddi_map_req_t *mp, off_t offset,
574 574 off_t len, caddr_t *vaddrp);
575 575
576 576 int
577 577 nullbusmap(dev_info_t *dip, dev_info_t *rdip, ddi_map_req_t *mp, off_t offset,
578 578 off_t len, caddr_t *vaddrp);
579 579
580 580 int ddi_peek8(dev_info_t *dip, int8_t *addr, int8_t *val_p);
581 581 int ddi_peek16(dev_info_t *dip, int16_t *addr, int16_t *val_p);
582 582 int ddi_peek32(dev_info_t *dip, int32_t *addr, int32_t *val_p);
583 583 int ddi_peek64(dev_info_t *dip, int64_t *addr, int64_t *val_p);
584 584
585 585 int ddi_poke8(dev_info_t *dip, int8_t *addr, int8_t val);
586 586 int ddi_poke16(dev_info_t *dip, int16_t *addr, int16_t val);
587 587 int ddi_poke32(dev_info_t *dip, int32_t *addr, int32_t val);
588 588 int ddi_poke64(dev_info_t *dip, int64_t *addr, int64_t val);
589 589
590 590 /*
591 591 * Peek and poke to and from a uio structure in xfersize pieces,
592 592 * using the parent nexi.
593 593 */
594 594 int ddi_peekpokeio(dev_info_t *devi, struct uio *uio, enum uio_rw rw,
595 595 caddr_t addr, size_t len, uint_t xfersize);
596 596
597 597 /*
598 598 * Pagesize conversions using the parent nexi
599 599 */
600 600 unsigned long ddi_btop(dev_info_t *dip, unsigned long bytes);
601 601 unsigned long ddi_btopr(dev_info_t *dip, unsigned long bytes);
602 602 unsigned long ddi_ptob(dev_info_t *dip, unsigned long pages);
603 603
604 604 /*
605 605 * There are no more "block" interrupt functions, per se.
606 606 * All thread of control should be done with MP/MT lockings.
607 607 *
608 608 * However, there are certain times in which a driver needs
609 609 * absolutely a critical guaranteed non-preemptable time
610 610 * in which to execute a few instructions.
611 611 *
612 612 * The following pair of functions attempt to guarantee this,
613 613 * but they are dangerous to use. That is, use them with
614 614 * extreme care. They do not guarantee to stop other processors
615 615 * from executing, but they do guarantee that the caller
616 616 * of ddi_enter_critical will continue to run until the
617 617 * caller calls ddi_exit_critical. No intervening DDI functions
618 618 * may be called between an entry and an exit from a critical
619 619 * region.
620 620 *
621 621 * ddi_enter_critical returns an integer identifier which must
622 622 * be passed to ddi_exit_critical.
623 623 *
624 624 * Be very sparing in the use of these functions since it is
625 625 * likely that absolutely nothing else can occur in the system
626 626 * whilst in the critical region.
627 627 */
628 628
629 629 unsigned int
630 630 ddi_enter_critical(void);
631 631
632 632 void
633 633 ddi_exit_critical(unsigned int);
634 634
635 635 /*
636 636 * devmap functions
637 637 */
638 638 int
639 639 devmap_setup(dev_t dev, offset_t off, ddi_as_handle_t as, caddr_t *addrp,
640 640 size_t len, uint_t prot, uint_t maxprot, uint_t flags, struct cred *cred);
641 641
642 642 int
643 643 ddi_devmap_segmap(dev_t dev, off_t off, ddi_as_handle_t as, caddr_t *addrp,
644 644 off_t len, uint_t prot, uint_t maxprot, uint_t flags, struct cred *cred);
645 645
646 646 int
647 647 devmap_load(devmap_cookie_t dhp, offset_t offset, size_t len, uint_t type,
648 648 uint_t rw);
649 649
650 650 int
651 651 devmap_unload(devmap_cookie_t dhp, offset_t offset, size_t len);
652 652
653 653 int
654 654 devmap_devmem_setup(devmap_cookie_t dhp, dev_info_t *dip,
655 655 struct devmap_callback_ctl *callback_ops,
656 656 uint_t rnumber, offset_t roff, size_t len, uint_t maxprot,
657 657 uint_t flags, ddi_device_acc_attr_t *accattrp);
658 658
659 659 int
660 660 devmap_umem_setup(devmap_cookie_t dhp, dev_info_t *dip,
661 661 struct devmap_callback_ctl *callback_ops,
662 662 ddi_umem_cookie_t cookie, offset_t off, size_t len, uint_t maxprot,
663 663 uint_t flags, ddi_device_acc_attr_t *accattrp);
664 664
665 665 int
666 666 devmap_devmem_remap(devmap_cookie_t dhp, dev_info_t *dip,
667 667 uint_t rnumber, offset_t roff, size_t len, uint_t maxprot,
668 668 uint_t flags, ddi_device_acc_attr_t *accattrp);
669 669
670 670 int
671 671 devmap_umem_remap(devmap_cookie_t dhp, dev_info_t *dip,
672 672 ddi_umem_cookie_t cookie, offset_t off, size_t len, uint_t maxprot,
673 673 uint_t flags, ddi_device_acc_attr_t *accattrp);
674 674
675 675 void
676 676 devmap_set_ctx_timeout(devmap_cookie_t dhp, clock_t ticks);
677 677
678 678 int
679 679 devmap_default_access(devmap_cookie_t dhp, void *pvtp, offset_t off,
680 680 size_t len, uint_t type, uint_t rw);
681 681
682 682 int
683 683 devmap_do_ctxmgt(devmap_cookie_t dhp, void *pvtp, offset_t off, size_t len,
684 684 uint_t type, uint_t rw, int (*ctxmgt)(devmap_cookie_t, void *, offset_t,
685 685 size_t, uint_t, uint_t));
686 686
687 687
688 688 void *ddi_umem_alloc(size_t size, int flag, ddi_umem_cookie_t *cookiep);
689 689
690 690 void ddi_umem_free(ddi_umem_cookie_t cookie);
691 691
692 692 /*
693 693 * Functions to lock user memory and do repeated I/O or do devmap_umem_setup
694 694 */
695 695 int
696 696 ddi_umem_lock(caddr_t addr, size_t size, int flags, ddi_umem_cookie_t *cookie);
697 697
698 698 void
699 699 ddi_umem_unlock(ddi_umem_cookie_t cookie);
700 700
701 701 struct buf *
702 702 ddi_umem_iosetup(ddi_umem_cookie_t cookie, off_t off, size_t len, int direction,
703 703 dev_t dev, daddr_t blkno, int (*iodone)(struct buf *), int sleepflag);
704 704
705 705 /*
706 706 * Mapping functions
707 707 */
708 708 int
709 709 ddi_segmap(dev_t dev, off_t offset, struct as *asp, caddr_t *addrp, off_t len,
710 710 uint_t prot, uint_t maxprot, uint_t flags, cred_t *credp);
711 711
712 712 int
713 713 ddi_segmap_setup(dev_t dev, off_t offset, struct as *as, caddr_t *addrp,
714 714 off_t len, uint_t prot, uint_t maxprot, uint_t flags, cred_t *cred,
715 715 ddi_device_acc_attr_t *accattrp, uint_t rnumber);
716 716
717 717 int
718 718 ddi_map_fault(dev_info_t *dip, struct hat *hat, struct seg *seg, caddr_t addr,
719 719 struct devpage *dp, pfn_t pfn, uint_t prot, uint_t lock);
720 720
721 721 int
722 722 ddi_device_mapping_check(dev_t dev, ddi_device_acc_attr_t *accattrp,
723 723 uint_t rnumber, uint_t *hat_flags);
724 724
725 725 /*
726 726 * Property functions: See also, ddipropdefs.h.
727 727 * In general, the underlying driver MUST be held
728 728 * to call it's property functions.
729 729 */
730 730
731 731 /*
732 732 * Used to create, modify, and lookup integer properties
733 733 */
734 734 int ddi_prop_get_int(dev_t match_dev, dev_info_t *dip, uint_t flags,
735 735 char *name, int defvalue);
736 736 int64_t ddi_prop_get_int64(dev_t match_dev, dev_info_t *dip, uint_t flags,
737 737 char *name, int64_t defvalue);
738 738 int ddi_prop_lookup_int_array(dev_t match_dev, dev_info_t *dip, uint_t flags,
739 739 char *name, int **data, uint_t *nelements);
740 740 int ddi_prop_lookup_int64_array(dev_t match_dev, dev_info_t *dip, uint_t flags,
741 741 char *name, int64_t **data, uint_t *nelements);
742 742 int ddi_prop_update_int(dev_t match_dev, dev_info_t *dip,
743 743 char *name, int data);
744 744 int ddi_prop_update_int64(dev_t match_dev, dev_info_t *dip,
745 745 char *name, int64_t data);
746 746 int ddi_prop_update_int_array(dev_t match_dev, dev_info_t *dip,
747 747 char *name, int *data, uint_t nelements);
748 748 int ddi_prop_update_int64_array(dev_t match_dev, dev_info_t *dip,
749 749 char *name, int64_t *data, uint_t nelements);
750 750 /*
751 751 * Used to create, modify, and lookup string properties
752 752 */
753 753 int ddi_prop_lookup_string(dev_t match_dev, dev_info_t *dip, uint_t flags,
754 754 char *name, char **data);
755 755 int ddi_prop_lookup_string_array(dev_t match_dev, dev_info_t *dip, uint_t flags,
756 756 char *name, char ***data, uint_t *nelements);
757 757 int ddi_prop_update_string(dev_t match_dev, dev_info_t *dip,
758 758 char *name, char *data);
759 759 int ddi_prop_update_string_array(dev_t match_dev, dev_info_t *dip,
760 760 char *name, char **data, uint_t nelements);
761 761
762 762 /*
763 763 * Used to create, modify, and lookup byte properties
764 764 */
765 765 int ddi_prop_lookup_byte_array(dev_t match_dev, dev_info_t *dip, uint_t flags,
766 766 char *name, uchar_t **data, uint_t *nelements);
767 767 int ddi_prop_update_byte_array(dev_t match_dev, dev_info_t *dip,
768 768 char *name, uchar_t *data, uint_t nelements);
769 769
770 770 /*
771 771 * Used to verify the existence of a property or to see if a boolean
772 772 * property exists.
773 773 */
774 774 int ddi_prop_exists(dev_t match_dev, dev_info_t *dip, uint_t flags, char *name);
775 775
776 776 /*
777 777 * Used to free the data returned by the above property routines.
778 778 */
779 779 void ddi_prop_free(void *data);
780 780
781 781 /*
782 782 * nopropop: For internal use in `dummy' cb_prop_op functions only
783 783 */
784 784
785 785 int
786 786 nopropop(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op, int mod_flags,
787 787 char *name, caddr_t valuep, int *lengthp);
788 788
789 789 /*
790 790 * ddi_prop_op: The basic property operator for drivers.
791 791 *
792 792 * In ddi_prop_op, the type of valuep is interpreted based on prop_op:
793 793 *
794 794 * prop_op valuep
795 795 * ------ ------
796 796 *
797 797 * PROP_LEN <unused>
798 798 *
799 799 * PROP_LEN_AND_VAL_BUF Pointer to callers buffer
800 800 *
801 801 * PROP_LEN_AND_VAL_ALLOC Address of callers pointer (will be set to
802 802 * address of allocated buffer, if successful)
803 803 */
804 804
805 805 int
806 806 ddi_prop_op(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op, int mod_flags,
807 807 char *name, caddr_t valuep, int *lengthp);
808 808
809 809 /* ddi_prop_op_size: for drivers that implement size in bytes */
810 810 int
811 811 ddi_prop_op_size(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op,
812 812 int mod_flags, char *name, caddr_t valuep, int *lengthp,
813 813 uint64_t size64);
814 814
815 815 /* ddi_prop_op_size_blksize: like ddi_prop_op_size, in blksize blocks */
816 816 int
817 817 ddi_prop_op_size_blksize(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op,
818 818 int mod_flags, char *name, caddr_t valuep, int *lengthp,
819 819 uint64_t size64, uint_t blksize);
820 820
821 821 /* ddi_prop_op_nblocks: for drivers that implement size in DEV_BSIZE blocks */
822 822 int
823 823 ddi_prop_op_nblocks(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op,
824 824 int mod_flags, char *name, caddr_t valuep, int *lengthp,
825 825 uint64_t nblocks64);
826 826
827 827 /* ddi_prop_op_nblocks_blksize: like ddi_prop_op_nblocks, in blksize blocks */
828 828 int
829 829 ddi_prop_op_nblocks_blksize(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op,
830 830 int mod_flags, char *name, caddr_t valuep, int *lengthp,
831 831 uint64_t nblocks64, uint_t blksize);
832 832
833 833 /*
834 834 * Variable length props...
835 835 */
836 836
837 837 /*
838 838 * ddi_getlongprop: Get variable length property len+val into a buffer
839 839 * allocated by property provider via kmem_alloc. Requester
840 840 * is responsible for freeing returned property via kmem_free.
841 841 *
842 842 * Arguments:
843 843 *
844 844 * dev: Input: dev_t of property.
845 845 * dip: Input: dev_info_t pointer of child.
846 846 * flags: Input: Possible flag modifiers are:
847 847 * DDI_PROP_DONTPASS: Don't pass to parent if prop not found.
848 848 * DDI_PROP_CANSLEEP: Memory allocation may sleep.
849 849 * name: Input: name of property.
850 850 * valuep: Output: Addr of callers buffer pointer.
851 851 * lengthp:Output: *lengthp will contain prop length on exit.
852 852 *
853 853 * Possible Returns:
854 854 *
855 855 * DDI_PROP_SUCCESS: Prop found and returned.
856 856 * DDI_PROP_NOT_FOUND: Prop not found
857 857 * DDI_PROP_UNDEFINED: Prop explicitly undefined.
858 858 * DDI_PROP_NO_MEMORY: Prop found, but unable to alloc mem.
859 859 */
860 860
861 861 int
862 862 ddi_getlongprop(dev_t dev, dev_info_t *dip, int flags,
863 863 char *name, caddr_t valuep, int *lengthp);
864 864
865 865 /*
866 866 *
867 867 * ddi_getlongprop_buf: Get long prop into pre-allocated callers
868 868 * buffer. (no memory allocation by provider).
869 869 *
870 870 * dev: Input: dev_t of property.
871 871 * dip: Input: dev_info_t pointer of child.
872 872 * flags: Input: DDI_PROP_DONTPASS or NULL
873 873 * name: Input: name of property
874 874 * valuep: Input: ptr to callers buffer.
875 875 * lengthp:I/O: ptr to length of callers buffer on entry,
876 876 * actual length of property on exit.
877 877 *
878 878 * Possible returns:
879 879 *
880 880 * DDI_PROP_SUCCESS Prop found and returned
881 881 * DDI_PROP_NOT_FOUND Prop not found
882 882 * DDI_PROP_UNDEFINED Prop explicitly undefined.
883 883 * DDI_PROP_BUF_TOO_SMALL Prop found, callers buf too small,
884 884 * no value returned, but actual prop
885 885 * length returned in *lengthp
886 886 *
887 887 */
888 888
889 889 int
890 890 ddi_getlongprop_buf(dev_t dev, dev_info_t *dip, int flags,
891 891 char *name, caddr_t valuep, int *lengthp);
892 892
893 893 /*
894 894 * Integer/boolean sized props.
895 895 *
896 896 * Call is value only... returns found boolean or int sized prop value or
897 897 * defvalue if prop not found or is wrong length or is explicitly undefined.
898 898 * Only flag is DDI_PROP_DONTPASS...
899 899 *
900 900 * By convention, this interface returns boolean (0) sized properties
901 901 * as value (int)1.
902 902 */
903 903
904 904 int
905 905 ddi_getprop(dev_t dev, dev_info_t *dip, int flags, char *name, int defvalue);
906 906
907 907 /*
908 908 * Get prop length interface: flags are 0 or DDI_PROP_DONTPASS
909 909 * if returns DDI_PROP_SUCCESS, length returned in *lengthp.
910 910 */
911 911
912 912 int
913 913 ddi_getproplen(dev_t dev, dev_info_t *dip, int flags, char *name, int *lengthp);
914 914
915 915
916 916 /*
917 917 * Interface to create/modify a managed property on child's behalf...
918 918 * Only flag is DDI_PROP_CANSLEEP to allow memory allocation to sleep
919 919 * if no memory available for internal prop structure. Long property
920 920 * (non integer sized) value references are not copied.
921 921 *
922 922 * Define property with DDI_DEV_T_NONE dev_t for properties not associated
923 923 * with any particular dev_t. Use the same dev_t when modifying or undefining
924 924 * a property.
925 925 *
926 926 * No guarantee on order of property search, so don't mix the same
927 927 * property name with wildcard and non-wildcard dev_t's.
928 928 */
929 929
930 930 /*
931 931 * ddi_prop_create: Define a managed property:
932 932 */
933 933
934 934 int
935 935 ddi_prop_create(dev_t dev, dev_info_t *dip, int flag,
936 936 char *name, caddr_t value, int length);
937 937
938 938 /*
939 939 * ddi_prop_modify: Modify a managed property value
940 940 */
941 941
942 942 int
943 943 ddi_prop_modify(dev_t dev, dev_info_t *dip, int flag,
944 944 char *name, caddr_t value, int length);
945 945
946 946 /*
947 947 * ddi_prop_remove: Undefine a managed property:
948 948 */
949 949
950 950 int
951 951 ddi_prop_remove(dev_t dev, dev_info_t *dip, char *name);
952 952
953 953 /*
954 954 * ddi_prop_remove_all: Used before unloading a driver to remove
955 955 * all properties. (undefines all dev_t's props.)
956 956 * Also removes `undefined' prop defs.
957 957 */
958 958
959 959 void
960 960 ddi_prop_remove_all(dev_info_t *dip);
961 961
962 962
963 963 /*
964 964 * ddi_prop_undefine: Explicitly undefine a property. Property
965 965 * searches which match this property return
966 966 * the error code DDI_PROP_UNDEFINED.
967 967 *
968 968 * Use ddi_prop_remove to negate effect of
969 969 * ddi_prop_undefine
970 970 */
971 971
972 972 int
973 973 ddi_prop_undefine(dev_t dev, dev_info_t *dip, int flag, char *name);
974 974
975 975
976 976 /*
977 977 * ddi_prop_cache_invalidate
978 978 * Invalidate a property in the current cached
979 979 * devinfo snapshot - next cached snapshot will
980 980 * return the latest property value available.
981 981 */
982 982 void
983 983 ddi_prop_cache_invalidate(dev_t dev, dev_info_t *dip, char *name, int flags);
984 984
985 985 /*
986 986 * The default ddi_bus_prop_op wrapper...
987 987 */
988 988
989 989 int
990 990 ddi_bus_prop_op(dev_t dev, dev_info_t *dip, dev_info_t *ch_dip,
991 991 ddi_prop_op_t prop_op, int mod_flags,
992 992 char *name, caddr_t valuep, int *lengthp);
993 993
994 994
995 995 /*
996 996 * Routines to traverse the tree of dev_info nodes.
997 997 * The general idea of these functions is to provide
998 998 * various tree traversal utilities. For each node
999 999 * that the tree traversal function finds, a caller
1000 1000 * supplied function is called with arguments of
1001 1001 * the current node and a caller supplied argument.
1002 1002 * The caller supplied function should return one
1003 1003 * of the integer values defined below which will
1004 1004 * indicate to the tree traversal function whether
1005 1005 * the traversal should be continued, and if so, how,
1006 1006 * or whether the traversal should terminate.
1007 1007 */
1008 1008
1009 1009 /*
1010 1010 * This general-purpose routine traverses the tree of dev_info nodes,
1011 1011 * starting from the given node, and calls the given function for each
1012 1012 * node that it finds with the current node and the pointer arg (which
1013 1013 * can point to a structure of information that the function
1014 1014 * needs) as arguments.
1015 1015 *
1016 1016 * It does the walk a layer at a time, not depth-first.
1017 1017 *
1018 1018 * The given function must return one of the values defined above.
1019 1019 *
1020 1020 */
1021 1021
1022 1022 void
1023 1023 ddi_walk_devs(dev_info_t *, int (*)(dev_info_t *, void *), void *);
1024 1024
1025 1025 /*
1026 1026 * Routines to get at elements of the dev_info structure
1027 1027 */
1028 1028
1029 1029 /*
1030 1030 * ddi_node_name gets the device's 'name' from the device node.
1031 1031 *
1032 1032 * ddi_binding_name gets the string the OS used to bind the node to a driver,
1033 1033 * in certain cases, the binding name may be different from the node name,
1034 1034 * if the node name does not name a specific device driver.
1035 1035 *
1036 1036 * ddi_get_name is a synonym for ddi_binding_name().
1037 1037 */
1038 1038 char *
1039 1039 ddi_get_name(dev_info_t *dip);
1040 1040
1041 1041 char *
1042 1042 ddi_binding_name(dev_info_t *dip);
1043 1043
1044 1044 const char *
1045 1045 ddi_driver_name(dev_info_t *dip);
1046 1046
1047 1047 major_t
1048 1048 ddi_driver_major(dev_info_t *dip);
1049 1049
1050 1050 major_t
1051 1051 ddi_compatible_driver_major(dev_info_t *dip, char **formp);
1052 1052
1053 1053 char *
1054 1054 ddi_node_name(dev_info_t *dip);
1055 1055
1056 1056 int
1057 1057 ddi_get_nodeid(dev_info_t *dip);
1058 1058
1059 1059 int
1060 1060 ddi_get_instance(dev_info_t *dip);
1061 1061
1062 1062 struct dev_ops *
1063 1063 ddi_get_driver(dev_info_t *dip);
1064 1064
1065 1065 void
1066 1066 ddi_set_driver(dev_info_t *dip, struct dev_ops *devo);
1067 1067
1068 1068 void
1069 1069 ddi_set_driver_private(dev_info_t *dip, void *data);
1070 1070
1071 1071 void *
1072 1072 ddi_get_driver_private(dev_info_t *dip);
1073 1073
1074 1074 /*
1075 1075 * ddi_dev_is_needed tells system that a device is about to use a
1076 1076 * component. Returns when component is ready.
1077 1077 */
1078 1078 int
1079 1079 ddi_dev_is_needed(dev_info_t *dip, int cmpt, int level);
1080 1080
1081 1081 /*
1082 1082 * check if DDI_SUSPEND may result in power being removed from a device.
1083 1083 */
1084 1084 int
1085 1085 ddi_removing_power(dev_info_t *dip);
1086 1086
1087 1087 /*
1088 1088 * (Obsolete) power entry point
1089 1089 */
1090 1090 int
1091 1091 ddi_power(dev_info_t *dip, int cmpt, int level);
1092 1092
1093 1093 /*
1094 1094 * ddi_get_parent requires that the branch of the tree with the
1095 1095 * node be held (ddi_hold_installed_driver) or that the devinfo tree
1096 1096 * lock be held
1097 1097 */
1098 1098 dev_info_t *
1099 1099 ddi_get_parent(dev_info_t *dip);
1100 1100
1101 1101 /*
1102 1102 * ddi_get_child and ddi_get_next_sibling require that the devinfo
1103 1103 * tree lock be held
1104 1104 */
1105 1105 dev_info_t *
1106 1106 ddi_get_child(dev_info_t *dip);
1107 1107
1108 1108 dev_info_t *
1109 1109 ddi_get_next_sibling(dev_info_t *dip);
1110 1110
1111 1111 dev_info_t *
1112 1112 ddi_get_next(dev_info_t *dip);
1113 1113
1114 1114 void
1115 1115 ddi_set_next(dev_info_t *dip, dev_info_t *nextdip);
1116 1116
1117 1117 /*
1118 1118 * dev_info manipulation functions
1119 1119 */
1120 1120
1121 1121 /*
1122 1122 * Add and remove child devices. These are part of the system framework.
1123 1123 *
1124 1124 * ddi_add_child creates a dev_info structure with the passed name,
1125 1125 * nodeid and instance arguments and makes it a child of pdip. Devices
1126 1126 * that are known directly by the hardware have real nodeids; devices
1127 1127 * that are software constructs use the defined DEVI_PSEUDO_NODEID
1128 1128 * for the node id.
1129 1129 *
1130 1130 * ddi_remove_node removes the node from the tree. This fails if this
1131 1131 * child has children. Parent and driver private data should already
1132 1132 * be released (freed) prior to calling this function. If flag is
1133 1133 * non-zero, the child is removed from it's linked list of instances.
1134 1134 */
1135 1135 dev_info_t *
1136 1136 ddi_add_child(dev_info_t *pdip, char *name, uint_t nodeid, uint_t instance);
1137 1137
1138 1138 int
1139 1139 ddi_remove_child(dev_info_t *dip, int flag);
1140 1140
1141 1141 /*
1142 1142 * Given the major number for a driver, make sure that dev_info nodes
1143 1143 * are created form the driver's hwconf file, the driver for the named
1144 1144 * device is loaded and attached, as well as any drivers for parent devices.
1145 1145 * Return a pointer to the driver's dev_ops struct with the dev_ops held.
1146 1146 * Note - Callers must release the dev_ops with ddi_rele_driver.
1147 1147 *
1148 1148 * When a driver is held, the branch of the devinfo tree from any of the
1149 1149 * drivers devinfos to the root node are automatically held. This only
1150 1150 * applies to tree traversals up (and back down) the tree following the
1151 1151 * parent pointers.
1152 1152 *
1153 1153 * Use of this interface is discouraged, it may be removed in a future release.
1154 1154 */
1155 1155 struct dev_ops *
1156 1156 ddi_hold_installed_driver(major_t major);
1157 1157
1158 1158 void
1159 1159 ddi_rele_driver(major_t major);
1160 1160
1161 1161 /*
1162 1162 * Attach and hold the specified instance of a driver. The flags argument
1163 1163 * should be zero.
1164 1164 */
1165 1165 dev_info_t *
1166 1166 ddi_hold_devi_by_instance(major_t major, int instance, int flags);
1167 1167
1168 1168 void
1169 1169 ddi_release_devi(dev_info_t *);
1170 1170
1171 1171 /*
1172 1172 * Associate a streams queue with a devinfo node
1173 1173 */
1174 1174 void
1175 1175 ddi_assoc_queue_with_devi(queue_t *, dev_info_t *);
1176 1176
1177 1177 /*
1178 1178 * Given the identifier string passed, make sure that dev_info nodes
1179 1179 * are created form the driver's hwconf file, the driver for the named
1180 1180 * device is loaded and attached, as well as any drivers for parent devices.
1181 1181 *
1182 1182 * Note that the driver is not held and is subject to being removed the instant
1183 1183 * this call completes. You probably really want ddi_hold_installed_driver.
1184 1184 */
1185 1185 int
1186 1186 ddi_install_driver(char *idstring);
1187 1187
1188 1188 /*
1189 1189 * Routines that return specific nodes
1190 1190 */
1191 1191
1192 1192 dev_info_t *
1193 1193 ddi_root_node(void);
1194 1194
1195 1195 /*
1196 1196 * Given a name and an instance number, find and return the
1197 1197 * dev_info from the current state of the device tree.
1198 1198 *
1199 1199 * If instance number is -1, return the first named instance.
1200 1200 *
1201 1201 * If attached is 1, exclude all nodes that are < DS_ATTACHED
1202 1202 *
1203 1203 * Requires that the devinfo tree be locked.
1204 1204 * If attached is 1, the driver must be held.
1205 1205 */
1206 1206 dev_info_t *
1207 1207 ddi_find_devinfo(char *name, int instance, int attached);
1208 1208
1209 1209 /*
1210 1210 * Synchronization of I/O with respect to various
1211 1211 * caches and system write buffers.
1212 1212 *
1213 1213 * Done at varying points during an I/O transfer (including at the
1214 1214 * removal of an I/O mapping).
1215 1215 *
1216 1216 * Due to the support of systems with write buffers which may
1217 1217 * not be able to be turned off, this function *must* used at
1218 1218 * any point in which data consistency might be required.
1219 1219 *
1220 1220 * Generally this means that if a memory object has multiple mappings
1221 1221 * (both for I/O, as described by the handle, and the IU, via, e.g.
1222 1222 * a call to ddi_dma_kvaddrp), and one mapping may have been
1223 1223 * used to modify the memory object, this function must be called
1224 1224 * to ensure that the modification of the memory object is
1225 1225 * complete, as well as possibly to inform other mappings of
1226 1226 * the object that any cached references to the object are
1227 1227 * now stale (and flush or invalidate these stale cache references
1228 1228 * as necessary).
1229 1229 *
1230 1230 * The function ddi_dma_sync() provides the general interface with
1231 1231 * respect to this capability. Generally, ddi_dma_free() (below) may
1232 1232 * be used in preference to ddi_dma_sync() as ddi_dma_free() calls
1233 1233 * ddi_dma_sync().
1234 1234 *
1235 1235 * Returns 0 if all caches that exist and are specified by cache_flags
1236 1236 * are successfully operated on, else -1.
1237 1237 *
1238 1238 * The argument offset specifies an offset into the mapping of the mapped
1239 1239 * object in which to perform the synchronization. It will be silently
1240 1240 * truncated to the granularity of underlying cache line sizes as
1241 1241 * appropriate.
1242 1242 *
1243 1243 * The argument len specifies a length starting from offset in which to
1244 1244 * perform the synchronization. A value of (uint_t) -1 means that the length
1245 1245 * proceeds from offset to the end of the mapping. The length argument
1246 1246 * will silently rounded up to the granularity of underlying cache line
1247 1247 * sizes as appropriate.
1248 1248 *
1249 1249 * The argument flags specifies what to synchronize (the device's view of
1250 1250 * the object or the cpu's view of the object).
1251 1251 *
1252 1252 * Inquiring minds want to know when ddi_dma_sync should be used:
1253 1253 *
1254 1254 * + When an object is mapped for dma, assume that an
1255 1255 * implicit ddi_dma_sync() is done for you.
1256 1256 *
1257 1257 * + When an object is unmapped (ddi_dma_free()), assume
1258 1258 * that an implicit ddi_dma_sync() is done for you.
1259 1259 *
1260 1260 * + At any time between the two times above that the
1261 1261 * memory object may have been modified by either
1262 1262 * the DMA device or a processor and you wish that
1263 1263 * the change be noticed by the master that didn't
1264 1264 * do the modifying.
1265 1265 *
1266 1266 * Clearly, only the third case above requires the use of ddi_dma_sync.
1267 1267 *
1268 1268 * Inquiring minds also want to know which flag to use:
1269 1269 *
1270 1270 * + If you *modify* with a cpu the object, you use
1271 1271 * ddi_dma_sync(...DDI_DMA_SYNC_FORDEV) (you are making sure
1272 1272 * that the DMA device sees the changes you made).
1273 1273 *
1274 1274 * + If you are checking, with the processor, an area
1275 1275 * of the object that the DMA device *may* have modified,
1276 1276 * you use ddi_dma_sync(....DDI_DMA_SYNC_FORCPU) (you are
1277 1277 * making sure that the processor(s) will see the changes
1278 1278 * that the DMA device may have made).
1279 1279 */
1280 1280
1281 1281 int
1282 1282 ddi_dma_sync(ddi_dma_handle_t handle, off_t offset, size_t len, uint_t flags);
1283 1283
1284 1284 /*
1285 1285 * Return the allowable DMA burst size for the object mapped by handle.
1286 1286 * The burst sizes will returned in an integer that encodes power
1287 1287 * of two burst sizes that are allowed in bit encoded format. For
1288 1288 * example, a transfer that could allow 1, 2, 4, 8 and 32 byte bursts
1289 1289 * would be encoded as 0x2f. A transfer that could be allowed as solely
1290 1290 * a halfword (2 byte) transfers would be returned as 0x2.
1291 1291 */
1292 1292
1293 1293 int
1294 1294 ddi_dma_burstsizes(ddi_dma_handle_t handle);
1295 1295
1296 1296 /*
1297 1297 * Merge DMA attributes
1298 1298 */
1299 1299
1300 1300 void
1301 1301 ddi_dma_attr_merge(ddi_dma_attr_t *attr, ddi_dma_attr_t *mod);
1302 1302
1303 1303 /*
1304 1304 * Allocate a DMA handle
1305 1305 */
1306 1306
1307 1307 int
1308 1308 ddi_dma_alloc_handle(dev_info_t *dip, ddi_dma_attr_t *attr,
1309 1309 int (*waitfp)(caddr_t), caddr_t arg,
1310 1310 ddi_dma_handle_t *handlep);
1311 1311
1312 1312 /*
1313 1313 * Free DMA handle
1314 1314 */
1315 1315
1316 1316 void
1317 1317 ddi_dma_free_handle(ddi_dma_handle_t *handlep);
1318 1318
1319 1319 /*
1320 1320 * Allocate memory for DMA transfers
1321 1321 */
1322 1322
1323 1323 int
1324 1324 ddi_dma_mem_alloc(ddi_dma_handle_t handle, size_t length,
1325 1325 ddi_device_acc_attr_t *accattrp, uint_t xfermodes,
1326 1326 int (*waitfp)(caddr_t), caddr_t arg, caddr_t *kaddrp,
1327 1327 size_t *real_length, ddi_acc_handle_t *handlep);
1328 1328
1329 1329 /*
1330 1330 * Free DMA memory
1331 1331 */
1332 1332
1333 1333 void
1334 1334 ddi_dma_mem_free(ddi_acc_handle_t *hp);
1335 1335
1336 1336 /*
1337 1337 * bind address to a DMA handle
1338 1338 */
1339 1339
1340 1340 int
1341 1341 ddi_dma_addr_bind_handle(ddi_dma_handle_t handle, struct as *as,
1342 1342 caddr_t addr, size_t len, uint_t flags,
1343 1343 int (*waitfp)(caddr_t), caddr_t arg,
1344 1344 ddi_dma_cookie_t *cookiep, uint_t *ccountp);
1345 1345
1346 1346 /*
1347 1347 * bind buffer to DMA handle
1348 1348 */
1349 1349
1350 1350 int
1351 1351 ddi_dma_buf_bind_handle(ddi_dma_handle_t handle, struct buf *bp,
1352 1352 uint_t flags, int (*waitfp)(caddr_t), caddr_t arg,
1353 1353 ddi_dma_cookie_t *cookiep, uint_t *ccountp);
1354 1354
1355 1355 /*
1356 1356 * unbind mapping object to handle
1357 1357 */
1358 1358
1359 1359 int
1360 1360 ddi_dma_unbind_handle(ddi_dma_handle_t handle);
1361 1361
1362 1362 /*
1363 1363 * get next DMA cookie
1364 1364 */
1365 1365
1366 1366 void
1367 1367 ddi_dma_nextcookie(ddi_dma_handle_t handle, ddi_dma_cookie_t *cookiep);
1368 1368
1369 1369 /*
1370 1370 * get number of DMA windows
1371 1371 */
1372 1372
1373 1373 int
1374 1374 ddi_dma_numwin(ddi_dma_handle_t handle, uint_t *nwinp);
1375 1375
1376 1376 /*
1377 1377 * get specific DMA window
1378 1378 */
1379 1379
1380 1380 int
1381 1381 ddi_dma_getwin(ddi_dma_handle_t handle, uint_t win, off_t *offp,
1382 1382 size_t *lenp, ddi_dma_cookie_t *cookiep, uint_t *ccountp);
1383 1383
1384 1384 /*
1385 1385 * activate 64 bit SBus support
1386 1386 */
1387 1387
1388 1388 int
1389 1389 ddi_dma_set_sbus64(ddi_dma_handle_t handle, ulong_t burstsizes);
1390 1390
1391 1391 /*
1392 1392 * Miscellaneous functions
1393 1393 */
1394 1394
1395 1395 /*
1396 1396 * ddi_report_dev: Report a successful attach.
1397 1397 */
1398 1398
1399 1399 void
1400 1400 ddi_report_dev(dev_info_t *dev);
1401 1401
1402 1402 /*
1403 1403 * ddi_dev_regsize
1404 1404 *
1405 1405 * If the device has h/w register(s), report
1406 1406 * the size, in bytes, of the specified one into *resultp.
1407 1407 *
1408 1408 * Returns DDI_FAILURE if there are not registers,
1409 1409 * or the specified register doesn't exist.
1410 1410 */
1411 1411
1412 1412 int
1413 1413 ddi_dev_regsize(dev_info_t *dev, uint_t rnumber, off_t *resultp);
1414 1414
1415 1415 /*
1416 1416 * ddi_dev_nregs
1417 1417 *
1418 1418 * If the device has h/w register(s), report
1419 1419 * how many of them that there are into resultp.
1420 1420 * Return DDI_FAILURE if the device has no registers.
1421 1421 */
1422 1422
1423 1423 int
1424 1424 ddi_dev_nregs(dev_info_t *dev, int *resultp);
1425 1425
1426 1426 /*
1427 1427 * ddi_dev_is_sid
1428 1428 *
1429 1429 * If the device is self-identifying, i.e.,
1430 1430 * has already been probed by a smart PROM
1431 1431 * (and thus registers are known to be valid)
1432 1432 * return DDI_SUCCESS, else DDI_FAILURE.
1433 1433 */
1434 1434
1435 1435
1436 1436 int
1437 1437 ddi_dev_is_sid(dev_info_t *dev);
1438 1438
1439 1439 /*
1440 1440 * ddi_slaveonly
1441 1441 *
1442 1442 * If the device is on a bus that precludes
1443 1443 * the device from being either a dma master or
1444 1444 * a dma slave, return DDI_SUCCESS.
1445 1445 */
1446 1446
1447 1447 int
1448 1448 ddi_slaveonly(dev_info_t *);
1449 1449
1450 1450
1451 1451 /*
1452 1452 * ddi_dev_affinity
1453 1453 *
1454 1454 * Report, via DDI_SUCCESS, whether there exists
1455 1455 * an 'affinity' between two dev_info_t's. An
1456 1456 * affinity is defined to be either a parent-child,
1457 1457 * or a sibling relationship such that the siblings
1458 1458 * or in the same part of the bus they happen to be
1459 1459 * on.
1460 1460 */
1461 1461
1462 1462 int
1463 1463 ddi_dev_affinity(dev_info_t *deva, dev_info_t *devb);
1464 1464
1465 1465
1466 1466 /*
1467 1467 * ddi_set_callback
1468 1468 *
1469 1469 * Set a function/arg pair into the callback list identified
1470 1470 * by listid. *listid must always initially start out as zero.
1471 1471 */
1472 1472
1473 1473 void
1474 1474 ddi_set_callback(int (*funcp)(caddr_t), caddr_t arg, uintptr_t *listid);
1475 1475
1476 1476 /*
1477 1477 * ddi_run_callback
1478 1478 *
1479 1479 * Run the callback list identified by listid.
1480 1480 */
1481 1481
1482 1482 void
1483 1483 ddi_run_callback(uintptr_t *listid);
1484 1484
1485 1485 /*
1486 1486 * More miscellaneous
1487 1487 */
1488 1488
1489 1489 int
1490 1490 nochpoll(dev_t dev, short events, int anyyet, short *reventsp,
1491 1491 struct pollhead **phpp);
1492 1492
1493 1493 dev_info_t *
1494 1494 nodevinfo(dev_t dev, int otyp);
1495 1495
1496 1496 int
1497 1497 ddi_no_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result);
1498 1498
1499 1499 int
1500 1500 ddi_getinfo_1to1(dev_info_t *dip, ddi_info_cmd_t infocmd,
1501 1501 void *arg, void **result);
1502 1502
1503 1503 int
1504 1504 ddifail(dev_info_t *devi, ddi_attach_cmd_t cmd);
1505 1505
1506 1506 int
1507 1507 ddi_no_dma_map(dev_info_t *dip, dev_info_t *rdip,
1508 1508 struct ddi_dma_req *dmareqp, ddi_dma_handle_t *handlep);
1509 1509
1510 1510 int
1511 1511 ddi_no_dma_allochdl(dev_info_t *dip, dev_info_t *rdip, ddi_dma_attr_t *attr,
1512 1512 int (*waitfp)(caddr_t), caddr_t arg, ddi_dma_handle_t *handlep);
1513 1513
1514 1514 int
1515 1515 ddi_no_dma_freehdl(dev_info_t *dip, dev_info_t *rdip,
1516 1516 ddi_dma_handle_t handle);
1517 1517
1518 1518 int
1519 1519 ddi_no_dma_bindhdl(dev_info_t *dip, dev_info_t *rdip,
1520 1520 ddi_dma_handle_t handle, struct ddi_dma_req *dmareq,
1521 1521 ddi_dma_cookie_t *cp, uint_t *ccountp);
1522 1522
1523 1523 int
1524 1524 ddi_no_dma_unbindhdl(dev_info_t *dip, dev_info_t *rdip,
1525 1525 ddi_dma_handle_t handle);
1526 1526
1527 1527 int
1528 1528 ddi_no_dma_flush(dev_info_t *dip, dev_info_t *rdip,
1529 1529 ddi_dma_handle_t handle, off_t off, size_t len,
1530 1530 uint_t cache_flags);
1531 1531
1532 1532 int
1533 1533 ddi_no_dma_win(dev_info_t *dip, dev_info_t *rdip,
1534 1534 ddi_dma_handle_t handle, uint_t win, off_t *offp,
1535 1535 size_t *lenp, ddi_dma_cookie_t *cookiep, uint_t *ccountp);
1536 1536
1537 1537 int
1538 1538 ddi_no_dma_mctl(register dev_info_t *dip, dev_info_t *rdip,
1539 1539 ddi_dma_handle_t handle, enum ddi_dma_ctlops request,
1540 1540 off_t *offp, size_t *lenp, caddr_t *objp, uint_t flags);
1541 1541
1542 1542 void
1543 1543 ddivoid();
1544 1544
1545 1545 cred_t *
1546 1546 ddi_get_cred(void);
1547 1547
1548 1548 time_t
1549 1549 ddi_get_time(void);
1550 1550
1551 1551 pid_t
1552 1552 ddi_get_pid(void);
1553 1553
1554 1554 kt_did_t
1555 1555 ddi_get_kt_did(void);
1556 1556
1557 1557 boolean_t
1558 1558 ddi_can_receive_sig(void);
1559 1559
1560 1560 void
1561 1561 swab(void *src, void *dst, size_t nbytes);
1562 1562
1563 1563 int
1564 1564 ddi_create_minor_node(dev_info_t *dip, char *name, int spec_type,
1565 1565 minor_t minor_num, char *node_type, int flag);
1566 1566
1567 1567 int
1568 1568 ddi_create_priv_minor_node(dev_info_t *dip, char *name, int spec_type,
1569 1569 minor_t minor_num, char *node_type, int flag,
1570 1570 const char *rdpriv, const char *wrpriv, mode_t priv_mode);
1571 1571
1572 1572 void
1573 1573 ddi_remove_minor_node(dev_info_t *dip, char *name);
1574 1574
1575 1575 int
1576 1576 ddi_in_panic(void);
1577 1577
↓ open down ↓ |
1577 lines elided |
↑ open up ↑ |
1578 1578 int
1579 1579 ddi_streams_driver(dev_info_t *dip);
1580 1580
1581 1581 /*
1582 1582 * DDI wrappers for ffs and fls
1583 1583 */
1584 1584 int
1585 1585 ddi_ffs(long mask);
1586 1586
1587 1587 int
1588 +ddi_ffsll(long long mask);
1589 +
1590 +int
1588 1591 ddi_fls(long mask);
1589 1592
1593 +int
1594 +ddi_flsll(long long mask);
1595 +
1590 1596 /*
1591 1597 * The ddi_soft_state* routines comprise generic storage management utilities
1592 1598 * for driver soft state structures. Two types of soft_state indexes are
1593 1599 * supported: 'integer index', and 'string index'.
1594 1600 */
1595 1601 typedef struct __ddi_soft_state_bystr ddi_soft_state_bystr;
1596 1602
1597 1603 /*
1598 1604 * Initialize a soft_state set, establishing the 'size' of soft state objects
1599 1605 * in the set.
1600 1606 *
1601 1607 * For an 'integer indexed' soft_state set, the initial set will accommodate
1602 1608 * 'n_items' objects - 'n_items' is a hint (i.e. zero is allowed), allocations
1603 1609 * that exceed 'n_items' have additional overhead.
1604 1610 *
1605 1611 * For a 'string indexed' soft_state set, 'n_items' should be the typical
1606 1612 * number of soft state objects in the set - 'n_items' is a hint, there may
1607 1613 * be additional overhead if the hint is too small (and wasted memory if the
1608 1614 * hint is too big).
1609 1615 */
1610 1616 int
1611 1617 ddi_soft_state_init(void **state_p, size_t size, size_t n_items);
1612 1618 int
1613 1619 ddi_soft_state_bystr_init(ddi_soft_state_bystr **state_p,
1614 1620 size_t size, int n_items);
1615 1621
1616 1622 /*
1617 1623 * Allocate a soft state object associated with either 'integer index' or
1618 1624 * 'string index' from a soft_state set.
1619 1625 */
1620 1626 int
1621 1627 ddi_soft_state_zalloc(void *state, int item);
1622 1628 int
1623 1629 ddi_soft_state_bystr_zalloc(ddi_soft_state_bystr *state, const char *str);
1624 1630
1625 1631 /*
1626 1632 * Get the pointer to the allocated soft state object associated with
1627 1633 * either 'integer index' or 'string index'.
1628 1634 */
1629 1635 void *
1630 1636 ddi_get_soft_state(void *state, int item);
1631 1637 void *
1632 1638 ddi_soft_state_bystr_get(ddi_soft_state_bystr *state, const char *str);
1633 1639
1634 1640 /*
1635 1641 * Free the soft state object associated with either 'integer index'
1636 1642 * or 'string index'.
1637 1643 */
1638 1644 void
1639 1645 ddi_soft_state_free(void *state, int item);
1640 1646 void
1641 1647 ddi_soft_state_bystr_free(ddi_soft_state_bystr *state, const char *str);
1642 1648
1643 1649 /*
1644 1650 * Free the soft state set and any associated soft state objects.
1645 1651 */
1646 1652 void
1647 1653 ddi_soft_state_fini(void **state_p);
1648 1654 void
1649 1655 ddi_soft_state_bystr_fini(ddi_soft_state_bystr **state_p);
1650 1656
1651 1657 /*
1652 1658 * The ddi_strid_* routines provide string-to-index management utilities.
1653 1659 */
1654 1660 typedef struct __ddi_strid ddi_strid;
1655 1661 int
1656 1662 ddi_strid_init(ddi_strid **strid_p, int n_items);
1657 1663 id_t
1658 1664 ddi_strid_alloc(ddi_strid *strid, char *str);
1659 1665 id_t
1660 1666 ddi_strid_str2id(ddi_strid *strid, char *str);
1661 1667 char *
1662 1668 ddi_strid_id2str(ddi_strid *strid, id_t id);
1663 1669 void
1664 1670 ddi_strid_free(ddi_strid *strid, id_t id);
1665 1671 void
1666 1672 ddi_strid_fini(ddi_strid **strid_p);
1667 1673
1668 1674 /*
1669 1675 * Set the addr field of the name in dip to name
1670 1676 */
1671 1677 void
1672 1678 ddi_set_name_addr(dev_info_t *dip, char *name);
1673 1679
1674 1680 /*
1675 1681 * Get the address part of the name.
1676 1682 */
1677 1683 char *
1678 1684 ddi_get_name_addr(dev_info_t *dip);
1679 1685
1680 1686 void
1681 1687 ddi_set_parent_data(dev_info_t *dip, void *pd);
1682 1688
1683 1689 void *
1684 1690 ddi_get_parent_data(dev_info_t *dip);
1685 1691
1686 1692 int
1687 1693 ddi_initchild(dev_info_t *parent, dev_info_t *proto);
1688 1694
1689 1695 int
1690 1696 ddi_uninitchild(dev_info_t *dip);
1691 1697
1692 1698 major_t
1693 1699 ddi_name_to_major(char *name);
1694 1700
1695 1701 char *
1696 1702 ddi_major_to_name(major_t major);
1697 1703
1698 1704 char *
1699 1705 ddi_deviname(dev_info_t *dip, char *name);
1700 1706
1701 1707 char *
1702 1708 ddi_pathname(dev_info_t *dip, char *path);
1703 1709
1704 1710 char *
1705 1711 ddi_pathname_minor(struct ddi_minor_data *dmdp, char *path);
1706 1712
1707 1713 char *
1708 1714 ddi_pathname_obp(dev_info_t *dip, char *path);
1709 1715
1710 1716 int
1711 1717 ddi_pathname_obp_set(dev_info_t *dip, char *component);
1712 1718
1713 1719 int
1714 1720 ddi_dev_pathname(dev_t devt, int spec_type, char *name);
1715 1721
1716 1722 dev_t
1717 1723 ddi_pathname_to_dev_t(char *pathname);
1718 1724
1719 1725 /*
1720 1726 * High resolution system timer functions.
1721 1727 *
1722 1728 * These functions are already in the kernel (see sys/time.h).
1723 1729 * The ddi supports the notion of a hrtime_t type and the
1724 1730 * functions gethrtime, hrtadd, hrtsub and hrtcmp.
1725 1731 */
1726 1732
1727 1733
1728 1734 /*
1729 1735 * Nexus wrapper functions
1730 1736 *
1731 1737 * These functions are for entries in a bus nexus driver's bus_ops
1732 1738 * structure for when the driver doesn't have such a function and
1733 1739 * doesn't wish to prohibit such a function from existing. They
1734 1740 * may also be called to start passing a request up the dev_info
1735 1741 * tree.
1736 1742 */
1737 1743
1738 1744 /*
1739 1745 * bus_ctl wrapper
1740 1746 */
1741 1747
1742 1748 int
1743 1749 ddi_ctlops(dev_info_t *d, dev_info_t *r, ddi_ctl_enum_t o, void *a, void *v);
1744 1750
1745 1751 /*
1746 1752 * bus_dma_map wrapper
1747 1753 */
1748 1754
1749 1755 int
1750 1756 ddi_dma_allochdl(dev_info_t *dip, dev_info_t *rdip, ddi_dma_attr_t *attr,
1751 1757 int (*waitfp)(caddr_t), caddr_t arg, ddi_dma_handle_t *handlep);
1752 1758
1753 1759 int
1754 1760 ddi_dma_freehdl(dev_info_t *dip, dev_info_t *rdip,
1755 1761 ddi_dma_handle_t handle);
1756 1762
1757 1763 int
1758 1764 ddi_dma_bindhdl(dev_info_t *dip, dev_info_t *rdip,
1759 1765 ddi_dma_handle_t handle, struct ddi_dma_req *dmareq,
1760 1766 ddi_dma_cookie_t *cp, uint_t *ccountp);
1761 1767
1762 1768 int
1763 1769 ddi_dma_unbindhdl(dev_info_t *dip, dev_info_t *rdip,
1764 1770 ddi_dma_handle_t handle);
1765 1771
1766 1772 int
1767 1773 ddi_dma_flush(dev_info_t *dip, dev_info_t *rdip,
1768 1774 ddi_dma_handle_t handle, off_t off, size_t len,
1769 1775 uint_t cache_flags);
1770 1776
1771 1777 int
1772 1778 ddi_dma_win(dev_info_t *dip, dev_info_t *rdip,
1773 1779 ddi_dma_handle_t handle, uint_t win, off_t *offp,
1774 1780 size_t *lenp, ddi_dma_cookie_t *cookiep, uint_t *ccountp);
1775 1781
1776 1782 /*
1777 1783 * bus_dma_ctl wrapper
1778 1784 */
1779 1785
1780 1786 int
1781 1787 ddi_dma_mctl(dev_info_t *dip, dev_info_t *rdip, ddi_dma_handle_t handle,
1782 1788 enum ddi_dma_ctlops request, off_t *offp, size_t *lenp,
1783 1789 caddr_t *objp, uint_t flags);
1784 1790
1785 1791 /*
1786 1792 * dvma support for networking drivers
1787 1793 */
1788 1794
1789 1795 unsigned long
1790 1796 dvma_pagesize(dev_info_t *dip);
1791 1797
1792 1798 int
1793 1799 dvma_reserve(dev_info_t *dip, ddi_dma_lim_t *limp, uint_t pages,
1794 1800 ddi_dma_handle_t *handlep);
1795 1801
1796 1802 void
1797 1803 dvma_release(ddi_dma_handle_t h);
1798 1804
1799 1805 void
1800 1806 dvma_kaddr_load(ddi_dma_handle_t h, caddr_t a, uint_t len, uint_t index,
1801 1807 ddi_dma_cookie_t *cp);
1802 1808
1803 1809 void
1804 1810 dvma_unload(ddi_dma_handle_t h, uint_t objindex, uint_t type);
1805 1811
1806 1812 void
1807 1813 dvma_sync(ddi_dma_handle_t h, uint_t objindex, uint_t type);
1808 1814
1809 1815 /*
1810 1816 * Layered driver support
1811 1817 */
1812 1818
1813 1819 extern int ddi_copyin(const void *, void *, size_t, int);
1814 1820 extern int ddi_copyout(const void *, void *, size_t, int);
1815 1821
1816 1822 /*
1817 1823 * Send signals to processes
1818 1824 */
1819 1825 extern void *proc_ref(void);
1820 1826 extern void proc_unref(void *pref);
1821 1827 extern int proc_signal(void *pref, int sig);
1822 1828
1823 1829 /* I/O port access routines */
1824 1830 extern uint8_t inb(int port);
1825 1831 extern uint16_t inw(int port);
1826 1832 extern uint32_t inl(int port);
1827 1833 extern void outb(int port, uint8_t value);
1828 1834 extern void outw(int port, uint16_t value);
1829 1835 extern void outl(int port, uint32_t value);
1830 1836
1831 1837 /*
1832 1838 * Console bell routines
1833 1839 */
1834 1840 extern void ddi_ring_console_bell(clock_t duration);
1835 1841 extern void ddi_set_console_bell(void (*bellfunc)(clock_t duration));
1836 1842
1837 1843 /*
1838 1844 * Fault-related functions
1839 1845 */
1840 1846 extern int ddi_check_acc_handle(ddi_acc_handle_t);
1841 1847 extern int ddi_check_dma_handle(ddi_dma_handle_t);
1842 1848 extern void ddi_dev_report_fault(dev_info_t *, ddi_fault_impact_t,
1843 1849 ddi_fault_location_t, const char *);
1844 1850 extern ddi_devstate_t ddi_get_devstate(dev_info_t *);
1845 1851
1846 1852 /*
1847 1853 * Miscellaneous redefines
1848 1854 */
1849 1855 #define uiophysio physio
1850 1856
1851 1857 /*
1852 1858 * utilities - "reg" mapping and all common portable data access functions
1853 1859 */
1854 1860
1855 1861 /*
1856 1862 * error code from ddi_regs_map_setup
1857 1863 */
1858 1864
1859 1865 #define DDI_REGS_ACC_CONFLICT (-10)
1860 1866
1861 1867 /*
1862 1868 * Device address advance flags
1863 1869 */
1864 1870
1865 1871 #define DDI_DEV_NO_AUTOINCR 0x0000
1866 1872 #define DDI_DEV_AUTOINCR 0x0001
1867 1873
1868 1874 int
1869 1875 ddi_regs_map_setup(dev_info_t *dip, uint_t rnumber, caddr_t *addrp,
1870 1876 offset_t offset, offset_t len, ddi_device_acc_attr_t *accattrp,
1871 1877 ddi_acc_handle_t *handle);
1872 1878
1873 1879 void
1874 1880 ddi_regs_map_free(ddi_acc_handle_t *handle);
1875 1881
1876 1882 /*
1877 1883 * these are the prototypes for the common portable data access functions
1878 1884 */
1879 1885
1880 1886 uint8_t
1881 1887 ddi_get8(ddi_acc_handle_t handle, uint8_t *addr);
1882 1888
1883 1889 uint16_t
1884 1890 ddi_get16(ddi_acc_handle_t handle, uint16_t *addr);
1885 1891
1886 1892 uint32_t
1887 1893 ddi_get32(ddi_acc_handle_t handle, uint32_t *addr);
1888 1894
1889 1895 uint64_t
1890 1896 ddi_get64(ddi_acc_handle_t handle, uint64_t *addr);
1891 1897
1892 1898 void
1893 1899 ddi_rep_get8(ddi_acc_handle_t handle, uint8_t *host_addr, uint8_t *dev_addr,
1894 1900 size_t repcount, uint_t flags);
1895 1901
1896 1902 void
1897 1903 ddi_rep_get16(ddi_acc_handle_t handle, uint16_t *host_addr, uint16_t *dev_addr,
1898 1904 size_t repcount, uint_t flags);
1899 1905
1900 1906 void
1901 1907 ddi_rep_get32(ddi_acc_handle_t handle, uint32_t *host_addr, uint32_t *dev_addr,
1902 1908 size_t repcount, uint_t flags);
1903 1909
1904 1910 void
1905 1911 ddi_rep_get64(ddi_acc_handle_t handle, uint64_t *host_addr, uint64_t *dev_addr,
1906 1912 size_t repcount, uint_t flags);
1907 1913
1908 1914 void
1909 1915 ddi_put8(ddi_acc_handle_t handle, uint8_t *addr, uint8_t value);
1910 1916
1911 1917 void
1912 1918 ddi_put16(ddi_acc_handle_t handle, uint16_t *addr, uint16_t value);
1913 1919
1914 1920 void
1915 1921 ddi_put32(ddi_acc_handle_t handle, uint32_t *addr, uint32_t value);
1916 1922
1917 1923 void
1918 1924 ddi_put64(ddi_acc_handle_t handle, uint64_t *addr, uint64_t value);
1919 1925
1920 1926 void
1921 1927 ddi_rep_put8(ddi_acc_handle_t handle, uint8_t *host_addr, uint8_t *dev_addr,
1922 1928 size_t repcount, uint_t flags);
1923 1929 void
1924 1930 ddi_rep_put16(ddi_acc_handle_t handle, uint16_t *host_addr, uint16_t *dev_addr,
1925 1931 size_t repcount, uint_t flags);
1926 1932 void
1927 1933 ddi_rep_put32(ddi_acc_handle_t handle, uint32_t *host_addr, uint32_t *dev_addr,
1928 1934 size_t repcount, uint_t flags);
1929 1935
1930 1936 void
1931 1937 ddi_rep_put64(ddi_acc_handle_t handle, uint64_t *host_addr, uint64_t *dev_addr,
1932 1938 size_t repcount, uint_t flags);
1933 1939
1934 1940 /*
1935 1941 * these are special device handling functions
1936 1942 */
1937 1943 int
1938 1944 ddi_device_zero(ddi_acc_handle_t handle, caddr_t dev_addr,
1939 1945 size_t bytecount, ssize_t dev_advcnt, uint_t dev_datasz);
1940 1946
1941 1947 int
1942 1948 ddi_device_copy(
1943 1949 ddi_acc_handle_t src_handle, caddr_t src_addr, ssize_t src_advcnt,
1944 1950 ddi_acc_handle_t dest_handle, caddr_t dest_addr, ssize_t dest_advcnt,
1945 1951 size_t bytecount, uint_t dev_datasz);
1946 1952
1947 1953 /*
1948 1954 * these are software byte swapping functions
1949 1955 */
1950 1956 uint16_t
1951 1957 ddi_swap16(uint16_t value);
1952 1958
1953 1959 uint32_t
1954 1960 ddi_swap32(uint32_t value);
1955 1961
1956 1962 uint64_t
1957 1963 ddi_swap64(uint64_t value);
1958 1964
1959 1965 /*
1960 1966 * these are the prototypes for PCI local bus functions
1961 1967 */
1962 1968 /*
1963 1969 * PCI power management capabilities reporting in addition to those
1964 1970 * provided by the PCI Power Management Specification.
1965 1971 */
1966 1972 #define PCI_PM_IDLESPEED 0x1 /* clock for idle dev - cap */
1967 1973 #define PCI_PM_IDLESPEED_ANY (void *)-1 /* any clock for idle dev */
1968 1974 #define PCI_PM_IDLESPEED_NONE (void *)-2 /* regular clock for idle dev */
1969 1975
1970 1976 int
1971 1977 pci_config_setup(dev_info_t *dip, ddi_acc_handle_t *handle);
1972 1978
1973 1979 void
1974 1980 pci_config_teardown(ddi_acc_handle_t *handle);
1975 1981
1976 1982 uint8_t
1977 1983 pci_config_get8(ddi_acc_handle_t handle, off_t offset);
1978 1984
1979 1985 uint16_t
1980 1986 pci_config_get16(ddi_acc_handle_t handle, off_t offset);
1981 1987
1982 1988 uint32_t
1983 1989 pci_config_get32(ddi_acc_handle_t handle, off_t offset);
1984 1990
1985 1991 uint64_t
1986 1992 pci_config_get64(ddi_acc_handle_t handle, off_t offset);
1987 1993
1988 1994 void
1989 1995 pci_config_put8(ddi_acc_handle_t handle, off_t offset, uint8_t value);
1990 1996
1991 1997 void
1992 1998 pci_config_put16(ddi_acc_handle_t handle, off_t offset, uint16_t value);
1993 1999
1994 2000 void
1995 2001 pci_config_put32(ddi_acc_handle_t handle, off_t offset, uint32_t value);
1996 2002
1997 2003 void
1998 2004 pci_config_put64(ddi_acc_handle_t handle, off_t offset, uint64_t value);
1999 2005
2000 2006 int
2001 2007 pci_report_pmcap(dev_info_t *dip, int cap, void *arg);
2002 2008
2003 2009 int
2004 2010 pci_restore_config_regs(dev_info_t *dip);
2005 2011
2006 2012 int
2007 2013 pci_save_config_regs(dev_info_t *dip);
2008 2014
2009 2015 void
2010 2016 pci_ereport_setup(dev_info_t *dip);
2011 2017
2012 2018 void
2013 2019 pci_ereport_teardown(dev_info_t *dip);
2014 2020
2015 2021 void
2016 2022 pci_ereport_post(dev_info_t *dip, ddi_fm_error_t *derr, uint16_t *status);
2017 2023
2018 2024 #if defined(__i386) || defined(__amd64)
2019 2025 int
2020 2026 pci_peekpoke_check(dev_info_t *, dev_info_t *, ddi_ctl_enum_t, void *, void *,
2021 2027 int (*handler)(dev_info_t *, dev_info_t *, ddi_ctl_enum_t, void *, void *),
2022 2028 kmutex_t *, kmutex_t *, void (*scan)(dev_info_t *, ddi_fm_error_t *));
2023 2029 #endif
2024 2030
2025 2031 void
2026 2032 pci_target_enqueue(uint64_t, char *, char *, uint64_t);
2027 2033
2028 2034 void
2029 2035 pci_targetq_init(void);
2030 2036
2031 2037 int
2032 2038 pci_post_suspend(dev_info_t *dip);
2033 2039
2034 2040 int
2035 2041 pci_pre_resume(dev_info_t *dip);
2036 2042
2037 2043 /*
2038 2044 * the prototype for the C Language Type Model inquiry.
2039 2045 */
2040 2046 model_t ddi_mmap_get_model(void);
2041 2047 model_t ddi_model_convert_from(model_t);
2042 2048
2043 2049 /*
2044 2050 * these are the prototypes for device id functions.
2045 2051 */
2046 2052 int
2047 2053 ddi_devid_valid(ddi_devid_t devid);
2048 2054
2049 2055 int
2050 2056 ddi_devid_register(dev_info_t *dip, ddi_devid_t devid);
2051 2057
2052 2058 void
2053 2059 ddi_devid_unregister(dev_info_t *dip);
2054 2060
2055 2061 int
2056 2062 ddi_devid_init(dev_info_t *dip, ushort_t devid_type, ushort_t nbytes,
2057 2063 void *id, ddi_devid_t *ret_devid);
2058 2064
2059 2065 int
2060 2066 ddi_devid_get(dev_info_t *dip, ddi_devid_t *ret_devid);
2061 2067
2062 2068 size_t
2063 2069 ddi_devid_sizeof(ddi_devid_t devid);
2064 2070
2065 2071 void
2066 2072 ddi_devid_free(ddi_devid_t devid);
2067 2073
2068 2074 int
2069 2075 ddi_devid_compare(ddi_devid_t id1, ddi_devid_t id2);
2070 2076
2071 2077 int
2072 2078 ddi_devid_scsi_encode(int version, char *driver_name,
2073 2079 uchar_t *inq, size_t inq_len, uchar_t *inq80, size_t inq80_len,
2074 2080 uchar_t *inq83, size_t inq83_len, ddi_devid_t *ret_devid);
2075 2081
2076 2082 int
2077 2083 ddi_devid_smp_encode(int version, char *driver_name,
2078 2084 char *wwnstr, uchar_t *srmir_buf, size_t srmir_len,
2079 2085 ddi_devid_t *ret_devid);
2080 2086
2081 2087 char
2082 2088 *ddi_devid_to_guid(ddi_devid_t devid);
2083 2089
2084 2090 void
2085 2091 ddi_devid_free_guid(char *guid);
2086 2092
2087 2093 int
2088 2094 ddi_lyr_get_devid(dev_t dev, ddi_devid_t *ret_devid);
2089 2095
2090 2096 int
2091 2097 ddi_lyr_get_minor_name(dev_t dev, int spec_type, char **minor_name);
2092 2098
2093 2099 int
2094 2100 ddi_lyr_devid_to_devlist(ddi_devid_t devid, char *minor_name, int *retndevs,
2095 2101 dev_t **retdevs);
2096 2102
2097 2103 void
2098 2104 ddi_lyr_free_devlist(dev_t *devlist, int ndevs);
2099 2105
2100 2106 char *
2101 2107 ddi_devid_str_encode(ddi_devid_t devid, char *minor_name);
2102 2108
2103 2109 int
2104 2110 ddi_devid_str_decode(char *devidstr, ddi_devid_t *devidp, char **minor_namep);
2105 2111
2106 2112 void
2107 2113 ddi_devid_str_free(char *devidstr);
2108 2114
2109 2115 int
2110 2116 ddi_devid_str_compare(char *id1_str, char *id2_str);
2111 2117
2112 2118 /*
2113 2119 * Event to post to when a devinfo node is removed.
2114 2120 */
2115 2121 #define DDI_DEVI_REMOVE_EVENT "DDI:DEVI_REMOVE"
2116 2122 #define DDI_DEVI_INSERT_EVENT "DDI:DEVI_INSERT"
2117 2123 #define DDI_DEVI_BUS_RESET_EVENT "DDI:DEVI_BUS_RESET"
2118 2124 #define DDI_DEVI_DEVICE_RESET_EVENT "DDI:DEVI_DEVICE_RESET"
2119 2125
2120 2126 /*
2121 2127 * Invoke bus nexus driver's implementation of the
2122 2128 * (*bus_remove_eventcall)() interface to remove a registered
2123 2129 * callback handler for "event".
2124 2130 */
2125 2131 int
2126 2132 ddi_remove_event_handler(ddi_callback_id_t id);
2127 2133
2128 2134 /*
2129 2135 * Invoke bus nexus driver's implementation of the
2130 2136 * (*bus_add_eventcall)() interface to register a callback handler
2131 2137 * for "event".
2132 2138 */
2133 2139 int
2134 2140 ddi_add_event_handler(dev_info_t *dip, ddi_eventcookie_t event,
2135 2141 void (*handler)(dev_info_t *, ddi_eventcookie_t, void *, void *),
2136 2142 void *arg, ddi_callback_id_t *id);
2137 2143
2138 2144 /*
2139 2145 * Return a handle for event "name" by calling up the device tree
2140 2146 * hierarchy via (*bus_get_eventcookie)() interface until claimed
2141 2147 * by a bus nexus or top of dev_info tree is reached.
2142 2148 */
2143 2149 int
2144 2150 ddi_get_eventcookie(dev_info_t *dip, char *name,
2145 2151 ddi_eventcookie_t *event_cookiep);
2146 2152
2147 2153 /*
2148 2154 * log a system event
2149 2155 */
2150 2156 int
2151 2157 ddi_log_sysevent(dev_info_t *dip, char *vendor, char *class_name,
2152 2158 char *subclass_name, nvlist_t *attr_list, sysevent_id_t *eidp,
2153 2159 int sleep_flag);
2154 2160
2155 2161 /*
2156 2162 * ddi_log_sysevent() vendors
2157 2163 */
2158 2164 #define DDI_VENDOR_SUNW "SUNW"
2159 2165
2160 2166 /*
2161 2167 * Opaque task queue handle.
2162 2168 */
2163 2169 typedef struct ddi_taskq ddi_taskq_t;
2164 2170
2165 2171 /*
2166 2172 * Use default system priority.
2167 2173 */
2168 2174 #define TASKQ_DEFAULTPRI -1
2169 2175
2170 2176 /*
2171 2177 * Create a task queue
2172 2178 */
2173 2179 ddi_taskq_t *ddi_taskq_create(dev_info_t *dip, const char *name,
2174 2180 int nthreads, pri_t pri, uint_t cflags);
2175 2181
2176 2182 /*
2177 2183 * destroy a task queue
2178 2184 */
2179 2185 void ddi_taskq_destroy(ddi_taskq_t *tq);
2180 2186
2181 2187 /*
2182 2188 * Dispatch a task to a task queue
2183 2189 */
2184 2190 int ddi_taskq_dispatch(ddi_taskq_t *tq, void (* func)(void *),
2185 2191 void *arg, uint_t dflags);
2186 2192
2187 2193 /*
2188 2194 * Wait for all previously scheduled tasks to complete.
2189 2195 */
2190 2196 void ddi_taskq_wait(ddi_taskq_t *tq);
2191 2197
2192 2198 /*
2193 2199 * Suspend all task execution.
2194 2200 */
2195 2201 void ddi_taskq_suspend(ddi_taskq_t *tq);
2196 2202
2197 2203 /*
2198 2204 * Resume task execution.
2199 2205 */
2200 2206 void ddi_taskq_resume(ddi_taskq_t *tq);
2201 2207
2202 2208 /*
2203 2209 * Is task queue suspended?
2204 2210 */
2205 2211 boolean_t ddi_taskq_suspended(ddi_taskq_t *tq);
2206 2212
2207 2213 /*
2208 2214 * Parse an interface name of the form <alphanumeric>##<numeric> where
2209 2215 * <numeric> is maximal.
2210 2216 */
2211 2217 int ddi_parse(const char *, char *, uint_t *);
2212 2218
2213 2219 /*
2214 2220 * DDI interrupt priority level
2215 2221 */
2216 2222 #define DDI_IPL_0 (0) /* kernel context */
2217 2223 #define DDI_IPL_1 (1) /* interrupt priority level 1 */
2218 2224 #define DDI_IPL_2 (2) /* interrupt priority level 2 */
2219 2225 #define DDI_IPL_3 (3) /* interrupt priority level 3 */
2220 2226 #define DDI_IPL_4 (4) /* interrupt priority level 4 */
2221 2227 #define DDI_IPL_5 (5) /* interrupt priority level 5 */
2222 2228 #define DDI_IPL_6 (6) /* interrupt priority level 6 */
2223 2229 #define DDI_IPL_7 (7) /* interrupt priority level 7 */
2224 2230 #define DDI_IPL_8 (8) /* interrupt priority level 8 */
2225 2231 #define DDI_IPL_9 (9) /* interrupt priority level 9 */
2226 2232 #define DDI_IPL_10 (10) /* interrupt priority level 10 */
2227 2233
2228 2234 /*
2229 2235 * DDI periodic timeout interface
2230 2236 */
2231 2237 ddi_periodic_t ddi_periodic_add(void (*)(void *), void *, hrtime_t, int);
2232 2238 void ddi_periodic_delete(ddi_periodic_t);
2233 2239
2234 2240 /*
2235 2241 * Default quiesce(9E) implementation for drivers that don't need to do
2236 2242 * anything.
2237 2243 */
2238 2244 int ddi_quiesce_not_needed(dev_info_t *);
2239 2245
2240 2246 /*
2241 2247 * Default quiesce(9E) initialization function for drivers that should
2242 2248 * implement quiesce but haven't yet.
2243 2249 */
2244 2250 int ddi_quiesce_not_supported(dev_info_t *);
2245 2251
2246 2252 /*
2247 2253 * DDI generic callback interface
2248 2254 */
2249 2255
2250 2256 typedef struct __ddi_cb **ddi_cb_handle_t;
2251 2257
2252 2258 int ddi_cb_register(dev_info_t *dip, ddi_cb_flags_t flags,
2253 2259 ddi_cb_func_t cbfunc, void *arg1, void *arg2,
2254 2260 ddi_cb_handle_t *ret_hdlp);
2255 2261 int ddi_cb_unregister(ddi_cb_handle_t hdl);
2256 2262
2257 2263 /* Notify DDI of memory added */
2258 2264 void ddi_mem_update(uint64_t addr, uint64_t size);
2259 2265
2260 2266 /* Path alias interfaces */
2261 2267 typedef struct plat_alias {
2262 2268 char *pali_current;
2263 2269 uint64_t pali_naliases;
2264 2270 char **pali_aliases;
2265 2271 } plat_alias_t;
2266 2272
2267 2273 typedef struct alias_pair {
2268 2274 char *pair_alias;
2269 2275 char *pair_curr;
2270 2276 } alias_pair_t;
2271 2277
2272 2278 extern boolean_t ddi_aliases_present;
2273 2279
2274 2280 typedef struct ddi_alias {
2275 2281 alias_pair_t *dali_alias_pairs;
2276 2282 alias_pair_t *dali_curr_pairs;
2277 2283 int dali_num_pairs;
2278 2284 mod_hash_t *dali_alias_TLB;
2279 2285 mod_hash_t *dali_curr_TLB;
2280 2286 } ddi_alias_t;
2281 2287
2282 2288 extern ddi_alias_t ddi_aliases;
2283 2289
2284 2290 void ddi_register_aliases(plat_alias_t *pali, uint64_t npali);
2285 2291 dev_info_t *ddi_alias_redirect(char *alias);
2286 2292 char *ddi_curr_redirect(char *curr);
2287 2293
2288 2294 #endif /* _KERNEL */
2289 2295
2290 2296 #ifdef __cplusplus
2291 2297 }
2292 2298 #endif
2293 2299
2294 2300 #endif /* _SYS_SUNDDI_H */
↓ open down ↓ |
695 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX