| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // BootloaderType implementation | 5 // BootloaderType implementation |
| 6 | 6 |
| 7 #include <stdio.h> | 7 #include <stdio.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 #include <sys/types.h> | 9 #include <sys/types.h> |
| 10 | 10 |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "bootloader_type.h" | 13 #include "bootloader_type.h" |
| 14 | 14 |
| 15 namespace cros_boot_mode { | 15 namespace cros_boot_mode { |
| 16 | 16 |
| 17 const char *BootloaderType::kBootloaderTypeText[] = { | 17 const char *BootloaderType::kBootloaderTypeText[] = { |
| 18 "debug", // cros_debug (cros_fw with developer override) |
| 18 "chromeos", // cros_fw (any platform) | 19 "chromeos", // cros_fw (any platform) |
| 19 "efi", // cros_efi | 20 "efi", // cros_efi |
| 20 "legacy", // cros_legacy | 21 "legacy", // cros_legacy |
| 21 "debug", // cros_debug (cros_fw with developer override) | |
| 22 }; | 22 }; |
| 23 const size_t BootloaderType::kBootloaderTypeCount = | 23 const size_t BootloaderType::kBootloaderTypeCount = |
| 24 sizeof(kBootloaderTypeText) / sizeof(*kBootloaderTypeText); | 24 sizeof(kBootloaderTypeText) / sizeof(*kBootloaderTypeText); |
| 25 // These values are expected to be found in the kernel commandline with space | 25 // These values are expected to be found in the kernel commandline with space |
| 26 // or '\0' word boundaries. The ordering of this array must correspond to | 26 // or '\0' word boundaries. The ordering of this array must correspond to |
| 27 // the array above and the defined enum. | 27 // the array above and the defined enum. |
| 28 const char *BootloaderType::kSupportedBootloaders[] = { | 28 const char *BootloaderType::kSupportedBootloaders[] = { |
| 29 "cros_debug", |
| 29 "cros_secure", | 30 "cros_secure", |
| 30 "cros_efi", | 31 "cros_efi", |
| 31 "cros_legacy", | 32 "cros_legacy", |
| 32 "cros_debug", | |
| 33 }; | 33 }; |
| 34 | 34 |
| 35 const int BootloaderType::kMaxKernelCmdlineSize = 4096; // one page. | 35 const int BootloaderType::kMaxKernelCmdlineSize = 4096; // one page. |
| 36 | 36 |
| 37 BootloaderType::BootloaderType() { } | 37 BootloaderType::BootloaderType() { } |
| 38 BootloaderType::~BootloaderType() { } | 38 BootloaderType::~BootloaderType() { } |
| 39 | 39 |
| 40 // This function looks for given argument space or nul delimited in | 40 // This function looks for given argument space or nul delimited in |
| 41 // a /proc/cmdline style char array. See bootloader_type.h for details. | 41 // a /proc/cmdline style char array. See bootloader_type.h for details. |
| 42 int BootloaderType::Process(const char *contents, size_t length) { | 42 int BootloaderType::Process(const char *contents, size_t length) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 53 if ((*end == kTerminal || *end == kDelimiter) && | 53 if ((*end == kTerminal || *end == kDelimiter) && |
| 54 (start == contents || *(start - 1) == kDelimiter)) | 54 (start == contents || *(start - 1) == kDelimiter)) |
| 55 return i; | 55 return i; |
| 56 start = strstr(end, candidate); | 56 start = strstr(end, candidate); |
| 57 } | 57 } |
| 58 } | 58 } |
| 59 return kUnsupported; | 59 return kUnsupported; |
| 60 } | 60 } |
| 61 | 61 |
| 62 } // namespace cros_boot_mode | 62 } // namespace cros_boot_mode |
| OLD | NEW |