1SUMMARY = "OpenPOWER processor control services installation"
2PR = "r1"
3
4LICENSE = "Apache-2.0"
5LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
6
7inherit allarch
8
9RDEPENDS:${PN} += "op-proc-control"
10RDEPENDS:${PN} += "phosphor-state-manager-obmc-targets"
11
12ALLOW_EMPTY:${PN} = "1"
13
14pkg_postinst:${PN}() {
15	mkdir -p $D$systemd_system_unitdir/obmc-host-stop@0.target.wants
16	mkdir -p $D$systemd_system_unitdir/obmc-host-force-warm-reboot@0.target.requires
17	mkdir -p $D$systemd_system_unitdir/obmc-host-startmin@0.target.requires
18	mkdir -p $D$systemd_system_unitdir/obmc-host-startmin@0.target.wants
19	mkdir -p $D$systemd_system_unitdir/obmc-host-diagnostic-mode@0.target.requires
20	mkdir -p $D$systemd_system_unitdir/obmc-chassis-poweron@0.target.requires
21	mkdir -p $D$systemd_system_unitdir/obmc-host-quiesce@0.target.wants
22
23	LINK="$D$systemd_system_unitdir/obmc-host-stop@0.target.wants/op-stop-instructions@0.service"
24	TARGET="../op-stop-instructions@.service"
25	ln -s $TARGET $LINK
26
27	LINK="$D$systemd_system_unitdir/obmc-host-quiesce@0.target.wants/op-clear-sys-dump-active@0.service"
28	TARGET="../op-clear-sys-dump-active@.service"
29	ln -s $TARGET $LINK
30
31	LINK="$D$systemd_system_unitdir/obmc-host-quiesce@0.target.wants/op-stop-instructions@0.service"
32	TARGET="../op-stop-instructions@.service"
33	ln -s $TARGET $LINK
34
35	LINK="$D$systemd_system_unitdir/obmc-host-startmin@0.target.requires/op-cfam-reset.service"
36	TARGET="../op-cfam-reset.service"
37	ln -s $TARGET $LINK
38
39	LINK="$D$systemd_system_unitdir/obmc-host-startmin@0.target.wants/xyz.openbmc_project.Control.Host.NMI.service"
40	TARGET="../xyz.openbmc_project.Control.Host.NMI.service"
41	ln -s $TARGET $LINK
42
43	LINK="$D$systemd_system_unitdir/obmc-chassis-poweron@0.target.requires/op-cfam-reset.service"
44	TARGET="../op-cfam-reset.service"
45	ln -s $TARGET $LINK
46
47	# Only install cfam override if p9 system
48	if [ "${@bb.utils.contains("MACHINE_FEATURES", "p9-cfam-override", "True", "False", d)}" = True ]; then
49		mkdir -p $D$systemd_system_unitdir/obmc-host-startmin@0.target.requires
50		LINK="$D$systemd_system_unitdir/obmc-host-startmin@0.target.requires/cfam_override@0.service"
51		TARGET="../cfam_override@.service"
52		ln -s $TARGET $LINK
53	fi
54
55	LINK="$D$systemd_system_unitdir/obmc-host-startmin@0.target.requires/op-continue-mpreboot@0.service"
56	TARGET="../op-continue-mpreboot@.service"
57	ln -s $TARGET $LINK
58
59	# Only install certain units if phal enabled
60	if [ "${@bb.utils.filter('MACHINE_FEATURES', 'phal', d)}" = phal ]; then
61		LINK="$D$systemd_system_unitdir/obmc-host-stop@0.target.wants/op-clear-sys-dump-active@0.service"
62		TARGET="../op-clear-sys-dump-active@.service"
63		ln -s $TARGET $LINK
64
65		mkdir -p $D$systemd_system_unitdir/multi-user.target.wants
66		LINK="$D$systemd_system_unitdir/multi-user.target.wants/op-clear-sys-dump-active@0.service"
67		TARGET="../op-clear-sys-dump-active@.service"
68		ln -s $TARGET $LINK
69
70		mkdir -p $D$systemd_system_unitdir/obmc-host-start@0.target.requires
71		LINK="$D$systemd_system_unitdir/obmc-host-start@0.target.requires/phal-reinit-devtree.service"
72		TARGET="../phal-reinit-devtree.service"
73		ln -s $TARGET $LINK
74
75		LINK="$D$systemd_system_unitdir/obmc-chassis-poweroff@0.target.requires/proc-pre-poweroff@0.service"
76		TARGET="../proc-pre-poweroff@.service"
77		ln -s $TARGET $LINK
78
79		LINK="$D$systemd_system_unitdir/obmc-host-reset@0.target.requires/op-reset-host-check@0.service"
80		TARGET="../op-reset-host-check@.service"
81		ln -s $TARGET $LINK
82
83		LINK="$D$systemd_system_unitdir/multi-user.target.wants/phal-import-devtree@0.service"
84		TARGET="../phal-import-devtree@.service"
85		ln -s $TARGET $LINK
86
87		mkdir -p $D$systemd_system_unitdir/obmc-host-startmin@0.target.wants
88		LINK="$D$systemd_system_unitdir/obmc-host-startmin@0.target.wants/phal-export-devtree@0.service"
89		TARGET="../phal-export-devtree@.service"
90		ln -s $TARGET $LINK
91
92		mkdir -p $D$systemd_system_unitdir/obmc-host-start@0.target.wants
93		LINK="$D$systemd_system_unitdir/obmc-host-start@0.target.wants/phal-create-boottime-guard-indicator.service"
94		TARGET="../phal-create-boottime-guard-indicator.service"
95		ln -s $TARGET $LINK
96		LINK="$D$systemd_system_unitdir/obmc-host-quiesce@0.target.wants/phal-create-boottime-guard-indicator.service"
97		ln -s $TARGET $LINK
98
99		mkdir -p $D$systemd_system_unitdir/obmc-host-startmin@0.target.wants
100		LINK="$D$systemd_system_unitdir/obmc-host-startmin@0.target.wants/op-clock-data-logger@0.service"
101		TARGET="../op-clock-data-logger@.service"
102		ln -s $TARGET $LINK
103
104		mkdir -p $D$systemd_system_unitdir/obmc-chassis-poweroff@0.target.wants
105		LINK="$D$systemd_system_unitdir/obmc-chassis-poweroff@0.target.wants/set-spi-mux.service"
106		TARGET="../set-spi-mux.service"
107		ln -s $TARGET $LINK
108	fi
109
110	# If the memory preserving reboot feature is enabled, set it up
111	if [ "${@bb.utils.filter('DISTRO_FEATURES', 'mpreboot', d)}" = mpreboot ]; then
112		# on mpreboot systems, obmc-host-crash@.target is used for mpreboot
113		mkdir -p $D$systemd_system_unitdir/obmc-host-crash@0.target.requires
114		LINK="$D$systemd_system_unitdir/obmc-host-crash@0.target.requires/obmc-host-force-warm-reboot@0.target"
115		TARGET="../obmc-host-force-warm-reboot@.target"
116		ln -s $TARGET $LINK
117
118		LINK="$D$systemd_system_unitdir/obmc-host-crash@0.target.requires/op-enter-mpreboot@0.service"
119		TARGET="../op-enter-mpreboot@.service"
120		ln -s $TARGET $LINK
121
122		# ensure diagnostic mode is shown for MPREBOOT
123		LINK="$D$systemd_system_unitdir/obmc-host-crash@0.target.requires/obmc-host-diagnostic-mode@0.target"
124		TARGET="../obmc-host-diagnostic-mode@.target"
125		ln -s $TARGET $LINK
126	else
127		# If not a mpreboot system, default to quiesce target in crash target to support
128		# older system designs like witherspoon
129		mkdir -p $D$systemd_system_unitdir/obmc-host-crash@0.target.wants
130		LINK="$D$systemd_system_unitdir/obmc-host-crash@0.target.wants/obmc-host-quiesce@0.target"
131		TARGET="../obmc-host-quiesce@.target"
132		ln -s $TARGET $LINK
133	fi
134}
135
136pkg_prerm:${PN}() {
137	LINK="$D$systemd_system_unitdir/obmc-host-stop@0.target.wants/op-stop-instructions@0.service"
138	rm $LINK
139	LINK="$D$systemd_system_unitdir/obmc-host-startmin@0.target.requires/op-cfam-reset.service"
140	rm $LINK
141	LINK="$D$systemd_system_unitdir/obmc-chassis-poweron@0.target.requires/op-cfam-reset.service"
142	rm $LINK
143	LINK="$D$systemd_system_unitdir/obmc-host-startmin@0.target.wants/xyz.openbmc_project.Control.Host.NMI.service"
144	rm $LINK
145	# Only uninstall cfam override if p9 system
146	if [ "${@bb.utils.contains("MACHINE_FEATURES", "p9-cfam-override", "True", "False", d)}" = True ]; then
147		LINK="$D$systemd_system_unitdir/obmc-host-startmin@0.target.requires/cfam_override@0.service"
148		rm $LINK
149	fi
150	LINK="$D$systemd_system_unitdir/obmc-host-startmin@0.target.requires/op-continue-mpreboot@0.service"
151	rm $LINK
152
153	# Remove phal specific units if enabled
154	if [ "${@bb.utils.filter('MACHINE_FEATURES', 'phal', d)}" = phal ]; then
155		LINK="$D$systemd_system_unitdir/obmc-host-start@0.target.requires/phal-reinit-devtree.service"
156		rm $LINK
157
158		LINK="$D$systemd_system_unitdir/obmc-chassis-poweroff@0.target.requires/proc-pre-poweroff@0.service"
159		rm $LINK
160
161		LINK="$D$systemd_system_unitdir/obmc-chassis-poweroff@0.target.wants/set-spi-mux.service"
162		rm $LINK
163
164		LINK="$D$systemd_system_unitdir/multi-user.target.wants/phal-import-devtree@0.service"
165		rm $LINK
166
167		LINK="$D$systemd_system_unitdir/obmc-host-startmin@0.target.wants/phal-export-devtree@0.service"
168		rm $LINK
169
170		LINK="$D$systemd_system_unitdir/obmc-host-start@0.target.wants/phal-create-boottime-guard-indicator.service"
171		rm $LINK
172		LINK="$D$systemd_system_unitdir/obmc-host-quiesce@0.target.wants/phal-create-boottime-guard-indicator.service"
173		rm $LINK
174
175		LINK="$D$systemd_system_unitdir/obmc-host-startmin@0.target.wants/op-clock-data-logger@0.service"
176		rm $LINK
177	fi
178
179	# Remove mpreboot specific units if enabled
180	if [ "${@bb.utils.filter('DISTRO_FEATURES', 'mpreboot', d)}" = mpreboot ]; then
181		LINK="$D$systemd_system_unitdir/obmc-host-crash@0.target.requires/obmc-host-force-warm-reboot@0.target"
182		rm $LINK
183
184		LINK="$D$systemd_system_unitdir/obmc-host-crash@0.target.requires/op-enter-mpreboot@0.service"
185		rm $LINK
186	else
187		LINK="$D$systemd_system_unitdir/obmc-host-crash@0.target.wants/obmc-host-quiesce@0.target"
188		rm $LINK
189	fi
190}
191