devd.conf revision 134584
1108983Simp# $FreeBSD: head/etc/devd.conf 134584 2004-09-01 00:08:15Z brooks $
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.
20130151Sschweikh	set ethernet-nic-regex
21119917Swpaul		"(an|ar|ath|aue|awi|bfe|bge|cm|cnw|cs|cue|dc|de|ed|el|em|ep|\
22119917Swpaul		ex|fe|fxp|gem|gx|hme|ie|kue|lge|lnc|my|nge|pcn|ray|re|rl|rue|\
23108983Simp		sf|sis|sk|sn|snc|ste|ti|tl|tx|txp|vr|vx|wb|wi|xe|xl)[0-9]+";
24108983Simp	set scsi-controller-regex
25108983Simp		"(adv|advw|aic|aha|ahb|ahc|ahd|bt|ct|iir|isp|mly|mpt|ncv|nsp|\
26108983Simp		stg|sym|wds)[0-9]+";
27108983Simp};
28108983Simp
29108983Simp# Note that the attach/detach with the highest value wins, so that one can
30108983Simp# override these general rules.
31108983Simp
32108983Simp#
33108983Simp# For ethernet like devices, the default is to run dhclient.  Due to
34126905Scperciva# a historical accident, this script is called pccard_ether.
35108983Simp#
36108983Simpattach 0 {
37108983Simp	device-name "$ethernet-nic-regex";
38108983Simp	action "/etc/pccard_ether $device-name start";
39108983Simp};
40108983Simp
41108983Simpdetach 0 {
42108983Simp	device-name "$ethernet-nic-regex";
43108983Simp	action "/etc/pccard_ether $device-name stop";
44108983Simp};
45108983Simp
46108983Simp# An entry like this might be in a different file, but is included here
47108983Simp# as an example of how to override things.  Normally 'ed50' would match
48108983Simp# the above attach/detach stuff, but the value of 100 makes it
49108983Simp# ed50 is hard wired to 1.2.3.4
50108983Simpattach 100 {
51108983Simp	device-name "ed50";
52108983Simp	action "ifconfig $device-name inet 1.2.3.4 netmask 0xffff0000";
53108983Simp};
54108983Simpdetach 100 {
55108983Simp	device-name "ed50";
56108983Simp};
57108983Simp
58134584Sbrooks# When a USB keyboard arrives, attach it as the console keyboard
59134584Sbrooksattach 100 {
60134584Sbrooks	device-name "ukbd0";
61134584Sbrooks	action "test -c /dev/kbd1 && kbdcontrol -k /dev/kbd1 < /dev/console";
62134584Sbrooks};
63134584Sbrooksdetach 100 {
64134584Sbrooks	device-name "ukbd0";
65134584Sbrooks	action "kbdcontrol -k /dev/kbd0 < /dev/console";
66134584Sbrooks};
67134584Sbrooks
68108983Simp#
69108983Simp# Rescan scsi device-names on attach, but not detach.
70108983Simp#
71108983Simpattach 0 {
72108983Simp	device-name "$scsi-controller-regex";
73131646Simp//	action "camcontrol rescan all";
74108983Simp};
75108983Simp
76108983Simp# Don't even try to second guess what to do about drivers that don't
77114799Simp# match here.  Instead, pass it off to syslog.  Commented out for the
78114799Simp# moment, as pnpinfo isn't set in devd yet
79119254Simpnomatch 0 {
80114852Simp#	action "logger Unknown device: $pnpinfo $location $bus";
81119254Simp};
82108983Simp
83123626Snjl# Switch power profiles when the AC line state changes
84123626Snjlnotify 10 {
85123626Snjl	match "system"		"ACPI";
86123626Snjl	match "subsystem"	"ACAD";
87125366Snjl	action "/etc/rc.d/power_profile $notify";
88123626Snjl};
89123626Snjl
90125366Snjl# Notify all users before beginning emergency shutdown when we get
91125366Snjl# a _CRT or _HOT thermal event and we're going to power down the system
92125366Snjl# very soon.
93125366Snjlnotify 10 {
94125366Snjl	match "system"		"ACPI";
95125366Snjl	match "subsystem"	"Thermal";
96125366Snjl	match "notify"		"0xcc";
97125366Snjl	action "logger -p kern.emerg 'WARNING: system temperature too high, shutting down soon!'";
98125366Snjl};
99125366Snjl
100108983Simp/* EXAMPLES TO END OF FILE
101108983Simp
102108983Simp# The following might be an example of something that a vendor might
103108983Simp# install if you were to add their device.  This might reside in
104108983Simp# /usr/local/etc/devd/deqna.conf.  A deqna is, in this hypothetical
105108983Simp# example, a pccard ethernet-like device.  Students of history may
106108983Simp# know other devices by this name, and will get the in-jokes in this
107108983Simp# entry.
108108983Simpnomatch 10 {
109108983Simp	match "bus" "pccard[0-9]+";
110108983Simp	match "manufacturer" "0x1234";
111108983Simp	match "product" "0x2323";
112108983Simp	action "kldload if_deqna";
113108983Simp};
114108983Simpattach 10 {
115108983Simp	device-name "deqna[0-9]+";
116108983Simp	action "/etc/pccard_ether $device-name start";
117108983Simp};
118108983Simpdetach 10 {
119108983Simp	device-name "deqna[0-9]+";
120108983Simp	action "/etc/pccard_ether $device-name stop";
121108983Simp};
122108983Simp
123121493Snjl# Examples of notify hooks.  A notify is a generic way for a kernel
124121493Snjl# subsystem to send event notification to userland.
125121493Snjl#
126121493Snjl# Here are some examples of ACPI notify handlers.  ACPI subsystems that
127121493Snjl# generate notifies include the AC adapter, power/sleep buttons,
128121493Snjl# control method batteries, lid switch, and thermal zones.
129121493Snjl#
130121493Snjl# Information returned is not always the same as the ACPI notify
131121493Snjl# events.  See the ACPI specification for more information about
132121493Snjl# notifies.  Here is the information returned for each subsystem:
133121493Snjl#
134121493Snjl# ACAD:		AC line state (0 is offline, 1 is online)
135121493Snjl# Button:	Button pressed (0 for power, 1 for sleep)
136121493Snjl# CMBAT:	ACPI battery events
137121493Snjl# Lid:		Lid state (0 is closed, 1 is open)
138121493Snjl# Thermal:	ACPI thermal zone events
139121493Snjl#
140121493Snjl# This example calls a script when the AC state changes, passing the
141121493Snjl# notify value as the first argument.  If the state is 0x00, it might
142121493Snjl# call some sysctls to implement economy mode.  If 0x01, it might set
143121493Snjl# the mode to performance.
144121493Snjlnotify 10 {
145121493Snjl	match "system"		"ACPI";
146121493Snjl	match "subsystem"	"ACAD";
147121493Snjl	action			"/etc/acpi_ac $notify";
148121493Snjl};
149108983Simp*/
150