xref: /freebsd/share/man/man9/DEVICE_PROBE.9 (revision 315ee00f)
1.\" -*- nroff -*-
2.\"
3.\" Copyright (c) 1998 Doug Rabson
4.\"
5.\" All rights reserved.
6.\"
7.\" This program is free software.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
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.
17.\"
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.
28.\"
29.Dd February 8, 2012
30.Dt DEVICE_PROBE 9
31.Os
32.Sh NAME
33.Nm DEVICE_PROBE
34.Nd probe for device existence
35.Sh SYNOPSIS
36.In sys/param.h
37.In sys/bus.h
38.Ft int
39.Fn DEVICE_PROBE "device_t dev"
40.Sh DESCRIPTION
41The
42.Fn DEVICE_PROBE
43method should probe to see if the device is present.
44It should return 0 if the device exists,
45.Er ENXIO
46if it cannot be found.
47If some other error happens during the probe (such as a memory
48allocation failure), an appropriate error code should be returned.
49For
50cases where more than one driver matches a device, a priority value can
51be returned.
52In this case, success codes are values less than or equal
53to zero with the highest value representing the best match.
54Failure
55codes are represented by positive values and the regular
56.Ux
57error
58codes should be used for the purpose.
59.Pp
60If a driver returns a success code which is less than zero, it must
61not assume that it will be the same driver which is attached to the
62device.
63In particular, it must not assume that any values stored in
64the softc structure will be available for its attach method and any
65resources allocated during probe must be released and re-allocated
66if the attach method is called.
67In addition it is an absolute requirement that the probe routine have
68no side effects whatsoever.
69The probe routine may be called more than once before the attach
70routine is called.
71.Pp
72If a success code of zero is
73returned, the driver can assume that it will be the one attached, but
74must not hold any resources when the probe routine returns.
75A driver may assume that the softc is preserved when it returns
76a success code of zero.
77.Sh RETURN VALUES
78A value equal to or less than zero indicates success, greater than
79zero indicates an error (errno).
80For values equal to or less than
81zero: zero indicates highest priority, no further probing is done;
82for a value less than zero, the lower the value the lower the
83priority, e.g.\& -100 indicates a lower priority than -50.
84.Pp
85The following values are used by convention to indicate different
86strengths of matching in a probe routine.
87Except as noted, these are just suggested values, and there's nothing
88magical about them.
89.Bl -tag -width BUS_PROBE_NOWILDCARD
90.It BUS_PROBE_SPECIFIC
91The device that cannot be reprobed, and that no
92possible other driver may exist (typically legacy drivers who don't follow
93all the rules, or special needs drivers).
94.It BUS_PROBE_VENDOR
95The device is supported by a vendor driver.
96This is for source or binary drivers that are not yet integrated into the
97.Fx
98tree.
99Its use in the base OS is prohibited.
100.It BUS_PROBE_DEFAULT
101The device is a normal device matching some plug and play ID.
102This is
103the normal return value for drivers to use.
104It is intended that nearly all of the drivers in the tree should return
105this value.
106.It BUS_PROBE_LOW_PRIORITY
107The driver is a legacy driver, or an otherwise less desirable driver
108for a given plug and play ID.
109The driver has special requirements like when there are two drivers
110that support overlapping series of hardware devices.
111In this case the one that supports the older part of the line would
112return this value, while the one that supports the newer ones would
113return BUS_PROBE_DEFAULT.
114.It BUS_PROBE_GENERIC
115The driver matches the type of device generally.
116This allows drivers to match all serial ports generally, with specialized
117drivers matching particular types of serial ports that need special
118treatment for some reason.
119.It BUS_PROBE_HOOVER
120The driver matches all unclaimed devices on a bus.
121The
122.Xr ugen 4
123device is one example.
124.It BUS_PROBE_NOWILDCARD
125The driver expects its parent to tell it which children to manage
126and no probing is really done.
127The device only matches if its parent bus specifically said to use
128this driver.
129.El
130.Sh SEE ALSO
131.Xr device 9 ,
132.Xr DEVICE_ATTACH 9 ,
133.Xr DEVICE_DETACH 9 ,
134.Xr DEVICE_IDENTIFY 9 ,
135.Xr DEVICE_SHUTDOWN 9
136.Sh AUTHORS
137This manual page was written by
138.An Doug Rabson .
139