FreeBSD kernel kern code
bus_if.m
Go to the documentation of this file.
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 # $BSDSUniX$
27 #
28 
29 #include <sys/types.h>
30 #include <sys/systm.h>
31 #include <sys/bus.h>
32 
39 INTERFACE bus;
40 
41 #
42 # Default implementations of some methods.
43 #
45  static struct resource *
46  null_alloc_resource(device_t dev, device_t child,
47  int type, int *rid, u_long start, u_long end,
48  u_long 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 
85 METHOD int print_child {
86  device_t _dev;
87  device_t _child;
89 
99 METHOD void probe_nomatch {
100  device_t _dev;
101  device_t _child;
102 };
103 
131 METHOD int read_ivar {
132  device_t _dev;
133  device_t _child;
134  int _index;
135  uintptr_t *_result;
136 };
137 
155 METHOD int write_ivar {
156  device_t _dev;
157  device_t _child;
158  int _indx;
159  uintptr_t _value;
160 };
161 
171 METHOD void child_deleted {
172  device_t _dev;
173  device_t _child;
174 };
175 
185 METHOD void child_detached {
186  device_t _dev;
187  device_t _child;
188 };
189 
201 METHOD void driver_added {
202  device_t _dev;
203  driver_t *_driver;
205 
225 METHOD device_t add_child {
226  device_t _dev;
227  u_int _order;
228  const char *_name;
229  int _unit;
231 
260 METHOD struct resource * alloc_resource {
261  device_t _dev;
262  device_t _child;
263  int _type;
264  int *_rid;
265  u_long _start;
266  u_long _end;
267  u_long _count;
268  u_int _flags;
270 
284 METHOD int activate_resource {
285  device_t _dev;
286  device_t _child;
287  int _type;
288  int _rid;
289  struct resource *_r;
290 };
291 
306  device_t _dev;
307  device_t _child;
308  int _type;
309  int _rid;
310  struct resource *_r;
311 };
312 
328 METHOD int adjust_resource {
329  device_t _dev;
330  device_t _child;
331  int _type;
332  struct resource *_res;
333  u_long _start;
334  u_long _end;
335 };
336 
350 METHOD int release_resource {
351  device_t _dev;
352  device_t _child;
353  int _type;
354  int _rid;
355  struct resource *_res;
356 };
357 
381 METHOD int setup_intr {
382  device_t _dev;
383  device_t _child;
384  struct resource *_irq;
385  int _flags;
386  driver_filter_t *_filter;
387  driver_intr_t *_intr;
388  void *_arg;
389  void **_cookiep;
390 };
391 
405 METHOD int teardown_intr {
406  device_t _dev;
407  device_t _child;
408  struct resource *_irq;
409  void *_cookie;
410 };
411 
429 METHOD int set_resource {
430  device_t _dev;
431  device_t _child;
432  int _type;
433  int _rid;
434  u_long _start;
435  u_long _count;
436 };
437 
453 METHOD int get_resource {
454  device_t _dev;
455  device_t _child;
456  int _type;
457  int _rid;
458  u_long *_startp;
459  u_long *_countp;
460 };
461 
473 METHOD void delete_resource {
474  device_t _dev;
475  device_t _child;
476  int _type;
477  int _rid;
478 };
479 
490 METHOD struct resource_list * get_resource_list {
491  device_t _dev;
492  device_t _child;
494 
510 METHOD int child_present {
511  device_t _dev;
512  device_t _child;
514 
527 METHOD int child_pnpinfo_str {
528  device_t _dev;
529  device_t _child;
530  char *_buf;
531  size_t _buflen;
532 };
533 
546 METHOD int child_location_str {
547  device_t _dev;
548  device_t _child;
549  char *_buf;
550  size_t _buflen;
551 };
552 
562 METHOD int bind_intr {
563  device_t _dev;
564  device_t _child;
565  struct resource *_irq;
566  int _cpu;
568 
578 METHOD int config_intr {
579  device_t _dev;
580  int _irq;
581  enum intr_trigger _trig;
582  enum intr_polarity _pol;
584 
596 METHOD int describe_intr {
597  device_t _dev;
598  device_t _child;
599  struct resource *_irq;
600  void *_cookie;
601  const char *_descr;
603 
620 METHOD void hinted_child {
621  device_t _dev;
622  const char *_dname;
623  int _dunit;
624 };
625 
632 METHOD bus_dma_tag_t get_dma_tag {
633  device_t _dev;
634  device_t _child;
636 
645 METHOD void hint_device_unit {
646  device_t _dev;
647  device_t _child;
648  const char *_name;
649  int *_unitp;
650 };
651 
657 METHOD void new_pass {
658  device_t _dev;
660 
668 METHOD int remap_intr {
669  device_t _dev;
670  device_t _child;
671  u_int _irq;
enum intr_trigger _trig
Definition: bus_if.m:581
driver_t * _driver
Definition: bus_if.m:203
char * _buf
Definition: bus_if.m:530
device_t _child
Definition: bus_if.m:87
METHOD bus_dma_tag_t get_dma_tag
Returns bus_dma_tag_t for use w/ devices on the bus.
Definition: bus_if.m:632
DEFAULT bus_generic_new_pass
Definition: bus_if.m:659
void ** _cookiep
Definition: bus_if.m:389
DEFAULT bus_generic_child_present
Definition: bus_if.m:513
METHOD int child_pnpinfo_str
Returns the pnp info for this device.
Definition: bus_if.m:527
size_t _buflen
Definition: bus_if.m:531
METHOD struct resource * alloc_resource
Allocate a system resource.
Definition: bus_if.m:260
u_int _order
Definition: bus_if.m:227
DEFAULT bus_generic_driver_added
Definition: bus_if.m:204
METHOD void hinted_child
Notify a (bus) driver about a child that the hints mechanism believes it has discovered.
Definition: bus_if.m:620
DEFAULT bus_generic_get_resource_list
Definition: bus_if.m:493
INTERFACE bus
Definition: bus_if.m:39
u_int _flags
Definition: bus_if.m:268
void *** start
Definition: linker_if.m:86
struct resource * _r
Definition: bus_if.m:289
enum intr_polarity _pol
Definition: bus_if.m:582
struct resource * _irq
Definition: bus_if.m:384
void panic(const char *fmt,...)
METHOD void probe_nomatch
Print a notification about an unprobed child device.
Definition: bus_if.m:99
METHOD void delete_resource
Delete a resource.
Definition: bus_if.m:473
DEFAULT bus_generic_describe_intr
Definition: bus_if.m:602
const char * name
Definition: kern_fail.c:97
DEFAULT null_add_child
Definition: bus_if.m:230
METHOD int set_resource
Define a resource which can be allocated with BUS_ALLOC_RESOURCE().
Definition: bus_if.m:429
int _unit
Definition: bus_if.m:229
int * type
Definition: cpufreq_if.m:98
u_long * _startp
Definition: bus_if.m:458
u_long _end
Definition: bus_if.m:266
DEFAULT bus_generic_bind_intr
Definition: bus_if.m:567
METHOD int config_intr
Allow (bus) drivers to specify the trigger mode and polarity of the specified interrupt.
Definition: bus_if.m:578
METHOD int release_resource
Release a resource.
Definition: bus_if.m:350
driver_filter_t * _filter
Definition: bus_if.m:386
METHOD void driver_added
Notify a bus that a new driver was added.
Definition: bus_if.m:201
DEFAULT null_alloc_resource
Definition: bus_if.m:269
uintptr_t _value
Definition: bus_if.m:159
METHOD int write_ivar
Write the value of a bus-specific attribute of a device.
Definition: bus_if.m:155
METHOD int child_present
Is the hardware described by _child still attached to the system?
Definition: bus_if.m:510
METHOD int describe_intr
Allow drivers to associate a description with an active interrupt handler.
Definition: bus_if.m:596
int _dunit
Definition: bus_if.m:623
METHOD struct resource_list * get_resource_list
Return a struct resource_list.
Definition: bus_if.m:490
METHOD void hint_device_unit
Allow the bus to determine the unit number of a device.
Definition: bus_if.m:645
METHOD int setup_intr
Install an interrupt handler.
Definition: bus_if.m:381
METHOD int activate_resource
Activate a resource.
Definition: bus_if.m:284
int * _rid
Definition: bus_if.m:264
METHOD int child_location_str
Returns the location for this device.
Definition: bus_if.m:546
METHOD int adjust_resource
Adjust a resource.
Definition: bus_if.m:328
int _cpu
Definition: bus_if.m:566
DEFAULT bus_generic_config_intr
Definition: bus_if.m:583
void * _cookie
Definition: bus_if.m:409
#define DEFAULT(foo, bar)
void * _arg
Definition: bus_if.m:388
METHOD void child_deleted
Notify a bus that a child was deleted.
Definition: bus_if.m:171
u_long * _countp
Definition: bus_if.m:459
int _index
Definition: bus_if.m:134
DEFAULT bus_generic_print_child
Definition: bus_if.m:88
METHOD int teardown_intr
Uninstall an interrupt handler.
Definition: bus_if.m:405
int _type
Definition: bus_if.m:263
struct resource * _res
Definition: bus_if.m:332
CODE
Definition: bus_if.m:44
DEFAULT null_remap_intr
Definition: bus_if.m:672
METHOD int bind_intr
Allow drivers to request that an interrupt be bound to a specific CPU.
Definition: bus_if.m:562
driver_intr_t * _intr
Definition: bus_if.m:387
int _indx
Definition: bus_if.m:158
METHOD int print_child
Print a description of a child device.
Definition: bus_if.m:85
METHOD int deactivate_resource
Deactivate a resource.
Definition: bus_if.m:305
u_long _count
Definition: bus_if.m:267
METHOD int remap_intr
Notify a bus that specified child's IRQ should be remapped.
Definition: bus_if.m:668
u_long _start
Definition: bus_if.m:265
const char * _name
Definition: bus_if.m:228
METHOD device_t add_child
Create a new child device.
Definition: bus_if.m:225
METHOD void child_detached
Notify a bus that a child was detached.
Definition: bus_if.m:185
int * _unitp
Definition: bus_if.m:649
METHOD int read_ivar
Read the value of a bus-specific attribute of a device.
Definition: bus_if.m:131
const char * _dname
Definition: bus_if.m:622
const char * _descr
Definition: bus_if.m:601
METHOD void new_pass
Notify a bus that the bus pass level has been changed.
Definition: bus_if.m:657
uintptr_t * _result
Definition: bus_if.m:135
DEFAULT bus_generic_get_dma_tag
Definition: bus_if.m:635
METHOD int get_resource
Describe a resource.
Definition: bus_if.m:453
int * count
Definition: cpufreq_if.m:63