summaryrefslogtreecommitdiff
path: root/cesar
diff options
context:
space:
mode:
Diffstat (limited to 'cesar')
-rw-r--r--cesar/lib/src/trace.c77
-rw-r--r--cesar/lib/trace.h8
2 files changed, 38 insertions, 47 deletions
diff --git a/cesar/lib/src/trace.c b/cesar/lib/src/trace.c
index 9a3f37c637..c10d7c7307 100644
--- a/cesar/lib/src/trace.c
+++ b/cesar/lib/src/trace.c
@@ -21,6 +21,8 @@
#define TRACE_ALIGN (sizeof (u32))
#define TRACE_DEBUG_ARGS 0
+#define TRACE_CHUNK_SIZE (BLK_SIZE / TRACE_ALIGN)
+
/** Trace system context. */
struct trace_t
{
@@ -248,8 +250,8 @@ trace_buffer_add (trace_buffer_t *buf, const char *name, uint drop_level,
trace_chunk_t *i = buf->head;
do
{
- i->data_end = i->data;
- i->chunk_end = i->data + BLK_SIZE / TRACE_ALIGN;
+ i->tail_index = 0;
+ i->commit_index = 0;
if (i == buf->tail)
break;
i = i->next;
@@ -420,7 +422,7 @@ trace_buffer_dump (trace_buffer_t *buf, trace_dump_callback_t cb, void *user)
do
{
data = head->data;
- data_end = head->data_end;
+ data_end = data + head->commit_index;
/* Loop on this chunk. */
while (data < data_end)
{
@@ -547,16 +549,13 @@ trace_printn_prepare (trace_buffer_t *buf, uint count)
{
dbg_assert (buf && buf->tail);
trace_chunk_t *tail = buf->tail;
- if (DEBUG_MORE)
- dbg_assert (tail->data <= tail->data_end
- && tail->data_end <= tail->chunk_end);
- if (tail->data_end + count > tail->chunk_end)
+ if (tail->tail_index + count > TRACE_CHUNK_SIZE)
{
/* No room left, allocate a new chunk. */
dbg_assert (!buf->locked);
trace_chunk_t *c = (trace_chunk_t *) blk_alloc_desc ();
- c->data_end = c->data;
- c->chunk_end = c->data + BLK_SIZE / TRACE_ALIGN;
+ c->tail_index = 0;
+ c->commit_index = 0;
tail->next = c;
REORDER_BARRIER ();
buf->tail = c;
@@ -645,11 +644,8 @@ trace_fast_printn_prepare (trace_buffer_t *buf, uint count)
if (DEBUG_MORE)
dbg_assert (buf && buf->tail);
trace_chunk_t *tail = buf->tail;
- if (DEBUG_MORE)
- dbg_assert (tail->data <= tail->data_end
- && tail->data_end <= tail->chunk_end);
- u32 *data_end = tail->data_end;
- if (data_end + count > tail->chunk_end)
+ u32 *data_end;
+ if (tail->tail_index + count > TRACE_CHUNK_SIZE)
{
/* No room left, use the oldest chunk for the new chunk. */
if (DEBUG_MORE)
@@ -660,21 +656,32 @@ trace_fast_printn_prepare (trace_buffer_t *buf, uint count)
buf->head = head->next;
tail = head;
data_end = tail->data;
- tail->data_end = data_end;
- tail->chunk_end = data_end + BLK_SIZE / TRACE_ALIGN;
+ tail->tail_index = count;
+ tail->commit_index = 0;
+ }
+ else
+ {
+ data_end = tail->data + tail->tail_index;
+ tail->tail_index += count;
}
/* Dump to buffer. */
return data_end;
}
+static inline void
+trace_fast_printn_commit (trace_buffer_t *buf)
+{
+ if (DEBUG_MORE)
+ dbg_assert (buf && buf->tail);
+ buf->tail->commit_index = buf->tail->tail_index;
+}
+
void ARCH_ILRAM
trace_fast_print0 (trace_buffer_t *buf, uint id)
{
u32 *p = trace_fast_printn_prepare (buf, 1);
*p++ = id << 8 | 0;
- trace_chunk_t *tail = buf->tail;
- REORDER_BARRIER ();
- tail->data_end = p;
+ trace_fast_printn_commit (buf);
}
void ARCH_ILRAM
@@ -683,9 +690,7 @@ trace_fast_print1 (trace_buffer_t *buf, uint id, int arg0)
u32 *p = trace_fast_printn_prepare (buf, 2);
*p++ = id << 8 | 1;
*p++ = arg0;
- trace_chunk_t *tail = buf->tail;
- REORDER_BARRIER ();
- tail->data_end = p;
+ trace_fast_printn_commit (buf);
}
void ARCH_ILRAM
@@ -695,9 +700,7 @@ trace_fast_print2 (trace_buffer_t *buf, uint id, int arg0, int arg1)
*p++ = id << 8 | 2;
*p++ = arg0;
*p++ = arg1;
- trace_chunk_t *tail = buf->tail;
- REORDER_BARRIER ();
- tail->data_end = p;
+ trace_fast_printn_commit (buf);
}
void ARCH_ILRAM
@@ -708,9 +711,7 @@ trace_fast_print3 (trace_buffer_t *buf, uint id, int arg0, int arg1, int arg2)
*p++ = arg0;
*p++ = arg1;
*p++ = arg2;
- trace_chunk_t *tail = buf->tail;
- REORDER_BARRIER ();
- tail->data_end = p;
+ trace_fast_printn_commit (buf);
}
void ARCH_ILRAM
@@ -723,9 +724,7 @@ trace_fast_print4 (trace_buffer_t *buf, uint id, int arg0, int arg1, int arg2,
*p++ = arg1;
*p++ = arg2;
*p++ = arg3;
- trace_chunk_t *tail = buf->tail;
- REORDER_BARRIER ();
- tail->data_end = p;
+ trace_fast_printn_commit (buf);
}
void ARCH_ILRAM
@@ -739,9 +738,7 @@ trace_fast_print5 (trace_buffer_t *buf, uint id, int arg0, int arg1, int arg2,
*p++ = arg2;
*p++ = arg3;
*p++ = arg4;
- trace_chunk_t *tail = buf->tail;
- REORDER_BARRIER ();
- tail->data_end = p;
+ trace_fast_printn_commit (buf);
}
void ARCH_ILRAM
@@ -756,9 +753,7 @@ trace_fast_print6 (trace_buffer_t *buf, uint id, int arg0, int arg1, int arg2,
*p++ = arg3;
*p++ = arg4;
*p++ = arg5;
- trace_chunk_t *tail = buf->tail;
- REORDER_BARRIER ();
- tail->data_end = p;
+ trace_fast_printn_commit (buf);
}
void ARCH_ILRAM
@@ -774,9 +769,7 @@ trace_fast_print7 (trace_buffer_t *buf, uint id, int arg0, int arg1, int arg2,
*p++ = arg4;
*p++ = arg5;
*p++ = arg6;
- trace_chunk_t *tail = buf->tail;
- REORDER_BARRIER ();
- tail->data_end = p;
+ trace_fast_printn_commit (buf);
}
void ARCH_ILRAM
@@ -793,8 +786,6 @@ trace_fast_print8 (trace_buffer_t *buf, uint id, int arg0, int arg1, int arg2,
*p++ = arg5;
*p++ = arg6;
*p++ = arg7;
- trace_chunk_t *tail = buf->tail;
- REORDER_BARRIER ();
- tail->data_end = p;
+ trace_fast_printn_commit (buf);
}
diff --git a/cesar/lib/trace.h b/cesar/lib/trace.h
index 49c6d860cb..9fb32cb756 100644
--- a/cesar/lib/trace.h
+++ b/cesar/lib/trace.h
@@ -102,10 +102,10 @@ struct trace_chunk_t
trace_chunk_t *next;
/** Data in this chunk. */
u32 *data;
- /** Number of data words in this chunk. */
- u32 *data_end;
- /** Maximum usable data words. */
- u32 *chunk_end;
+ /** Number of committed words in this chunk. */
+ uint commit_index;
+ /** Number of reserved words in this chunk. */
+ uint tail_index;
};
/**