aboutsummaryrefslogtreecommitdiff
path: root/include/tasks.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/tasks.h')
-rw-r--r--include/tasks.h56
1 files changed, 9 insertions, 47 deletions
diff --git a/include/tasks.h b/include/tasks.h
index 27bd968..b62b093 100644
--- a/include/tasks.h
+++ b/include/tasks.h
@@ -22,17 +22,21 @@ union StackPointer {
uint8_t lh8[2];
uint16_t lh16;
};
-typedef struct {
+
+struct Task {
uint8_t flags;
void (*func) (void *data);
void *data;
uint8_t _rflags;
uint8_t _stack_size;
union StackPointer _sp;
-} Task;
-int8_t task_spawn(Task * t, uint8_t stack_size);
+};
+typedef task_t volatile struct Task;
+
+int8_t task_spawn(struct Task * t, uint8_t stack_size);
+Task *tasks_self(void);
void taks_exit(void);
-int8_t task_kill(Task * t);
+int8_t task_kill(struct Task * t);
int8_t task_safe(void);
int8_t task_unsafe(void);
@@ -40,55 +44,13 @@ int8_t task_delay(uint16_t cycles);
int8_t task_delay_ms(uint16_t ms);
int8_t task_delay_till(volatile int8_t * boolean, uint16_t ms);
-#define MUTEX_F_TIMED (1<<0)
-#define MUTEX_F_TAKEN (1<<7)
-typedef struct {
- uint8_t flags;
- Task *_task_took;
-} Mutex;
-int8_t mutex_init(Mutex * mtx);
-int8_t mutex_free(Mutex * mtx);
-int8_t mutex_take(Mutex * mtx, uint16_t timeout);
-int8_t mutex_give(Mutex * mtx);
-
-typedef struct {
- uint8_t flags;
- uint8_t _count;
- Task **_tasks;
- uint8_t _tasks_len;
-} Semaphore;
-int8_t semaphore_init(Semaphore * sem, uint8_t count);
-int8_t semaphore_free(Semaphore * sem);
-int8_t semaphore_take(Semaphore * sem, uint16_t timeout);
-int8_t semaphore_give(Semaphore * sem);
-
#else /* CONFIG_IOE_TASKS */
-typedef struct {
-} Task;
-#define task_spawn(T, STACK_SIZE)
-#define task_exit()
-#define task_kill(T)
#define task_safe()
#define task_unsafe()
-
-#define task_delay(US) _delay_us(US) // TODO this should be cycles
+#define task_delay(CC) _delay_us(CC) // TODO this should be cycles
#define task_delay_ms(MS) _delay_ms(MS)
int8_t task_delay_till(volatile int8_t * boolean, uint16_t ms);
-typedef struct {
-} Mutex;
-#define mutex_init(MTX, FLAGS)
-#define mutex_free(MTX)
-#define mutex_take(MTX, TIMEOUT)
-#define mutex_give(MTX);
-
-typedef struct {
-} Semaphore;
-#define semaphore_init(SEM, FLAGS, COUNT)
-#define semaphore_free(SEM)
-#define semaphore_take(SEM, TIMEOUT)
-#define semaphore_give(SEM)
-
#endif /* CONFIG_IOE_TASKS */
#endif /* _IOE_TASKS_H_ */