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