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"
100
101SYSTEMD_SERVICE:${PN}-chassis-poweron-log += "phosphor-create-chassis-poweron-log@.service"
102
103FILES:${PN}-chassis += "${bindir}/obmcutil"
104
105FILES:${PN}-bmc = "${bindir}/phosphor-bmc-state-manager"
106FILES:${PN}-bmc += "${sysconfdir}/phosphor-systemd-target-monitor/phosphor-service-monitor-default.json"
107DBUS_SERVICE:${PN}-bmc += "xyz.openbmc_project.State.BMC.service"
108DBUS_SERVICE:${PN}-bmc += "obmc-bmc-service-quiesce@.target"
109
110FILES:${PN}-secure-check = "${bindir}/phosphor-secure-boot-check"
111SYSTEMD_SERVICE:${PN}-secure-check += "phosphor-bmc-security-check.service"
112
113FILES:${PN}-hypervisor = "${bindir}/phosphor-hypervisor-state-manager"
114DBUS_SERVICE:${PN}-hypervisor += "xyz.openbmc_project.State.Hypervisor.service"
115
116FILES:${PN}-discover = "${bindir}/phosphor-discover-system-state"
117SYSTEMD_SERVICE:${PN}-discover += "phosphor-discover-system-state@.service"
118
119FILES:${PN}-host-check = "${bindir}/phosphor-host-check"
120SYSTEMD_SERVICE:${PN}-host-check += "phosphor-reset-host-running@.service"
121FILES:${PN}-host-check = "${bindir}/phosphor-host-reset-recovery"
122SYSTEMD_SERVICE:${PN}-host-check += "phosphor-reset-host-recovery@.service"
123
124
125SYSTEMD_SERVICE:${PN}-reset-sensor-states += "phosphor-reset-sensor-states@.service"
126
127FILES:${PN}-systemd-target-monitor = " \
128    ${bindir}/phosphor-systemd-target-monitor \
129    ${sysconfdir}/phosphor-systemd-target-monitor/phosphor-target-monitor-default.json \
130    "
131SYSTEMD_SERVICE:${PN}-systemd-target-monitor += "phosphor-systemd-target-monitor.service"
132
133FILES:${PN}-scheduled-host-transition = "${bindir}/phosphor-scheduled-host-transition"
134DBUS_SERVICE:${PN}-scheduled-host-transition += "xyz.openbmc_project.State.ScheduledHostTransition@.service"
135
136FILES:${PN}-chassis-check-power-status = "${bindir}/phosphor-chassis-check-power-status"
137SYSTEMD_SERVICE:${PN}-chassis-check-power-status += "phosphor-chassis-check-power-status@.service"
138
139# Chassis power synchronization targets
140# - start-pre:         Services to run before we start power on process
141# - start:             Services to run to do the chassis power on
142# - on:                Services to run once power is on
143# - stop-pre,stop,off: Same as above but applied to powering off
144# - reset-on:          Services to check if chassis power is on after bmc reset
145CHASSIS_SYNCH_TARGETS = "start-pre start on stop-pre stop off reset-on"
146
147# Chassis action power targets
148# - on:  Services to run to power on the chassis
149# - off: Services to run to power off the chassis
150# - cycle: Services to run to cycle power to the chassis
151# - powered-off: Services to run once chassis power is off
152# - reset: Services to check chassis power state and update chassis "on" target
153# - hard-off: Services to force an immediate power off of the chassis
154# - blackout: Target to enter when chassis experiences blackout
155CHASSIS_ACTION_TARGETS = "poweron poweroff powercycle powered-off powerreset hard-poweroff blackout"
156
157# Track all host synchronization point targets
158# - start-pre:                 Services to run before we start host boot
159# - starting:                  Services to run to do the host boot
160# - started:                   Services to run once the host is booted
161# - stop-pre,stopping,stopped: Same as above but applied to shutting down the host
162# - reset-running:             Services to check if host is running after bmc reset
163HOST_SYNCH_TARGETS = "start-pre starting started stop-pre stopping stopped reset-running"
164
165# Track all host action targets
166# - start:    Will run startmin target, this target used for any additional
167#             services that user needs for an initial power on of host.
168#             For example, resetting the host reboot count could be put in
169#             this target so on any fresh power on, this count is reset.
170# - startmin: Minimum services required to start the host. This target will
171#             be called by reboot and start target.
172# - stop:     Services to run to shutdown the host
173# - quiesce:  Target to enter on host boot failure
174# - graceful-quiesce:  Target to enter on host boot failure (allow host graceful shutdown)
175# - shutdown: Tell host to shutdown, then stop system
176# - reset:   Services to check if host is running and update host "start" target
177# - crash:   Target to run when host crashes. it is very much similar to
178#            quiesce target but the only delta is that this target contains
179#            multiple services and one of them is the quiesce target.
180# - timeout: Target to run when host watchdog times out
181# - reboot:  Reboot the host with a chassis power cycle included
182# - warm-reboot: Reboot the host without a chassis power cycle.
183# - force-warm-reboot: Reboot the host without a chassis power cycle and without
184#                      notifying the host.
185# - diagnostic-mode: This will be entered when the host is collecting diagnostic
186#                    data for itself.
187HOST_ACTION_TARGETS = "start startmin stop quiesce graceful-quiesce reset shutdown crash timeout "
188HOST_ACTION_TARGETS += "reboot warm-reboot force-warm-reboot diagnostic-mode"
189
190CHASSIS_SYNCH_FMT = "obmc-power-{0}@.target"
191CHASSIS_ACTION_FMT = "obmc-chassis-{0}@.target"
192HOST_SYNCH_FMT = "obmc-host-{0}@.target"
193HOST_ACTION_FMT = "obmc-host-{0}@.target"
194
195CHASSIS_LINK_SYNCH_FMT = "${CHASSIS_SYNCH_FMT}:obmc-power-{0}@{1}.target"
196CHASSIS_LINK_ACTION_FMT = "${CHASSIS_ACTION_FMT}:obmc-chassis-{0}@{1}.target"
197HOST_LINK_SYNCH_FMT = "${HOST_SYNCH_FMT}:obmc-host-{0}@{1}.target"
198HOST_LINK_ACTION_FMT = "${HOST_ACTION_FMT}:obmc-host-{0}@{1}.target"
199FAN_LINK_FMT = "obmc-fan-control-ready@.target:obmc-fan-control-ready@{0}.target"
200
201# Targets to be executed on checkstop and watchdog timeout
202HOST_ERROR_TARGETS = "timeout"
203
204QUIESCE_TMPL = "obmc-host-quiesce@.target"
205CRASH_TIMEOUT_TGTFMT = "obmc-host-{0}@{1}.target"
206QUIESCE_INSTFMT = "obmc-host-quiesce@{1}.target"
207QUIESCE_FMT = "../${QUIESCE_TMPL}:${CRASH_TIMEOUT_TGTFMT}.wants/${QUIESCE_INSTFMT}"
208
209SYSTEMD_SERVICE:${PN}-obmc-targets += " \
210        obmc-fans-ready.target \
211        obmc-fan-control.target \
212        obmc-fan-control-ready@.target \
213        obmc-fan-watchdog-takeover.target \
214        "
215
216SYSTEMD_SERVICE:${PN}-obmc-targets += "${@compose_list(d, 'CHASSIS_SYNCH_FMT', 'CHASSIS_SYNCH_TARGETS')}"
217SYSTEMD_SERVICE:${PN}-obmc-targets += "${@compose_list(d, 'CHASSIS_ACTION_FMT', 'CHASSIS_ACTION_TARGETS')}"
218SYSTEMD_SERVICE:${PN}-obmc-targets += "${@compose_list(d, 'HOST_SYNCH_FMT', 'HOST_SYNCH_TARGETS')}"
219SYSTEMD_SERVICE:${PN}-obmc-targets += "${@compose_list(d, 'HOST_ACTION_FMT', 'HOST_ACTION_TARGETS')}"
220
221SYSTEMD_LINK:${PN}-obmc-targets += "${@compose_list(d, 'CHASSIS_LINK_SYNCH_FMT', 'CHASSIS_SYNCH_TARGETS', 'OBMC_CHASSIS_INSTANCES')}"
222SYSTEMD_LINK:${PN}-obmc-targets += "${@compose_list(d, 'CHASSIS_LINK_ACTION_FMT', 'CHASSIS_ACTION_TARGETS', 'OBMC_CHASSIS_INSTANCES')}"
223SYSTEMD_LINK:${PN}-obmc-targets += "${@compose_list(d, 'HOST_LINK_SYNCH_FMT', 'HOST_SYNCH_TARGETS', 'OBMC_HOST_INSTANCES')}"
224SYSTEMD_LINK:${PN}-obmc-targets += "${@compose_list(d, 'HOST_LINK_ACTION_FMT', 'HOST_ACTION_TARGETS', 'OBMC_HOST_INSTANCES')}"
225SYSTEMD_LINK:${PN}-obmc-targets += "${@compose_list(d, 'FAN_LINK_FMT', 'OBMC_CHASSIS_INSTANCES')}"
226SYSTEMD_LINK:${PN}-obmc-targets += "${@compose_list(d, 'QUIESCE_FMT', 'HOST_ERROR_TARGETS', 'OBMC_HOST_INSTANCES')}"
227
228# Create target relationships
229
230# Starting the host requires chassis power on
231START_TMPL_CTRL = "obmc-chassis-poweron@.target"
232START_TGTFMT_CTRL = "obmc-host-startmin@{1}.target"
233START_INSTFMT_CTRL = "obmc-chassis-poweron@{0}.target"
234START_FMT_CTRL = "../${START_TMPL_CTRL}:${START_TGTFMT_CTRL}.requires/${START_INSTFMT_CTRL}"
235SYSTEMD_LINK:${PN}-obmc-targets += "${@compose_list_zip(d, 'START_FMT_CTRL', 'OBMC_POWER_INSTANCES', 'OBMC_CHASSIS_INSTANCES')}"
236
237# Chassis off requires host off
238STOP_TMPL_CTRL = "obmc-host-stop@.target"
239STOP_TGTFMT_CTRL = "obmc-chassis-poweroff@{0}.target"
240STOP_INSTFMT_CTRL = "obmc-host-stop@{1}.target"
241STOP_FMT_CTRL = "../${STOP_TMPL_CTRL}:${STOP_TGTFMT_CTRL}.requires/${STOP_INSTFMT_CTRL}"
242SYSTEMD_LINK:${PN}-obmc-targets += "${@compose_list_zip(d, 'STOP_FMT_CTRL', 'OBMC_CHASSIS_INSTANCES', 'OBMC_HOST_INSTANCES')}"
243
244# Hard power off requires chassis off
245HARD_OFF_TMPL_CTRL = "obmc-chassis-poweroff@.target"
246HARD_OFF_TGTFMT_CTRL = "obmc-chassis-hard-poweroff@{0}.target"
247HARD_OFF_INSTFMT_CTRL = "obmc-chassis-poweroff@{0}.target"
248HARD_OFF_FMT_CTRL = "../${HARD_OFF_TMPL_CTRL}:${HARD_OFF_TGTFMT_CTRL}.requires/${HARD_OFF_INSTFMT_CTRL}"
249SYSTEMD_LINK:${PN}-obmc-targets += "${@compose_list_zip(d, 'HARD_OFF_FMT_CTRL', 'OBMC_CHASSIS_INSTANCES')}"
250
251# Force the standby target to run the chassis reset check target
252RESET_TMPL_CTRL = "obmc-chassis-powerreset@.target"
253SYSD_TGT = "multi-user.target"
254RESET_INSTFMT_CTRL = "obmc-chassis-powerreset@{0}.target"
255RESET_FMT_CTRL = "../${RESET_TMPL_CTRL}:${SYSD_TGT}.wants/${RESET_INSTFMT_CTRL}"
256SYSTEMD_LINK:${PN}-obmc-targets += "${@compose_list_zip(d, 'RESET_FMT_CTRL', 'OBMC_CHASSIS_INSTANCES')}"
257
258SRC_URI = "git://github.com/openbmc/phosphor-state-manager;branch=master;protocol=https"
259SRCREV = "564eb4fa9de27fb9c26213fd94eef703fbe6f2f9"
260
261S = "${WORKDIR}/git"
262