blob: c31162e1f4d4ac31df5832576d37b03fca1cd951 [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{
30 struct ll_task_i *next;
31 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
swissChilicfd3c3c2021-04-03 15:04:24 -070046void spawn_thread(void (*function)());
47extern void switch_task();