blob: ad91b16d21363980ed6e284115296d4797369d90 [file] [log] [blame]
Adriana Kobylak8bc2ab42020-07-15 09:16:27 -05001#include "config.h"
2
3#include "item_updater_mmc.hpp"
4
5#include "activation_mmc.hpp"
6#include "version.hpp"
7
Isaac Kurth0ddd4fa2021-07-14 17:35:37 -05008#include <filesystem>
9
Adriana Kobylak8bc2ab42020-07-15 09:16:27 -050010namespace openpower
11{
12namespace software
13{
14namespace updater
15{
16
17// These functions are just a stub (empty) because the current eMMC
18// implementation uses the BMC updater (repo phosphor-bmc-code-mgmt) to write
19// the new host FW to flash since it's delivered as a "System" image in the
20// same BMC tarball as the BMC image.
21
22std::unique_ptr<Activation> ItemUpdaterMMC::createActivationObject(
23 const std::string& path, const std::string& versionId,
24 const std::string& extVersion,
25 sdbusplus::xyz::openbmc_project::Software::server::Activation::Activations
26 activationStatus,
27 AssociationList& assocs)
28{
29 return std::make_unique<ActivationMMC>(
30 bus, path, *this, versionId, extVersion, activationStatus, assocs);
31}
32
33std::unique_ptr<Version> ItemUpdaterMMC::createVersionObject(
34 const std::string& objPath, const std::string& versionId,
35 const std::string& versionString,
36 sdbusplus::xyz::openbmc_project::Software::server::Version::VersionPurpose
37 versionPurpose,
38 const std::string& filePath)
39{
40 auto version = std::make_unique<Version>(
41 bus, objPath, *this, versionId, versionString, versionPurpose, filePath,
42 std::bind(&ItemUpdaterMMC::erase, this, std::placeholders::_1));
43 version->deleteObject = std::make_unique<Delete>(bus, objPath, *version);
44 return version;
45}
46
Brad Bishopc8f22502020-11-06 14:42:09 -050047bool ItemUpdaterMMC::validateImage(const std::string&)
Adriana Kobylak8bc2ab42020-07-15 09:16:27 -050048{
49 return true;
50}
51
52void ItemUpdaterMMC::processPNORImage()
Brad Bishop8facccf2020-11-04 09:44:58 -050053{}
Adriana Kobylak8bc2ab42020-07-15 09:16:27 -050054
55void ItemUpdaterMMC::reset()
Isaac Kurth0ddd4fa2021-07-14 17:35:37 -050056{
57 // Do not reset read-only files needed for reset or ext4 default files
58 const std::vector<std::string> exclusionList = {
59 "alternate", "hostfw-a", "hostfw-b", "lost+found", "running-ro"};
60 std::filesystem::path dirPath(std::string(MEDIA_DIR "hostfw/"));
61 // Delete all files in /media/hostfw/ except for those on exclusionList
62 for (const auto& p : std::filesystem::directory_iterator(dirPath))
63 {
64 if (std::find(exclusionList.begin(), exclusionList.end(),
65 p.path().stem().string()) == exclusionList.end())
66 {
67 std::filesystem::remove_all(p);
68 }
69 }
70
71 // Recreate default files.
72 auto bus = sdbusplus::bus::new_default();
73 constexpr auto initService = "obmc-flash-bios-init.service";
74 auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
75 SYSTEMD_INTERFACE, "StartUnit");
76 method.append(initService, "replace");
77 bus.call_noreply(method);
78
79 constexpr auto patchService = "obmc-flash-bios-patch.service";
80 method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
81 SYSTEMD_INTERFACE, "StartUnit");
82 method.append(patchService, "replace");
83 bus.call_noreply(method);
84
85 constexpr auto processService = "openpower-process-host-firmware.service";
86 method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
87 SYSTEMD_INTERFACE, "StartUnit");
88 method.append(processService, "replace");
89 bus.call_noreply(method);
90
91 constexpr auto updateService = "openpower-update-bios-attr-table.service";
92 method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
93 SYSTEMD_INTERFACE, "StartUnit");
94 method.append(updateService, "replace");
95 bus.call_noreply(method);
96}
Adriana Kobylak8bc2ab42020-07-15 09:16:27 -050097
98bool ItemUpdaterMMC::isVersionFunctional(const std::string& versionId)
99{
100 return versionId == functionalVersionId;
101}
102
Brad Bishopc8f22502020-11-06 14:42:09 -0500103void ItemUpdaterMMC::freePriority(uint8_t, const std::string&)
Brad Bishop8facccf2020-11-04 09:44:58 -0500104{}
Adriana Kobylak8bc2ab42020-07-15 09:16:27 -0500105
106void ItemUpdaterMMC::deleteAll()
Brad Bishop8facccf2020-11-04 09:44:58 -0500107{}
Adriana Kobylak8bc2ab42020-07-15 09:16:27 -0500108
109bool ItemUpdaterMMC::freeSpace()
110{
111 return true;
112}
113
Brad Bishopc8f22502020-11-06 14:42:09 -0500114void ItemUpdaterMMC::updateFunctionalAssociation(const std::string&)
Brad Bishop8facccf2020-11-04 09:44:58 -0500115{}
Adriana Kobylak8bc2ab42020-07-15 09:16:27 -0500116
117void GardResetMMC::reset()
Brad Bishop8facccf2020-11-04 09:44:58 -0500118{}
Adriana Kobylak8bc2ab42020-07-15 09:16:27 -0500119
120} // namespace updater
121} // namespace software
122} // namespace openpower