OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 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 // Provides a default implementation of a platform switch. On CrOS, switch |
| 6 // state is represented in an integer exposed via a file in /sys. Each |
| 7 // switch recieves one bit which is checked with a subclass-defined |
| 8 // bitmask(). |
| 9 // |
| 10 // A subclass only needs to set its name and bitmask to "just work". |
| 11 |
| 12 #ifndef CROS_BOOT_MODE_PLATFORM_SWITCH_H_ |
| 13 #define CROS_BOOT_MODE_PLATFORM_SWITCH_H_ |
| 14 |
| 15 #include "platform_reader.h" |
| 16 |
| 17 namespace cros_boot_mode { |
| 18 |
| 19 class PlatformSwitch : public PlatformReader { |
| 20 public: |
| 21 PlatformSwitch(); |
| 22 virtual ~PlatformSwitch(); |
| 23 |
| 24 enum { kDisabled, kEnabled }; |
| 25 static const char *kPositionText[]; |
| 26 |
| 27 virtual const char *c_str() const; |
| 28 virtual const char *default_platform_file_path() const { |
| 29 return "/sys/devices/platform/chromeos_acpi/CHSW"; |
| 30 } |
| 31 virtual size_t max_size() const { |
| 32 return sizeof("65535"); // largest allowed switch value |
| 33 } |
| 34 virtual int Process(const char *file_contents, size_t length); |
| 35 |
| 36 // To be overriden by the implementation |
| 37 virtual unsigned int bitmask() const = 0; |
| 38 virtual const char *name() const = 0; |
| 39 }; |
| 40 |
| 41 } // namespace cros_boot_mode |
| 42 #endif // CROS_BOOT_MODE_PLATFORM_SWITCH_H_ |
OLD | NEW |