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 // Implements PlatformSwitch by reading in the switch file (CHSW) and converting |
| 6 // its contents to an unsigned integer which is bitwise-ANDed with the |
| 7 // subclass-defined bitmask(). |
| 8 |
| 9 #include "platform_switch.h" |
| 10 |
| 11 #include "helpers.h" |
| 12 |
| 13 namespace cros_boot_mode { |
| 14 |
| 15 const char *PlatformSwitch::kPositionText[] = { "disabled", "enabled" }; |
| 16 |
| 17 PlatformSwitch::PlatformSwitch() { } |
| 18 PlatformSwitch::~PlatformSwitch() { } |
| 19 |
| 20 const char *PlatformSwitch::c_str() const { |
| 21 return (value() >= 0 ? kPositionText[value()] : "unsupported"); |
| 22 } |
| 23 |
| 24 int PlatformSwitch::Process(const char *file_contents, size_t length) { |
| 25 int read_int = helpers::to_int(file_contents, length); |
| 26 if (read_int < 0) |
| 27 return kUnsupported; |
| 28 unsigned int position = static_cast<unsigned int>(read_int); |
| 29 return !((position & bitmask()) == 0); |
| 30 } |
| 31 |
| 32 } // namespace cros_boot_mode |
OLD | NEW |