devd.conf revision 166701
1108983Simp# $FreeBSD: head/etc/devd.conf 166701 2007-02-14 08:13:54Z joerg $ 2108983Simp# 3108983Simp# Refer to devd.conf(5) and devd(8) man pages for the details on how to 4108983Simp# run and configure devd. 5108983Simp# 6108983Simp 7108983Simp# NB: All regular expressions have an implicit ^$ around them. 8108983Simp# NB: device-name is shorthand for 'match device-name' 9108983Simp 10108983Simpoptions { 11108983Simp # Each directory directive adds a directory the list of directories 12108983Simp # that we scan for files. Files are read-in in the order that they 13108983Simp # are returned from readdir(3). The rule-sets are combined to 14108983Simp # create a DFA that's used to match events to actions. 15108983Simp directory "/etc/devd"; 16108983Simp directory "/usr/local/etc/devd"; 17108983Simp pid-file "/var/run/devd.pid"; 18108983Simp 19108983Simp # Setup some shorthand for regex that we use later in the file. 20148471Simp #XXX Yes, these are gross -- imp 21108983Simp set scsi-controller-regex 22139027Sbrueffer "(aac|adv|adw|aha|ahb|ahc|ahd|aic|amd|amr|asr|bt|ciss|ct|dpt|\ 23146969Smarius esp|ida|iir|ips|isp|mlx|mly|mpt|ncr|ncv|nsp|stg|sym|trm|wds)\ 24139027Sbrueffer [0-9]+"; 25108983Simp}; 26108983Simp 27108983Simp# Note that the attach/detach with the highest value wins, so that one can 28108983Simp# override these general rules. 29108983Simp 30108983Simp# 31159126Sthompsa# Configure the interface on attach. Due to a historical accident, this 32159126Sthompsa# script is called pccard_ether. 33108983Simp# 34159126Sthompsanotify 0 { 35159126Sthompsa match "system" "IFNET"; 36159126Sthompsa match "type" "ATTACH"; 37159126Sthompsa action "/etc/pccard_ether $subsystem start"; 38108983Simp}; 39108983Simp 40159126Sthompsanotify 0 { 41159126Sthompsa match "system" "IFNET"; 42159126Sthompsa match "type" "DETACH"; 43159126Sthompsa action "/etc/pccard_ether $subsystem stop"; 44108983Simp}; 45108983Simp 46147088Sbrooks# 47147088Sbrooks# Try to start dhclient on Ethernet like interfaces when the link comes 48147088Sbrooks# up. Only devices that are configured to support DHCP will actually 49147088Sbrooks# run it. No link down rule exists because dhclient automaticly exits 50147088Sbrooks# when the link goes down. 51147088Sbrooks# 52147088Sbrooksnotify 0 { 53147088Sbrooks match "system" "IFNET"; 54147088Sbrooks match "type" "LINK_UP"; 55148642Ssam media-type "ethernet"; 56147088Sbrooks action "/etc/rc.d/dhclient start $subsystem"; 57147088Sbrooks}; 58147088Sbrooks 59148642Ssam# 60148642Ssam# Like Ethernet devices, but separate because 61148642Ssam# they have a different media type. We may want 62148642Ssam# to exploit this later. 63148642Ssam# 64148642Ssamdetach 0 { 65148642Ssam media-type "802.11"; 66148642Ssam action "/etc/pccard_ether $device-name stop"; 67148642Ssam}; 68148642Ssamattach 0 { 69148642Ssam media-type "802.11"; 70148642Ssam action "/etc/pccard_ether $device-name start"; 71148642Ssam}; 72148642Ssamnotify 0 { 73148642Ssam match "system" "IFNET"; 74148642Ssam match "type" "LINK_UP"; 75148642Ssam media-type "802.11"; 76148642Ssam action "/etc/rc.d/dhclient start $subsystem"; 77148642Ssam}; 78148642Ssam 79108983Simp# An entry like this might be in a different file, but is included here 80108983Simp# as an example of how to override things. Normally 'ed50' would match 81108983Simp# the above attach/detach stuff, but the value of 100 makes it 82139281Sbrueffer# hard wired to 1.2.3.4. 83108983Simpattach 100 { 84108983Simp device-name "ed50"; 85108983Simp action "ifconfig $device-name inet 1.2.3.4 netmask 0xffff0000"; 86108983Simp}; 87108983Simpdetach 100 { 88108983Simp device-name "ed50"; 89108983Simp}; 90108983Simp 91152326Semax# When a USB Bluetooth dongle appears activate it 92152326Semaxattach 100 { 93152326Semax device-name "ubt[0-9]+"; 94152326Semax action "/etc/rc.d/bluetooth start $device-name"; 95152326Semax}; 96152326Semaxdetach 100 { 97152326Semax device-name "ubt[0-9]+"; 98152326Semax action "/etc/rc.d/bluetooth stop $device-name"; 99152326Semax}; 100152326Semax 101139281Sbrueffer# When a USB keyboard arrives, attach it as the console keyboard. 102134584Sbrooksattach 100 { 103134584Sbrooks device-name "ukbd0"; 104156782Semax action "/etc/rc.d/syscons setkeyboard /dev/ukbd0"; 105134584Sbrooks}; 106134584Sbrooksdetach 100 { 107134584Sbrooks device-name "ukbd0"; 108156331Semax action "/etc/rc.d/syscons setkeyboard /dev/kbd0"; 109134584Sbrooks}; 110134584Sbrooks 111138175Siedowse# The entry below starts moused when a mouse is plugged in. Moused 112138175Siedowse# stops automatically (actually it bombs :) when the device disappears. 113138175Siedowseattach 100 { 114138175Siedowse device-name "ums[0-9]+"; 115138175Siedowse action "/etc/rc.d/moused start $device-name"; 116138175Siedowse}; 117138175Siedowse 118153300Siedowse# Firmware download into the ActiveWire board. After the firmware download is 119153300Siedowse# done the device detaches and reappears as something new and shiny 120153300Siedowse# automatically. 121153300Siedowseattach 100 { 122153300Siedowse match "vendor" "0x0854"; 123153300Siedowse match "product" "0x0100"; 124153300Siedowse match "release" "0x0000"; 125153300Siedowse action "/usr/local/bin/ezdownload -f /usr/local/share/usb/firmware/0854.0100.0_01.hex $device-name"; 126153300Siedowse}; 127153300Siedowse 128153300Siedowse# Firmware download for Entrega Serial DB25 adapter. 129153300Siedowseattach 100 { 130153300Siedowse match "vendor" "0x1645"; 131153300Siedowse match "product" "0x8001"; 132153300Siedowse match "release" "0x0101"; 133153300Siedowse 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"; 134153300Siedowse}; 135153300Siedowse 136153300Siedowse# This entry starts the ColdSync tool in daemon mode. Make sure you have an up 137153300Siedowse# to date /usr/local/etc/palms. We override the 'listen' settings for port and 138153300Siedowse# type in /usr/local/etc/coldsync.conf. 139153300Siedowseattach 100 { 140153300Siedowse device-name "ugen[0-9]+"; 141153300Siedowse match "vendor" "0x082d"; 142153300Siedowse match "product" "0x0100"; 143153300Siedowse match "release" "0x0100"; 144153300Siedowse action "/usr/local/bin/coldsync -md -p /dev/$device-name -t usb"; 145153300Siedowse}; 146153300Siedowse 147108983Simp# 148148471Simp# Rescan scsi device-names on attach, but not detach. However, it is 149148471Simp# disabled by default due to reports of problems. 150108983Simp# 151108983Simpattach 0 { 152108983Simp device-name "$scsi-controller-regex"; 153131646Simp// action "camcontrol rescan all"; 154108983Simp}; 155108983Simp 156108983Simp# Don't even try to second guess what to do about drivers that don't 157114799Simp# match here. Instead, pass it off to syslog. Commented out for the 158139281Sbrueffer# moment, as pnpinfo isn't set in devd yet. 159119254Simpnomatch 0 { 160114852Simp# action "logger Unknown device: $pnpinfo $location $bus"; 161119254Simp}; 162108983Simp 163166701Sjoerg# Various logging of unknown devices. 164166701Sjoergnomatch 10 { 165166701Sjoerg match "bus" "uhub[0-9]+"; 166166701Sjoerg action "logger Unknown USB device: vendor $vendor product $product \ 167166701Sjoerg bus $bus"; 168166701Sjoerg}; 169166701Sjoerg 170166701Sjoerg# Some PC-CARDs don't offer numerical manufacturer/product IDs, just 171166701Sjoerg# show the CIS info there. 172166701Sjoergnomatch 20 { 173166701Sjoerg match "bus" "pccard[0-9]+"; 174166701Sjoerg match "manufacturer" "0xffffffff"; 175166701Sjoerg match "product" "0xffffffff"; 176166701Sjoerg action "logger Unknown PCCARD device: CISproduct $cisproduct \ 177166701Sjoerg CIS-vendor $cisvendor bus $bus"; 178166701Sjoerg}; 179166701Sjoerg 180166701Sjoergnomatch 10 { 181166701Sjoerg match "bus" "pccard[0-9]+"; 182166701Sjoerg action "logger Unknown PCCARD device: manufacturer $manufacturer \ 183166701Sjoerg product $product CISproduct $cisproduct CIS-vendor \ 184166701Sjoerg $cisvendor bus $bus"; 185166701Sjoerg}; 186166701Sjoerg 187166701Sjoergnomatch 10 { 188166701Sjoerg match "bus" "cardbus[0-9]+"; 189166701Sjoerg action "logger Unknown Cardbus device: device $device class $class \ 190166701Sjoerg vendor $vendor bus $bus"; 191166701Sjoerg}; 192166701Sjoerg 193139281Sbrueffer# Switch power profiles when the AC line state changes. 194123626Snjlnotify 10 { 195123626Snjl match "system" "ACPI"; 196123626Snjl match "subsystem" "ACAD"; 197125366Snjl action "/etc/rc.d/power_profile $notify"; 198123626Snjl}; 199123626Snjl 200125366Snjl# Notify all users before beginning emergency shutdown when we get 201125366Snjl# a _CRT or _HOT thermal event and we're going to power down the system 202125366Snjl# very soon. 203125366Snjlnotify 10 { 204125366Snjl match "system" "ACPI"; 205125366Snjl match "subsystem" "Thermal"; 206125366Snjl match "notify" "0xcc"; 207125366Snjl action "logger -p kern.emerg 'WARNING: system temperature too high, shutting down soon!'"; 208125366Snjl}; 209125366Snjl 210108983Simp/* EXAMPLES TO END OF FILE 211108983Simp 212108983Simp# The following might be an example of something that a vendor might 213108983Simp# install if you were to add their device. This might reside in 214108983Simp# /usr/local/etc/devd/deqna.conf. A deqna is, in this hypothetical 215108983Simp# example, a pccard ethernet-like device. Students of history may 216108983Simp# know other devices by this name, and will get the in-jokes in this 217108983Simp# entry. 218108983Simpnomatch 10 { 219108983Simp match "bus" "pccard[0-9]+"; 220108983Simp match "manufacturer" "0x1234"; 221108983Simp match "product" "0x2323"; 222108983Simp action "kldload if_deqna"; 223108983Simp}; 224108983Simpattach 10 { 225108983Simp device-name "deqna[0-9]+"; 226108983Simp action "/etc/pccard_ether $device-name start"; 227108983Simp}; 228108983Simpdetach 10 { 229108983Simp device-name "deqna[0-9]+"; 230108983Simp action "/etc/pccard_ether $device-name stop"; 231108983Simp}; 232108983Simp 233121493Snjl# Examples of notify hooks. A notify is a generic way for a kernel 234121493Snjl# subsystem to send event notification to userland. 235121493Snjl# 236121493Snjl# Here are some examples of ACPI notify handlers. ACPI subsystems that 237121493Snjl# generate notifies include the AC adapter, power/sleep buttons, 238121493Snjl# control method batteries, lid switch, and thermal zones. 239121493Snjl# 240121493Snjl# Information returned is not always the same as the ACPI notify 241121493Snjl# events. See the ACPI specification for more information about 242121493Snjl# notifies. Here is the information returned for each subsystem: 243121493Snjl# 244121493Snjl# ACAD: AC line state (0 is offline, 1 is online) 245121493Snjl# Button: Button pressed (0 for power, 1 for sleep) 246121493Snjl# CMBAT: ACPI battery events 247121493Snjl# Lid: Lid state (0 is closed, 1 is open) 248121493Snjl# Thermal: ACPI thermal zone events 249121493Snjl# 250121493Snjl# This example calls a script when the AC state changes, passing the 251121493Snjl# notify value as the first argument. If the state is 0x00, it might 252121493Snjl# call some sysctls to implement economy mode. If 0x01, it might set 253121493Snjl# the mode to performance. 254121493Snjlnotify 10 { 255121493Snjl match "system" "ACPI"; 256121493Snjl match "subsystem" "ACAD"; 257121493Snjl action "/etc/acpi_ac $notify"; 258121493Snjl}; 259108983Simp*/ 260