From a8a3c6d9be83e260279ad4da469fc60a5a05d0fd Mon Sep 17 00:00:00 2001 From: Randall Spangler Date: Tue, 4 Sep 2012 16:53:33 -0700 Subject: Track amount of stack used for each EC task BUG=chrome-os-partner:13814 TEST=taskinfo; should show stack used per task BRANCH=all Change-Id: Ie40a70a8647c767ea6ec3d164f81c63b62b5008e Signed-off-by: Randall Spangler Reviewed-on: https://gerrit.chromium.org/gerrit/32590 Reviewed-by: Vincent Palatin --- core/cortex-m/task.c | 33 ++++++++++++++++++++++++++++----- include/util.h | 3 +++ 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/core/cortex-m/task.c b/core/cortex-m/task.c index a45e8e0e32..76e6275ec4 100644 --- a/core/cortex-m/task.c +++ b/core/cortex-m/task.c @@ -27,12 +27,19 @@ typedef union { uint32_t sp; /* saved stack pointer for context switch */ uint32_t events; /* bitmaps of received events */ uint64_t runtime; /* Time spent in task */ + uint32_t reserved; /* Reserved (for padding) */ uint32_t guard; /* Guard value to detect stack overflow */ - uint8_t stack[0]; /* task stack */ + uint32_t stack[0]; /* Task stack; must be 64-bit aligned */ }; uint32_t context[TASK_SIZE/4]; } task_; +/* Size of stack */ +#define STACK_SIZE (TASK_SIZE - OFFSET_OF(task_, stack)) + +/* Value to store in unused stack */ +#define STACK_UNUSED_VALUE 0xdeadd00d + /* declare task routine prototypes */ #define TASK(n, r, d) int r(void *); #include TASK_LIST @@ -502,12 +509,22 @@ void mutex_unlock(struct mutex *mtx) void task_print_list(void) { int i; - ccputs("Task Ready Name Events Time (s)\n"); + ccputs("Task Ready Name Events Time (s) StkUsed\n"); for (i = 0; i < TASK_ID_COUNT; i++) { char is_ready = (tasks_ready & (1<field)) +#endif #ifndef MAX #define MAX(a, b) ((a) > (b) ? (a) : (b)) #endif -- cgit v1.2.1