Alex Deymo | 4243291 | 2013-07-12 20:21:15 -0700 | [diff] [blame] | 1 | // Copyright (c) 2013 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Gilad Arnold | cf175a0 | 2014-07-10 16:48:47 -0700 | [diff] [blame^] | 5 | #ifndef UPDATE_ENGINE_HARDWARE_INTERFACE_H_ |
| 6 | #define UPDATE_ENGINE_HARDWARE_INTERFACE_H_ |
Alex Deymo | 4243291 | 2013-07-12 20:21:15 -0700 | [diff] [blame] | 7 | |
| 8 | #include <string> |
Alex Vakulenko | 59e253e | 2014-02-24 10:40:21 -0800 | [diff] [blame] | 9 | #include <vector> |
Alex Deymo | 4243291 | 2013-07-12 20:21:15 -0700 | [diff] [blame] | 10 | |
Alex Deymo | bccbc38 | 2014-04-03 13:38:55 -0700 | [diff] [blame] | 11 | #include <base/time/time.h> |
| 12 | |
Alex Deymo | 4243291 | 2013-07-12 20:21:15 -0700 | [diff] [blame] | 13 | namespace chromeos_update_engine { |
| 14 | |
| 15 | // The hardware interface allows access to the following parts of the system, |
| 16 | // closely related to the hardware: |
| 17 | // * crossystem exposed properties: firmware, hwid, etc. |
| 18 | // * Physical disk: partition booted from and partition name conversions. |
| 19 | // These stateless functions are tied together in this interface to facilitate |
| 20 | // unit testing. |
| 21 | class HardwareInterface { |
| 22 | public: |
Don Garrett | 83692e4 | 2013-11-08 10:11:30 -0800 | [diff] [blame] | 23 | // Returns the currently booted kernel partition. "/dev/sda2", for example. |
Alex Vakulenko | d0fdfb3 | 2014-02-21 15:26:26 -0800 | [diff] [blame] | 24 | virtual std::string BootKernelDevice() const = 0; |
Don Garrett | 83692e4 | 2013-11-08 10:11:30 -0800 | [diff] [blame] | 25 | |
| 26 | // Returns the currently booted rootfs partition. "/dev/sda3", for example. |
Alex Vakulenko | d0fdfb3 | 2014-02-21 15:26:26 -0800 | [diff] [blame] | 27 | virtual std::string BootDevice() const = 0; |
Alex Deymo | 4243291 | 2013-07-12 20:21:15 -0700 | [diff] [blame] | 28 | |
Alex Deymo | 5708ecd | 2014-04-29 19:44:50 -0700 | [diff] [blame] | 29 | // Return whether the BootDevice() is a removable device. |
| 30 | virtual bool IsBootDeviceRemovable() const = 0; |
| 31 | |
Alex Vakulenko | 59e253e | 2014-02-24 10:40:21 -0800 | [diff] [blame] | 32 | // Returns a list of all kernel partitions available (whether bootable or not) |
Alex Vakulenko | d0fdfb3 | 2014-02-21 15:26:26 -0800 | [diff] [blame] | 33 | virtual std::vector<std::string> GetKernelDevices() const = 0; |
Alex Vakulenko | 59e253e | 2014-02-24 10:40:21 -0800 | [diff] [blame] | 34 | |
Don Garrett | 83692e4 | 2013-11-08 10:11:30 -0800 | [diff] [blame] | 35 | // Is the specified kernel partition currently bootable, based on GPT flags? |
| 36 | // Returns success. |
| 37 | virtual bool IsKernelBootable(const std::string& kernel_device, |
Alex Vakulenko | d0fdfb3 | 2014-02-21 15:26:26 -0800 | [diff] [blame] | 38 | bool* bootable) const = 0; |
Don Garrett | 83692e4 | 2013-11-08 10:11:30 -0800 | [diff] [blame] | 39 | |
| 40 | // Mark the specified kernel partition unbootable in GPT flags. We mark |
| 41 | // the other kernel as bootable inside postinst, not inside the UE. |
| 42 | // Returns success. |
| 43 | virtual bool MarkKernelUnbootable(const std::string& kernel_device) = 0; |
| 44 | |
J. Richard Barnette | 056b0ab | 2013-10-29 15:24:56 -0700 | [diff] [blame] | 45 | // Returns true if this is an official Chrome OS build, false otherwise. |
Alex Vakulenko | d0fdfb3 | 2014-02-21 15:26:26 -0800 | [diff] [blame] | 46 | virtual bool IsOfficialBuild() const = 0; |
J. Richard Barnette | 056b0ab | 2013-10-29 15:24:56 -0700 | [diff] [blame] | 47 | |
| 48 | // Returns true if the boot mode is normal or if it's unable to |
| 49 | // determine the boot mode. Returns false if the boot mode is |
| 50 | // developer. |
Alex Vakulenko | d0fdfb3 | 2014-02-21 15:26:26 -0800 | [diff] [blame] | 51 | virtual bool IsNormalBootMode() const = 0; |
J. Richard Barnette | 522d36f | 2013-10-28 17:22:12 -0700 | [diff] [blame] | 52 | |
Alex Deymo | bccbc38 | 2014-04-03 13:38:55 -0700 | [diff] [blame] | 53 | // Returns true if the OOBE process has been completed and EULA accepted, |
| 54 | // False otherwise. If True is returned, and |out_time_of_oobe| isn't null, |
| 55 | // the time-stamp of when OOBE happened is stored at |out_time_of_oobe|. |
| 56 | virtual bool IsOOBEComplete(base::Time* out_time_of_oobe) const = 0; |
| 57 | |
J. Richard Barnette | 522d36f | 2013-10-28 17:22:12 -0700 | [diff] [blame] | 58 | // Returns the HWID or an empty string on error. |
Alex Vakulenko | d0fdfb3 | 2014-02-21 15:26:26 -0800 | [diff] [blame] | 59 | virtual std::string GetHardwareClass() const = 0; |
J. Richard Barnette | 522d36f | 2013-10-28 17:22:12 -0700 | [diff] [blame] | 60 | |
| 61 | // Returns the firmware version or an empty string if the system is |
| 62 | // not running chrome os firmware. |
Alex Vakulenko | d0fdfb3 | 2014-02-21 15:26:26 -0800 | [diff] [blame] | 63 | virtual std::string GetFirmwareVersion() const = 0; |
J. Richard Barnette | 522d36f | 2013-10-28 17:22:12 -0700 | [diff] [blame] | 64 | |
| 65 | // Returns the ec version or an empty string if the system is not |
| 66 | // running a custom chrome os ec. |
Alex Vakulenko | d0fdfb3 | 2014-02-21 15:26:26 -0800 | [diff] [blame] | 67 | virtual std::string GetECVersion() const = 0; |
Alex Deymo | 4243291 | 2013-07-12 20:21:15 -0700 | [diff] [blame] | 68 | |
| 69 | virtual ~HardwareInterface() {} |
| 70 | }; |
| 71 | |
| 72 | } // namespace chromeos_update_engine |
| 73 | |
Gilad Arnold | cf175a0 | 2014-07-10 16:48:47 -0700 | [diff] [blame^] | 74 | #endif // UPDATE_ENGINE_HARDWARE_INTERFACE_H_ |