aboutsummaryrefslogtreecommitdiffstats
path: root/sysutils/devcpu/files/devcpu.in
blob: 54af29b3405e0aa9fb5e7d618f858d897a6b1435 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/sh
#
# $FreeBSD$
#

# PROVIDE:  devcpu
# REQUIRE:  root mountcritlocal
# KEYWORD:  nojail

#
# Add the following line to /etc/rc.conf to enable flow-capture:
# devcpu_enable (bool): Set it to "YES" to update cpucodes on startup
#           Set to "NO" by default.
# devcpu_datadir (str): Directory, cpucode updates stored in.
#               Default is "%%DATADIR%%"
# devcpu_cpus (str):    A list of cpus to update on startup, or "-a" for all.
#           Example: devcpu_cpus="cpu0 /dev/cpu1"
#           Set to "-a" by default. 

. /etc/rc.subr

name="devcpu"
rcvar=devcpu_enable
stop_cmd=":"
start_precmd="devcpu_prepare"
start_cmd="devcpu_start"
requires_modules="cpu"

CMT="%%PREFIX%%/bin/cpu_microcode_tool"

devcpu_prepare()
{
    if ! kldstat -q -m cpu; then
        if ! kldload cpu > /dev/null 2>&1; then
            warn "Can't load cpu module."
            return 1
        fi
    fi
}

devcpu_start()
{
    echo "Updating cpucodes."
    ${CMT} -I "${devcpu_datadir}" ${devcpu_cpus}
}

load_rc_config $name

# Set default values
: ${devcpu_enable="NO"}
: ${devcpu_datadir="%%DATADIR%%"}
: ${devcpu_cpus="-a"}

run_rc_command "$1"