blob: 9171eaab374e87fe16a875bc3d34f10381a041b0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
#ifndef _THREAD_H
#define _THREAD_H
#include <stddef.h>
#include <inttypes.h>
#include "core.h"
struct semaphore;
struct thread_list {
struct thread_list *next, *prev;
};
struct thread_block {
struct thread_list list;
struct thread *thread;
struct semaphore *semaphore;
jiffies_t block_time;
jiffies_t timeout;
bool timed_out;
};
struct sys_timeouts;
struct thread {
void *esp; /* Must be first; stack pointer */
struct thread_list list;
struct thread_block *blocked;
struct sys_timeouts *timeouts; /* For the benefit of lwIP */
int prio;
};
void __schedule(void);
void __switch_to(struct thread *);
void thread_yield(void);
extern struct thread *__current;
static inline struct thread *current(void)
{
return __current;
}
struct semaphore {
int count;
struct thread_list list;
};
jiffies_t sem_down(struct semaphore *, jiffies_t);
void sem_up(struct semaphore *);
void sem_init(struct semaphore *, int);
typedef unsigned long irq_state_t;
static inline irq_state_t irq_state(void)
{
irq_state_t __st;
asm volatile("pushfl ; popl %0" : "=rm" (__st));
return __st;
}
static inline irq_state_t irq_save(void)
{
irq_state_t __st;
asm volatile("pushfl ; popl %0 ; cli" : "=rm" (__st));
return __st;
}
static inline void irq_restore(irq_state_t __st)
{
asm volatile("pushl %0 ; popfl" : : "rm" (__st));
}
struct thread *start_thread(size_t stack_size, int prio,
void (*start_func)(void *), void *func_arg);
void __exit_thread(void);
void kill_thread(struct thread *);
void start_idle_thread(void);
void test_thread(void);
#endif /* _THREAD_H */
|