summaryrefslogtreecommitdiff
path: root/core/cortex-m0/task.c
diff options
context:
space:
mode:
Diffstat (limited to 'core/cortex-m0/task.c')
-rw-r--r--core/cortex-m0/task.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/core/cortex-m0/task.c b/core/cortex-m0/task.c
index 274b6a263d..e8aec0926e 100644
--- a/core/cortex-m0/task.c
+++ b/core/cortex-m0/task.c
@@ -22,7 +22,7 @@ typedef union {
* for __switchto() to work.
*/
uint32_t sp; /* Saved stack pointer for context switch */
- uint32_t events; /* Bitmaps of received events */
+ atomic_t events; /* Bitmaps of received events */
uint64_t runtime; /* Time spent in task */
uint32_t *stack; /* Start of stack */
};
@@ -136,13 +136,13 @@ task_ *current_task = (task_ *)scratchpad;
* can do their init within a task switching context. The hooks task will then
* make a call to enable all tasks.
*/
-static uint32_t tasks_ready = BIT(TASK_ID_HOOKS);
+static atomic_t tasks_ready = BIT(TASK_ID_HOOKS);
/*
* Initially allow only the HOOKS and IDLE task to run, regardless of ready
* status, in order for HOOK_INIT to complete before other tasks.
* task_enable_all_tasks() will open the flood gates.
*/
-static uint32_t tasks_enabled = BIT(TASK_ID_HOOKS) | BIT(TASK_ID_IDLE);
+static atomic_t tasks_enabled = BIT(TASK_ID_HOOKS) | BIT(TASK_ID_IDLE);
static int start_called; /* Has task swapping started */
@@ -197,7 +197,7 @@ task_id_t task_get_current(void)
return current_task - tasks;
}
-uint32_t *task_get_event_bitmap(task_id_t tskid)
+atomic_t *task_get_event_bitmap(task_id_t tskid)
{
task_ *tsk = __task_id_to_ptr(tskid);
return &tsk->events;
@@ -304,7 +304,9 @@ void task_start_irq_handler(void *excep_return)
* Continue iff the tasks are ready and we are not called from another
* exception (as the time accouting is done in the outer irq).
*/
- if (!start_called || ((uint32_t)excep_return & 0xf) == 1)
+ if (!start_called
+ || (((uint32_t)excep_return & EXC_RETURN_MODE_MASK)
+ == EXC_RETURN_MODE_HANDLER))
return;
exc_start_time = t;
@@ -322,7 +324,9 @@ void task_end_irq_handler(void *excep_return)
* Continue iff the tasks are ready and we are not called from another
* exception (as the time accouting is done in the outer irq).
*/
- if (!start_called || ((uint32_t)excep_return & 0xf) == 1)
+ if (!start_called
+ || (((uint32_t)excep_return & EXC_RETURN_MODE_MASK)
+ == EXC_RETURN_MODE_HANDLER))
return;
/* Track time in interrupts */
@@ -565,7 +569,7 @@ void task_print_list(void)
ccputs("Task Ready Name Events Time (s) StkUsed\n");
for (i = 0; i < TASK_ID_COUNT; i++) {
- char is_ready = (tasks_ready & (1<<i)) ? 'R' : ' ';
+ char is_ready = ((uint32_t)tasks_ready & BIT(i)) ? 'R' : ' ';
uint32_t *sp;
int stackused = tasks_init[i].stack_size;
@@ -576,7 +580,7 @@ void task_print_list(void)
stackused -= sizeof(uint32_t);
ccprintf("%4d %c %-16s %08x %11.6lld %3d/%3d\n", i, is_ready,
- task_names[i], tasks[i].events, tasks[i].runtime,
+ task_names[i], (int)tasks[i].events, tasks[i].runtime,
stackused, tasks_init[i].stack_size);
cflush();
}
@@ -619,10 +623,10 @@ DECLARE_CONSOLE_COMMAND(taskinfo, command_task_info,
static int command_task_ready(int argc, char **argv)
{
if (argc < 2) {
- ccprintf("tasks_ready: 0x%08x\n", tasks_ready);
+ ccprintf("tasks_ready: 0x%08x\n", (int)tasks_ready);
} else {
tasks_ready = strtoi(argv[1], NULL, 16);
- ccprintf("Setting tasks_ready to 0x%08x\n", tasks_ready);
+ ccprintf("Setting tasks_ready to 0x%08x\n", (int)tasks_ready);
__schedule(0, 0);
}