1FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
2
3#===============================================================================
4# TODO: need to be removed once patch merged.
5# meta-facebook: phosphor-state-manager: refactor targets and relationships
6# https://gerrit.openbmc.org/c/openbmc/openbmc/+/69903
7
8PACKAGECONFIG:remove = "only-run-apr-on-power-loss"
9
10# The host-graceful-poweroff service replaces the `pldmSoftPowerOff` and
11# `xyz.openbmc_project.Ipmi.Internal.SoftPowerOff` services to gracefully
12# shutdown the host.
13HOST_DEFAULT_TARGETS:append = " \
14    obmc-host-shutdown@{}.target.requires/host-graceful-poweroff@{}.service \
15    "
16
17# The "warm-reboot" is what does the graceful shutdown operation and the
18# normal "reboot" is suppose to do a forced reboot.  `host-shutdown` is used
19# as part of the graceful shutdown path, which we want to skip in a normal
20# reboot, so remove the dependency.  The `phosphor-reboot-host@.service` does
21# continue to be in `obmc-host-reboot` requirements and it depends on
22# `obmc-host-stop`, which will initiate a `host-force-poweroff`.
23HOST_DEFAULT_TARGETS:remove = " \
24    obmc-host-reboot@{}.target.requires/obmc-host-shutdown@{}.service \
25    "
26
27# The host-poweron service is the equivalent to the start_host@ service
28# from meta-openpower.
29HOST_DEFAULT_TARGETS:append = " \
30    obmc-host-startmin@{}.target.requires/host-poweron@{}.service \
31    "
32
33# The host-stop service is called as a side-effect of force-warm-reboot and is
34# expected to force-stop the processors.  They will be restarted in the
35# subsequent `obmc-host-reboot` (which calls `host-startmin`)
36HOST_DEFAULT_TARGETS:append = " \
37    obmc-host-stop@{}.target.requires/host-force-poweroff@{}.service \
38    "
39
40HOST_DEFAULT_TARGETS:remove = " \
41    obmc-host-warm-reboot@{}.target.requires/xyz.openbmc_project.Ipmi.Internal.SoftPowerOff.service \
42    obmc-host-warm-reboot@{}.target.requires/obmc-host-force-warm-reboot@{}.target \
43    obmc-host-force-warm-reboot@{}.target.requires/obmc-host-stop@{}.target \
44    obmc-host-force-warm-reboot@{}.target.requires/phosphor-reboot-host@{}.service \
45    obmc-host-graceful-quiesce@{}.target.wants/pldmSoftPowerOff.service \
46    "
47
48HOST_DEFAULT_TARGETS:append = " \
49    obmc-host-warm-reboot@{}.target.wants/host-powerreset@{}.service \
50    "
51
52# Add services for the chassis power operations.
53CHASSIS_DEFAULT_TARGETS:append = " \
54    obmc-chassis-poweron@{}.target.requires/chassis-poweron@{}.service \
55    obmc-chassis-powercycle@{}.target.requires/chassis-powercycle@{}.service \
56    "
57
58# We don't use the obmc-power-start or obmc-power-stop, which use the
59# `org.openbmc` interface but instead install our own chassis-poweron and
60# chassis-poweroff.
61CHASSIS_DEFAULT_TARGETS:remove = " \
62    obmc-chassis-poweron@{}.target.requires/obmc-power-start@{}.service \
63    obmc-chassis-poweroff@{}.target.requires/obmc-power-stop@{}.service \
64    "
65
66# The obmc-chassis-powerreset target is used to determine the state of the host
67# when the BMC resets (to handle cases where the BMC reset while the host is
68# running).  The default implementation of these relies on `org.openbmc`
69# interfaces we do not implement, so we need to remove them.
70CHASSIS_DEFAULT_TARGETS:remove = " \
71    obmc-chassis-powerreset@{}.target.requires/phosphor-reset-chassis-on@{}.service \
72    obmc-chassis-powerreset@{}.target.requires/phosphor-reset-chassis-running@{}.service \
73    "
74
75RDEPENDS:${PN}:append = " bash"
76
77FILES:${PN} += "${systemd_system_unitdir}/*.service"
78FILES:${PN} += "${libexecdir}/${PN}"
79
80CHASSIS_DEFAULT_TARGETS:remove = " \
81    obmc-chassis-poweron@{}.target.wants/chassis-poweron@{}.service \
82    obmc-chassis-hard-poweroff@{}.target.wants/chassis-poweroff@{}.service \
83    obmc-chassis-powercycle@{}.target.wants/chassis-powercycle@{}.service \
84"
85
86HOST_DEFAULT_TARGETS:remove = " \
87    obmc-host-shutdown@{}.target.wants/host-poweroff@{}.service \
88    obmc-host-start@{}.target.wants/host-poweron@{}.service \
89    obmc-host-reboot@{}.target.wants/host-powercycle@{}.service \
90"
91#===============================================================================
92
93RDEPENDS:${PN}:append = " bash"
94PACKAGECONFIG:append = " host-gpio"
95
96SRC_URI:append = " \
97    file://chassis-power-state-init \
98    file://chassis-power-state-init.conf \
99    file://chassis-powercycle \
100    file://chassis-powercycle@.service \
101    file://chassis-poweron \
102    file://chassis-poweron@.service \
103    file://host-force-poweroff \
104    file://host-force-poweroff@.service \
105    file://host-graceful-poweroff \
106    file://host-graceful-poweroff@.service \
107    file://host-poweron \
108    file://host-poweron@.service \
109    file://host-powerreset \
110    file://host-powerreset@.service \
111    file://power-cmd \
112    file://phosphor-wait-power-off@.service \
113    "
114
115#We need to ensure that the chassis power is always on.
116CHASSIS_DEFAULT_TARGETS:remove = " \
117    obmc-host-shutdown@{}.target.requires/obmc-chassis-poweroff@{}.target \
118    "
119HARD_OFF_TMPL_CTRL=""
120HARD_OFF_TGTFMT_CTRL=""
121HARD_OFF_FMT_CTRL=""
122HARD_OFF_INSTFMT_CTRL=""
123
124#Remove unexpected ChassisPowerOnStarted log at host first start
125RRECOMMENDS:${PN}-chassis:remove = " ${PN}-chassis-poweron-log"
126
127do_install:append() {
128    install -d ${D}${systemd_system_unitdir}
129    install -m 0644 ${UNPACKDIR}/*.service ${D}${systemd_system_unitdir}/
130
131    install -d ${D}${libexecdir}/${PN}
132    install -m 0755 ${UNPACKDIR}/chassis-power-state-init ${D}${libexecdir}/${PN}/
133    install -m 0755 ${UNPACKDIR}/chassis-poweron ${D}${libexecdir}/${PN}/
134    install -m 0755 ${UNPACKDIR}/chassis-powercycle ${D}${libexecdir}/${PN}/
135    install -m 0755 ${UNPACKDIR}/host-force-poweroff ${D}${libexecdir}/${PN}/
136    install -m 0755 ${UNPACKDIR}/host-graceful-poweroff ${D}${libexecdir}/${PN}/
137    install -m 0755 ${UNPACKDIR}/host-poweron ${D}${libexecdir}/${PN}/
138    install -m 0755 ${UNPACKDIR}/host-powerreset ${D}${libexecdir}/${PN}/
139    install -m 0755 ${UNPACKDIR}/power-cmd ${D}${libexecdir}/${PN}/
140}
141
142SYSTEMD_OVERRIDE:${PN}-host += "chassis-power-state-init.conf:xyz.openbmc_project.State.Host@0.service.d/chassis-power-state-init.conf"
143