blob: ab39bcb87b2367533c7e4ca3b834f857f2ab643a [file] [log] [blame]
Karthikeyan Pasupathi36f035b2022-08-28 17:35:29 +05301#!/bin/bash
2
3# Provide source directive to shellcheck.
4# shellcheck source=meta-facebook/recipes-phosphor/state/phosphor-state-manager/greatlakes/host-poweron
5source /usr/libexec/power-cmd
6
7SLOT_ID=$(( $1-1 << 2 ))
8
9# Host Reboot
10host-reboot()
11{
12 power_delay=$1
13 for pwr_cmd in "${power_seq[@]}"
14 do
15 result="$(busctl call $SERVICE $OBJECT_PATH $INTERFACE sendRequest yyyyay $SLOT_ID $NETFN $LUN $CMD $DATA_LEN 0x01 0x42 0x01 0x00 "$pwr_cmd")"
16 echo "$result"
17 if [ "$pwr_cmd" == $POWER_BTN_LOW ]
18 then
19 sleep "$power_delay"
20 fi
21 done
22}
23
24# Check Host Response and Status
25check-response()
26{
27 response="$(busctl call $SERVICE $OBJECT_PATH $INTERFACE sendRequest yyyyay $SLOT_ID 0x38 $LUN 0x3 0x03 0x15 0xa0 0x00)"
28
29 result=$(echo "$response" | cut -d" " -f $PWRGD_SYS_PWROK_INDEX)
30 res="$(( "$result" & 0x80 ))"
31 pgood="$(( "$res" >> 7 ))"
32 if [ "$pgood" == $STATE_ON ]
33 then
34 host-reboot 6
35 sleep 15
36 host-reboot 2
37 exit 0;
38 else
39 echo "Host is Off"
40 exit 1;
41 fi
42}
43check-response