devd.conf revision 153300
128328Ssos# $FreeBSD: head/etc/devd.conf 153300 2005-12-11 00:18:28Z iedowse $
2229784Suqs#
328328Ssos# Refer to devd.conf(5) and devd(8) man pages for the details on how to
428328Ssos# run and configure devd.
528328Ssos#
628328Ssos
728328Ssos# NB: All regular expressions have an implicit ^$ around them.
828328Ssos# NB: device-name is shorthand for 'match device-name'
928328Ssos
1028328Ssosoptions {
1128328Ssos	# Each directory directive adds a directory the list of directories
1228328Ssos	# that we scan for files.  Files are read-in in the order that they
1328328Ssos	# are returned from readdir(3).  The rule-sets are combined to
1428328Ssos	# create a DFA that's used to match events to actions.
1597748Sschweikh	directory "/etc/devd";
1628328Ssos	directory "/usr/local/etc/devd";
1728328Ssos	pid-file "/var/run/devd.pid";
1828328Ssos
1928328Ssos	# Setup some shorthand for regex that we use later in the file.
2028328Ssos	#XXX Yes, these are gross -- imp
2128328Ssos	set scsi-controller-regex
2228328Ssos		"(aac|adv|adw|aha|ahb|ahc|ahd|aic|amd|amr|asr|bt|ciss|ct|dpt|\
2328328Ssos		esp|ida|iir|ips|isp|mlx|mly|mpt|ncr|ncv|nsp|stg|sym|trm|wds)\
2428328Ssos		[0-9]+";
2528328Ssos};
2628328Ssos
2728328Ssos# Note that the attach/detach with the highest value wins, so that one can
2828328Ssos# override these general rules.
2983551Sdillon
3083551Sdillon#
3183551Sdillon# For ethernet like devices start configuring the interface.  Due to
3228328Ssos# a historical accident, this script is called pccard_ether.
3328328Ssos#
3428328Ssosattach 0 {
3528328Ssos	media-type "ethernet";
3628328Ssos	action "/etc/pccard_ether $device-name start";
3728328Ssos};
3866834Sphk
3966834Sphkdetach 0 {
4066834Sphk	media-type "ethernet";
4128328Ssos	action "/etc/pccard_ether $device-name stop";
4228328Ssos};
4370991Snsouch
4470991Snsouch#
4553013Syokota# Try to start dhclient on Ethernet like interfaces when the link comes
4653013Syokota# up.  Only devices that are configured to support DHCP will actually
4753013Syokota# run it.  No link down rule exists because dhclient automaticly exits
4828328Ssos# when the link goes down.
4953013Syokota#
5053013Syokotanotify 0 {
5153013Syokota	match "system"		"IFNET";
5228328Ssos	match "type"		"LINK_UP";
5328328Ssos	media-type		"ethernet";
5428328Ssos	action "/etc/rc.d/dhclient start $subsystem";
5553013Syokota};
5653013Syokota
5728328Ssos#
5880270Syokota# Like Ethernet devices, but separate because
5928328Ssos# they have a different media type.  We may want
6053013Syokota# to exploit this later.
6130044Ssos#
6276852Ssobomaxdetach 0 {
6328328Ssos	media-type "802.11";
6428328Ssos	action "/etc/pccard_ether $device-name stop";
6528328Ssos};
6628328Ssosattach 0 {
6728328Ssos	media-type "802.11";
6828328Ssos	action "/etc/pccard_ether $device-name start";
6930044Ssos};
7030044Ssosnotify 0 {
7153013Syokota	match "system"		"IFNET";
7280270Syokota	match "type"		"LINK_UP";
7380270Syokota	media-type		"802.11";
7453013Syokota	action "/etc/rc.d/dhclient start $subsystem";
7553013Syokota};
7653013Syokota
7753013Syokota# An entry like this might be in a different file, but is included here
7853013Syokota# as an example of how to override things.  Normally 'ed50' would match
7953013Syokota# the above attach/detach stuff, but the value of 100 makes it
8050483Syokota# hard wired to 1.2.3.4.
8153013Syokotaattach 100 {
8250141Syokota	device-name "ed50";
8350141Syokota	action "ifconfig $device-name inet 1.2.3.4 netmask 0xffff0000";
8450141Syokota};
8550141Syokotadetach 100 {
8650141Syokota	device-name "ed50";
8776852Ssobomax};
8876852Ssobomax
8950141Syokota# When a USB Bluetooth dongle appears activate it
9050141Syokotaattach 100 {
9150141Syokota	device-name "ubt[0-9]+";
9250141Syokota	action "/etc/rc.d/bluetooth start $device-name";
9350141Syokota};
9450141Syokotadetach 100 {
9528328Ssos	device-name "ubt[0-9]+";
9628328Ssos	action "/etc/rc.d/bluetooth stop $device-name";
9728328Ssos};
9828328Ssos
9953013Syokota# When a USB keyboard arrives, attach it as the console keyboard.
10053013Syokotaattach 100 {
10153013Syokota	device-name "ukbd0";
10228328Ssos	action "kbdcontrol -k /dev/ukbd0 < /dev/console && /etc/rc.d/syscons restart";
10353013Syokota};
10430044Ssosdetach 100 {
10528328Ssos	device-name "ukbd0";
10628328Ssos	action "kbdcontrol -k /dev/kbd0 < /dev/console";
10728328Ssos};
108130245Sstefanf
10928328Ssos# The entry below starts moused when a mouse is plugged in. Moused
11080270Syokota# stops automatically (actually it bombs :) when the device disappears.
11180270Syokotaattach 100 {
11280270Syokota	device-name "ums[0-9]+";
11380270Syokota	action "/etc/rc.d/moused start $device-name";
11480270Syokota};
11580270Syokota
11628328Ssos# Firmware download into the ActiveWire board. After the firmware download is
11728328Ssos# done the device detaches and reappears as something new and shiny
11828328Ssos# automatically.
119130245Sstefanfattach 100 {
12028328Ssos	match "vendor"	"0x0854";
12128328Ssos	match "product"	"0x0100";
12228328Ssos	match "release"	"0x0000";
12328328Ssos	action "/usr/local/bin/ezdownload -f /usr/local/share/usb/firmware/0854.0100.0_01.hex $device-name";
12428328Ssos};
12528328Ssos
12628328Ssos# Firmware download for Entrega Serial DB25 adapter.
12728328Ssosattach 100 {
12828328Ssos	match "vendor"	"0x1645";
12928328Ssos	match "product"	"0x8001";
13028328Ssos	match "release"	"0x0101";
13128328Ssos	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";
13228328Ssos};
13353013Syokota
13428328Ssos# This entry starts the ColdSync tool in daemon mode. Make sure you have an up
13553013Syokota# to date /usr/local/etc/palms. We override the 'listen' settings for port and
13653013Syokota# type in /usr/local/etc/coldsync.conf.
13753013Syokotaattach 100 {
13828328Ssos	device-name "ugen[0-9]+";
13928328Ssos	match "vendor" "0x082d";
14050483Syokota	match "product" "0x0100";
14128328Ssos	match "release" "0x0100";
14228328Ssos	action "/usr/local/bin/coldsync -md -p /dev/$device-name -t usb";
14380270Syokota};
14428328Ssos
14528328Ssos#
14628328Ssos# Rescan scsi device-names on attach, but not detach.  However, it is
14780270Syokota# disabled by default due to reports of problems.
14828328Ssos#
14953013Syokotaattach 0 {
15053013Syokota	device-name "$scsi-controller-regex";
15153013Syokota//	action "camcontrol rescan all";
15253013Syokota};
15353013Syokota
15453013Syokota# Don't even try to second guess what to do about drivers that don't
15553013Syokota# match here.  Instead, pass it off to syslog.  Commented out for the
15653013Syokota# moment, as pnpinfo isn't set in devd yet.
15728328Ssosnomatch 0 {
15871643Ssobomax#	action "logger Unknown device: $pnpinfo $location $bus";
15976852Ssobomax};
16076852Ssobomax
16176852Ssobomax# Switch power profiles when the AC line state changes.
16271643Ssobomaxnotify 10 {
16376852Ssobomax	match "system"		"ACPI";
16471643Ssobomax	match "subsystem"	"ACAD";
16553013Syokota	action "/etc/rc.d/power_profile $notify";
16653013Syokota};
16753013Syokota
16828328Ssos# Notify all users before beginning emergency shutdown when we get
16953013Syokota# a _CRT or _HOT thermal event and we're going to power down the system
17053013Syokota# very soon.
17153013Syokotanotify 10 {
17228328Ssos	match "system"		"ACPI";
17328328Ssos	match "subsystem"	"Thermal";
17453013Syokota	match "notify"		"0xcc";
17553013Syokota	action "logger -p kern.emerg 'WARNING: system temperature too high, shutting down soon!'";
17653013Syokota};
17753013Syokota
17853013Syokota/* EXAMPLES TO END OF FILE
17953013Syokota
18053013Syokota# The following might be an example of something that a vendor might
18153013Syokota# install if you were to add their device.  This might reside in
18253013Syokota# /usr/local/etc/devd/deqna.conf.  A deqna is, in this hypothetical
18353013Syokota# example, a pccard ethernet-like device.  Students of history may
18453013Syokota# know other devices by this name, and will get the in-jokes in this
18553013Syokota# entry.
18653013Syokotanomatch 10 {
18753013Syokota	match "bus" "pccard[0-9]+";
18828328Ssos	match "manufacturer" "0x1234";
18928328Ssos	match "product" "0x2323";
19053013Syokota	action "kldload if_deqna";
19153013Syokota};
19253013Syokotaattach 10 {
19353013Syokota	device-name "deqna[0-9]+";
19453013Syokota	action "/etc/pccard_ether $device-name start";
19553013Syokota};
19628328Ssosdetach 10 {
19771623Snsouch	device-name "deqna[0-9]+";
19828328Ssos	action "/etc/pccard_ether $device-name stop";
19953013Syokota};
20028328Ssos
20171623Snsouch# Examples of notify hooks.  A notify is a generic way for a kernel
20228328Ssos# subsystem to send event notification to userland.
20370991Snsouch#
20470991Snsouch# Here are some examples of ACPI notify handlers.  ACPI subsystems that
20570991Snsouch# generate notifies include the AC adapter, power/sleep buttons,
20670991Snsouch# control method batteries, lid switch, and thermal zones.
20770991Snsouch#
20870991Snsouch# Information returned is not always the same as the ACPI notify
20970991Snsouch# events.  See the ACPI specification for more information about
21070991Snsouch# notifies.  Here is the information returned for each subsystem:
21170991Snsouch#
21270991Snsouch# ACAD:		AC line state (0 is offline, 1 is online)
21370991Snsouch# Button:	Button pressed (0 for power, 1 for sleep)
21470991Snsouch# CMBAT:	ACPI battery events
21570991Snsouch# Lid:		Lid state (0 is closed, 1 is open)
21670991Snsouch# Thermal:	ACPI thermal zone events
21770991Snsouch#
21870991Snsouch# This example calls a script when the AC state changes, passing the
21970991Snsouch# notify value as the first argument.  If the state is 0x00, it might
22070991Snsouch# call some sysctls to implement economy mode.  If 0x01, it might set
22170991Snsouch# the mode to performance.
22228328Ssosnotify 10 {
22328328Ssos	match "system"		"ACPI";
22453013Syokota	match "subsystem"	"ACAD";
22528328Ssos	action			"/etc/acpi_ac $notify";
22628328Ssos};
22728328Ssos*/
22828328Ssos