summaryrefslogtreecommitdiff
path: root/cesar
diff options
context:
space:
mode:
Diffstat (limited to 'cesar')
-rw-r--r--cesar/hal/arch/io.h3
-rw-r--r--cesar/hal/hle/src/ipmbox_debug_dump.c7
-rw-r--r--cesar/hal/hle/test/src/hal_hle_ipmbox.c13
-rw-r--r--cesar/lib/dbg.h3
-rw-r--r--cesar/lib/src/dbg.c6
5 files changed, 18 insertions, 14 deletions
diff --git a/cesar/hal/arch/io.h b/cesar/hal/arch/io.h
index 5e66f59b3a..be06d65647 100644
--- a/cesar/hal/arch/io.h
+++ b/cesar/hal/arch/io.h
@@ -79,7 +79,8 @@ arch_io_write (const char *text, uint text_size);
} while (0)
# define arch_io_write(text, text_size) do { \
- write (1, (text), (text_size)); \
+ if (text_size) \
+ write (1, (text), (text_size)); \
} while (0)
#endif /* !(defined (ECOS) && ECOS) */
diff --git a/cesar/hal/hle/src/ipmbox_debug_dump.c b/cesar/hal/hle/src/ipmbox_debug_dump.c
index 13ce329aa8..1a459c39e1 100644
--- a/cesar/hal/hle/src/ipmbox_debug_dump.c
+++ b/cesar/hal/hle/src/ipmbox_debug_dump.c
@@ -26,7 +26,7 @@
* Synchronous dump to ARM side.
* \param user user parameter (ipmbox context)
* \param text text buffer with text to write
- * \param text_size size of text to write
+ * \param text_size size of text to write, or 0 for end of dump
* \return sent size
*/
int
@@ -42,10 +42,11 @@ ipmbox_dump (void *user, const char *text, uint text_size)
u32 w;
uint wb;
int sent = text_size;
+ bool end_of_dump = text_size == 0;
ipmbox_t *ctx = user;
dbg_assert (ctx);
/** Loop until satisfied. */
- while (text_size)
+ while (text_size || end_of_dump)
{
/* Get mailbox content. */
msg_buffer = NULL;
@@ -91,6 +92,8 @@ ipmbox_dump (void *user, const char *text, uint text_size)
(PARAM_DEBUG_DUMP_LENGTH, dumped));
msg_tx[1] = m[1];
ipmbox_tx (ctx, msg_tx, 2);
+ /* Clear end_of_dump flag, it was sent. */
+ end_of_dump = false;
break;
default:
/* Ignore message. */
diff --git a/cesar/hal/hle/test/src/hal_hle_ipmbox.c b/cesar/hal/hle/test/src/hal_hle_ipmbox.c
index 82532f20db..5073425ee1 100644
--- a/cesar/hal/hle/test/src/hal_hle_ipmbox.c
+++ b/cesar/hal/hle/test/src/hal_hle_ipmbox.c
@@ -365,14 +365,6 @@ test_ipmbox_debug_dump (void)
utest_L2A_tail = utest_L2A_head;
i = 0;
n = 0;
- /* Nothing to dump. */
- test_begin (test, "nothing")
- {
- /* Dump. */
- ipmbox_dump (ctx, "", 0);
- /* Check result. */
- test_fail_unless (utest_L2A_tail - utest_L2A_head == 0);
- } test_end;
/* Various sizes. */
test_begin (test, "1 char")
{
@@ -405,6 +397,11 @@ test_ipmbox_debug_dump (void)
test_ipmbox_debug_dump_step (test, &i, &n, "0123456789abcdefg",
"0123456789abcdef", "g");
} test_end;
+ /* End of dump. */
+ test_begin (test, "end of dump")
+ {
+ test_ipmbox_debug_dump_step (test, &i, &n, "", "", NULL);
+ } test_end;
}
int main (int argc, char **argv)
diff --git a/cesar/lib/dbg.h b/cesar/lib/dbg.h
index 852b28479c..cc55b7f5a6 100644
--- a/cesar/lib/dbg.h
+++ b/cesar/lib/dbg.h
@@ -396,7 +396,8 @@ extern char dbg_fatal_text_[];
* Callback for debug dump.
* \param user user parameter
* \param text text buffer with text to write
- * \param text_size size of text to write, i.e. number of characters
+ * \param text_size size of text to write, i.e. number of characters, or 0
+ * for end of dump
* \return should return size, any other value will stop dump
*/
typedef int (*dbg_dump_callback_t) (void *user, const char *text,
diff --git a/cesar/lib/src/dbg.c b/cesar/lib/src/dbg.c
index 229151d406..32d560df70 100644
--- a/cesar/lib/src/dbg.c
+++ b/cesar/lib/src/dbg.c
@@ -92,13 +92,13 @@ dbg_fatal (const char *fmt, ...)
* Default dump callback, dump on stderr.
* \param user ignored user parameter
* \param text text to dump
- * \param text_size size of text
+ * \param text_size size of text or 0 for end of dump
* \return size of dumped text
*/
static int
dbg_default_dump_cb (void *user, const char *text, uint text_size)
{
- dbg_assert (text && text_size);
+ dbg_assert ((text && text_size) || text_size == 0);
arch_io_write (text, text_size);
return text_size;
}
@@ -161,6 +161,8 @@ dbg_vfatal_internal (const char *fmt, va_list ap)
}
in_fatal = false;
}
+ /* Signal end of dump. */
+ cb (dbg_dump_cb_user, NULL, 0);
/* Signal on blinking GPIO. */
#if CONFIG_GPIO_FATAL_BLINK
while (1)