[Skiboot] [PATCH 1/4] Move FSP specific abort() code to platform layer
Vasant Hegde
hegdevasant at linux.vnet.ibm.com
Thu Aug 20 17:03:31 AEST 2015
Presently abort() call sets up HID0, triggers attention and finally
calls infinite for loop. FSP takes care of collecting required logs
and reboots the system. This sequence is specific to FSP machine
and it will not work on BMC based machine. Hence move FSP specific
code to hw/fsp/fsp-attn.c.
Note that this patch adds new parameter to abort call. Hence changed
_abort() to abort() in exception.c
Signed-off-by: Vasant Hegde <hegdevasant at linux.vnet.ibm.com>
---
core/exceptions.c | 2 +-
core/utils.c | 18 +++---------------
hw/fsp/fsp-attn.c | 26 +++++++++++++++++++++++++-
include/fsp.h | 3 +++
libc/include/assert.h | 5 -----
libc/include/stdlib.h | 10 +++++-----
6 files changed, 37 insertions(+), 27 deletions(-)
diff --git a/core/exceptions.c b/core/exceptions.c
index aa472a6..c4acf85 100644
--- a/core/exceptions.c
+++ b/core/exceptions.c
@@ -45,7 +45,7 @@ void exception_entry(struct stack_frame *stack)
prerror("***********************************************\n");
prerror("Unexpected exception %llx !\n", stack->type);
dump_regs(stack);
- _abort();
+ abort();
}
static int64_t opal_register_exc_handler(uint64_t opal_exception __unused,
diff --git a/core/utils.c b/core/utils.c
index f340b4f..df9a815 100644
--- a/core/utils.c
+++ b/core/utils.c
@@ -26,34 +26,22 @@ unsigned long __stack_chk_guard = 0xdeadf00dbaad300d;
void __noreturn assert_fail(const char *msg)
{
prlog(PR_EMERG, "Assert fail: %s\n", msg);
- _abort();
+ _abort(msg);
}
-void __noreturn _abort(void)
+void __noreturn _abort(const char *msg)
{
static bool in_abort = false;
- unsigned long hid0;
if (in_abort)
for (;;) ;
in_abort = true;
- op_display(OP_FATAL, OP_MOD_CORE, 0x6666);
-
prlog(PR_EMERG, "Aborting!\n");
backtrace();
- /* XXX FIXME: We should fsp_poll for a while to ensure any pending
- * console writes have made it out, but until we have decent PSI
- * link handling we must not do it forever. Polling can prevent the
- * FSP from bringing the PSI link up and it can get stuck in a
- * reboot loop.
- */
+ ibm_fsp_terminate(msg);
- hid0 = mfspr(SPR_HID0);
- hid0 |= SPR_HID0_ENABLE_ATTN;
- set_hid0(hid0);
- trigger_attn();
for (;;) ;
}
diff --git a/hw/fsp/fsp-attn.c b/hw/fsp/fsp-attn.c
index 71de780..8a2ec92 100644
--- a/hw/fsp/fsp-attn.c
+++ b/hw/fsp/fsp-attn.c
@@ -88,7 +88,7 @@ static void init_sp_attn_area(void)
/* Updates src in sp attention area
*/
-void update_sp_attn_area(const char *msg)
+static void update_sp_attn_area(const char *msg)
{
#define STACK_BUF_ENTRIES 20
struct bt_entry bt_buf[STACK_BUF_ENTRIES];
@@ -116,6 +116,30 @@ void update_sp_attn_area(const char *msg)
strlen(ti_attn->msg.file_info);
}
+void __attribute__((noreturn)) ibm_fsp_terminate(const char *msg)
+{
+ unsigned long hid0;
+
+ /* Update SP attention area */
+ update_sp_attn_area(msg);
+
+ /* Update op panel op_display */
+ op_display(OP_FATAL, OP_MOD_CORE, 0x6666);
+
+ /* XXX FIXME: We should fsp_poll for a while to ensure any pending
+ * console writes have made it out, but until we have decent PSI
+ * link handling we must not do it forever. Polling can prevent the
+ * FSP from bringing the PSI link up and it can get stuck in a
+ * reboot loop.
+ */
+
+ hid0 = mfspr(SPR_HID0);
+ hid0 |= SPR_HID0_ENABLE_ATTN;
+ set_hid0(hid0);
+ trigger_attn();
+ for (;;) ;
+}
+
/* Intialises SP attention area */
void fsp_attn_init(void)
{
diff --git a/include/fsp.h b/include/fsp.h
index 0291084..4e247cc 100644
--- a/include/fsp.h
+++ b/include/fsp.h
@@ -827,4 +827,7 @@ extern void fsp_dpo_init(void);
/* Chiptod */
extern void fsp_chiptod_init(void);
+/* Terminate immediate */
+extern void __attribute__((noreturn)) ibm_fsp_terminate(const char *msg);
+
#endif /* __FSP_H */
diff --git a/libc/include/assert.h b/libc/include/assert.h
index 68f01ab..2c49fd7 100644
--- a/libc/include/assert.h
+++ b/libc/include/assert.h
@@ -13,13 +13,8 @@
#ifndef _ASSERT_H
#define _ASSERT_H
-extern void update_sp_attn_area(const char *msg);
-
#define assert(cond) \
do { if (!(cond)) { \
- update_sp_attn_area(__FILE__ \
- ":" stringify(__LINE__) \
- ":" stringify(cond)); \
assert_fail(__FILE__ \
":" stringify(__LINE__) \
":" stringify(cond)); } \
diff --git a/libc/include/stdlib.h b/libc/include/stdlib.h
index 68ca386..a0feb03 100644
--- a/libc/include/stdlib.h
+++ b/libc/include/stdlib.h
@@ -25,11 +25,11 @@ unsigned long int strtoul(const char *nptr, char **endptr, int base);
long int strtol(const char *nptr, char **endptr, int base);
int rand(void);
-void __attribute__((noreturn)) _abort(void);
-#define abort() do { \
- update_sp_attn_area("abort():" __FILE__ \
- ":" stringify(__LINE__)); \
- _abort(); \
+void __attribute__((noreturn)) _abort(const char *msg);
+#define abort() do { \
+ _abort("abort():" __FILE__ \
+ ":" stringify(__LINE__) \
+ ":" stringify(cond)); \
} while(0)
--
2.1.0
More information about the Skiboot
mailing list