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