blob: 98773d95d03b5e8c16f68189cc8ad11eb1b25d13 [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>
9
10namespace 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.
18class HardwareInterface {
19 public:
20 // Returns the currently booted device. "/dev/sda3", for example.
21 // This will not interpret LABEL= or UUID=. You'll need to use findfs
22 // or something with equivalent funcionality to interpret those.
23 virtual const std::string BootDevice() = 0;
24
25 // Returns the kernel device associated with the given boot device,
26 // for example, this function returns "/dev/sda2" if |boot_device| is
27 // "/dev/sda3".
28 // To obtain the current booted kernel device, the suggested calling
29 // convention is KernelDeviceOfBootDevice(BootDevice()).
30 // This function works by doing string modification on |boot_device|.
31 // Returns empty string on failure.
32 virtual const std::string KernelDeviceOfBootDevice(
33 const std::string& boot_device) = 0;
34
35 // TODO(deymo): Move other hardware-dependant functions to this interface:
36 // GetECVersion, GetFirmwareVersion, GetHardwareClass, IsNormalBootMode and
37 // IsOfficialBuild.
38
39 virtual ~HardwareInterface() {}
40};
41
42} // namespace chromeos_update_engine
43
44#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_HARDWARE_INTERFACE_H__