blob: 9ffa9148a7c74816c51c89c7931660a12873b2a0 [file] [log] [blame]
Jonathan Doman94c94bf2020-10-05 23:25:45 -07001#!/bin/sh
2
3# Utility to print all SST data present on D-Bus.
4# Simply searches for all objects implementing known interfaces and prints out
5# the property values on those interfaces.
6
Jonathan Doman703a1852020-11-11 13:04:02 -08007set -e
8
Jonathan Doman94c94bf2020-10-05 23:25:45 -07009BUSCTL='busctl'
10XYZ='xyz.openbmc_project'
11OBJECT_MAPPER="$XYZ.ObjectMapper /xyz/openbmc_project/object_mapper $XYZ.ObjectMapper"
12CPU_INTF="$XYZ.Control.Processor.CurrentOperatingConfig"
13CONFIG_INTF="$XYZ.Inventory.Item.Cpu.OperatingConfig"
14
15trim_quotes() {
16 trim_obj=${1%\"}
17 trim_obj=${trim_obj#\"}
18 echo $trim_obj
19}
20
21get_sub_tree_paths() {
22 resp=$($BUSCTL call $OBJECT_MAPPER GetSubTreePaths sias "$1" 0 "$2" "$3" \
Patrick Williams306df482022-12-08 06:26:05 -060023 | cut -d' ' -f3-)
Jonathan Doman94c94bf2020-10-05 23:25:45 -070024 for obj in $resp
25 do
26 trim_quotes $obj
27 done
28}
29
30get_service_from_object() {
31 trim_quotes $($BUSCTL call $OBJECT_MAPPER GetObject sas "$1" "$2" "$3" \
Patrick Williams306df482022-12-08 06:26:05 -060032 | cut -d' ' -f3)
Jonathan Doman94c94bf2020-10-05 23:25:45 -070033}
34
35get_property_names() {
36 service=$1
37 object=$2
38 intf=$3
39 $BUSCTL introspect $service $object $intf \
40 | awk '/property/ {print substr($1, 2)}'
41}
42
43get_property() {
44 service=$1
45 object=$2
46 intf=$3
47 prop=$4
48 $BUSCTL get-property $service $object $intf $prop
49}
50
Jonathan Doman703a1852020-11-11 13:04:02 -080051set_property() {
52 service=$1
53 object=$2
54 intf=$3
55 prop=$4
56 signature=$5
57 value=$6
58 $BUSCTL set-property $service $object $intf $prop $signature $value
59}
Jonathan Doman94c94bf2020-10-05 23:25:45 -070060
Jonathan Doman703a1852020-11-11 13:04:02 -080061show() {
62 cpu_paths=$(get_sub_tree_paths "/" 1 "$CPU_INTF")
63 for cpu_path in $cpu_paths
Jonathan Doman94c94bf2020-10-05 23:25:45 -070064 do
Jonathan Doman703a1852020-11-11 13:04:02 -080065 service=$(get_service_from_object $cpu_path 1 $CPU_INTF)
66 echo "Found SST on $cpu_path on $service"
67 for prop in $(get_property_names $service $cpu_path $CPU_INTF)
Jonathan Doman94c94bf2020-10-05 23:25:45 -070068 do
Jonathan Doman703a1852020-11-11 13:04:02 -080069 echo " $prop: $(get_property $service $cpu_path $CPU_INTF $prop)"
70 done
71
72
73 profiles=$(get_sub_tree_paths "$cpu_path" 1 "$CONFIG_INTF")
74 for profile in $profiles
75 do
76 echo
77 echo " Found Profile $profile"
78 for prop in $(get_property_names $service $profile $CONFIG_INTF)
79 do
80 echo " $prop: $(get_property $service $profile $CONFIG_INTF $prop)"
81 done
Jonathan Doman94c94bf2020-10-05 23:25:45 -070082 done
83 done
Jonathan Doman703a1852020-11-11 13:04:02 -080084}
85
86set_cpu_prop() {
87 cpu_basename=$1
88 prop=$2
89 signature=$3
90 value=$4
91
92
93 cpu_paths=$(get_sub_tree_paths "/" 1 "$CPU_INTF")
94 for cpu_path in $cpu_paths
95 do
96 if [[ $cpu_path != *$cpu_basename ]]
97 then
98 continue
99 fi
100
101 if [[ "$prop" == "AppliedConfig" ]]
102 then
103 value=$cpu_path/$value
104 fi
105
106 service=$(get_service_from_object $cpu_path 1 $CPU_INTF)
107 set_property $service $cpu_path $CPU_INTF $prop $signature $value
108 return 0
109 done
110
111 echo "$cpu_basename not found"
112 return 1
113}
114
115if [[ ${DEBUG:=0} -eq 1 ]]
116then
117 set -x
118fi
119
120action=${1:-show}
121
122case "$action" in
123 show) show ;;
124 set-config) set_cpu_prop $2 AppliedConfig o $3 ;;
125 set-bf) set_cpu_prop $2 BaseSpeedPriorityEnabled b $3 ;;
126 *)
127 echo "Usage:"
128 echo "$0 (show|set-config|set-bf) [ARGS...]"
129 echo ""
130 echo "show (Default action) - show info"
131 echo "set-config cpuN configM - Set applied operating config for cpuN to configM"
132 echo "set-bf cpuN val - Set SST-BF enablement for cpuN to val (boolean)"
133 ;;
134esac