3 .\" Copyright (c) 2001 Alexander Langer
5 .\" All rights reserved.
7 .\" This program is free software.
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\" notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\" notice, this list of conditions and the following disclaimer in the
16 .\" documentation and/or other materials provided with the distribution.
18 .\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
19 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 .\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
22 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 .Nd identify a device, register it
41 .Fn DEVICE_IDENTIFY "driver_t *driver" "device_t parent"
43 The identify function for a device is only needed for devices on busses
44 that cannot identify their children independently, e.g.\& the ISA bus.
45 It is used to recognize the device (usually done by accessing non-ambiguous
46 registers in the hardware) and to tell the kernel about it and thus
47 creating a new device instance.
50 is used to register the device as a child of the bus.
51 The device's resources (such as IRQ and I/O ports) are registered
52 with the kernel by calling
54 for each resource (refer to
55 .Xr bus_set_resource 9
56 for more information).
58 Since the device tree and the device driver tree are disjoint, the
60 routine needs to take this into account.
61 If you load and unload your device driver that has the identify
62 routine, the child node has the potential for adding the same node
63 multiple times unless specific measure are taken to preclude that
66 The following pseudo-code shows an example of a function that
67 probes for a piece of hardware and registers it and its resource
68 (an I/O port) with the kernel.
71 foo_identify(driver_t *driver, device_t parent)
75 retrieve_device_information;
76 if (devices matches one of your supported devices &&
77 not already in device tree) {
78 child = BUS_ADD_CHILD(parent, 0, "foo", -1);
79 bus_set_resource(child, SYS_RES_IOPORT, 0, FOO_IOADDR, 1);
85 .Xr bus_set_resource 9 ,
87 .Xr device_add_child 9 ,
93 This manual page was written by
94 .An Alexander Langer Aq alex@FreeBSD.org .