]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/kern/bus_if.m
zfs: merge openzfs/zfs@86783d7d9 (zfs-2.1-release) into stable/13
[FreeBSD/FreeBSD.git] / sys / kern / bus_if.m
1 #-
2 # Copyright (c) 1998-2004 Doug Rabson
3 # All rights reserved.
4 #
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
7 # are met:
8 # 1. Redistributions of source code must retain the above copyright
9 #    notice, this list of conditions and the following disclaimer.
10 # 2. Redistributions in binary form must reproduce the above copyright
11 #    notice, this list of conditions and the following disclaimer in the
12 #    documentation and/or other materials provided with the distribution.
13 #
14 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 # SUCH DAMAGE.
25 #
26 # $FreeBSD$
27 #
28
29 #include <sys/types.h>
30 #include <sys/systm.h>
31 #include <sys/bus.h>
32
33 /**
34  * @defgroup BUS bus - KObj methods for drivers of devices with children
35  * @brief A set of methods required device drivers that support
36  * child devices.
37  * @{
38  */
39 INTERFACE bus;
40
41 #
42 # Default implementations of some methods.
43 #
44 CODE {
45         static struct resource *
46         null_alloc_resource(device_t dev, device_t child,
47             int type, int *rid, rman_res_t start, rman_res_t end,
48             rman_res_t count, u_int flags)
49         {
50             return (0);
51         }
52
53         static int
54         null_remap_intr(device_t bus, device_t dev, u_int irq)
55         {
56
57                 if (dev != NULL)
58                         return (BUS_REMAP_INTR(dev, NULL, irq));
59                 return (ENXIO);
60         }
61
62         static device_t
63         null_add_child(device_t bus, int order, const char *name,
64             int unit)
65         {
66
67                 panic("bus_add_child is not implemented");
68         }
69
70         static int
71         null_reset_post(device_t bus, device_t dev)
72         {
73                 return (0);
74         }
75
76         static int
77         null_reset_prepare(device_t bus, device_t dev)
78         {
79                 return (0);
80         }
81
82         static int
83         null_translate_resource(device_t bus, int type, rman_res_t start,
84                 rman_res_t *newstart)
85         {
86                 if (device_get_parent(bus) != NULL)
87                         return (BUS_TRANSLATE_RESOURCE(device_get_parent(bus),
88                             type, start, newstart));
89
90                 *newstart = start;
91                 return (0);
92         }
93 };
94
95 /**
96  * @brief Print a description of a child device
97  *
98  * This is called from system code which prints out a description of a
99  * device. It should describe the attachment that the child has with
100  * the parent. For instance the TurboLaser bus prints which node the
101  * device is attached to. See bus_generic_print_child() for more
102  * information.
103  *
104  * @param _dev          the device whose child is being printed
105  * @param _child        the child device to describe
106  *
107  * @returns             the number of characters output.
108  */
109 METHOD int print_child {
110         device_t _dev;
111         device_t _child;
112 } DEFAULT bus_generic_print_child;
113
114 /**
115  * @brief Print a notification about an unprobed child device.
116  *
117  * Called for each child device that did not succeed in probing for a
118  * driver.
119  *
120  * @param _dev          the device whose child was being probed
121  * @param _child        the child device which failed to probe
122  */
123 METHOD void probe_nomatch {
124         device_t _dev;
125         device_t _child;
126 };
127
128 /**
129  * @brief Read the value of a bus-specific attribute of a device
130  *
131  * This method, along with BUS_WRITE_IVAR() manages a bus-specific set
132  * of instance variables of a child device.  The intention is that
133  * each different type of bus defines a set of appropriate instance
134  * variables (such as ports and irqs for ISA bus etc.)
135  *
136  * This information could be given to the child device as a struct but
137  * that makes it hard for a bus to add or remove variables without
138  * forcing an edit and recompile for all drivers which may not be
139  * possible for vendor supplied binary drivers.
140  *
141  * This method copies the value of an instance variable to the
142  * location specified by @p *_result.
143  *
144  * @param _dev          the device whose child was being examined
145  * @param _child        the child device whose instance variable is
146  *                      being read
147  * @param _index        the instance variable to read
148  * @param _result       a location to receive the instance variable
149  *                      value
150  *
151  * @retval 0            success
152  * @retval ENOENT       no such instance variable is supported by @p
153  *                      _dev
154  */
155 METHOD int read_ivar {
156         device_t _dev;
157         device_t _child;
158         int _index;
159         uintptr_t *_result;
160 };
161
162 /**
163  * @brief Write the value of a bus-specific attribute of a device
164  *
165  * This method sets the value of an instance variable to @p _value.
166  *
167  * @param _dev          the device whose child was being updated
168  * @param _child        the child device whose instance variable is
169  *                      being written
170  * @param _index        the instance variable to write
171  * @param _value        the value to write to that instance variable
172  *
173  * @retval 0            success
174  * @retval ENOENT       no such instance variable is supported by @p
175  *                      _dev
176  * @retval EINVAL       the instance variable was recognised but
177  *                      contains a read-only value
178  */
179 METHOD int write_ivar {
180         device_t _dev;
181         device_t _child;
182         int _indx;
183         uintptr_t _value;
184 };
185
186 /**
187  * @brief Notify a bus that a child was deleted
188  *
189  * Called at the beginning of device_delete_child() to allow the parent
190  * to teardown any bus-specific state for the child.
191  *
192  * @param _dev          the device whose child is being deleted
193  * @param _child        the child device which is being deleted
194  */
195 METHOD void child_deleted {
196         device_t _dev;
197         device_t _child;
198 };
199
200 /**
201  * @brief Notify a bus that a child was detached
202  *
203  * Called after the child's DEVICE_DETACH() method to allow the parent
204  * to reclaim any resources allocated on behalf of the child.
205  *
206  * @param _dev          the device whose child changed state
207  * @param _child        the child device which changed state
208  */
209 METHOD void child_detached {
210         device_t _dev;
211         device_t _child;
212 };
213
214 /**
215  * @brief Notify a bus that a new driver was added
216  *
217  * Called when a new driver is added to the devclass which owns this
218  * bus. The generic implementation of this method attempts to probe and
219  * attach any un-matched children of the bus.
220  *
221  * @param _dev          the device whose devclass had a new driver
222  *                      added to it
223  * @param _driver       the new driver which was added
224  */
225 METHOD void driver_added {
226         device_t _dev;
227         driver_t *_driver;
228 } DEFAULT bus_generic_driver_added;
229
230 /**
231  * @brief Create a new child device
232  *
233  * For buses which use use drivers supporting DEVICE_IDENTIFY() to
234  * enumerate their devices, this method is used to create new
235  * device instances. The new device will be added after the last
236  * existing child with the same order. Implementations of bus_add_child
237  * call device_add_child_ordered to add the child and often add
238  * a suitable ivar to the device specific to that bus.
239  *
240  * @param _dev          the bus device which will be the parent of the
241  *                      new child device
242  * @param _order        a value which is used to partially sort the
243  *                      children of @p _dev - devices created using
244  *                      lower values of @p _order appear first in @p
245  *                      _dev's list of children
246  * @param _name         devclass name for new device or @c NULL if not
247  *                      specified
248  * @param _unit         unit number for new device or @c -1 if not
249  *                      specified
250  */
251 METHOD device_t add_child {
252         device_t _dev;
253         u_int _order;
254         const char *_name;
255         int _unit;
256 } DEFAULT null_add_child;
257
258 /**
259  * @brief Rescan the bus
260  *
261  * This method is called by a parent bridge or devctl to trigger a bus
262  * rescan.  The rescan should delete devices no longer present and
263  * enumerate devices that have newly arrived.
264  *
265  * @param _dev          the bus device
266  */
267 METHOD int rescan {
268         device_t _dev;
269 } DEFAULT bus_null_rescan;
270
271 /**
272  * @brief Allocate a system resource
273  *
274  * This method is called by child devices of a bus to allocate resources.
275  * The types are defined in <machine/resource.h>; the meaning of the
276  * resource-ID field varies from bus to bus (but @p *rid == 0 is always
277  * valid if the resource type is). If a resource was allocated and the
278  * caller did not use the RF_ACTIVE to specify that it should be
279  * activated immediately, the caller is responsible for calling
280  * BUS_ACTIVATE_RESOURCE() when it actually uses the resource.
281  *
282  * @param _dev          the parent device of @p _child
283  * @param _child        the device which is requesting an allocation
284  * @param _type         the type of resource to allocate
285  * @param _rid          a pointer to the resource identifier
286  * @param _start        hint at the start of the resource range - pass
287  *                      @c 0 for any start address
288  * @param _end          hint at the end of the resource range - pass
289  *                      @c ~0 for any end address
290  * @param _count        hint at the size of range required - pass @c 1
291  *                      for any size
292  * @param _flags        any extra flags to control the resource
293  *                      allocation - see @c RF_XXX flags in
294  *                      <sys/rman.h> for details
295  *
296  * @returns             the resource which was allocated or @c NULL if no
297  *                      resource could be allocated
298  */
299 METHOD struct resource * alloc_resource {
300         device_t        _dev;
301         device_t        _child;
302         int             _type;
303         int            *_rid;
304         rman_res_t      _start;
305         rman_res_t      _end;
306         rman_res_t      _count;
307         u_int           _flags;
308 } DEFAULT null_alloc_resource;
309
310 /**
311  * @brief Activate a resource
312  *
313  * Activate a resource previously allocated with
314  * BUS_ALLOC_RESOURCE().  This may enable decoding of this resource in a
315  * device for instance.  It will also establish a mapping for the resource
316  * unless RF_UNMAPPED was set when allocating the resource.
317  *
318  * @param _dev          the parent device of @p _child
319  * @param _child        the device which allocated the resource
320  * @param _type         the type of resource
321  * @param _rid          the resource identifier
322  * @param _r            the resource to activate
323  */
324 METHOD int activate_resource {
325         device_t        _dev;
326         device_t        _child;
327         int             _type;
328         int             _rid;
329         struct resource *_r;
330 };
331
332
333 /**
334  * @brief Map a resource
335  *
336  * Allocate a mapping for a range of an active resource.  The mapping
337  * is described by a struct resource_map object.  This may for instance
338  * map a memory region into the kernel's virtual address space.
339  *
340  * @param _dev          the parent device of @p _child
341  * @param _child        the device which allocated the resource
342  * @param _type         the type of resource
343  * @param _r            the resource to map
344  * @param _args         optional attributes of the mapping
345  * @param _map          the mapping
346  */
347 METHOD int map_resource {
348         device_t        _dev;
349         device_t        _child;
350         int             _type;
351         struct resource *_r;
352         struct resource_map_request *_args;
353         struct resource_map *_map;
354 } DEFAULT bus_generic_map_resource;
355
356
357 /**
358  * @brief Unmap a resource
359  *
360  * Release a mapping previously allocated with
361  * BUS_MAP_RESOURCE(). This may for instance unmap a memory region
362  * from the kernel's virtual address space.
363  *
364  * @param _dev          the parent device of @p _child
365  * @param _child        the device which allocated the resource
366  * @param _type         the type of resource
367  * @param _r            the resource
368  * @param _map          the mapping to release
369  */
370 METHOD int unmap_resource {
371         device_t        _dev;
372         device_t        _child;
373         int             _type;
374         struct resource *_r;
375         struct resource_map *_map;
376 } DEFAULT bus_generic_unmap_resource;
377
378
379 /**
380  * @brief Deactivate a resource
381  *
382  * Deactivate a resource previously allocated with
383  * BUS_ALLOC_RESOURCE().
384  *
385  * @param _dev          the parent device of @p _child
386  * @param _child        the device which allocated the resource
387  * @param _type         the type of resource
388  * @param _rid          the resource identifier
389  * @param _r            the resource to deactivate
390  */
391 METHOD int deactivate_resource {
392         device_t        _dev;
393         device_t        _child;
394         int             _type;
395         int             _rid;
396         struct resource *_r;
397 };
398
399 /**
400  * @brief Adjust a resource
401  *
402  * Adjust the start and/or end of a resource allocated by
403  * BUS_ALLOC_RESOURCE.  At least part of the new address range must overlap
404  * with the existing address range.  If the successful, the resource's range
405  * will be adjusted to [start, end] on return.
406  *
407  * @param _dev          the parent device of @p _child
408  * @param _child        the device which allocated the resource
409  * @param _type         the type of resource
410  * @param _res          the resource to adjust
411  * @param _start        the new starting address of the resource range
412  * @param _end          the new ending address of the resource range
413  */
414 METHOD int adjust_resource {
415         device_t        _dev;
416         device_t        _child;
417         int             _type;
418         struct resource *_res;
419         rman_res_t      _start;
420         rman_res_t      _end;
421 };
422
423
424 /**
425  * @brief translate a resource value
426  *
427  *
428  * @param _dev          the device associated with the resource
429  * @param _type         the type of resource
430  * @param _start        the starting address of the resource range
431  * @param _newstart     the new starting address of the resource range
432  */
433 METHOD int translate_resource {
434         device_t        _dev;
435         int             _type;
436         rman_res_t      _start;
437         rman_res_t      *_newstart;
438 } DEFAULT null_translate_resource;
439
440 /**
441  * @brief Release a resource
442  *
443  * Free a resource allocated by the BUS_ALLOC_RESOURCE.  The @p _rid
444  * value must be the same as the one returned by BUS_ALLOC_RESOURCE()
445  * (which is not necessarily the same as the one the client passed).
446  *
447  * @param _dev          the parent device of @p _child
448  * @param _child        the device which allocated the resource
449  * @param _type         the type of resource
450  * @param _rid          the resource identifier
451  * @param _r            the resource to release
452  */
453 METHOD int release_resource {
454         device_t        _dev;
455         device_t        _child;
456         int             _type;
457         int             _rid;
458         struct resource *_res;
459 };
460
461 /**
462  * @brief Install an interrupt handler
463  *
464  * This method is used to associate an interrupt handler function with
465  * an irq resource. When the interrupt triggers, the function @p _intr
466  * will be called with the value of @p _arg as its single
467  * argument. The value returned in @p *_cookiep is used to cancel the
468  * interrupt handler - the caller should save this value to use in a
469  * future call to BUS_TEARDOWN_INTR().
470  *
471  * @param _dev          the parent device of @p _child
472  * @param _child        the device which allocated the resource
473  * @param _irq          the resource representing the interrupt
474  * @param _flags        a set of bits from enum intr_type specifying
475  *                      the class of interrupt
476  * @param _intr         the function to call when the interrupt
477  *                      triggers
478  * @param _arg          a value to use as the single argument in calls
479  *                      to @p _intr
480  * @param _cookiep      a pointer to a location to receive a cookie
481  *                      value that may be used to remove the interrupt
482  *                      handler
483  */
484 METHOD int setup_intr {
485         device_t        _dev;
486         device_t        _child;
487         struct resource *_irq;
488         int             _flags;
489         driver_filter_t *_filter;
490         driver_intr_t   *_intr;
491         void            *_arg;
492         void            **_cookiep;
493 };
494
495 /**
496  * @brief Uninstall an interrupt handler
497  *
498  * This method is used to disassociate an interrupt handler function
499  * with an irq resource. The value of @p _cookie must be the value
500  * returned from a previous call to BUS_SETUP_INTR().
501  *
502  * @param _dev          the parent device of @p _child
503  * @param _child        the device which allocated the resource
504  * @param _irq          the resource representing the interrupt
505  * @param _cookie       the cookie value returned when the interrupt
506  *                      was originally registered
507  */
508 METHOD int teardown_intr {
509         device_t        _dev;
510         device_t        _child;
511         struct resource *_irq;
512         void            *_cookie;
513 };
514
515 /**
516  * @brief Suspend an interrupt handler
517  *
518  * This method is used to mark a handler as suspended in the case
519  * that the associated device is powered down and cannot be a source
520  * for the, typically shared, interrupt.
521  * The value of @p _irq must be the interrupt resource passed
522  * to a previous call to BUS_SETUP_INTR().
523  *
524  * @param _dev          the parent device of @p _child
525  * @param _child        the device which allocated the resource
526  * @param _irq          the resource representing the interrupt
527  */
528 METHOD int suspend_intr {
529         device_t        _dev;
530         device_t        _child;
531         struct resource *_irq;
532 } DEFAULT bus_generic_suspend_intr;
533
534 /**
535  * @brief Resume an interrupt handler
536  *
537  * This method is used to clear suspended state of a handler when
538  * the associated device is powered up and can be an interrupt source
539  * again.
540  * The value of @p _irq must be the interrupt resource passed
541  * to a previous call to BUS_SETUP_INTR().
542  *
543  * @param _dev          the parent device of @p _child
544  * @param _child        the device which allocated the resource
545  * @param _irq          the resource representing the interrupt
546  */
547 METHOD int resume_intr {
548         device_t        _dev;
549         device_t        _child;
550         struct resource *_irq;
551 } DEFAULT bus_generic_resume_intr;
552
553 /**
554  * @brief Define a resource which can be allocated with
555  * BUS_ALLOC_RESOURCE().
556  *
557  * This method is used by some buses (typically ISA) to allow a
558  * driver to describe a resource range that it would like to
559  * allocate. The resource defined by @p _type and @p _rid is defined
560  * to start at @p _start and to include @p _count indices in its
561  * range.
562  *
563  * @param _dev          the parent device of @p _child
564  * @param _child        the device which owns the resource
565  * @param _type         the type of resource
566  * @param _rid          the resource identifier
567  * @param _start        the start of the resource range
568  * @param _count        the size of the resource range
569  */
570 METHOD int set_resource {
571         device_t        _dev;
572         device_t        _child;
573         int             _type;
574         int             _rid;
575         rman_res_t      _start;
576         rman_res_t      _count;
577 };
578
579 /**
580  * @brief Describe a resource
581  *
582  * This method allows a driver to examine the range used for a given
583  * resource without actually allocating it.
584  *
585  * @param _dev          the parent device of @p _child
586  * @param _child        the device which owns the resource
587  * @param _type         the type of resource
588  * @param _rid          the resource identifier
589  * @param _start        the address of a location to receive the start
590  *                      index of the resource range
591  * @param _count        the address of a location to receive the size
592  *                      of the resource range
593  */
594 METHOD int get_resource {
595         device_t        _dev;
596         device_t        _child;
597         int             _type;
598         int             _rid;
599         rman_res_t      *_startp;
600         rman_res_t      *_countp;
601 };
602
603 /**
604  * @brief Delete a resource.
605  *
606  * Use this to delete a resource (possibly one previously added with
607  * BUS_SET_RESOURCE()).
608  *
609  * @param _dev          the parent device of @p _child
610  * @param _child        the device which owns the resource
611  * @param _type         the type of resource
612  * @param _rid          the resource identifier
613  */
614 METHOD void delete_resource {
615         device_t        _dev;
616         device_t        _child;
617         int             _type;
618         int             _rid;
619 };
620
621 /**
622  * @brief Return a struct resource_list.
623  *
624  * Used by drivers which use bus_generic_rl_alloc_resource() etc. to
625  * implement their resource handling. It should return the resource
626  * list of the given child device.
627  *
628  * @param _dev          the parent device of @p _child
629  * @param _child        the device which owns the resource list
630  */
631 METHOD struct resource_list * get_resource_list {
632         device_t        _dev;
633         device_t        _child;
634 } DEFAULT bus_generic_get_resource_list;
635
636 /**
637  * @brief Is the hardware described by @p _child still attached to the
638  * system?
639  *
640  * This method should return 0 if the device is not present.  It
641  * should return -1 if it is present.  Any errors in determining
642  * should be returned as a normal errno value.  Client drivers are to
643  * assume that the device is present, even if there is an error
644  * determining if it is there.  Buses are to try to avoid returning
645  * errors, but newcard will return an error if the device fails to
646  * implement this method.
647  *
648  * @param _dev          the parent device of @p _child
649  * @param _child        the device which is being examined
650  */
651 METHOD int child_present {
652         device_t        _dev;
653         device_t        _child;
654 } DEFAULT bus_generic_child_present;
655
656 /**
657  * @brief Returns the pnp info for this device.
658  *
659  * Return it as a string.  If the storage is insufficient for the
660  * string, then return EOVERFLOW.
661  *
662  * The string must be formatted as a space-separated list of
663  * name=value pairs.  Names may only contain alphanumeric characters,
664  * underscores ('_') and hyphens ('-').  Values can contain any
665  * non-whitespace characters.  Values containing whitespace can be
666  * quoted with double quotes ('"').  Double quotes and backslashes in
667  * quoted values can be escaped with backslashes ('\').
668  *
669  * @param _dev          the parent device of @p _child
670  * @param _child        the device which is being examined
671  * @param _buf          the address of a buffer to receive the pnp
672  *                      string
673  * @param _buflen       the size of the buffer pointed to by @p _buf
674  */
675 METHOD int child_pnpinfo_str {
676         device_t        _dev;
677         device_t        _child;
678         char            *_buf;
679         size_t          _buflen;
680 };
681
682 /**
683  * @brief Returns the location for this device.
684  *
685  * Return it as a string.  If the storage is insufficient for the
686  * string, then return EOVERFLOW.
687  *
688  * The string must be formatted as a space-separated list of
689  * name=value pairs.  Names may only contain alphanumeric characters,
690  * underscores ('_') and hyphens ('-').  Values can contain any
691  * non-whitespace characters.  Values containing whitespace can be
692  * quoted with double quotes ('"').  Double quotes and backslashes in
693  * quoted values can be escaped with backslashes ('\').
694  *
695  * @param _dev          the parent device of @p _child
696  * @param _child        the device which is being examined
697  * @param _buf          the address of a buffer to receive the location
698  *                      string
699  * @param _buflen       the size of the buffer pointed to by @p _buf
700  */
701 METHOD int child_location_str {
702         device_t        _dev;
703         device_t        _child;
704         char            *_buf;
705         size_t          _buflen;
706 };
707
708 /**
709  * @brief Allow drivers to request that an interrupt be bound to a specific
710  * CPU.
711  *
712  * @param _dev          the parent device of @p _child
713  * @param _child        the device which allocated the resource
714  * @param _irq          the resource representing the interrupt
715  * @param _cpu          the CPU to bind the interrupt to
716  */
717 METHOD int bind_intr {
718         device_t        _dev;
719         device_t        _child;
720         struct resource *_irq;
721         int             _cpu;
722 } DEFAULT bus_generic_bind_intr;
723
724 /**
725  * @brief Allow (bus) drivers to specify the trigger mode and polarity
726  * of the specified interrupt.
727  *
728  * @param _dev          the bus device
729  * @param _irq          the interrupt number to modify
730  * @param _trig         the trigger mode required
731  * @param _pol          the interrupt polarity required
732  */
733 METHOD int config_intr {
734         device_t        _dev;
735         int             _irq;
736         enum intr_trigger _trig;
737         enum intr_polarity _pol;
738 } DEFAULT bus_generic_config_intr;
739
740 /**
741  * @brief Allow drivers to associate a description with an active
742  * interrupt handler.
743  *
744  * @param _dev          the parent device of @p _child
745  * @param _child        the device which allocated the resource
746  * @param _irq          the resource representing the interrupt
747  * @param _cookie       the cookie value returned when the interrupt
748  *                      was originally registered
749  * @param _descr        the description to associate with the interrupt
750  */
751 METHOD int describe_intr {
752         device_t        _dev;
753         device_t        _child;
754         struct resource *_irq;
755         void            *_cookie;
756         const char      *_descr;
757 } DEFAULT bus_generic_describe_intr;
758
759 /**
760  * @brief Notify a (bus) driver about a child that the hints mechanism
761  * believes it has discovered.
762  *
763  * The bus is responsible for then adding the child in the right order
764  * and discovering other things about the child.  The bus driver is
765  * free to ignore this hint, to do special things, etc.  It is all up
766  * to the bus driver to interpret.
767  *
768  * This method is only called in response to the parent bus asking for
769  * hinted devices to be enumerated.
770  *
771  * @param _dev          the bus device
772  * @param _dname        the name of the device w/o unit numbers
773  * @param _dunit        the unit number of the device
774  */
775 METHOD void hinted_child {
776         device_t        _dev;
777         const char      *_dname;
778         int             _dunit;
779 };
780
781 /**
782  * @brief Returns bus_dma_tag_t for use w/ devices on the bus.
783  *
784  * @param _dev          the parent device of @p _child
785  * @param _child        the device to which the tag will belong
786  */
787 METHOD bus_dma_tag_t get_dma_tag {
788         device_t        _dev;
789         device_t        _child;
790 } DEFAULT bus_generic_get_dma_tag;
791
792 /**
793  * @brief Returns bus_space_tag_t for use w/ devices on the bus.
794  *
795  * @param _dev          the parent device of @p _child
796  * @param _child        the device to which the tag will belong
797  */
798 METHOD bus_space_tag_t get_bus_tag {
799         device_t        _dev;
800         device_t        _child;
801 } DEFAULT bus_generic_get_bus_tag;
802
803 /**
804  * @brief Allow the bus to determine the unit number of a device.
805  *
806  * @param _dev          the parent device of @p _child
807  * @param _child        the device whose unit is to be wired
808  * @param _name         the name of the device's new devclass
809  * @param _unitp        a pointer to the device's new unit value
810  */
811 METHOD void hint_device_unit {
812         device_t        _dev;
813         device_t        _child;
814         const char      *_name;
815         int             *_unitp;
816 };
817
818 /**
819  * @brief Notify a bus that the bus pass level has been changed
820  *
821  * @param _dev          the bus device
822  */
823 METHOD void new_pass {
824         device_t        _dev;
825 } DEFAULT bus_generic_new_pass;
826
827 /**
828  * @brief Notify a bus that specified child's IRQ should be remapped.
829  *
830  * @param _dev          the bus device
831  * @param _child        the child device
832  * @param _irq          the irq number
833  */
834 METHOD int remap_intr {
835         device_t        _dev;
836         device_t        _child;
837         u_int           _irq;
838 } DEFAULT null_remap_intr;
839
840 /**
841  * @brief Suspend a given child
842  *
843  * @param _dev          the parent device of @p _child
844  * @param _child        the device to suspend
845  */
846 METHOD int suspend_child {
847         device_t        _dev;
848         device_t        _child;
849 } DEFAULT bus_generic_suspend_child;
850
851 /**
852  * @brief Resume a given child
853  *
854  * @param _dev          the parent device of @p _child
855  * @param _child        the device to resume
856  */
857 METHOD int resume_child {
858         device_t        _dev;
859         device_t        _child;
860 } DEFAULT bus_generic_resume_child;
861
862 /**
863  * @brief Get the VM domain handle for the given bus and child.
864  *
865  * @param _dev          the bus device
866  * @param _child        the child device
867  * @param _domain       a pointer to the bus's domain handle identifier
868  */
869 METHOD int get_domain {
870         device_t        _dev;
871         device_t        _child;
872         int             *_domain;
873 } DEFAULT bus_generic_get_domain;
874
875 /**
876  * @brief Request a set of CPUs
877  *
878  * @param _dev          the bus device
879  * @param _child        the child device
880  * @param _op           type of CPUs to request
881  * @param _setsize      the size of the set passed in _cpuset
882  * @param _cpuset       a pointer to a cpuset to receive the requested
883  *                      set of CPUs
884  */
885 METHOD int get_cpus {
886         device_t        _dev;
887         device_t        _child;
888         enum cpu_sets   _op;
889         size_t          _setsize;
890         struct _cpuset  *_cpuset;
891 } DEFAULT bus_generic_get_cpus;
892
893 /**
894  * @brief Prepares the given child of the bus for reset
895  *
896  * Typically bus detaches or suspends children' drivers, and then
897  * calls this method to save bus-specific information, for instance,
898  * PCI config space, which is damaged by reset.
899  *
900  * The bus_helper_reset_prepare() helper is provided to ease
901  * implementing bus reset methods.
902  *
903  * @param _dev          the bus device
904  * @param _child        the child device
905  */
906 METHOD int reset_prepare {
907         device_t _dev;
908         device_t _child;
909 } DEFAULT null_reset_prepare;
910
911 /**
912  * @brief Restores the child operations after the reset
913  *
914  * The bus_helper_reset_post() helper is provided to ease
915  * implementing bus reset methods.
916  *
917  * @param _dev          the bus device
918  * @param _child        the child device
919  */
920 METHOD int reset_post {
921         device_t _dev;
922         device_t _child;
923 } DEFAULT null_reset_post;
924
925 /**
926  * @brief Performs reset of the child
927  *
928  * @param _dev          the bus device
929  * @param _child        the child device
930  * @param _flags        DEVF_RESET_ flags
931  */
932 METHOD int reset_child {
933         device_t _dev;
934         device_t _child;
935         int _flags;
936 };
937
938 /**
939  * @brief Gets child's specific property
940  *
941  * The bus_get_property can be used to access device
942  * specific properties stored on the bus. If _propvalue
943  * is NULL or _size is 0, then method only returns size
944  * of the property.
945  *
946  * @param _dev                  the bus device
947  * @param _child                the child device
948  * @param _propname             property name
949  * @param _propvalue    property value destination
950  * @param _size                 property value size
951  *
952  * @returns size of property if successful otherwise -1
953  */
954 METHOD ssize_t get_property {
955         device_t _dev;
956         device_t _child;
957         const char *_propname;
958         void *_propvalue;
959         size_t _size;
960         device_property_type_t type;
961 } DEFAULT bus_generic_get_property;