Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Unified Diff: platform_switch.h

Issue 3530001: first cut: establishes base helper classes and main (Closed) Base URL: http://git.chromium.org/git/cros_boot_mode.git
Patch Set: truncation is bad, m'kay. . . Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « platform_reader.cc ('k') | platform_switch.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: platform_switch.h
diff --git a/platform_switch.h b/platform_switch.h
new file mode 100644
index 0000000000000000000000000000000000000000..b749a6b5c0752b4ab3612d9fbc29e6bb2fedd8ea
--- /dev/null
+++ b/platform_switch.h
@@ -0,0 +1,42 @@
+// Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+// Provides a default implementation of a platform switch. On CrOS, switch
+// state is represented in an integer exposed via a file in /sys. Each
+// switch recieves one bit which is checked with a subclass-defined
+// bitmask().
+//
+// A subclass only needs to set its name and bitmask to "just work".
+
+#ifndef CROS_BOOT_MODE_PLATFORM_SWITCH_H_
+#define CROS_BOOT_MODE_PLATFORM_SWITCH_H_
+
+#include "platform_reader.h"
+
+namespace cros_boot_mode {
+
+class PlatformSwitch : public PlatformReader {
+ public:
+ PlatformSwitch();
+ virtual ~PlatformSwitch();
+
+ enum { kDisabled, kEnabled };
+ static const char *kPositionText[];
+
+ virtual const char *c_str() const;
+ virtual const char *default_platform_file_path() const {
+ return "/sys/devices/platform/chromeos_acpi/CHSW";
+ }
+ virtual size_t max_size() const {
+ return sizeof("65535"); // largest allowed switch value
+ }
+ virtual int Process(const char *file_contents, size_t length);
+
+ // To be overriden by the implementation
+ virtual unsigned int bitmask() const = 0;
+ virtual const char *name() const = 0;
+};
+
+} // namespace cros_boot_mode
+#endif // CROS_BOOT_MODE_PLATFORM_SWITCH_H_
« no previous file with comments | « platform_reader.cc ('k') | platform_switch.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698