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

Side by Side Diff: bootloader_type.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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « boot_mode_unittest.cc ('k') | bootloader_type.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 // Defines the BootloaderType class. This class wraps the kernel commandline
6 // to determine the bootloader type. Our bootloaders are configured to boot
7 // with identifying kernel command lines:
8 // - EFI uses cros_efi
9 // - Legacy uses cros_legacy
10 // - Chrome OS uses cros_secure
11 // - A debug override can use cros_debug.
12 // This done by walking /proc/cmdline.
13 //
14 #ifndef CROS_BOOT_MODE_BOOTLOADER_TYPE_H_
15 #define CROS_BOOT_MODE_BOOTLOADER_TYPE_H_
16
17 #include <sys/types.h>
18
19 #include "platform_reader.h"
20
21 namespace cros_boot_mode {
22
23 class BootloaderType : public PlatformReader {
24 public:
25 static const char *kBootloaderTypePath;
26 enum {
27 kChromeOS = 0,
28 kEFI,
29 kLegacy,
30 kDebug,
31 };
32 // API-exposed names
33 static const char *kBootloaderTypeText[];
34 static const size_t kBootloaderTypeCount;
35 // Maximum allowed /proc/cmdline size.
36 static const int kMaxKernelCmdlineSize;
37 // Functional names found in /proc/cmdline.
38 static const char *kSupportedBootloaders[];
39
40
41 BootloaderType();
42 virtual ~BootloaderType();
43
44 // Process walks over the /proc/cmdline and converts it to the enum
45 // above. The conversion is done by finding the first match in
46 // kSupportedBootloaders and then emits the enum that corresponds to
47 // the matching array index (or kUnsupported).
48 virtual int Process(const char *contents, size_t length);
49 virtual const char *name() const {
50 return "bootloader_type";
51 }
52 virtual const char *c_str() const {
53 return (value() >= 0 ? kBootloaderTypeText[value()] : "unsupported");
54 }
55 virtual const char *default_platform_file_path() const {
56 return "/proc/cmdline";
57 }
58 virtual size_t max_size() const {
59 return kMaxKernelCmdlineSize;
60 }
61 };
62
63 } // namespace cros_boot_mode
64 #endif // CROS_BOOT_MODE_BOOTLOADER_TYPE_H_
OLDNEW
« no previous file with comments | « boot_mode_unittest.cc ('k') | bootloader_type.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698