meta-ufispace: Add meta-ufispace layer and meta-ncplite machine
Iniitial submission of meta-layer and meta-machine layer.
Tested: Build and run on our machine successfully.
Change-Id: I4920d8ce6aff119ba5cbc4772d84a6377784f85d
Signed-off-by: Jordan Chang <jordan.chang@ufispace.com>
diff --git a/meta-ufispace/meta-ncplite/recipes-ncplite/ncplite-inventory-log/files/inventory-log.service b/meta-ufispace/meta-ncplite/recipes-ncplite/ncplite-inventory-log/files/inventory-log.service
new file mode 100644
index 0000000..f02821f
--- /dev/null
+++ b/meta-ufispace/meta-ncplite/recipes-ncplite/ncplite-inventory-log/files/inventory-log.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Check GPIO State Manager
+After=phosphor-gpio-presence@.service
+Wants=phosphor-gpio-presence@.service
+
+[Service]
+ExecStart=@LIBEXECDIR@/ncplite-inventory-log/inventory-log.sh
+SyslogIdentifier=inventory-log
+Type=simple
+
+[Install]
+WantedBy=multi-user.target
diff --git a/meta-ufispace/meta-ncplite/recipes-ncplite/ncplite-inventory-log/files/inventory-log.sh b/meta-ufispace/meta-ncplite/recipes-ncplite/ncplite-inventory-log/files/inventory-log.sh
new file mode 100644
index 0000000..ee30b0e
--- /dev/null
+++ b/meta-ufispace/meta-ncplite/recipes-ncplite/ncplite-inventory-log/files/inventory-log.sh
@@ -0,0 +1,54 @@
+#!/bin/bash
+
+SERVICE_NAME="xyz.openbmc_project.Inventory.Manager"
+INVENTORY_OBJPATH=( \
+ "/xyz/openbmc_project/inventory/system/chassis/motherboard/ALL_PWR_GOOD_H"
+ "/xyz/openbmc_project/inventory/system/chassis/motherboard/FAN_STATUS_INT_L"
+ "/xyz/openbmc_project/inventory/system/chassis/motherboard/THERMAL_ALERT_L"
+ "/xyz/openbmc_project/inventory/system/chassis/motherboard/CPU_CATERR_L"
+ "/xyz/openbmc_project/inventory/system/chassis/motherboard/CPU_THERMTEIP_L"
+ "/xyz/openbmc_project/inventory/system/chassis/motherboard/PSU0_INT_L"
+ "/xyz/openbmc_project/inventory/system/chassis/motherboard/PSU1_INT_L"
+ "/xyz/openbmc_project/inventory/system/chassis/motherboard/PSU0_POWER_OK"
+ "/xyz/openbmc_project/inventory/system/chassis/motherboard/PSU1_POWER_OK"
+ "/xyz/openbmc_project/inventory/system/chassis/motherboard/PSU0_PRSNT_L"
+ "/xyz/openbmc_project/inventory/system/chassis/motherboard/PSU1_PRSNT_L"
+)
+INTERFACE_NAME="xyz.openbmc_project.Inventory.Item"
+
+IPMI_LOG_SERVICE="xyz.openbmc_project.Logging.IPMI"
+IPMI_LOG_OBJPATH="/xyz/openbmc_project/Logging/IPMI"
+IPMI_LOG_INTERFACE="xyz.openbmc_project.Logging.IPMI"
+IPMI_LOG_FUNCT="IpmiSelAdd"
+IPMI_LOG_PARA_FORMAT="ssaybq" #5 parameters, s : string, s : string, ay : byte array, b : boolean, q : UINT16
+
+LOG_ERR="Configuration Error(Incorrect_interconnection)"
+LOG_EVENT_DATA="3 0x01 0xff 0xff"
+LOG_ASSERT_FLAG="true"
+LOG_DEASSERT_FLAG="false"
+LOG_GENID_FLAG="0x0020"
+
+initial_state=("false" "false" "false" "false" "false" "false" "false" "false" "false" "false" "false" "false")
+
+for i in "${!INVENTORY_OBJPATH[@]}"
+do
+ mapper wait "${INVENTORY_OBJPATH[$i]}"
+done
+
+while true; do
+ for i in "${!INVENTORY_OBJPATH[@]}"
+ do
+ current_status="$(busctl get-property $SERVICE_NAME "${INVENTORY_OBJPATH[$i]}" $INTERFACE_NAME Present | awk '{print $2}')"
+
+ if [ "$current_status" == "true" ] && [ "${initial_state[$i]}" == "false" ];then
+ initial_state[$i]="true"
+ busctl call $IPMI_LOG_SERVICE $IPMI_LOG_OBJPATH $IPMI_LOG_INTERFACE $IPMI_LOG_FUNCT $IPMI_LOG_PARA_FORMAT "$LOG_ERR" "${INVENTORY_OBJPATH[$i]}" "$LOG_EVENT_DATA" $LOG_ASSERT_FLAG $LOG_GENID_FLAG
+ elif [ "$current_status" == "false" ] && [ "${initial_state[$i]}" == "true" ]; then
+ initial_state[$i]="false"
+ busctl call $IPMI_LOG_SERVICE $IPMI_LOG_OBJPATH $IPMI_LOG_INTERFACE $IPMI_LOG_FUNCT $IPMI_LOG_PARA_FORMAT "$LOG_ERR" "${INVENTORY_OBJPATH[$i]}" "$LOG_EVENT_DATA" $LOG_DEASSERT_FLAG $LOG_GENID_FLAG
+ fi
+ done
+ usleep 100000
+done
+
+exit 0
diff --git a/meta-ufispace/meta-ncplite/recipes-ncplite/ncplite-inventory-log/ncplite-inventory-log.bb b/meta-ufispace/meta-ncplite/recipes-ncplite/ncplite-inventory-log/ncplite-inventory-log.bb
new file mode 100644
index 0000000..43d2c05
--- /dev/null
+++ b/meta-ufispace/meta-ncplite/recipes-ncplite/ncplite-inventory-log/ncplite-inventory-log.bb
@@ -0,0 +1,25 @@
+SUMMARY = "OpenBMC NCPLite Check Inventory State Service"
+DESCRIPTION = "OpenBMC NCPLite Check Inventory State Daemon."
+PR = "r1"
+LICENSE = "Apache-2.0"
+LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
+
+inherit systemd
+
+DEPENDS += "systemd"
+RDEPENDS:${PN} += "bash"
+
+SRC_URI = " file://inventory-log.sh \
+ file://inventory-log.service \
+ "
+
+do_install() {
+ install -d ${D}${libexecdir}/${BPN}
+ install -m 0755 ${WORKDIR}/inventory-log.sh ${D}${libexecdir}/${BPN}
+
+ install -d ${D}${systemd_system_unitdir}
+ install -m 0644 ${WORKDIR}/inventory-log.service ${D}${systemd_system_unitdir}
+}
+
+SYSTEMD_PACKAGES = "${PN}"
+SYSTEMD_SERVICE:${PN} = "inventory-log.service"