Jonathan Doman | 94c94bf | 2020-10-05 23:25:45 -0700 | [diff] [blame] | 1 | #!/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 | |
| 7 | BUSCTL='busctl' |
| 8 | XYZ='xyz.openbmc_project' |
| 9 | OBJECT_MAPPER="$XYZ.ObjectMapper /xyz/openbmc_project/object_mapper $XYZ.ObjectMapper" |
| 10 | CPU_INTF="$XYZ.Control.Processor.CurrentOperatingConfig" |
| 11 | CONFIG_INTF="$XYZ.Inventory.Item.Cpu.OperatingConfig" |
| 12 | |
| 13 | trim_quotes() { |
| 14 | trim_obj=${1%\"} |
| 15 | trim_obj=${trim_obj#\"} |
| 16 | echo $trim_obj |
| 17 | } |
| 18 | |
| 19 | get_sub_tree_paths() { |
| 20 | resp=$($BUSCTL call $OBJECT_MAPPER GetSubTreePaths sias "$1" 0 "$2" "$3" \ |
| 21 | | cut -d' ' -f3-) |
| 22 | for obj in $resp |
| 23 | do |
| 24 | trim_quotes $obj |
| 25 | done |
| 26 | } |
| 27 | |
| 28 | get_service_from_object() { |
| 29 | trim_quotes $($BUSCTL call $OBJECT_MAPPER GetObject sas "$1" "$2" "$3" \ |
| 30 | | cut -d' ' -f3) |
| 31 | } |
| 32 | |
| 33 | get_property_names() { |
| 34 | service=$1 |
| 35 | object=$2 |
| 36 | intf=$3 |
| 37 | $BUSCTL introspect $service $object $intf \ |
| 38 | | awk '/property/ {print substr($1, 2)}' |
| 39 | } |
| 40 | |
| 41 | get_property() { |
| 42 | service=$1 |
| 43 | object=$2 |
| 44 | intf=$3 |
| 45 | prop=$4 |
| 46 | $BUSCTL get-property $service $object $intf $prop |
| 47 | } |
| 48 | |
| 49 | |
| 50 | cpu_paths=$(get_sub_tree_paths "/" 1 "$CPU_INTF") |
| 51 | for cpu_path in $cpu_paths |
| 52 | do |
| 53 | service=$(get_service_from_object $cpu_path 1 $CPU_INTF) |
| 54 | echo "Found SST on $cpu_path on $service" |
| 55 | for prop in $(get_property_names $service $cpu_path $CPU_INTF) |
| 56 | do |
| 57 | echo " $prop: $(get_property $service $cpu_path $CPU_INTF $prop)" |
| 58 | done |
| 59 | |
| 60 | |
| 61 | profiles=$(get_sub_tree_paths "$cpu_path" 1 "$CONFIG_INTF") |
| 62 | for profile in $profiles |
| 63 | do |
| 64 | echo |
| 65 | echo " Found Profile $profile" |
| 66 | for prop in $(get_property_names $service $profile $CONFIG_INTF) |
| 67 | do |
| 68 | echo " $prop: $(get_property $service $profile $CONFIG_INTF $prop)" |
| 69 | done |
| 70 | done |
| 71 | done |