blob: 234423e46e08d41d84675077d29ff273dcdde4b2 [file] [log] [blame]
#!/bin/bash
# Provide source directive to shellcheck.
# shellcheck source=meta-facebook/recipes-phosphor/state/phosphor-state-manager/greatlakes/power-cmd
source /usr/libexec/power-cmd
SLOT_ID=$(( $1-1 << 2 ))
# Host Power On
host-power-on()
{
for pwr_cmd in "${power_seq[@]}"
do
result="$(busctl call $SERVICE $OBJECT_PATH $INTERFACE sendRequest yyyyay $SLOT_ID $NETFN $LUN $CMD $DATA_LEN 0x01 0x42 0x01 0x00 "$pwr_cmd")"
echo "$result"
if [ "$pwr_cmd" == $POWER_BTN_LOW ]
then
sleep 2
fi
done
echo "Host power on"
exit 0;
}
# Check Host Response and Status
host-power-status()
{
response="$(busctl call $SERVICE $OBJECT_PATH $INTERFACE sendRequest yyyyay $SLOT_ID 0x38 $LUN 0x03 0x03 0x15 0xa0 0x00)"
result=$(echo "$response" | cut -d" " -f $PWRGD_SYS_PWROK_INDEX)
res="$(( "$result" & 0x80 ))"
pgood="$(( "$res" >> 7 ))"
if [ "$pgood" == $STATE_OFF ]
then
host-power-on
fi
echo "Power is already on"
exit 1;
}
host-power-status