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 | |
| 5 | #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_HARDWARE_INTERFACE_H__ |
| 6 | #define CHROMEOS_PLATFORM_UPDATE_ENGINE_HARDWARE_INTERFACE_H__ |
| 7 | |
| 8 | #include <string> |
| 9 | |
| 10 | namespace chromeos_update_engine { |
| 11 | |
| 12 | // The hardware interface allows access to the following parts of the system, |
| 13 | // closely related to the hardware: |
| 14 | // * crossystem exposed properties: firmware, hwid, etc. |
| 15 | // * Physical disk: partition booted from and partition name conversions. |
| 16 | // These stateless functions are tied together in this interface to facilitate |
| 17 | // unit testing. |
| 18 | class HardwareInterface { |
| 19 | public: |
Don Garrett | 83692e4 | 2013-11-08 10:11:30 -0800 | [diff] [blame] | 20 | // Returns the currently booted kernel partition. "/dev/sda2", for example. |
| 21 | virtual const std::string BootKernelDevice() = 0; |
| 22 | |
| 23 | // Returns the currently booted rootfs partition. "/dev/sda3", for example. |
Alex Deymo | 4243291 | 2013-07-12 20:21:15 -0700 | [diff] [blame] | 24 | virtual const std::string BootDevice() = 0; |
| 25 | |
Don Garrett | 83692e4 | 2013-11-08 10:11:30 -0800 | [diff] [blame] | 26 | // Is the specified kernel partition currently bootable, based on GPT flags? |
| 27 | // Returns success. |
| 28 | virtual bool IsKernelBootable(const std::string& kernel_device, |
| 29 | bool* bootable) = 0; |
| 30 | |
| 31 | // Mark the specified kernel partition unbootable in GPT flags. We mark |
| 32 | // the other kernel as bootable inside postinst, not inside the UE. |
| 33 | // Returns success. |
| 34 | virtual bool MarkKernelUnbootable(const std::string& kernel_device) = 0; |
| 35 | |
J. Richard Barnette | 056b0ab | 2013-10-29 15:24:56 -0700 | [diff] [blame] | 36 | // Returns true if this is an official Chrome OS build, false otherwise. |
| 37 | virtual bool IsOfficialBuild() = 0; |
| 38 | |
| 39 | // Returns true if the boot mode is normal or if it's unable to |
| 40 | // determine the boot mode. Returns false if the boot mode is |
| 41 | // developer. |
| 42 | virtual bool IsNormalBootMode() = 0; |
J. Richard Barnette | 522d36f | 2013-10-28 17:22:12 -0700 | [diff] [blame] | 43 | |
| 44 | // Returns the HWID or an empty string on error. |
| 45 | virtual std::string GetHardwareClass() = 0; |
| 46 | |
| 47 | // Returns the firmware version or an empty string if the system is |
| 48 | // not running chrome os firmware. |
| 49 | virtual std::string GetFirmwareVersion() = 0; |
| 50 | |
| 51 | // Returns the ec version or an empty string if the system is not |
| 52 | // running a custom chrome os ec. |
| 53 | virtual std::string GetECVersion() = 0; |
Alex Deymo | 4243291 | 2013-07-12 20:21:15 -0700 | [diff] [blame] | 54 | |
| 55 | virtual ~HardwareInterface() {} |
| 56 | }; |
| 57 | |
| 58 | } // namespace chromeos_update_engine |
| 59 | |
| 60 | #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_HARDWARE_INTERFACE_H__ |