xref: /freebsd/sbin/devd/devd.conf (revision e9b1dc32c9bd2ebae5f9e140bfa0e0321bc366b5)
1# $FreeBSD$
2#
3# Refer to devd.conf(5) and devd(8) man pages for the details on how to
4# run and configure devd.
5#
6
7# NB: All regular expressions have an implicit ^$ around them.
8# NB: device-name is shorthand for 'match device-name'
9
10options {
11	# Each "directory" directive adds a directory to the list of
12	# directories that we scan for files.  Files are loaded in the order
13	# that they are returned from readdir(3).  The rule-sets are combined
14	# to create a DFA that's used to match events to actions.
15	directory "/etc/devd";
16	directory "/usr/local/etc/devd";
17	pid-file "/var/run/devd.pid";
18
19	# Setup some shorthand for regex that we use later in the file.
20	#XXX Yes, these are gross -- imp
21	set scsi-controller-regex
22		"(aac|adv|adw|aha|ahc|ahd|aic|amr|bt|ciss|dpt|\
23		esp|ida|iir|ips|isp|mlx|mly|mpr|mps|mpt|ncr|ncv|nsp|stg|sym|\
24		trm)\
25		[0-9]+";
26	set wifi-driver-regex
27		"(ath|bwi|bwn|ipw|iwi|iwm|iwn|malo|mwl|ral|rsu|rtwn|rum|run|\
28		uath|upgt|ural|urtw|wi|wpi|wtap|zyd)[0-9]+";
29};
30
31# Note that the attach/detach with the highest value wins, so that one can
32# override these general rules.
33
34#
35# Configure the interface on attach.  Due to a historical accident, this
36# script is called pccard_ether.
37#
38# NB: DETACH events are ignored; the kernel should handle all cleanup
39#     (routes, arp cache).  Beware of races against immediate create
40#     of a device with the same name; e.g.
41#     ifconfig bridge0 destroy; ifconfig bridge0 create
42#
43notify 0 {
44	match "system"		"IFNET";
45	match "subsystem"	"!usbus[0-9]+";
46	match "type"		"ATTACH";
47	action "/etc/pccard_ether $subsystem start";
48};
49
50#
51# Try to start dhclient on Ethernet-like interfaces when the link comes
52# up.  Only devices that are configured to support DHCP will actually
53# run it.  No link down rule exists because dhclient automatically exits
54# when the link goes down.
55#
56notify 0 {
57	match "system"		"IFNET";
58	match "type"		"LINK_UP";
59	media-type		"ethernet";
60	action "service dhclient quietstart $subsystem";
61};
62
63#
64# Like Ethernet devices, but separate because 802.11 require spawning
65# wlan(4) interface.
66#
67attach 0 {
68	device-name "$wifi-driver-regex";
69	action "/etc/pccard_ether $device-name startchildren";
70};
71detach 0 {
72	device-name "$wifi-driver-regex";
73	action "/etc/pccard_ether $device-name stopchildren";
74};
75notify 0 {
76	match "system"		"IFNET";
77	match "type"		"LINK_UP";
78	media-type		"802.11";
79	action "service dhclient quietstart $subsystem";
80};
81
82# An entry like this might be in a different file, but is included here
83# as an example of how to override things.  Normally 'ed50' would match
84# the above attach/detach stuff, but the value of 100 makes it
85# hard wired to 1.2.3.4.
86attach 100 {
87	device-name "ed50";
88	action "ifconfig $device-name inet 1.2.3.4 netmask 0xffff0000";
89};
90detach 100 {
91	device-name "ed50";
92};
93
94# When a USB Bluetooth dongle appears, activate it
95attach 100 {
96	device-name "ubt[0-9]+";
97	action "service bluetooth quietstart $device-name";
98};
99detach 100 {
100	device-name "ubt[0-9]+";
101	action "service bluetooth quietstop $device-name";
102};
103
104# Firmware downloader for Atheros AR3011 based USB Bluetooth devices
105#attach 100 {
106#	match "vendor" "0x0cf3";
107#	match "product" "0x3000";
108#	action "sleep 2 && /usr/sbin/ath3kfw -d $device-name -f /usr/local/etc/ath3k-1.fw";
109#};
110
111# When a USB keyboard arrives, attach it as the console keyboard.
112attach 100 {
113	device-name "ukbd0";
114	action "service syscons setkeyboard /dev/ukbd0";
115};
116detach 100 {
117	device-name "ukbd0";
118	action "service syscons setkeyboard /dev/kbd0";
119};
120
121notify 100 {
122	match "system" "DEVFS";
123	match "subsystem" "CDEV";
124	match "type" "CREATE";
125	match "cdev" "atp[0-9]+";
126
127	action "service moused quietstart $cdev";
128};
129
130notify 100 {
131	match "system" "DEVFS";
132	match "subsystem" "CDEV";
133	match "type" "CREATE";
134	match "cdev" "ums[0-9]+";
135
136	action "service moused quietstart $cdev";
137};
138
139notify 100 {
140	match "system" "DEVFS";
141	match "subsystem" "CDEV";
142	match "type" "CREATE";
143	match "cdev" "wsp[0-9]+";
144
145	action "service moused quietstart $cdev";
146};
147
148notify 100 {
149	match "system" "DEVFS";
150	match "subsystem" "CDEV";
151	match "type" "DESTROY";
152	match "cdev" "ums[0-9]+";
153
154	action "service moused stop $cdev";
155};
156
157# Firmware download into the ActiveWire board. After the firmware download is
158# done, the device detaches and reappears as something new and shiny
159# automatically.
160attach 100 {
161	match "vendor"	"0x0854";
162	match "product"	"0x0100";
163	match "release"	"0x0000";
164	action "/usr/local/bin/ezdownload -f /usr/local/share/usb/firmware/0854.0100.0_01.hex $device-name";
165};
166
167# Firmware download for Entrega Serial DB25 adapter.
168attach 100 {
169	match "vendor"	"0x1645";
170	match "product"	"0x8001";
171	match "release"	"0x0101";
172	action "if ! kldstat -n usio > /dev/null 2>&1 ; then kldload usio; fi; /usr/sbin/ezdownload -v -f /usr/share/usb/firmware/1645.8001.0101 /dev/$device-name";
173};
174
175# This entry starts the ColdSync tool in daemon mode. Make sure you have an up
176# to date /usr/local/etc/palms. We override the 'listen' settings for port and
177# type in /usr/local/etc/coldsync.conf.
178notify 100 {
179	match "system"		"USB";
180	match "subsystem"	"DEVICE";
181	match "type"		"ATTACH";
182	match "vendor"		"0x082d";
183	match "product"		"0x0100";
184	match "release"		"0x0100";
185	action "/usr/local/bin/coldsync -md -p /dev/$cdev -t usb";
186};
187
188#
189# Rescan SCSI device-names on attach, but not detach.  However, it is
190# disabled by default due to reports of problems.
191#
192attach 0 {
193	device-name "$scsi-controller-regex";
194//	action "camcontrol rescan all";
195};
196
197# Don't even try to second guess what to do about drivers that don't
198# match here.  Instead, pass it off to syslog.  Commented out for the
199# moment, as the pnpinfo variable isn't set in devd yet.  Individual
200# variables within the bus supplied pnpinfo are set.
201nomatch 0 {
202#	action "logger Unknown device: $pnpinfo $location $bus";
203};
204
205# Various logging of unknown devices.
206nomatch 10 {
207	match "bus" "uhub[0-9]+";
208	action "logger Unknown USB device: vendor $vendor product $product \
209		bus $bus";
210};
211
212# Some PC-CARDs don't offer numerical manufacturer/product IDs, just
213# show the CIS info there.
214nomatch 20 {
215	match "bus" "pccard[0-9]+";
216	match "manufacturer" "0xffffffff";
217	match "product" "0xffffffff";
218	action "logger Unknown PCCARD device: CISproduct $cisproduct \
219		CIS-vendor $cisvendor bus $bus";
220};
221
222nomatch 10 {
223	match "bus" "pccard[0-9]+";
224	action "logger Unknown PCCARD device: manufacturer $manufacturer \
225		product $product CISproduct $cisproduct CIS-vendor \
226		$cisvendor bus $bus";
227};
228
229nomatch 10 {
230	match "bus" "cardbus[0-9]+";
231	action "logger Unknown Cardbus device: device $device class $class \
232		vendor $vendor bus $bus";
233};
234
235# Switch power profiles when the AC line state changes.
236notify 10 {
237	match "system"		"ACPI";
238	match "subsystem"	"ACAD";
239	action "service power_profile $notify";
240};
241
242# Notify all users before beginning emergency shutdown when we get
243# a _CRT or _HOT thermal event and we're going to power down the system
244# very soon.
245notify 10 {
246	match "system"		"ACPI";
247	match "subsystem"	"Thermal";
248	match "notify"		"0xcc";
249	action "logger -p kern.emerg 'WARNING: system temperature too high, shutting down soon!'";
250};
251
252# User requested suspend, so perform preparation steps and then execute
253# the actual suspend process.
254notify 10 {
255	match "system"		"ACPI";
256	match "subsystem"	"Suspend";
257	action "/etc/rc.suspend acpi $notify";
258};
259notify 10 {
260	match "system"		"ACPI";
261	match "subsystem"	"Resume";
262	action "/etc/rc.resume acpi $notify";
263};
264
265/* EXAMPLES TO END OF FILE
266
267# An example of something that a vendor might install if you were to
268# add their device.  This might reside in /usr/local/etc/devd/deqna.conf.
269# A deqna is, in this hypothetical example, a pccard ethernet-like device.
270# Students of history may know other devices by this name, and will get
271# the in-jokes in this entry.
272nomatch 10 {
273	match "bus" "pccard[0-9]+";
274	match "manufacturer" "0x1234";
275	match "product" "0x2323";
276	action "kldload -n if_deqna";
277};
278attach 10 {
279	device-name "deqna[0-9]+";
280	action "/etc/pccard_ether $device-name start";
281};
282detach 10 {
283	device-name "deqna[0-9]+";
284	action "/etc/pccard_ether $device-name stop";
285};
286
287# Examples of notify hooks.  A notify is a generic way for a kernel
288# subsystem to send event notification to userland.
289
290# Here are some examples of ACPI notify handlers.  ACPI subsystems that
291# generate notifies include the AC adapter, power/sleep buttons,
292# control method batteries, lid switch, and thermal zones.
293#
294# Information returned is not always the same as the ACPI notify
295# events.  See the ACPI specification for more information about
296# notifies.  Here is the information returned for each subsystem:
297#
298# ACAD:            AC line state (0 is offline, 1 is online)
299# Button:          Button pressed (0 for power, 1 for sleep)
300# CMBAT:           ACPI battery events
301# Lid:             Lid state (0 is closed, 1 is open)
302# Suspend, Resume: Suspend and resume notification
303# Thermal:         ACPI thermal zone events
304#
305# This example calls a script when the AC state changes, passing the
306# notify value as the first argument.  If the state is 0x00, it might
307# call some sysctls to implement economy mode.  If 0x01, it might set
308# the mode to performance.
309notify 10 {
310	match "system"		"ACPI";
311	match "subsystem"	"ACAD";
312	action			"/etc/acpi_ac $notify";
313};
314
315# This example works around a memory leak in PostgreSQL, restarting
316# it when the "user:postgres:swap:devctl=1G" rctl(8) rule gets triggered.
317notify 0 {
318	match "system"		"RCTL";
319	match "rule"		"user:770:swap:.*";
320	action			"service postgresql restart";
321};
322
323# Discard autofs caches, useful for the -media special map.
324notify 100 {
325	match "system" "GEOM";
326	match "subsystem" "DEV";
327	action "/usr/sbin/automount -c";
328};
329
330# Handle userland coredumps.
331# This commented out handler makes it possible to run an
332# automated debugging session after the core dump is generated.
333# Replace action with a proper coredump handler, but be aware that
334# it will run with elevated privileges.
335notify 10 {
336	match "system"          "kernel";
337	match "subsystem"       "signal";
338	match "type"            "coredump";
339	action "logger $comm $core";
340};
341
342# Let the init(8) know there's a new USB serial interface it might
343# want to run getty(8) for.  This includes device-side tty created
344# by usb_template(4).
345notify 100 {
346	match "system"		"DEVFS";
347	match "subsystem"	"CDEV";
348	match "type"		"CREATE";
349	match "cdev"		"ttyU[0-9]+";
350	action "/sbin/init q";
351};
352
353*/
354