45#include "dev/watchdog.h"
50#define LOG_MODULE "Stack"
51#define LOG_LEVEL LOG_LEVEL_MAIN
57#if STACK_CHECK_PERIODIC_CHECKS
58PROCESS(stack_check_process,
"Stack check");
62#define STACK_FILL 0xcd
66#define GET_STACK_ORIGIN() STACK_ORIGIN
69extern int _stack_origin;
70#define GET_STACK_ORIGIN() (&_stack_origin)
80 static void *stack_top;
86 while(p < (uint8_t *)stack_top) {
90#if STACK_CHECK_PERIODIC_CHECKS
107 while(*p != STACK_FILL && p < (uint8_t *)GET_STACK_ORIGIN()) {
112 while(*p == STACK_FILL && p < (uint8_t *)GET_STACK_ORIGIN()) {
119 if(p >= (uint8_t*)GET_STACK_ORIGIN()) {
124 return (uint8_t *)GET_STACK_ORIGIN() - p;
130 return (uint8_t *)GET_STACK_ORIGIN() - &_stack;
133#if STACK_CHECK_PERIODIC_CHECKS
144 int32_t actual, allowed;
150 if(actual < 0 || allowed < 0) {
151 LOG_ERR(
"Check in inconsistent state: %" PRId32
" vs. %" PRId32
"\n",
153 }
else if(actual > allowed) {
154 LOG_ERR(
"Check failed: %" PRId32
" vs. %" PRId32
"\n", actual, allowed);
156 LOG_DBG(
"Check ok: %" PRId32
" vs. %" PRId32
"\n", actual, allowed);
PROCESS_THREAD(cc2538_rf_process, ev, data)
Implementation of the cc2538 RF driver process.
void watchdog_periodic(void)
Writes the WDT clear sequence.
void etimer_reset(struct etimer *et)
Reset an event timer with the same interval as was previously set.
int etimer_expired(struct etimer *et)
Check if an event timer has expired.
void etimer_set(struct etimer *et, clock_time_t interval)
Set an event timer.
#define PROCESS(name, strname)
Declare a process.
#define PROCESS_BEGIN()
Define the beginning of a process.
#define PROCESS_WAIT_EVENT_UNTIL(c)
Wait for an event to be posted to the process, with an extra condition.
#define PROCESS_END()
Define the end of a process.
void process_start(struct process *p, process_data_t data)
Start a process.
int32_t stack_check_get_reserved_size(void)
Calculate the maximal permitted stack usage.
int32_t stack_check_get_usage(void)
Calculate the maximal stack usage so far.
void stack_check_init(void)
Initialize the stack area with a known pattern.
Header file for the logging system.
Stack checker library header file.