blob: f55d7008133091cb578d0e10e0a48a2bb6275fc6 [file] [log] [blame]
Alex Deymo42432912013-07-12 20:21:15 -07001// 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>
Alex Vakulenko59e253e2014-02-24 10:40:21 -08009#include <vector>
Alex Deymo42432912013-07-12 20:21:15 -070010
11namespace chromeos_update_engine {
12
13// The hardware interface allows access to the following parts of the system,
14// closely related to the hardware:
15// * crossystem exposed properties: firmware, hwid, etc.
16// * Physical disk: partition booted from and partition name conversions.
17// These stateless functions are tied together in this interface to facilitate
18// unit testing.
19class HardwareInterface {
20 public:
Don Garrett83692e42013-11-08 10:11:30 -080021 // Returns the currently booted kernel partition. "/dev/sda2", for example.
Alex Vakulenkod0fdfb32014-02-21 15:26:26 -080022 virtual std::string BootKernelDevice() const = 0;
Don Garrett83692e42013-11-08 10:11:30 -080023
24 // Returns the currently booted rootfs partition. "/dev/sda3", for example.
Alex Vakulenkod0fdfb32014-02-21 15:26:26 -080025 virtual std::string BootDevice() const = 0;
Alex Deymo42432912013-07-12 20:21:15 -070026
Alex Vakulenko59e253e2014-02-24 10:40:21 -080027 // Returns a list of all kernel partitions available (whether bootable or not)
Alex Vakulenkod0fdfb32014-02-21 15:26:26 -080028 virtual std::vector<std::string> GetKernelDevices() const = 0;
Alex Vakulenko59e253e2014-02-24 10:40:21 -080029
Don Garrett83692e42013-11-08 10:11:30 -080030 // Is the specified kernel partition currently bootable, based on GPT flags?
31 // Returns success.
32 virtual bool IsKernelBootable(const std::string& kernel_device,
Alex Vakulenkod0fdfb32014-02-21 15:26:26 -080033 bool* bootable) const = 0;
Don Garrett83692e42013-11-08 10:11:30 -080034
35 // Mark the specified kernel partition unbootable in GPT flags. We mark
36 // the other kernel as bootable inside postinst, not inside the UE.
37 // Returns success.
38 virtual bool MarkKernelUnbootable(const std::string& kernel_device) = 0;
39
J. Richard Barnette056b0ab2013-10-29 15:24:56 -070040 // Returns true if this is an official Chrome OS build, false otherwise.
Alex Vakulenkod0fdfb32014-02-21 15:26:26 -080041 virtual bool IsOfficialBuild() const = 0;
J. Richard Barnette056b0ab2013-10-29 15:24:56 -070042
43 // Returns true if the boot mode is normal or if it's unable to
44 // determine the boot mode. Returns false if the boot mode is
45 // developer.
Alex Vakulenkod0fdfb32014-02-21 15:26:26 -080046 virtual bool IsNormalBootMode() const = 0;
J. Richard Barnette522d36f2013-10-28 17:22:12 -070047
48 // Returns the HWID or an empty string on error.
Alex Vakulenkod0fdfb32014-02-21 15:26:26 -080049 virtual std::string GetHardwareClass() const = 0;
J. Richard Barnette522d36f2013-10-28 17:22:12 -070050
51 // Returns the firmware version or an empty string if the system is
52 // not running chrome os firmware.
Alex Vakulenkod0fdfb32014-02-21 15:26:26 -080053 virtual std::string GetFirmwareVersion() const = 0;
J. Richard Barnette522d36f2013-10-28 17:22:12 -070054
55 // Returns the ec version or an empty string if the system is not
56 // running a custom chrome os ec.
Alex Vakulenkod0fdfb32014-02-21 15:26:26 -080057 virtual std::string GetECVersion() const = 0;
Alex Deymo42432912013-07-12 20:21:15 -070058
59 virtual ~HardwareInterface() {}
60};
61
62} // namespace chromeos_update_engine
63
64#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_HARDWARE_INTERFACE_H__