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

Unified Diff: boot_mode.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 | « active_main_firmware.cc ('k') | boot_mode.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: boot_mode.h
diff --git a/boot_mode.h b/boot_mode.h
new file mode 100644
index 0000000000000000000000000000000000000000..dfd49782c647d3d0d67bceb30f2980cb0dc1b285
--- /dev/null
+++ b/boot_mode.h
@@ -0,0 +1,76 @@
+// 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.
+//
+// boot_mode uses BINF.0, BINF.1, and CHSW to provide a confident guess as
+// to the current boot state.
+#ifndef CROS_BOOT_MODE_BOOT_MODE_H_
+#define CROS_BOOT_MODE_BOOT_MODE_H_
+
+#include <stdio.h>
+
+#include "active_main_firmware.h"
+#include "bootloader_type.h"
+#include "developer_switch.h"
+
+namespace cros_boot_mode {
+
+class BootMode {
+ public:
+ BootMode();
+ virtual ~BootMode();
+
+ enum Mode {
+ kUnsupported = -1,
+ kNormal = 0,
+ kDeveloper,
+ // Recovery modes below this line.
+ kNormalRecovery,
+ kDeveloperRecovery,
+ };
+
+ // Initializes the class by reading from the platform-specific
+ // implementation. Even if something fails, the class will be in
+ // a valid state, but the system will appear to be unsupported.
+ virtual void Initialize(bool unsupported_is_developer, bool use_bootloader);
+ // Returns a string of [mode][space][modifier(s)]
+ virtual const char *mode_text() const {
+ return (mode() >= 0 ? kBootModeText[mode()] : "unsupported");
+ }
+ virtual Mode mode() const {
+ return mode_;
+ }
+ virtual bool recovery() const {
+ return (mode() >= kNormalRecovery);
+ }
+
+ // Overrides for swapping out dependencies
+ // Pointer ownership is not taken in any case.
+ virtual void set_developer_switch(DeveloperSwitch *ds);
+ virtual void set_active_main_firmware(ActiveMainFirmware *amf);
+ virtual void set_bootloader_type(BootloaderType *bt);
+ virtual const DeveloperSwitch *developer_switch() const {
+ return developer_switch_;
+ }
+ virtual const ActiveMainFirmware *active_main_firmware() const {
+ return active_main_firmware_;
+ }
+ virtual const BootloaderType *bootloader_type() const {
+ return bootloader_type_;
+ }
+
+ private:
+ static const char *kBootModeText[];
+ static const size_t kBootModeCount;
+ DeveloperSwitch default_developer_switch_;
+ ActiveMainFirmware default_active_main_firmware_;
+ BootloaderType default_bootloader_type_;
+ Mode mode_;
+ DeveloperSwitch *developer_switch_;
+ ActiveMainFirmware *active_main_firmware_;
+ BootloaderType *bootloader_type_;
+};
+
+} // namespace cros_boot_mode
+
+#endif // CROS_BOOT_MODE_BOOT_MODE_H_
« no previous file with comments | « active_main_firmware.cc ('k') | boot_mode.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698