openpower-debug-collector: Define checkstop and watchdog services

openpower-debug-collector had the checkstop service which was
getting invoked in host checkstop scenario. Now there is a need
to get debug data in case of host watchdog timeout scenarios and
this commit adds that support.

Fixes openbmc/openbmc#1634

Change-Id: Iadb7ba516cbdd2d8010c66912bdcd647800aa198
Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
diff --git a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/debug/openpower-debug-collector.bb b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/debug/openpower-debug-collector.bb
index 757ca31..21737de 100644
--- a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/debug/openpower-debug-collector.bb
+++ b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/debug/openpower-debug-collector.bb
@@ -21,11 +21,23 @@
 
 S = "${WORKDIR}/git"
 
-# This needs to be executed as part of host crash
-DEBUG_TMPL = "openpower-debug-collector@.service"
-CRASH_TGTFMT = "obmc-host-crash@{0}.target"
-DEBUG_INSTFMT = "openpower-debug-collector@{0}.service"
-CRASH_DEBUG_FMT = "../${DEBUG_TMPL}:${CRASH_TGTFMT}.wants/${DEBUG_INSTFMT}"
+# This provides below 2 applications that are called into in case
+# of host checkstop and host watchdog timeout respectively.
+APPS = "checkstop watchdog"
 
-SYSTEMD_SERVICE_${PN} += "${DEBUG_TMPL}"
-SYSTEMD_LINK_${PN} += "${@compose_list(d, 'CRASH_DEBUG_FMT', 'OBMC_HOST_INSTANCES')}"
+DEBUG_TMPL = "openpower-debug-collector-{0}@.service"
+SYSTEMD_SERVICE_${PN} += "${@compose_list(d, 'DEBUG_TMPL', 'APPS')}"
+
+# This needs to be executed as part of host crash
+CHECKSTOP_TMPL = "openpower-debug-collector-checkstop@.service"
+CRASH_TGTFMT = "obmc-host-crash@{0}.target"
+CHECKSTOP_INSTFMT = "openpower-debug-collector-checkstop@{0}.service"
+CRASH_CHECKSTOP_FMT = "../${CHECKSTOP_TMPL}:${CRASH_TGTFMT}.wants/${CHECKSTOP_INSTFMT}"
+
+# For now, just create a watchdog symlink in base
+WDOG_TMPL = "openpower-debug-collector-watchdog@.service"
+WDOG_INSTFMT = "openpower-debug-collector-watchdog@{0}.service"
+LINK_FMT = "${WDOG_TMPL}:${WDOG_INSTFMT}"
+
+SYSTEMD_LINK_${PN} += "${@compose_list(d, 'CRASH_CHECKSTOP_FMT', 'OBMC_HOST_INSTANCES')}"
+SYSTEMD_LINK_${PN} += "${@compose_list(d, 'LINK_FMT', 'OBMC_HOST_INSTANCES')}"
diff --git a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/debug/openpower-debug-collector/openpower-debug-collector@.service b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/debug/openpower-debug-collector/openpower-debug-collector-checkstop@.service
similarity index 64%
rename from meta-openbmc-machines/meta-openpower/common/recipes-phosphor/debug/openpower-debug-collector/openpower-debug-collector@.service
rename to meta-openbmc-machines/meta-openpower/common/recipes-phosphor/debug/openpower-debug-collector/openpower-debug-collector-checkstop@.service
index 9ed37e3..67f314b 100644
--- a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/debug/openpower-debug-collector/openpower-debug-collector@.service
+++ b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/debug/openpower-debug-collector/openpower-debug-collector-checkstop@.service
@@ -1,5 +1,5 @@
 [Unit]
-Description=OpenPOWER debug data collector
+Description=OpenPOWER debug data collector for host checkstop
 Before=obmc-host-quiesce@%i.target
 
 [Service]
diff --git a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/debug/openpower-debug-collector/openpower-debug-collector-watchdog@.service b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/debug/openpower-debug-collector/openpower-debug-collector-watchdog@.service
new file mode 100644
index 0000000..0bb2221
--- /dev/null
+++ b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/debug/openpower-debug-collector/openpower-debug-collector-watchdog@.service
@@ -0,0 +1,8 @@
+[Unit]
+Description=OpenPOWER debug data collector for host watchdog timeout
+Before=obmc-host-quiesce@%i.target
+
+[Service]
+ExecStart={sbindir}/watchdog_timeout
+Type=oneshot
+Restart=no