blob: ce5b04ce60e971b1b048ca4db466d69f8c565849 [file] [log] [blame]
swissChilie20b79b2021-03-17 21:20:13 -07001#pragma once
2
3#include "kint.h"
swissChilie9289ee2021-03-20 21:54:28 -07004#include "registers.h"
swissChilie20b79b2021-03-17 21:20:13 -07005
swissChilie9289ee2021-03-20 21:54:28 -07006struct process
7{
8 bool exists;
swissChilicfd3c3c2021-04-03 15:04:24 -07009 int id; // kernel uses pid 0, which cannot exit
swissChilie9289ee2021-03-20 21:54:28 -070010 int ring;
11 int uid;
12 char name[32];
swissChilicfd3c3c2021-04-03 15:04:24 -070013 uint page_directory_p;
14 // most recent (bottom) stack used by a task, next
15 // stack should be under this one.
16 // NOTE: must be PAGE ALIGNED
17 uint last_stack_pos;
swissChilie9289ee2021-03-20 21:54:28 -070018};
19
20struct task
21{
22 int id;
23 struct process *proc;
24 uint stack_top_p; // stack frame PHYSICAL address
25 uint esp, ebp, eip;
swissChilie9289ee2021-03-20 21:54:28 -070026};
27
28struct ll_task_i
29{
swissChilif01ddcc2021-04-04 11:31:34 -070030 struct ll_task_i *next, *prev;
swissChilie9289ee2021-03-20 21:54:28 -070031 struct task task;
32};
33
34// extern struct process processes[1024];
35// extern struct ll_task_i *first_task, *current_task;
36
swissChilicfd3c3c2021-04-03 15:04:24 -070037extern void init_tasks();
swissChilie9289ee2021-03-20 21:54:28 -070038struct process *get_process(uint pid);
39
40int get_process_id();
41int get_task_id();
42
43// For compatibility I guess
44#define getpid get_process_id
45
swissChilif01ddcc2021-04-04 11:31:34 -070046void spawn_thread(void (*function)(void *), void *data);
47void kill_this_thread();
swissChilicfd3c3c2021-04-03 15:04:24 -070048extern void switch_task();
swissChilif01ddcc2021-04-04 11:31:34 -070049void switch_to_task(struct task *task);