URI:
       bd-prochot - scripts - various script and utils
  HTML git clone git://z3bra.org/scripts
   DIR Log
   DIR Files
   DIR Refs
       ---
       bd-prochot (970B)
       ---
            1 #!/bin/sh
            2 
            3 # Initial value read 2026-02-26: e4005f
            4 
            5 # BD-PROCHOT is a mechanism to protect processor overheating.
            6 # The side-effect is that is slow the hell out of it by throttling the
            7 # CPU frequency to its minimum.
            8 #
            9 # The model-specific register (MSR) holds the configuration for this
           10 # feature at address 0x1FC. The last bit defines wether or not BD-PROCHOT
           11 # will actually throttle o not the CPU.
           12 #
           13 # Clearing that last bit unleash the CPU (or rather prevents limiting it).
           14 
           15 # Get full register value
           16 reg="0x$(doas rdmsr 0x1FC)"
           17 
           18 usage() {
           19         echo "usage: $(basename $0) [-cs]" >&2
           20 }
           21 
           22 bdph_bit() {
           23         echo $((reg & 0x000001))
           24 }
           25 bdph_set() {
           26         echo $((reg | 0x000001))
           27 }
           28 bdph_clr() {
           29         echo $((reg & 0xfffffe))
           30 }
           31 
           32 while getopts "hcs" OPT; do
           33         case "$OPT" in
           34         c) v=$((reg & 0xfffffe));;
           35         s) v=$((reg | 0x1));;
           36         h) usage; exit 0;;
           37         *) usage; exit 1;;
           38         esac
           39 done
           40 shift $((OPTIND-1))
           41 
           42 if [ -n "$v" ]; then
           43         doas wrmsr 0x1FC $(printf %d $v)
           44         doas rdmsr 0x1FC
           45 else
           46         bdph_bit
           47 fi