Adriana Kobylak | 70f5bc0 | 2020-05-13 14:08:14 -0500 | [diff] [blame] | 1 | #include "config.h" |
| 2 | |
Adriana Kobylak | 86013f3 | 2020-05-13 12:12:38 -0500 | [diff] [blame] | 3 | #include "flash.hpp" |
| 4 | |
| 5 | #include "activation.hpp" |
Adriana Kobylak | 25773a7 | 2022-01-21 15:24:48 +0000 | [diff] [blame] | 6 | #include "item_updater.hpp" |
Adriana Kobylak | 86013f3 | 2020-05-13 12:12:38 -0500 | [diff] [blame] | 7 | |
| 8 | namespace phosphor |
| 9 | { |
| 10 | namespace software |
| 11 | { |
| 12 | namespace updater |
| 13 | { |
| 14 | |
Adriana Kobylak | 70f5bc0 | 2020-05-13 14:08:14 -0500 | [diff] [blame] | 15 | namespace softwareServer = sdbusplus::xyz::openbmc_project::Software::server; |
| 16 | |
Adriana Kobylak | 86013f3 | 2020-05-13 12:12:38 -0500 | [diff] [blame] | 17 | void Activation::flashWrite() |
| 18 | { |
Adriana Kobylak | 70f5bc0 | 2020-05-13 14:08:14 -0500 | [diff] [blame] | 19 | auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH, |
| 20 | SYSTEMD_INTERFACE, "StartUnit"); |
| 21 | auto serviceFile = "obmc-flash-mmc@" + versionId + ".service"; |
| 22 | method.append(serviceFile, "replace"); |
| 23 | bus.call_noreply(method); |
Adriana Kobylak | 86013f3 | 2020-05-13 12:12:38 -0500 | [diff] [blame] | 24 | } |
| 25 | |
Adriana Kobylak | 70f5bc0 | 2020-05-13 14:08:14 -0500 | [diff] [blame] | 26 | void Activation::onStateChanges(sdbusplus::message::message& msg) |
Adriana Kobylak | 86013f3 | 2020-05-13 12:12:38 -0500 | [diff] [blame] | 27 | { |
Adriana Kobylak | 70f5bc0 | 2020-05-13 14:08:14 -0500 | [diff] [blame] | 28 | uint32_t newStateID{}; |
| 29 | sdbusplus::message::object_path newStateObjPath; |
| 30 | std::string newStateUnit{}; |
| 31 | std::string newStateResult{}; |
| 32 | |
| 33 | // Read the msg and populate each variable |
| 34 | msg.read(newStateID, newStateObjPath, newStateUnit, newStateResult); |
| 35 | |
| 36 | auto mmcServiceFile = "obmc-flash-mmc@" + versionId + ".service"; |
Adriana Kobylak | 25773a7 | 2022-01-21 15:24:48 +0000 | [diff] [blame] | 37 | auto flashId = parent.versions.find(versionId)->second->path(); |
| 38 | auto mmcSetPrimary = "obmc-flash-mmc-setprimary@" + flashId + ".service"; |
Adriana Kobylak | 70f5bc0 | 2020-05-13 14:08:14 -0500 | [diff] [blame] | 39 | |
| 40 | if (newStateUnit == mmcServiceFile && newStateResult == "done") |
| 41 | { |
| 42 | roVolumeCreated = true; |
| 43 | activationProgress->progress(activationProgress->progress() + 1); |
| 44 | } |
| 45 | |
Adriana Kobylak | 3412435 | 2020-05-22 09:40:40 -0500 | [diff] [blame] | 46 | if (newStateUnit == mmcSetPrimary && newStateResult == "done") |
| 47 | { |
| 48 | ubootEnvVarsUpdated = true; |
| 49 | } |
| 50 | |
| 51 | if (newStateUnit == mmcServiceFile || newStateUnit == mmcSetPrimary) |
Adriana Kobylak | 70f5bc0 | 2020-05-13 14:08:14 -0500 | [diff] [blame] | 52 | { |
| 53 | if (newStateResult == "failed" || newStateResult == "dependency") |
| 54 | { |
| 55 | Activation::activation( |
| 56 | softwareServer::Activation::Activations::Failed); |
| 57 | } |
| 58 | else if (roVolumeCreated) |
| 59 | { |
Adriana Kobylak | 3412435 | 2020-05-22 09:40:40 -0500 | [diff] [blame] | 60 | if (!ubootEnvVarsUpdated) |
| 61 | { |
| 62 | activationProgress->progress(90); |
| 63 | |
| 64 | // Set the priority which triggers the service that updates the |
| 65 | // environment variables. |
| 66 | if (!Activation::redundancyPriority) |
| 67 | { |
| 68 | Activation::redundancyPriority = |
| 69 | std::make_unique<RedundancyPriority>(bus, path, *this, |
| 70 | 0); |
| 71 | } |
| 72 | } |
| 73 | else // Environment variables were updated |
| 74 | { |
| 75 | Activation::onFlashWriteSuccess(); |
| 76 | } |
Adriana Kobylak | 70f5bc0 | 2020-05-13 14:08:14 -0500 | [diff] [blame] | 77 | } |
| 78 | } |
| 79 | |
| 80 | return; |
Adriana Kobylak | 86013f3 | 2020-05-13 12:12:38 -0500 | [diff] [blame] | 81 | } |
| 82 | |
| 83 | } // namespace updater |
| 84 | } // namespace software |
| 85 | } // namespace phosphor |