[PATCH] OLPC XO-1.75 - an epitaph of kernel log buffer for CForth to read

James Cameron quozl at laptop.org
Tue Jan 24 20:54:32 EST 2012


Along with CForth commit 1a604a37e340da67419a1df5d840ee319090b619
provides a dump of the kernel log buffer on serial port after a
watchdog restart.  Intended for when the kernel serial driver is
disabled.

The kernel patch creates an aligned structure with pointers to the
kernel log buffer, and a pointer for calculating the offset from
virtual to physical addresses.

Harmless if used without the CForth change present.

Not intended for upstream.
---
 arch/arm/mach-mmp/olpc-xo-1-75.c |   19 +++++++++++++++++++
 include/linux/printk.h           |    5 +++++
 kernel/printk.c                  |    7 +++++++
 3 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-mmp/olpc-xo-1-75.c b/arch/arm/mach-mmp/olpc-xo-1-75.c
index e0db8a8..adb1f15 100644
--- a/arch/arm/mach-mmp/olpc-xo-1-75.c
+++ b/arch/arm/mach-mmp/olpc-xo-1-75.c
@@ -548,10 +548,29 @@ static void __init olpc_init_early(void)
 }
 extern struct olpc_platform_t olpc_platform_info;
 
+struct epitaph {
+	u32	magic_1;
+	u32	magic_2;
+	u32	myself;
+	u32	log_buf_len;
+	u32	log_buf;
+	u32	log_end;
+};
+
+static struct epitaph epitaph __attribute__((aligned(4096))) = {
+	.magic_1 = 0x2163666f,
+	.magic_2 = 0x72746821
+};
+
 static void __init olpc_xo_1_75_init(void)
 {
 	u32 twsi6_lcr;
 
+	log_buf_olpc_setup(&epitaph.log_buf_len,
+			   &epitaph.log_buf,
+			   &epitaph.log_end);
+	epitaph.myself = (u32) &epitaph;
+
 	pm_power_off = olpc_xo_1_75_poweroff;
 	arm_pm_restart = olpc_xo_1_75_restart;
 
diff --git a/include/linux/printk.h b/include/linux/printk.h
index 0101d55..795ed5a 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -115,6 +115,7 @@ extern int dmesg_restrict;
 extern int kptr_restrict;
 
 void log_buf_kexec_setup(void);
+void log_buf_olpc_setup(u32 *len, u32 *buf, u32 *end);
 void __init setup_log_buf(int early);
 #else
 static inline __attribute__ ((format (printf, 1, 0)))
@@ -141,6 +142,10 @@ static inline void log_buf_kexec_setup(void)
 {
 }
 
+static inline void log_buf_olpc_setup(u32 *len, u32 *buf, u32 *end)
+{
+}
+
 static inline void setup_log_buf(int early)
 {
 }
diff --git a/kernel/printk.c b/kernel/printk.c
index 084982f..4cc9c00 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -168,6 +168,13 @@ void log_buf_kexec_setup(void)
 }
 #endif
 
+void log_buf_olpc_setup(u32 *len, u32 *buf, u32 *end)
+{
+	*len = log_buf_len;
+	*buf = (u32) log_buf;
+	*end = (u32) &log_end;
+}
+
 /* requested log_buf_len from kernel cmdline */
 static unsigned long __initdata new_log_buf_len;
 
-- 
1.7.5.4


-- 
James Cameron
http://quozl.linux.org.au/



More information about the Devel mailing list