devd.conf revision 166701
1289694Sngie# $FreeBSD: head/etc/devd.conf 166701 2007-02-14 08:13:54Z joerg $ 2289694Sngie# 3289694Sngie# Refer to devd.conf(5) and devd(8) man pages for the details on how to 4289694Sngie# run and configure devd. 5289694Sngie# 6289694Sngie 7289694Sngie# NB: All regular expressions have an implicit ^$ around them. 8289694Sngie# NB: device-name is shorthand for 'match device-name' 9289694Sngie 10289694Sngieoptions { 11289694Sngie # Each directory directive adds a directory the list of directories 12289694Sngie # that we scan for files. Files are read-in in the order that they 13289694Sngie # are returned from readdir(3). The rule-sets are combined to 14289694Sngie # create a DFA that's used to match events to actions. 15289694Sngie directory "/etc/devd"; 16289694Sngie directory "/usr/local/etc/devd"; 17289694Sngie pid-file "/var/run/devd.pid"; 18289694Sngie 19289694Sngie # Setup some shorthand for regex that we use later in the file. 20289694Sngie #XXX Yes, these are gross -- imp 21289694Sngie set scsi-controller-regex 22289694Sngie "(aac|adv|adw|aha|ahb|ahc|ahd|aic|amd|amr|asr|bt|ciss|ct|dpt|\ 23289694Sngie esp|ida|iir|ips|isp|mlx|mly|mpt|ncr|ncv|nsp|stg|sym|trm|wds)\ 24289694Sngie [0-9]+"; 25289694Sngie}; 26289694Sngie 27289694Sngie# Note that the attach/detach with the highest value wins, so that one can 28289694Sngie# override these general rules. 29289694Sngie 30289897Sngie# 31289897Sngie# Configure the interface on attach. Due to a historical accident, this 32289897Sngie# script is called pccard_ether. 33289694Sngie# 34289694Sngienotify 0 { 35289897Sngie match "system" "IFNET"; 36289694Sngie match "type" "ATTACH"; 37289897Sngie action "/etc/pccard_ether $subsystem start"; 38289694Sngie}; 39289897Sngie 40289897Sngienotify 0 { 41289897Sngie match "system" "IFNET"; 42289897Sngie match "type" "DETACH"; 43289897Sngie action "/etc/pccard_ether $subsystem stop"; 44289897Sngie}; 45289897Sngie 46289897Sngie# 47289897Sngie# Try to start dhclient on Ethernet like interfaces when the link comes 48289897Sngie# up. Only devices that are configured to support DHCP will actually 49289897Sngie# run it. No link down rule exists because dhclient automaticly exits 50289897Sngie# when the link goes down. 51289897Sngie# 52289897Sngienotify 0 { 53289897Sngie match "system" "IFNET"; 54289897Sngie match "type" "LINK_UP"; 55289897Sngie media-type "ethernet"; 56339048Sasomers action "/etc/rc.d/dhclient start $subsystem"; 57339048Sasomers}; 58339048Sasomers 59339048Sasomers# 60339048Sasomers# Like Ethernet devices, but separate because 61339048Sasomers# they have a different media type. We may want 62339048Sasomers# to exploit this later. 63339048Sasomers# 64339048Sasomersdetach 0 { 65339048Sasomers media-type "802.11"; 66339048Sasomers action "/etc/pccard_ether $device-name stop"; 67339048Sasomers}; 68339048Sasomersattach 0 { 69339048Sasomers media-type "802.11"; 70339048Sasomers action "/etc/pccard_ether $device-name start"; 71339048Sasomers}; 72339048Sasomersnotify 0 { 73339048Sasomers match "system" "IFNET"; 74339048Sasomers match "type" "LINK_UP"; 75339048Sasomers media-type "802.11"; 76339048Sasomers action "/etc/rc.d/dhclient start $subsystem"; 77339048Sasomers}; 78339048Sasomers 79289897Sngie# An entry like this might be in a different file, but is included here 80289897Sngie# as an example of how to override things. Normally 'ed50' would match 81289897Sngie# the above attach/detach stuff, but the value of 100 makes it 82289897Sngie# hard wired to 1.2.3.4. 83289897Sngieattach 100 { 84289694Sngie device-name "ed50"; 85289694Sngie action "ifconfig $device-name inet 1.2.3.4 netmask 0xffff0000"; 86289897Sngie}; 87289897Sngiedetach 100 { 88289694Sngie device-name "ed50"; 89289897Sngie}; 90289897Sngie 91289694Sngie# When a USB Bluetooth dongle appears activate it 92289897Sngieattach 100 { 93289897Sngie device-name "ubt[0-9]+"; 94289897Sngie action "/etc/rc.d/bluetooth start $device-name"; 95289897Sngie}; 96289897Sngiedetach 100 { 97289897Sngie device-name "ubt[0-9]+"; 98289897Sngie action "/etc/rc.d/bluetooth stop $device-name"; 99289897Sngie}; 100289897Sngie 101289897Sngie# When a USB keyboard arrives, attach it as the console keyboard. 102289897Sngieattach 100 { 103289897Sngie device-name "ukbd0"; 104289897Sngie action "/etc/rc.d/syscons setkeyboard /dev/ukbd0"; 105289897Sngie}; 106289897Sngiedetach 100 { 107289897Sngie device-name "ukbd0"; 108289897Sngie action "/etc/rc.d/syscons setkeyboard /dev/kbd0"; 109289897Sngie}; 110289897Sngie 111289897Sngie# The entry below starts moused when a mouse is plugged in. Moused 112289897Sngie# stops automatically (actually it bombs :) when the device disappears. 113289897Sngieattach 100 { 114289897Sngie device-name "ums[0-9]+"; 115289897Sngie action "/etc/rc.d/moused start $device-name"; 116289897Sngie}; 117289897Sngie 118289897Sngie# Firmware download into the ActiveWire board. After the firmware download is 119289897Sngie# done the device detaches and reappears as something new and shiny 120289897Sngie# automatically. 121289897Sngieattach 100 { 122289897Sngie match "vendor" "0x0854"; 123289897Sngie match "product" "0x0100"; 124289897Sngie match "release" "0x0000"; 125289897Sngie action "/usr/local/bin/ezdownload -f /usr/local/share/usb/firmware/0854.0100.0_01.hex $device-name"; 126289897Sngie}; 127289897Sngie 128289897Sngie# Firmware download for Entrega Serial DB25 adapter. 129289897Sngieattach 100 { 130289897Sngie match "vendor" "0x1645"; 131290267Sngie match "product" "0x8001"; 132289897Sngie match "release" "0x0101"; 133289897Sngie 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"; 134289897Sngie}; 135339048Sasomers 136289897Sngie# This entry starts the ColdSync tool in daemon mode. Make sure you have an up 137289897Sngie# to date /usr/local/etc/palms. We override the 'listen' settings for port and 138289897Sngie# type in /usr/local/etc/coldsync.conf. 139289897Sngieattach 100 { 140289897Sngie device-name "ugen[0-9]+"; 141289897Sngie match "vendor" "0x082d"; 142289897Sngie match "product" "0x0100"; 143289897Sngie match "release" "0x0100"; 144289897Sngie action "/usr/local/bin/coldsync -md -p /dev/$device-name -t usb"; 145289897Sngie}; 146289897Sngie 147289897Sngie# 148289897Sngie# Rescan scsi device-names on attach, but not detach. However, it is 149289897Sngie# disabled by default due to reports of problems. 150289897Sngie# 151289897Sngieattach 0 { 152289897Sngie device-name "$scsi-controller-regex"; 153289897Sngie// action "camcontrol rescan all"; 154289743Sngie}; 155289897Sngie 156289897Sngie# Don't even try to second guess what to do about drivers that don't 157289897Sngie# match here. Instead, pass it off to syslog. Commented out for the 158339048Sasomers# moment, as pnpinfo isn't set in devd yet. 159289897Sngienomatch 0 { 160289897Sngie# action "logger Unknown device: $pnpinfo $location $bus"; 161289897Sngie}; 162289694Sngie 163289897Sngie# Various logging of unknown devices. 164289694Sngienomatch 10 { 165289897Sngie match "bus" "uhub[0-9]+"; 166289897Sngie action "logger Unknown USB device: vendor $vendor product $product \ 167289694Sngie bus $bus"; 168289897Sngie}; 169289897Sngie 170289897Sngie# Some PC-CARDs don't offer numerical manufacturer/product IDs, just 171289897Sngie# show the CIS info there. 172289897Sngienomatch 20 { 173289897Sngie match "bus" "pccard[0-9]+"; 174289897Sngie match "manufacturer" "0xffffffff"; 175289897Sngie match "product" "0xffffffff"; 176289897Sngie action "logger Unknown PCCARD device: CISproduct $cisproduct \ 177289897Sngie CIS-vendor $cisvendor bus $bus"; 178289694Sngie}; 179289897Sngie 180289897Sngienomatch 10 { 181289897Sngie match "bus" "pccard[0-9]+"; 182289897Sngie action "logger Unknown PCCARD device: manufacturer $manufacturer \ 183289694Sngie product $product CISproduct $cisproduct CIS-vendor \ 184290270Sngie $cisvendor bus $bus"; 185290270Sngie}; 186290270Sngie 187290270Sngienomatch 10 { 188290270Sngie match "bus" "cardbus[0-9]+"; 189290270Sngie action "logger Unknown Cardbus device: device $device class $class \ 190290270Sngie vendor $vendor bus $bus"; 191290270Sngie}; 192290270Sngie 193290270Sngie# Switch power profiles when the AC line state changes. 194290270Sngienotify 10 { 195290270Sngie match "system" "ACPI"; 196290270Sngie match "subsystem" "ACAD"; 197290270Sngie action "/etc/rc.d/power_profile $notify"; 198290270Sngie}; 199290270Sngie 200290270Sngie# Notify all users before beginning emergency shutdown when we get 201290270Sngie# a _CRT or _HOT thermal event and we're going to power down the system 202290270Sngie# very soon. 203290270Sngienotify 10 { 204290270Sngie match "system" "ACPI"; 205290270Sngie match "subsystem" "Thermal"; 206290270Sngie match "notify" "0xcc"; 207290270Sngie action "logger -p kern.emerg 'WARNING: system temperature too high, shutting down soon!'"; 208320681Sasomers}; 209290270Sngie 210290270Sngie/* EXAMPLES TO END OF FILE 211290270Sngie 212290270Sngie# The following might be an example of something that a vendor might 213290270Sngie# install if you were to add their device. This might reside in 214290270Sngie# /usr/local/etc/devd/deqna.conf. A deqna is, in this hypothetical 215290270Sngie# example, a pccard ethernet-like device. Students of history may 216290270Sngie# know other devices by this name, and will get the in-jokes in this 217290270Sngie# entry. 218290270Sngienomatch 10 { 219290270Sngie match "bus" "pccard[0-9]+"; 220290270Sngie match "manufacturer" "0x1234"; 221290270Sngie match "product" "0x2323"; 222290270Sngie action "kldload if_deqna"; 223290270Sngie}; 224290270Sngieattach 10 { 225290270Sngie device-name "deqna[0-9]+"; 226290270Sngie action "/etc/pccard_ether $device-name start"; 227290270Sngie}; 228290270Sngiedetach 10 { 229290270Sngie device-name "deqna[0-9]+"; 230290270Sngie action "/etc/pccard_ether $device-name stop"; 231290270Sngie}; 232290270Sngie 233290270Sngie# Examples of notify hooks. A notify is a generic way for a kernel 234290270Sngie# subsystem to send event notification to userland. 235290270Sngie# 236290270Sngie# Here are some examples of ACPI notify handlers. ACPI subsystems that 237290270Sngie# generate notifies include the AC adapter, power/sleep buttons, 238290270Sngie# control method batteries, lid switch, and thermal zones. 239290270Sngie# 240320681Sasomers# Information returned is not always the same as the ACPI notify 241290270Sngie# events. See the ACPI specification for more information about 242290270Sngie# notifies. Here is the information returned for each subsystem: 243290270Sngie# 244290270Sngie# ACAD: AC line state (0 is offline, 1 is online) 245290270Sngie# Button: Button pressed (0 for power, 1 for sleep) 246290270Sngie# CMBAT: ACPI battery events 247290270Sngie# Lid: Lid state (0 is closed, 1 is open) 248289694Sngie# Thermal: ACPI thermal zone events 249289694Sngie# 250289694Sngie# This example calls a script when the AC state changes, passing the 251339048Sasomers# notify value as the first argument. If the state is 0x00, it might 252339048Sasomers# call some sysctls to implement economy mode. If 0x01, it might set 253289897Sngie# the mode to performance. 254289897Sngienotify 10 { 255289897Sngie match "system" "ACPI"; 256289897Sngie match "subsystem" "ACAD"; 257289897Sngie action "/etc/acpi_ac $notify"; 258289897Sngie}; 259289897Sngie*/ 260290270Sngie