*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
-__xdata struct ao_task * __xdata ao_tasks[AO_NUM_TASKS];
-__data uint8_t ao_num_tasks;
-__xdata struct ao_task *__data ao_cur_task;
+struct ao_task * ao_tasks[AO_NUM_TASKS];
+uint8_t ao_num_tasks;
+struct ao_task *ao_cur_task;
#if HAS_TASK_QUEUE
#define SLEEP_HASH_SIZE 17
static struct ao_list run_queue;
static struct ao_list alarm_queue;
#if HAS_TASK_QUEUE
#define SLEEP_HASH_SIZE 17
static struct ao_list run_queue;
static struct ao_list alarm_queue;
ao_list_del(&task->queue);
ao_list_append(&task->queue, &run_queue);
}
ao_list_del(&task->queue);
ao_list_append(&task->queue, &run_queue);
}
ao_list_del(&task->queue);
ao_list_append(&task->queue, ao_task_sleep_queue(wchan));
}
ao_list_del(&task->queue);
ao_list_append(&task->queue, ao_task_sleep_queue(wchan));
}
ao_list_for_each_entry(alarm, &alarm_queue, struct ao_task, alarm_queue) {
if ((int16_t) (alarm->alarm - task->alarm) >= 0) {
ao_list_insert(&task->alarm_queue, alarm->alarm_queue.prev);
ao_list_for_each_entry(alarm, &alarm_queue, struct ao_task, alarm_queue) {
if ((int16_t) (alarm->alarm - task->alarm) >= 0) {
ao_list_insert(&task->alarm_queue, alarm->alarm_queue.prev);
+static inline void *
+ao_stack_top(struct ao_task *task)
+{
+ uint8_t *top = &task->stack8[AO_STACK_SIZE];
+
+ /* Subtract off the TLS space, but keep the resulting
+ * stack 8-byte aligned
+ */
+#if USE_TLS
+ return top - ((_tls_size() + 7) & ~3);
+#else
+ return top;
+#endif
+}
+
- ao_arch_init_stack(task, start);
+ uint32_t *sp = ao_stack_top(task);
+#if USE_TLS
+ _init_tls(sp);
+#endif
+ ao_arch_init_stack(task, sp, task_func);
- ao_arch_wait_interrupt();
+ if (ao_task_minimize_latency) {
+ ao_arch_release_interrupts();
+ ao_arch_block_interrupts();
+ } else
+ ao_arch_wait_interrupt();
/* Make sure we sleep *at least* delay ticks, which means adding
* one to account for the fact that we may be close to the next tick
*/
/* Make sure we sleep *at least* delay ticks, which means adding
* one to account for the fact that we may be close to the next tick
*/
- printf("%12s: wchan %04x\n",
- task->name,
- (int) task->wchan);
+ printf("%2d: wchan %08x alarm %5d %s\n",
+ task->task_id,
+ (int) task->wchan,
+ task->alarm ? (int16_t) (task->alarm - now) : 9999,
+ task->name);