Initial commit

This commit is contained in:
Your Name
2026-04-23 17:07:55 +08:00
commit b7e39e063b
16725 changed files with 1625565 additions and 0 deletions
@@ -0,0 +1,59 @@
#!/bin/bash -e
# Provide source directive to shellcheck.
# shellcheck source=meta-facebook/recipes-phosphor/state/phosphor-state-manager/greatlakes/power-cmd
source /usr/libexec/phosphor-state-manager/power-cmd
SLOT_ID="$1"
function get_power_status()
{
POWER_OK_SLOT=$(( $1+9 ))
HOST_INSTANCE=$(( $1-1 << 2 ))
chassis_status=$(gpioget 0 $POWER_OK_SLOT)
if [ "$chassis_status" == "$STATE_OFF" ]; then
echo "AC Off"
return 0
fi
response="$(busctl call "$SERVICE" "$OBJECT_PATH" "$INTERFACE" sendRequest yyyyay "$HOST_INSTANCE" 0x38 "$LUN" 0x03 "$IANA_LEN" "$IANA")"
# Responses are BIC gpio states, the GPIO B7 represents host DC status
result=$(echo "$response" | cut -d" " -f "$PWRGD_SYS_PWROK_INDEX")
res="$(( "$result" & 0x80 ))"
host_status="$(( "$res" >> 7 ))"
if [ "$host_status" == "$STATE_OFF" ]; then
echo "Host Off"
return 0
fi
}
set_host_state()
{
PROPERTY_VAL="xyz.openbmc_project.State.Host.HostState.$2"
busctl set-property "$HOST_BUS_NAME$1" "$HOST_OBJ_PATH$1" "$HOST_INTF_NAME" "$HOST_PROPERTY_NAME" s "$PROPERTY_VAL"
}
set_chassis_state()
{
PROPERTY_VAL="xyz.openbmc_project.State.Chassis.PowerState.$2"
busctl set-property "$CHASSIS_BUS_NAME$1" "$CHASSIS_OBJ_PATH$1" "$CHASSIS_INTF_NAME" "$CHASSIS_PROPERTY_NAME" s "$PROPERTY_VAL"
}
POWER_STATUS=$(get_power_status "$SLOT_ID")
# Default power status
CHASSIS_STATE_VAL="Off"
HOST_STATE_VAL="Off"
# Real power status
if [ "$POWER_STATUS" != "AC Off" ]; then
CHASSIS_STATE_VAL="On"
if [ "$POWER_STATUS" != "Host Off" ]; then
HOST_STATE_VAL="Running"
fi
fi
set_chassis_state "$SLOT_ID" "$CHASSIS_STATE_VAL"
set_host_state "$SLOT_ID" "$HOST_STATE_VAL"
@@ -0,0 +1,15 @@
[Unit]
Description=Greatlakes host state and chassis power state initialize for slot%i
Before=phosphor-multi-gpio-monitor.service
Wants=xyz.openbmc_project.State.Chassis@%i.service
After=xyz.openbmc_project.State.Chassis@%i.service
Wants=xyz.openbmc_project.State.Host@%i.service
After=xyz.openbmc_project.State.Host@%i.service
[Service]
ExecStart=/usr/libexec/greatlakes-sysinit/greatlakes-system-state-init %i
SyslogIdentifier=greatlakes-system-state-init slot%i
Type=oneshot
[Install]
WantedBy=sysinit.target
@@ -0,0 +1,26 @@
SUMMARY = "Initialize system state"
DESCRIPTION = "Initialize system state"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
inherit pkgconfig
inherit systemd
inherit obmc-phosphor-systemd
RDEPENDS:${PN} += "bash"
SRC_URI += " \
file://greatlakes-system-state-init \
file://greatlakes-system-state-init@.service \
"
do_install() {
install -d ${D}${libexecdir}/${PN}
install -m 0755 ${WORKDIR}/greatlakes-system-state-init ${D}${libexecdir}/${PN}/
}
TGT = "${SYSTEMD_DEFAULT_TARGET}"
GREATLAKES_SYS_ST_INIT_INSTFMT="../greatlakes-system-state-init@.service:${TGT}.wants/greatlakes-system-state-init@{0}.service"
SYSTEMD_SERVICE:${PN} += "greatlakes-system-state-init@.service"
SYSTEMD_LINK:${PN} += "${@compose_list(d, 'GREATLAKES_SYS_ST_INIT_INSTFMT', 'OBMC_HOST_INSTANCES')}"