summaryrefslogtreecommitdiff
path: root/static/freebsd/man9/DEVICE_IDENTIFY.9 3.html
blob: 5134840fa42ccb9d8d1631754cd2480b6f9c7c90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<table class="head">
  <tr>
    <td class="head-ltitle">DEVICE_IDENTIFY(9)</td>
    <td class="head-vol">Kernel Developer's Manual</td>
    <td class="head-rtitle">DEVICE_IDENTIFY(9)</td>
  </tr>
</table>
<div class="manual-text">
<section class="Sh">
<h1 class="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h1>
<p class="Pp"><code class="Nm">DEVICE_IDENTIFY</code> &#x2014;
    <span class="Nd">identify new child devices and register them</span></p>
</section>
<section class="Sh">
<h1 class="Sh" id="SYNOPSIS"><a class="permalink" href="#SYNOPSIS">SYNOPSIS</a></h1>
<p class="Pp"><code class="In">#include
    &lt;<a class="In">sys/param.h</a>&gt;</code>
  <br/>
  <code class="In">#include &lt;<a class="In">sys/bus.h</a>&gt;</code></p>
<p class="Pp"><var class="Ft">void</var>
  <br/>
  <code class="Fn">DEVICE_IDENTIFY</code>(<var class="Fa" style="white-space: nowrap;">driver_t
    *driver</var>, <var class="Fa" style="white-space: nowrap;">device_t
    parent</var>);</p>
</section>
<section class="Sh">
<h1 class="Sh" id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">DESCRIPTION</a></h1>
<p class="Pp">The identify method of a device driver is used to add devices that
    cannot be enumerated by the standard method on a bus device. Devices can be
    enumerated in various ways including accessing non-ambiguous device
    registers and parsing firmware tables. Software-only pseudo devices are also
    often enumerated via identify methods.</p>
<p class="Pp">For each newly identified device, a new device instance should be
    created by invoking the <a class="Xr">BUS_ADD_CHILD(9)</a> method. If the
    identify method is able to discover other properties about the new device,
    those should also be set. For example, device resources should be added to
    the device by calling <a class="Xr">bus_set_resource(9)</a> for each
    resource.</p>
<p class="Pp">An identify method might be invoked multiple times. If a device
    driver is unloaded and loaded, the identify method will be called a second
    time after being reloaded. As a result, the identify method should avoid
    duplicate devices. Devices added by identify methods typically use a fixed
    device name in which case <a class="Xr">device_find_child(9)</a> can be used
    to detect existing devices.</p>
</section>
<section class="Sh">
<h1 class="Sh" id="EXAMPLES"><a class="permalink" href="#EXAMPLES">EXAMPLES</a></h1>
<p class="Pp">The following pseudo-code shows an example of a function that
    probes for a piece of hardware and registers it and its resource (an I/O
    port) with the parent bus device.</p>
<div class="Bd Pp Li">
<pre>void
foo_identify(driver_t *driver, device_t parent)
{
	device_t child;

	retrieve_device_information;
	if (devices matches one of your supported devices &amp;&amp;
	    device_find_child(parent, &quot;foo&quot;, DEVICE_UNIT_ANY) == NULL) {
		child = BUS_ADD_CHILD(parent, 0, &quot;foo&quot;, DEVICE_UNIT_ANY);
		bus_set_resource(child, SYS_RES_IOPORT, 0, FOO_IOADDR, 1);
	}
}</pre>
</div>
</section>
<section class="Sh">
<h1 class="Sh" id="SEE_ALSO"><a class="permalink" href="#SEE_ALSO">SEE
  ALSO</a></h1>
<p class="Pp"><a class="Xr">BUS_ADD_CHILD(9)</a>,
    <a class="Xr">bus_identify_children(9)</a>,
    <a class="Xr">bus_set_resource(9)</a>, <a class="Xr">device(9)</a>,
    <a class="Xr">device_find_child(9)</a></p>
</section>
<section class="Sh">
<h1 class="Sh" id="AUTHORS"><a class="permalink" href="#AUTHORS">AUTHORS</a></h1>
<p class="Pp">This manual page was written by <span class="An">Alexander
    Langer</span>
    &lt;<a class="Mt" href="mailto:alex@FreeBSD.org">alex@FreeBSD.org</a>&gt;.</p>
</section>
</div>
<table class="foot">
  <tr>
    <td class="foot-date">February 5, 2025</td>
    <td class="foot-os">FreeBSD 15.0</td>
  </tr>
</table>