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 // boot_mode uses BINF.0, BINF.1, and CHSW to provide a confident guess as |
| 6 // to the current boot state. |
| 7 #ifndef CROS_BOOT_MODE_BOOT_MODE_H_ |
| 8 #define CROS_BOOT_MODE_BOOT_MODE_H_ |
| 9 |
| 10 #include <stdio.h> |
| 11 |
| 12 #include "active_main_firmware.h" |
| 13 #include "bootloader_type.h" |
| 14 #include "developer_switch.h" |
| 15 |
| 16 namespace cros_boot_mode { |
| 17 |
| 18 class BootMode { |
| 19 public: |
| 20 BootMode(); |
| 21 virtual ~BootMode(); |
| 22 |
| 23 enum Mode { |
| 24 kUnsupported = -1, |
| 25 kNormal = 0, |
| 26 kDeveloper, |
| 27 // Recovery modes below this line. |
| 28 kNormalRecovery, |
| 29 kDeveloperRecovery, |
| 30 }; |
| 31 |
| 32 // Initializes the class by reading from the platform-specific |
| 33 // implementation. Even if something fails, the class will be in |
| 34 // a valid state, but the system will appear to be unsupported. |
| 35 virtual void Initialize(bool unsupported_is_developer, bool use_bootloader); |
| 36 // Returns a string of [mode][space][modifier(s)] |
| 37 virtual const char *mode_text() const { |
| 38 return (mode() >= 0 ? kBootModeText[mode()] : "unsupported"); |
| 39 } |
| 40 virtual Mode mode() const { |
| 41 return mode_; |
| 42 } |
| 43 virtual bool recovery() const { |
| 44 return (mode() >= kNormalRecovery); |
| 45 } |
| 46 |
| 47 // Overrides for swapping out dependencies |
| 48 // Pointer ownership is not taken in any case. |
| 49 virtual void set_developer_switch(DeveloperSwitch *ds); |
| 50 virtual void set_active_main_firmware(ActiveMainFirmware *amf); |
| 51 virtual void set_bootloader_type(BootloaderType *bt); |
| 52 virtual const DeveloperSwitch *developer_switch() const { |
| 53 return developer_switch_; |
| 54 } |
| 55 virtual const ActiveMainFirmware *active_main_firmware() const { |
| 56 return active_main_firmware_; |
| 57 } |
| 58 virtual const BootloaderType *bootloader_type() const { |
| 59 return bootloader_type_; |
| 60 } |
| 61 |
| 62 private: |
| 63 static const char *kBootModeText[]; |
| 64 static const size_t kBootModeCount; |
| 65 DeveloperSwitch default_developer_switch_; |
| 66 ActiveMainFirmware default_active_main_firmware_; |
| 67 BootloaderType default_bootloader_type_; |
| 68 Mode mode_; |
| 69 DeveloperSwitch *developer_switch_; |
| 70 ActiveMainFirmware *active_main_firmware_; |
| 71 BootloaderType *bootloader_type_; |
| 72 }; |
| 73 |
| 74 } // namespace cros_boot_mode |
| 75 |
| 76 #endif // CROS_BOOT_MODE_BOOT_MODE_H_ |
OLD | NEW |