projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
altos: Replace ao_xmem functions with direct mem calls
[fw/altos]
/
src
/
kernel
/
ao_task.c
diff --git
a/src/kernel/ao_task.c
b/src/kernel/ao_task.c
index e8a092aaf660fcf6bbec48706e14d2f7936e297b..0bc85d40aad2dc86c2df71ee884fb313733fbcb7 100644
(file)
--- a/
src/kernel/ao_task.c
+++ b/
src/kernel/ao_task.c
@@
-29,12
+29,12
@@
#define AO_NO_TASK_INDEX 0xff
#define AO_NO_TASK_INDEX 0xff
-
__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
#if !HAS_TASK_QUEUE
-static
__data
uint8_t ao_cur_task_index;
+static uint8_t ao_cur_task_index;
#endif
#ifdef ao_arch_task_globals
#endif
#ifdef ao_arch_task_globals
@@
-67,7
+67,7
@@
static inline void ao_check_stack(void) {
static struct ao_list run_queue;
static struct ao_list alarm_queue;
static struct ao_list run_queue;
static struct ao_list alarm_queue;
-static struct ao_list sleep_queue[SLEEP_HASH_SIZE];
+static struct ao_list
ao_
sleep_queue[SLEEP_HASH_SIZE];
static void
ao_task_to_run_queue(struct ao_task *task)
static void
ao_task_to_run_queue(struct ao_task *task)
@@
-80,7
+80,7
@@
ao_task_to_run_queue(struct ao_task *task)
static struct ao_list *
ao_task_sleep_queue(void *wchan)
{
static struct ao_list *
ao_task_sleep_queue(void *wchan)
{
- return &sleep_queue[(uintptr_t) wchan % SLEEP_HASH_SIZE];
+ return &
ao_
sleep_queue[(uintptr_t) wchan % SLEEP_HASH_SIZE];
}
static void
}
static void
@@
-195,7
+195,7
@@
ao_task_init(void)
ao_list_init(&alarm_queue);
ao_task_alarm_tick = 0;
for (i = 0; i < SLEEP_HASH_SIZE; i++)
ao_list_init(&alarm_queue);
ao_task_alarm_tick = 0;
for (i = 0; i < SLEEP_HASH_SIZE; i++)
- ao_list_init(&sleep_queue[i]);
+ ao_list_init(&
ao_
sleep_queue[i]);
}
#if DEBUG
}
#if DEBUG
@@
-290,7
+290,7
@@
ao_task_validate(void)
#endif /* HAS_TASK_QUEUE */
void
#endif /* HAS_TASK_QUEUE */
void
-ao_add_task(
__xdata struct ao_task * task, void (*start)(void), __code char *name) __reentrant
+ao_add_task(
struct ao_task * task, void (*task_func)(void), const char *name)
{
uint8_t task_id;
uint8_t t;
{
uint8_t task_id;
uint8_t t;
@@
-310,7
+310,7
@@
ao_add_task(__xdata struct ao_task * task, void (*start)(void), __code char *nam
* Construct a stack frame so that it will 'return'
* to the start of the task
*/
* Construct a stack frame so that it will 'return'
* to the start of the task
*/
- ao_arch_init_stack(task,
start
);
+ ao_arch_init_stack(task,
task_func
);
ao_arch_critical(
#if HAS_TASK_QUEUE
ao_task_init_queue(task);
ao_arch_critical(
#if HAS_TASK_QUEUE
ao_task_init_queue(task);
@@
-321,7
+321,7
@@
ao_add_task(__xdata struct ao_task * task, void (*start)(void), __code char *nam
);
}
);
}
-
__data uint8_t
ao_task_minimize_latency;
+
uint8_t
ao_task_minimize_latency;
/* Task switching function. This must not use any stack variables */
void
/* Task switching function. This must not use any stack variables */
void
@@
-373,12
+373,16
@@
ao_yield(void) ao_arch_naked_define
if (!ao_list_is_empty(&run_queue))
break;
/* Wait for interrupts when there's nothing ready */
if (!ao_list_is_empty(&run_queue))
break;
/* Wait for interrupts when there's nothing ready */
- ao_arch_wait_interrupt();
+ if (ao_task_minimize_latency) {
+ ao_arch_release_interrupts();
+ ao_arch_block_interrupts();
+ } else
+ ao_arch_wait_interrupt();
}
ao_cur_task = ao_list_first_entry(&run_queue, struct ao_task, queue);
#else
{
}
ao_cur_task = ao_list_first_entry(&run_queue, struct ao_task, queue);
#else
{
-
__pdata
uint8_t ao_last_task_index = ao_cur_task_index;
+ uint8_t ao_last_task_index = ao_cur_task_index;
for (;;) {
++ao_cur_task_index;
if (ao_cur_task_index == ao_num_tasks)
for (;;) {
++ao_cur_task_index;
if (ao_cur_task_index == ao_num_tasks)
@@
-414,7
+418,7
@@
ao_yield(void) ao_arch_naked_define
}
uint8_t
}
uint8_t
-ao_sleep(
__xdata
void *wchan)
+ao_sleep(void *wchan)
{
#if HAS_TASK_QUEUE
uint32_t flags;
{
#if HAS_TASK_QUEUE
uint32_t flags;
@@
-435,7
+439,7
@@
ao_sleep(__xdata void *wchan)
}
void
}
void
-ao_wakeup(
__xdata void *wchan) __reentrant
+ao_wakeup(
void *wchan)
{
ao_validate_cur_stack();
#if HAS_TASK_QUEUE
{
ao_validate_cur_stack();
#if HAS_TASK_QUEUE
@@
-466,7
+470,7
@@
ao_wakeup(__xdata void *wchan) __reentrant
}
uint8_t
}
uint8_t
-ao_sleep_for(
__xdata
void *wchan, uint16_t timeout)
+ao_sleep_for(void *wchan, uint16_t timeout)
{
uint8_t ret;
if (timeout) {
{
uint8_t ret;
if (timeout) {
@@
-500,7
+504,7
@@
ao_sleep_for(__xdata void *wchan, uint16_t timeout)
return ret;
}
return ret;
}
-static
__xdata
uint8_t ao_forever;
+static uint8_t ao_forever;
void
ao_delay(uint16_t ticks)
void
ao_delay(uint16_t ticks)
@@
-537,7
+541,7
@@
void
ao_task_info(void)
{
uint8_t i;
ao_task_info(void)
{
uint8_t i;
-
__xdata
struct ao_task *task;
+ struct ao_task *task;
uint16_t now = ao_time();
for (i = 0; i < ao_num_tasks; i++) {
uint16_t now = ao_time();
for (i = 0; i < ao_num_tasks; i++) {
@@
-565,4
+569,5
@@
ao_start_scheduler(void)
ao_arch_start_scheduler();
#endif
ao_yield();
ao_arch_start_scheduler();
#endif
ao_yield();
+ __builtin_unreachable();
}
}