X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=src%2Fao_task.c;h=f5850fa4c15bab07b88fcd6c4a191ffd33323762;hp=72c9d7d61f67216a71436ce9ffd7c4d0989c5bef;hb=6492218fc316f8cf6214a577807a8dd0a80a9b6a;hpb=447c121fc1ceb878e45718ad1364a5349965a59a diff --git a/src/ao_task.c b/src/ao_task.c index 72c9d7d6..f5850fa4 100644 --- a/src/ao_task.c +++ b/src/ao_task.c @@ -48,32 +48,37 @@ ao_add_task(__xdata struct ao_task * task, void (*start)(void), __code char *nam */ stack = task->stack; - *stack++ = ((uint16_t) start); - *stack++ = ((uint16_t) start) >> 8; + *stack++ = ((uint16_t) start); /* 0 */ + *stack++ = ((uint16_t) start) >> 8; /* 1 */ /* and the stuff saved by ao_switch */ - *stack++ = 0; /* acc */ - *stack++ = 0x80; /* IE */ - *stack++ = 0; /* DPL */ - *stack++ = 0; /* DPH */ - *stack++ = 0; /* B */ - *stack++ = 0; /* R2 */ - *stack++ = 0; /* R3 */ - *stack++ = 0; /* R4 */ - *stack++ = 0; /* R5 */ - *stack++ = 0; /* R6 */ - *stack++ = 0; /* R7 */ - *stack++ = 0; /* R0 */ - *stack++ = 0; /* R1 */ - *stack++ = 0; /* PSW */ - *stack++ = 0; /* BP */ - task->stack_count = stack - task->stack; + *stack++ = 0; /* 2 acc */ + *stack++ = 0x80; /* 3 IE */ + + /* 4 DPL + * 5 DPH + * 6 B + * 7 R2 + * 8 R3 + * 9 R4 + * 10 R5 + * 11 R6 + * 12 R7 + * 13 R0 + * 14 R1 + * 15 PSW + * 16 BP + */ + for (t = 0; t < 13; t++) + *stack++ = 0; + + task->stack_count = 17; task->wchan = NULL; } /* Task switching function. This must not use any stack variables */ void -ao_yield(void) _naked +ao_yield(void) __naked { /* Save current context */ @@ -204,12 +209,11 @@ ao_sleep(__xdata void *wchan) ao_cur_task->wchan = wchan; } ao_yield(); + ao_cur_task->alarm = 0; if (ao_cur_task->wchan) { ao_cur_task->wchan = NULL; - ao_cur_task->alarm = 0; return 1; } - ao_cur_task->alarm = 0; return 0; } @@ -233,12 +237,6 @@ ao_alarm(uint16_t delay) ao_cur_task->alarm = 1; } -void -ao_wake_task(__xdata struct ao_task *task) -{ - task->wchan = NULL; -} - void ao_exit(void) __critical {