summaryrefslogtreecommitdiff
path: root/stage3/thread.h
blob: 9f5ff2f1d1750cb414b80da0d5242a291192a3fc (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
#ifndef THREAD_H
#define THREAD_H

#include "def.h"

typedef struct {
	bool exit;
	i64 timeout;
} yield_arg;

void *yield(void *arg);

typedef struct {
	str name;
	void *stack_bottom;
	void *stack;
} thread;

typedef struct {
	u8 irq;
	union {
		u8 scancode;
	} data;
} event;

typedef struct {
	usize len;
	usize cap;
	event *data;
} event_queue;

extern event_queue queue_write;
extern thread *irq_services[16];

void thread_init();
void thread_resume(void *ret, thread *t);
thread *thread_create(str name, void *init);
void thread_sched(yield_arg *arg, void *stack);

#endif