1SUMMARY = "Phosphor State Management"
2DESCRIPTION = "Phosphor State Manager provides a set of system state \
3management daemons. It is suitable for use on a wide variety of OpenBMC \
4platforms."
5HOMEPAGE = "https://github.com/openbmc/phosphor-state-manager"
6PR = "r1"
7PV = "1.0+git${SRCPV}"
8LICENSE = "Apache-2.0"
9LIC_FILES_CHKSUM = "file://${S}/LICENSE;md5=e3fc50a88d0a364313df4b21ef20c29e"
10
11include phosphor-state-manager-systemd-links.inc
12
13STATE_MGR_PACKAGES = " \
14    ${PN}-host \
15    ${PN}-chassis \
16    ${PN}-bmc \
17    ${PN}-hypervisor \
18    ${PN}-discover \
19    ${PN}-host-check \
20    ${PN}-reset-sensor-states \
21    ${PN}-systemd-target-monitor \
22    ${PN}-obmc-targets \
23    ${PN}-scheduled-host-transition \
24    ${PN}-chassis-check-power-status \
25    ${PN}-secure-check \
26    ${PN}-chassis-poweron-log \
27"
28PACKAGE_BEFORE_PN += "${STATE_MGR_PACKAGES}"
29ALLOW_EMPTY:${PN} = "1"
30
31DBUS_PACKAGES = "${STATE_MGR_PACKAGES}"
32
33SYSTEMD_PACKAGES = "${PN}-discover \
34                    ${PN}-reset-sensor-states \
35                    ${PN}-systemd-target-monitor \
36"
37
38PACKAGECONFIG ??= "no-warm-reboot \
39                   only-run-apr-on-power-loss \
40                   only-allow-boot-when-bmc-ready"
41
42# Disable warm reboots of host
43PACKAGECONFIG[no-warm-reboot] = "-Dwarm-reboot=disabled,-Dwarm-reboot=enabled"
44
45# Only run auto power restore logic if system had ac loss
46PACKAGECONFIG[only-run-apr-on-power-loss] = "-Donly-run-apr-on-power-loss=true,-Donly-run-apr-on-power-loss=false"
47
48# Only allow boot operations when BMC is in Ready state
49PACKAGECONFIG[only-allow-boot-when-bmc-ready] = "-Donly-allow-boot-when-bmc-ready=true,-Donly-allow-boot-when-bmc-ready=false"
50
51# The host-check function will check if the host is running
52# after a BMC reset.
53# The reset-sensor-states function will reset the host
54# sensors on a BMC reset or system power loss.
55# Neither is required for host state function but are
56# recommended to deal properly with these reset scenarios.
57RRECOMMENDS:${PN}-host = "${PN}-host-check ${PN}-reset-sensor-states"
58
59# The obmc-targets are the base targets required to boot a computer system
60RRECOMMENDS:${PN}-host += "${PN}-obmc-targets"
61
62# Make it the default to create an info log when the chassis transitions
63# from off to on
64RRECOMMENDS:${PN}-chassis:append = " ${PN}-chassis-poweron-log"
65
66inherit meson pkgconfig
67inherit obmc-phosphor-dbus-service
68inherit obmc-phosphor-systemd
69
70DEPENDS += "sdbusplus"
71DEPENDS += "sdeventplus"
72DEPENDS += "phosphor-logging"
73DEPENDS += "phosphor-dbus-interfaces"
74DEPENDS += "libcereal"
75DEPENDS += "nlohmann-json"
76DEPENDS += "cli11"
77DEPENDS += "libgpiod"
78
79RDEPENDS:${PN}-chassis += "bash"
80RDEPENDS:${PN}-host += "bash"
81
82EXTRA_OEMESON:append = " -Dtests=disabled"
83
84FILES:${PN}-host = "${bindir}/phosphor-host-state-manager"
85FILES:${PN}-host += "${libexecdir}/host-reboot"
86DBUS_SERVICE:${PN}-host += "xyz.openbmc_project.State.Host@.service"
87DBUS_SERVICE:${PN}-host += "phosphor-reboot-host@.service"
88SYSTEMD_SERVICE:${PN}-host += "phosphor-reset-host-reboot-attempts@.service"
89SYSTEMD_SERVICE:${PN}-host += "phosphor-clear-one-time@.service"
90SYSTEMD_SERVICE:${PN}-host += "phosphor-set-host-transition-to-running@.service"
91SYSTEMD_SERVICE:${PN}-host += "phosphor-set-host-transition-to-off@.service"
92
93FILES:${PN}-chassis = "${bindir}/phosphor-chassis-state-manager"
94DBUS_SERVICE:${PN}-chassis += "xyz.openbmc_project.State.Chassis@.service"
95SYSTEMD_SERVICE:${PN}-chassis += "obmc-power-start@.service"
96SYSTEMD_SERVICE:${PN}-chassis += "obmc-power-stop@.service"
97SYSTEMD_SERVICE:${PN}-chassis += "obmc-powered-off@.service"
98SYSTEMD_SERVICE:${PN}-chassis += "phosphor-reset-chassis-on@.service"
99SYSTEMD_SERVICE:${PN}-chassis += "phosphor-reset-chassis-running@.service"
100SYSTEMD_SERVICE:${PN}-chassis += "phosphor-set-chassis-transition-to-on@.service"
101SYSTEMD_SERVICE:${PN}-chassis += "phosphor-set-chassis-transition-to-off@.service"
102
103SYSTEMD_SERVICE:${PN}-chassis-poweron-log += "phosphor-create-chassis-poweron-log@.service"
104
105FILES:${PN}-chassis += "${bindir}/obmcutil"
106
107FILES:${PN}-bmc = "${bindir}/phosphor-bmc-state-manager"
108FILES:${PN}-bmc += "${sysconfdir}/phosphor-systemd-target-monitor/phosphor-service-monitor-default.json"
109DBUS_SERVICE:${PN}-bmc += "xyz.openbmc_project.State.BMC.service"
110DBUS_SERVICE:${PN}-bmc += "obmc-bmc-service-quiesce@.target"
111
112FILES:${PN}-secure-check = "${bindir}/phosphor-secure-boot-check"
113SYSTEMD_SERVICE:${PN}-secure-check += "phosphor-bmc-security-check.service"
114
115FILES:${PN}-hypervisor = "${bindir}/phosphor-hypervisor-state-manager"
116DBUS_SERVICE:${PN}-hypervisor += "xyz.openbmc_project.State.Hypervisor.service"
117
118FILES:${PN}-discover = "${bindir}/phosphor-discover-system-state"
119SYSTEMD_SERVICE:${PN}-discover += "phosphor-discover-system-state@.service"
120
121FILES:${PN}-host-check = "${bindir}/phosphor-host-check"
122SYSTEMD_SERVICE:${PN}-host-check += "phosphor-reset-host-running@.service"
123FILES:${PN}-host-check = "${bindir}/phosphor-host-reset-recovery"
124SYSTEMD_SERVICE:${PN}-host-check += "phosphor-reset-host-recovery@.service"
125
126
127SYSTEMD_SERVICE:${PN}-reset-sensor-states += "phosphor-reset-sensor-states@.service"
128
129FILES:${PN}-systemd-target-monitor = " \
130    ${bindir}/phosphor-systemd-target-monitor \
131    ${sysconfdir}/phosphor-systemd-target-monitor/phosphor-target-monitor-default.json \
132    "
133SYSTEMD_SERVICE:${PN}-systemd-target-monitor += "phosphor-systemd-target-monitor.service"
134
135FILES:${PN}-scheduled-host-transition = "${bindir}/phosphor-scheduled-host-transition"
136DBUS_SERVICE:${PN}-scheduled-host-transition += "xyz.openbmc_project.State.ScheduledHostTransition@.service"
137
138FILES:${PN}-chassis-check-power-status = "${bindir}/phosphor-chassis-check-power-status"
139SYSTEMD_SERVICE:${PN}-chassis-check-power-status += "phosphor-chassis-check-power-status@.service"
140
141# Chassis power synchronization targets
142# - start-pre:         Services to run before we start power on process
143# - start:             Services to run to do the chassis power on
144# - on:                Services to run once power is on
145# - stop-pre,stop,off: Same as above but applied to powering off
146# - reset-on:          Services to check if chassis power is on after bmc reset
147CHASSIS_SYNCH_TARGETS = "start-pre start on stop-pre stop off reset-on"
148
149# Chassis action power targets
150# - on:  Services to run to power on the chassis
151# - off: Services to run to power off the chassis
152# - cycle: Services to run to cycle power to the chassis
153# - powered-off: Services to run once chassis power is off
154# - reset: Services to check chassis power state and update chassis "on" target
155# - hard-off: Services to force an immediate power off of the chassis
156# - blackout: Target to enter when chassis experiences blackout
157CHASSIS_ACTION_TARGETS = "poweron poweroff powercycle powered-off powerreset hard-poweroff blackout"
158
159# Track all host synchronization point targets
160# - start-pre:                 Services to run before we start host boot
161# - starting:                  Services to run to do the host boot
162# - started:                   Services to run once the host is booted
163# - stop-pre,stopping,stopped: Same as above but applied to shutting down the host
164# - reset-running:             Services to check if host is running after bmc reset
165HOST_SYNCH_TARGETS = "start-pre starting started stop-pre stopping stopped reset-running"
166
167# Track all host action targets
168# - start:    Will run startmin target, this target used for any additional
169#             services that user needs for an initial power on of host.
170#             For example, resetting the host reboot count could be put in
171#             this target so on any fresh power on, this count is reset.
172# - startmin: Minimum services required to start the host. This target will
173#             be called by reboot and start target.
174# - stop:     Services to run to shutdown the host
175# - quiesce:  Target to enter on host boot failure
176# - graceful-quiesce:  Target to enter on host boot failure (allow host graceful shutdown)
177# - shutdown: Tell host to shutdown, then stop system
178# - reset:   Services to check if host is running and update host "start" target
179# - crash:   Target to run when host crashes. it is very much similar to
180#            quiesce target but the only delta is that this target contains
181#            multiple services and one of them is the quiesce target.
182# - timeout: Target to run when host watchdog times out
183# - reboot:  Reboot the host with a chassis power cycle included
184# - warm-reboot: Reboot the host without a chassis power cycle.
185# - force-warm-reboot: Reboot the host without a chassis power cycle and without
186#                      notifying the host.
187# - diagnostic-mode: This will be entered when the host is collecting diagnostic
188#                    data for itself.
189HOST_ACTION_TARGETS = "start startmin stop quiesce graceful-quiesce reset shutdown crash timeout "
190HOST_ACTION_TARGETS += "reboot warm-reboot force-warm-reboot diagnostic-mode"
191
192CHASSIS_SYNCH_FMT = "obmc-power-{0}@.target"
193CHASSIS_ACTION_FMT = "obmc-chassis-{0}@.target"
194HOST_SYNCH_FMT = "obmc-host-{0}@.target"
195HOST_ACTION_FMT = "obmc-host-{0}@.target"
196
197CHASSIS_LINK_SYNCH_FMT = "${CHASSIS_SYNCH_FMT}:obmc-power-{0}@{1}.target"
198CHASSIS_LINK_ACTION_FMT = "${CHASSIS_ACTION_FMT}:obmc-chassis-{0}@{1}.target"
199HOST_LINK_SYNCH_FMT = "${HOST_SYNCH_FMT}:obmc-host-{0}@{1}.target"
200HOST_LINK_ACTION_FMT = "${HOST_ACTION_FMT}:obmc-host-{0}@{1}.target"
201FAN_LINK_FMT = "obmc-fan-control-ready@.target:obmc-fan-control-ready@{0}.target"
202
203# Targets to be executed on checkstop and watchdog timeout
204HOST_ERROR_TARGETS = "timeout"
205
206QUIESCE_TMPL = "obmc-host-quiesce@.target"
207CRASH_TIMEOUT_TGTFMT = "obmc-host-{0}@{1}.target"
208QUIESCE_INSTFMT = "obmc-host-quiesce@{1}.target"
209QUIESCE_FMT = "../${QUIESCE_TMPL}:${CRASH_TIMEOUT_TGTFMT}.wants/${QUIESCE_INSTFMT}"
210
211SYSTEMD_SERVICE:${PN}-obmc-targets += " \
212        obmc-fans-ready.target \
213        obmc-fan-control.target \
214        obmc-fan-control-ready@.target \
215        obmc-fan-watchdog-takeover.target \
216        "
217
218SYSTEMD_SERVICE:${PN}-obmc-targets += "${@compose_list(d, 'CHASSIS_SYNCH_FMT', 'CHASSIS_SYNCH_TARGETS')}"
219SYSTEMD_SERVICE:${PN}-obmc-targets += "${@compose_list(d, 'CHASSIS_ACTION_FMT', 'CHASSIS_ACTION_TARGETS')}"
220SYSTEMD_SERVICE:${PN}-obmc-targets += "${@compose_list(d, 'HOST_SYNCH_FMT', 'HOST_SYNCH_TARGETS')}"
221SYSTEMD_SERVICE:${PN}-obmc-targets += "${@compose_list(d, 'HOST_ACTION_FMT', 'HOST_ACTION_TARGETS')}"
222
223SYSTEMD_LINK:${PN}-obmc-targets += "${@compose_list(d, 'CHASSIS_LINK_SYNCH_FMT', 'CHASSIS_SYNCH_TARGETS', 'OBMC_CHASSIS_INSTANCES')}"
224SYSTEMD_LINK:${PN}-obmc-targets += "${@compose_list(d, 'CHASSIS_LINK_ACTION_FMT', 'CHASSIS_ACTION_TARGETS', 'OBMC_CHASSIS_INSTANCES')}"
225SYSTEMD_LINK:${PN}-obmc-targets += "${@compose_list(d, 'HOST_LINK_SYNCH_FMT', 'HOST_SYNCH_TARGETS', 'OBMC_HOST_INSTANCES')}"
226SYSTEMD_LINK:${PN}-obmc-targets += "${@compose_list(d, 'HOST_LINK_ACTION_FMT', 'HOST_ACTION_TARGETS', 'OBMC_HOST_INSTANCES')}"
227SYSTEMD_LINK:${PN}-obmc-targets += "${@compose_list(d, 'FAN_LINK_FMT', 'OBMC_CHASSIS_INSTANCES')}"
228SYSTEMD_LINK:${PN}-obmc-targets += "${@compose_list(d, 'QUIESCE_FMT', 'HOST_ERROR_TARGETS', 'OBMC_HOST_INSTANCES')}"
229
230# Create target relationships
231
232# Starting the host requires chassis power on
233START_TMPL_CTRL = "obmc-chassis-poweron@.target"
234START_TGTFMT_CTRL = "obmc-host-startmin@{1}.target"
235START_INSTFMT_CTRL = "obmc-chassis-poweron@{0}.target"
236START_FMT_CTRL = "../${START_TMPL_CTRL}:${START_TGTFMT_CTRL}.requires/${START_INSTFMT_CTRL}"
237SYSTEMD_LINK:${PN}-obmc-targets += "${@compose_list_zip(d, 'START_FMT_CTRL', 'OBMC_CHASSIS_INSTANCES', 'OBMC_CHASSIS_INSTANCES')}"
238
239# Chassis off requires host off
240STOP_TMPL_CTRL = "obmc-host-stop@.target"
241STOP_TGTFMT_CTRL = "obmc-chassis-poweroff@{0}.target"
242STOP_INSTFMT_CTRL = "obmc-host-stop@{1}.target"
243STOP_FMT_CTRL = "../${STOP_TMPL_CTRL}:${STOP_TGTFMT_CTRL}.requires/${STOP_INSTFMT_CTRL}"
244SYSTEMD_LINK:${PN}-obmc-targets += "${@compose_list_zip(d, 'STOP_FMT_CTRL', 'OBMC_CHASSIS_INSTANCES', 'OBMC_HOST_INSTANCES')}"
245
246# Hard power off requires chassis off
247HARD_OFF_TMPL_CTRL = "obmc-chassis-poweroff@.target"
248HARD_OFF_TGTFMT_CTRL = "obmc-chassis-hard-poweroff@{0}.target"
249HARD_OFF_INSTFMT_CTRL = "obmc-chassis-poweroff@{0}.target"
250HARD_OFF_FMT_CTRL = "../${HARD_OFF_TMPL_CTRL}:${HARD_OFF_TGTFMT_CTRL}.requires/${HARD_OFF_INSTFMT_CTRL}"
251SYSTEMD_LINK:${PN}-obmc-targets += "${@compose_list_zip(d, 'HARD_OFF_FMT_CTRL', 'OBMC_CHASSIS_INSTANCES')}"
252
253# Force the standby target to run the chassis reset check target
254RESET_TMPL_CTRL = "obmc-chassis-powerreset@.target"
255SYSD_TGT = "multi-user.target"
256RESET_INSTFMT_CTRL = "obmc-chassis-powerreset@{0}.target"
257RESET_FMT_CTRL = "../${RESET_TMPL_CTRL}:${SYSD_TGT}.wants/${RESET_INSTFMT_CTRL}"
258SYSTEMD_LINK:${PN}-obmc-targets += "${@compose_list_zip(d, 'RESET_FMT_CTRL', 'OBMC_CHASSIS_INSTANCES')}"
259
260SRC_URI = "git://github.com/openbmc/phosphor-state-manager;branch=master;protocol=https"
261SRCREV = "31cddb75de28499d8b748a1e020a795763405656"
262
263S = "${WORKDIR}/git"
264