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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « boot_mode_unittest.cc ('k') | bootloader_type.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bootloader_type.h
diff --git a/bootloader_type.h b/bootloader_type.h
new file mode 100644
index 0000000000000000000000000000000000000000..0a3fd8db1544c29810ce823eb1500674c406084a
--- /dev/null
+++ b/bootloader_type.h
@@ -0,0 +1,64 @@
+// 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.
+//
+// Defines the BootloaderType class. This class wraps the kernel commandline
+// to determine the bootloader type. Our bootloaders are configured to boot
+// with identifying kernel command lines:
+// - EFI uses cros_efi
+// - Legacy uses cros_legacy
+// - Chrome OS uses cros_secure
+// - A debug override can use cros_debug.
+// This done by walking /proc/cmdline.
+//
+#ifndef CROS_BOOT_MODE_BOOTLOADER_TYPE_H_
+#define CROS_BOOT_MODE_BOOTLOADER_TYPE_H_
+
+#include <sys/types.h>
+
+#include "platform_reader.h"
+
+namespace cros_boot_mode {
+
+class BootloaderType : public PlatformReader {
+ public:
+ static const char *kBootloaderTypePath;
+ enum {
+ kChromeOS = 0,
+ kEFI,
+ kLegacy,
+ kDebug,
+ };
+ // API-exposed names
+ static const char *kBootloaderTypeText[];
+ static const size_t kBootloaderTypeCount;
+ // Maximum allowed /proc/cmdline size.
+ static const int kMaxKernelCmdlineSize;
+ // Functional names found in /proc/cmdline.
+ static const char *kSupportedBootloaders[];
+
+
+ BootloaderType();
+ virtual ~BootloaderType();
+
+ // Process walks over the /proc/cmdline and converts it to the enum
+ // above. The conversion is done by finding the first match in
+ // kSupportedBootloaders and then emits the enum that corresponds to
+ // the matching array index (or kUnsupported).
+ virtual int Process(const char *contents, size_t length);
+ virtual const char *name() const {
+ return "bootloader_type";
+ }
+ virtual const char *c_str() const {
+ return (value() >= 0 ? kBootloaderTypeText[value()] : "unsupported");
+ }
+ virtual const char *default_platform_file_path() const {
+ return "/proc/cmdline";
+ }
+ virtual size_t max_size() const {
+ return kMaxKernelCmdlineSize;
+ }
+};
+
+} // namespace cros_boot_mode
+#endif // CROS_BOOT_MODE_BOOTLOADER_TYPE_H_
« 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