From: Andrey Smirnov <andrew.smirnov@gmail.com>
To: barebox@lists.infradead.org
Cc: Andrey Smirnov <andrew.smirnov@gmail.com>
Subject: [PATCH 06/10] common: pbl: Allow boards to override hang()
Date: Wed, 13 May 2015 19:54:23 -0700 [thread overview]
Message-ID: <1431572067-4038-6-git-send-email-andrew.smirnov@gmail.com> (raw)
In-Reply-To: <1431572067-4038-1-git-send-email-andrew.smirnov@gmail.com>
Add provisions such that board code can re-define the behaviour of
hang() to implement a behaviour better suited for a particular
hardware platform.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
common/startup.c | 15 ++++++++++++++-
include/common.h | 22 ++++++++++++++++++++++
pbl/misc.c | 19 ++++++++++++++++++-
3 files changed, 54 insertions(+), 2 deletions(-)
diff --git a/common/startup.c b/common/startup.c
index e59b06d..d701fab 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -118,12 +118,25 @@ void __noreturn start_barebox(void)
/* NOTREACHED - no way out of command loop except booting */
}
-void __noreturn hang (void)
+void __noreturn __hang (void)
{
puts ("### ERROR ### Please RESET the board ###\n");
for (;;);
}
+static hang_handler_t hang_handler = __hang;
+
+void __noreturn hang(void)
+{
+ hang_handler();
+}
+
+void set_hang_handler(hang_handler_t handler)
+{
+ hang_handler = handler;
+}
+
+
void (*board_shutdown)(void);
/* Everything needed to cleanly shutdown barebox.
diff --git a/include/common.h b/include/common.h
index eef371c..86e755d 100644
--- a/include/common.h
+++ b/include/common.h
@@ -56,7 +56,11 @@
*/
void reginfo(void);
+typedef void __noreturn (*hang_handler_t)(void);
+
void __noreturn hang (void);
+void __noreturn __hang (void);
+void set_hang_handler(hang_handler_t handler);
char *size_human_readable(unsigned long long size);
@@ -193,6 +197,24 @@ void barebox_set_hostname(const char *);
#define IOMEM(addr) ((void __force __iomem *)(addr))
#endif
+#if defined(CONFIG_ARM)
+#include <asm/barebox-arm.h>
+
+static inline void *get_true_address(const void *ptr)
+{
+ resource_size_t address = (resource_size_t)ptr;
+
+ address -= get_runtime_offset();
+
+ return (void *)address;
+}
+#else
+static inline void *get_true_address(const void *ptr)
+{
+ return (void *)ptr;
+}
+#endif
+
/*
* Check if two regions overlap. returns true if they do, false otherwise
*/
diff --git a/pbl/misc.c b/pbl/misc.c
index 7e76120..3d5a881 100644
--- a/pbl/misc.c
+++ b/pbl/misc.c
@@ -4,11 +4,28 @@
#include <linux/string.h>
#include <linux/ctype.h>
-void __noreturn hang(void)
+void __noreturn __hang(void)
{
while (1);
}
+static hang_handler_t hang_handler = __hang;
+
+void __noreturn hang(void)
+{
+ hang_handler_t *__hand_handler_p = get_true_address(&hang_handler);
+ hang_handler_t __hang_handler = get_true_address(*__hand_handler_p);
+
+ __hang_handler();
+}
+
+void set_hang_handler(hang_handler_t handler)
+{
+ hang_handler_t *__hang_handler_p = get_true_address(&hang_handler);
+
+ *__hang_handler_p = handler;
+}
+
void __noreturn panic(const char *fmt, ...)
{
while(1);
--
2.1.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2015-05-14 2:55 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-14 2:54 [PATCH 01/10] common/memtest.c: Fix incorrect array boundary check Andrey Smirnov
2015-05-14 2:54 ` [PATCH 02/10] common/memtest.c: Do not omit offset of 0 from tests Andrey Smirnov
2015-05-14 2:54 ` [PATCH 03/10] common/memtest.c: Refactor mem_test() into three surbroutines Andrey Smirnov
2015-05-14 2:54 ` [PATCH 04/10] common/memtest.c: Distil common error reporting code Andrey Smirnov
2015-05-14 2:54 ` [PATCH 05/10] serial: i.MX: Write settings to a correct register Andrey Smirnov
2015-05-14 2:54 ` Andrey Smirnov [this message]
2015-05-15 5:25 ` [PATCH 06/10] common: pbl: Allow boards to override hang() Sascha Hauer
2015-05-23 18:13 ` Andrey Smirnov
2015-05-14 2:54 ` [PATCH 07/10] debug_ll: i.MX: Add support for input to DEBUG_LL Andrey Smirnov
2015-05-14 2:54 ` [PATCH 08/10] i.MX51: babbage: Add UART RXD pin configuration Andrey Smirnov
2015-05-14 2:54 ` [PATCH 09/10] pbl: Implement ctrlc() using getc_ll() Andrey Smirnov
2015-05-14 2:54 ` [PATCH 10/10] ARM: pbl: Add an option to validate DRAM Andrey Smirnov
2015-05-19 7:06 ` Sascha Hauer
2015-05-23 18:48 ` Andrey Smirnov
2015-05-23 20:44 ` Alexander Aring
2015-05-24 18:39 ` Andrey Smirnov
2015-05-26 6:57 ` Sascha Hauer
2015-06-01 13:09 ` Andrey Smirnov
2015-06-03 8:10 ` Sascha Hauer
2015-05-15 5:33 ` [PATCH 01/10] common/memtest.c: Fix incorrect array boundary check Sascha Hauer
2015-05-23 18:20 ` Andrey Smirnov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1431572067-4038-6-git-send-email-andrew.smirnov@gmail.com \
--to=andrew.smirnov@gmail.com \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox