[coreboot-gerrit] New patch to review for coreboot: 63cb0de elog: Add function to log boot reason in ChromeOS case

Marc Jones (marc.jones@se-eng.com) gerrit at coreboot.org
Wed Dec 31 06:32:38 CET 2014


Marc Jones (marc.jones at se-eng.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/7991

-gerrit

commit 63cb0de241f9b7a88a2e4612bf3bd874cf0e9c96
Author: David Hendricks <dhendrix at chromium.org>
Date:   Tue May 13 20:28:49 2014 -0700

    elog: Add function to log boot reason in ChromeOS case
    
    This adds a generic helper function for adding boot reason in the
    ChromeOS case. If vboot is enabled, it will use information passed
    in via the vboot handoff table in cbmem to determine mode and
    reason in the case of recovery.
    
    BUG=chromium:373467
    BRANCH=nyan
    TEST=built along with follow-up CL and booted on Big under various
    modes, verified entry was added to eventlog with "mosys eventlog list"
    Signed-off-by: David Hendricks <dhendrix at chromium.org>
    
    Original-Change-Id: I50a7aa6d55eb46413fe9929e732d6eb18c758d4b
    Original-Reviewed-on: https://chromium-review.googlesource.com/199690
    Original-Reviewed-by: Duncan Laurie <dlaurie at chromium.org>
    Original-Commit-Queue: David Hendricks <dhendrix at chromium.org>
    Original-Tested-by: David Hendricks <dhendrix at chromium.org>
    (cherry picked from commit 961c0bd1dd5512b1c2feb2ed4391bf507900eb7a)
    Signed-off-by: Marc Jones <marc.jones at se-eng.com>
    
    Change-Id: I6ae4e2a891966d2d1de7d37dcc551383e94e4d75
---
 src/vendorcode/google/chromeos/Makefile.inc |  2 +-
 src/vendorcode/google/chromeos/chromeos.h   |  4 +++
 src/vendorcode/google/chromeos/elog.c       | 55 +++++++++++++++++++++++++++++
 3 files changed, 60 insertions(+), 1 deletion(-)

diff --git a/src/vendorcode/google/chromeos/Makefile.inc b/src/vendorcode/google/chromeos/Makefile.inc
index 678c4ee..e17f50c 100644
--- a/src/vendorcode/google/chromeos/Makefile.inc
+++ b/src/vendorcode/google/chromeos/Makefile.inc
@@ -22,7 +22,7 @@ ramstage-$(CONFIG_ARCH_RAMSTAGE_X86_32) += vbnv_cmos.c
 romstage-$(CONFIG_ARCH_ROMSTAGE_ARMV7) += vbnv_ec.c
 ramstage-$(CONFIG_ARCH_RAMSTAGE_ARMV7) += vbnv_ec.c
 romstage-$(CONFIG_ARCH_ROMSTAGE_X86_32) += vboot.c
-
+ramstage-$(CONFIG_ELOG) += elog.c
 ramstage-y += gnvs.c
 romstage-y += fmap.c
 ramstage-y += fmap.c
diff --git a/src/vendorcode/google/chromeos/chromeos.h b/src/vendorcode/google/chromeos/chromeos.h
index 9b2537d..a2ecac8 100644
--- a/src/vendorcode/google/chromeos/chromeos.h
+++ b/src/vendorcode/google/chromeos/chromeos.h
@@ -34,8 +34,12 @@ void save_vbnv(const uint8_t *vbnv_copy);
 #if CONFIG_CHROMEOS
 /* functions implemented in vboot.c */
 void init_chromeos(int bootmode);
+
+/* functions implemented in elog.c */
+void elog_add_boot_reason(void);
 #else
 static inline void init_chromeos(int bootmode) { }
+static inline void elog_add_boot_reason(void) { return; }
 #endif /* CONFIG_CHROMEOS */
 
 struct romstage_handoff;
diff --git a/src/vendorcode/google/chromeos/elog.c b/src/vendorcode/google/chromeos/elog.c
new file mode 100644
index 0000000..8bf9efc
--- /dev/null
+++ b/src/vendorcode/google/chromeos/elog.c
@@ -0,0 +1,55 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2014 The ChromiumOS Authors.  All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
+ */
+
+#include <cbmem.h>
+#include <console/console.h>
+#include <elog.h>
+#include <vendorcode/google/chromeos/chromeos.h>
+#if CONFIG_VBOOT_VERIFY_FIRMWARE
+#include "vboot_handoff.h"
+#include <vboot_struct.h>
+#endif
+
+void elog_add_boot_reason(void)
+{
+	if (developer_mode_enabled()) {
+		elog_add_event(ELOG_TYPE_CROS_DEVELOPER_MODE);
+		printk(BIOS_DEBUG, "%s: Logged dev mode boot\n", __func__);
+	} else if (recovery_mode_enabled()) {
+		u8 reason = 0;
+#if CONFIG_VBOOT_VERIFY_FIRMWARE
+		struct vboot_handoff *vbho = cbmem_find(CBMEM_ID_VBOOT_HANDOFF);
+
+		reason = get_recovery_mode_from_vbnv();
+		if (vbho && !reason) {
+			VbSharedDataHeader *sd = (VbSharedDataHeader *)
+				vbho->shared_data;
+			reason = sd->recovery_reason;
+		}
+#endif
+
+		elog_add_event_byte(ELOG_TYPE_CROS_RECOVERY_MODE,
+			reason ? reason : ELOG_CROS_RECOVERY_MODE_BUTTON);
+		printk(BIOS_DEBUG, "%s: Logged recovery mode boot, "
+				"reason: 0x%02x\n", __func__, reason);
+	} else {
+		printk(BIOS_DEBUG, "%s: Normal mode boot, nothing "
+					"interesting to log\n", __func__);
+	}
+}



More information about the coreboot-gerrit mailing list