blob: 2c9c100963eed183eeee0fef36f91f2e2e5b69f2 [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
Gilad Arnoldcf175a02014-07-10 16:48:47 -07005#ifndef UPDATE_ENGINE_HARDWARE_INTERFACE_H_
6#define UPDATE_ENGINE_HARDWARE_INTERFACE_H_
Alex Deymo42432912013-07-12 20:21:15 -07007
8#include <string>
Alex Vakulenko59e253e2014-02-24 10:40:21 -08009#include <vector>
Alex Deymo42432912013-07-12 20:21:15 -070010
Alex Deymobccbc382014-04-03 13:38:55 -070011#include <base/time/time.h>
12
Alex Deymo42432912013-07-12 20:21:15 -070013namespace 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.
21class HardwareInterface {
22 public:
Don Garrett83692e42013-11-08 10:11:30 -080023 // Returns the currently booted kernel partition. "/dev/sda2", for example.
Alex Vakulenkod0fdfb32014-02-21 15:26:26 -080024 virtual std::string BootKernelDevice() const = 0;
Don Garrett83692e42013-11-08 10:11:30 -080025
26 // Returns the currently booted rootfs partition. "/dev/sda3", for example.
Alex Vakulenkod0fdfb32014-02-21 15:26:26 -080027 virtual std::string BootDevice() const = 0;
Alex Deymo42432912013-07-12 20:21:15 -070028
Alex Deymo5708ecd2014-04-29 19:44:50 -070029 // Return whether the BootDevice() is a removable device.
30 virtual bool IsBootDeviceRemovable() const = 0;
31
Alex Vakulenko59e253e2014-02-24 10:40:21 -080032 // Returns a list of all kernel partitions available (whether bootable or not)
Alex Vakulenkod0fdfb32014-02-21 15:26:26 -080033 virtual std::vector<std::string> GetKernelDevices() const = 0;
Alex Vakulenko59e253e2014-02-24 10:40:21 -080034
Don Garrett83692e42013-11-08 10:11:30 -080035 // Is the specified kernel partition currently bootable, based on GPT flags?
36 // Returns success.
37 virtual bool IsKernelBootable(const std::string& kernel_device,
Alex Vakulenkod0fdfb32014-02-21 15:26:26 -080038 bool* bootable) const = 0;
Don Garrett83692e42013-11-08 10:11:30 -080039
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 Barnette056b0ab2013-10-29 15:24:56 -070045 // Returns true if this is an official Chrome OS build, false otherwise.
Alex Vakulenkod0fdfb32014-02-21 15:26:26 -080046 virtual bool IsOfficialBuild() const = 0;
J. Richard Barnette056b0ab2013-10-29 15:24:56 -070047
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 Vakulenkod0fdfb32014-02-21 15:26:26 -080051 virtual bool IsNormalBootMode() const = 0;
J. Richard Barnette522d36f2013-10-28 17:22:12 -070052
Alex Deymobccbc382014-04-03 13:38:55 -070053 // 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 Barnette522d36f2013-10-28 17:22:12 -070058 // Returns the HWID or an empty string on error.
Alex Vakulenkod0fdfb32014-02-21 15:26:26 -080059 virtual std::string GetHardwareClass() const = 0;
J. Richard Barnette522d36f2013-10-28 17:22:12 -070060
61 // Returns the firmware version or an empty string if the system is
62 // not running chrome os firmware.
Alex Vakulenkod0fdfb32014-02-21 15:26:26 -080063 virtual std::string GetFirmwareVersion() const = 0;
J. Richard Barnette522d36f2013-10-28 17:22:12 -070064
65 // Returns the ec version or an empty string if the system is not
66 // running a custom chrome os ec.
Alex Vakulenkod0fdfb32014-02-21 15:26:26 -080067 virtual std::string GetECVersion() const = 0;
Alex Deymo42432912013-07-12 20:21:15 -070068
Alex Deymoebbe7ef2014-10-30 13:02:49 -070069 // Returns the powerwash_count from the stateful. If the file is not found
70 // or is invalid, returns -1. Brand new machines out of the factory or after
71 // recovery don't have this value set.
72 virtual int GetPowerwashCount() const = 0;
73
Alex Deymo42432912013-07-12 20:21:15 -070074 virtual ~HardwareInterface() {}
75};
76
77} // namespace chromeos_update_engine
78
Gilad Arnoldcf175a02014-07-10 16:48:47 -070079#endif // UPDATE_ENGINE_HARDWARE_INTERFACE_H_