From 8ae67affddec6a2bafc4c3a8714180f356b4ca73 Mon Sep 17 00:00:00 2001 From: David Keitel Date: Tue, 26 Mar 2013 18:50:03 -0700 Subject: [PATCH] sysctl: add cold_boot sysctl entry Add a cold_boot parameter which supplements the boot_reason sysctl entry with information about whether the system was booted from cold or warm state. /proc/sys/kernel/cold_boot entry is updated with 1 or 0 when system was booted from cold or warm boot state respecitively. CRs-Fixed: 461256 Change-Id: I2bc5d80c8f26eb9e9dbb4b34960d991a51a224e4 Signed-off-by: David Keitel --- Documentation/sysctl/kernel.txt | 11 +++++++++++ arch/arm/include/asm/processor.h | 1 + arch/arm/kernel/setup.c | 3 +++ include/linux/sysctl.h | 1 + kernel/sysctl.c | 10 +++++++++- kernel/sysctl_binary.c | 1 + 6 files changed, 26 insertions(+), 1 deletion(-) diff --git a/Documentation/sysctl/kernel.txt b/Documentation/sysctl/kernel.txt index a419f5e3143..8a20b4786e8 100644 --- a/Documentation/sysctl/kernel.txt +++ b/Documentation/sysctl/kernel.txt @@ -26,6 +26,7 @@ show up in /proc/sys/kernel: - boot_reason [ ARM only ] - callhome [ S390 only ] - cap_last_cap +- cold_boot [ ARM only ] - core_pattern - core_pipe_limit - core_uses_pid @@ -176,6 +177,16 @@ cap_last_cap Highest valid capability of the running kernel. Exports CAP_LAST_CAP from the kernel. +=============================================================== + +cold_boot + +ARM -- indicator for system cold boot + +A single bit will be set in the unsigned integer value to identify +whether the device was booted from a cold or warm state. Zero +indicating a warm boot and one indicating a cold boot. + ============================================================== core_pattern: diff --git a/arch/arm/include/asm/processor.h b/arch/arm/include/asm/processor.h index 07209d7538b..3a2cd22504e 100644 --- a/arch/arm/include/asm/processor.h +++ b/arch/arm/include/asm/processor.h @@ -30,6 +30,7 @@ #endif extern unsigned int boot_reason; +extern unsigned int cold_boot; struct debug_info { #ifdef CONFIG_HAVE_HW_BREAKPOINT diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index 28b114fc406..7298f9ae694 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -107,6 +107,9 @@ EXPORT_SYMBOL(elf_hwcap); unsigned int boot_reason; EXPORT_SYMBOL(boot_reason); +unsigned int cold_boot; +EXPORT_SYMBOL(cold_boot); + #ifdef MULTI_CPU struct processor processor __read_mostly; #endif diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h index 84c59dc43e4..d950b5c9dd0 100644 --- a/include/linux/sysctl.h +++ b/include/linux/sysctl.h @@ -154,6 +154,7 @@ enum KERN_NMI_WATCHDOG=75, /* int: enable/disable nmi watchdog */ KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */ KERN_BOOT_REASON = 77, /* int: identify reason system was booted */ + KERN_COLD_BOOT = 78, /* int: identify if system cold booted */ }; diff --git a/kernel/sysctl.c b/kernel/sysctl.c index b390dadc52c..d16a59ec644 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -1009,7 +1009,15 @@ static struct ctl_table kern_table[] = { .maxlen = sizeof(int), .mode = 0444, .proc_handler = proc_dointvec, -}, + }, + + { + .procname = "cold_boot", + .data = &cold_boot, + .maxlen = sizeof(int), + .mode = 0444, + .proc_handler = proc_dointvec, + }, #endif /* * NOTE: do not add new entries to this table unless you have read diff --git a/kernel/sysctl_binary.c b/kernel/sysctl_binary.c index acb60bef99f..6170f456096 100644 --- a/kernel/sysctl_binary.c +++ b/kernel/sysctl_binary.c @@ -138,6 +138,7 @@ static const struct bin_table bin_kern_table[] = { { CTL_INT, KERN_MAX_LOCK_DEPTH, "max_lock_depth" }, { CTL_INT, KERN_PANIC_ON_NMI, "panic_on_unrecovered_nmi" }, { CTL_INT, KERN_BOOT_REASON, "boot_reason" }, + { CTL_INT, KERN_COLD_BOOT, "cold_boot" }, {} };