All checks were successful
Build documentation / build-and-deploy (push) Successful in 40s
76 lines
1.9 KiB
C
76 lines
1.9 KiB
C
#ifndef _KERNEL_PROC_PROC_H
|
|
#define _KERNEL_PROC_PROC_H
|
|
|
|
#include <aux/compiler.h>
|
|
#include <aux/elf.h>
|
|
#include <libk/list.h>
|
|
#include <libk/rbtree.h>
|
|
#include <libk/std.h>
|
|
#include <proc/resource.h>
|
|
#include <proc/suspension_q.h>
|
|
#include <sync/rw_spin_lock.h>
|
|
#include <sync/spin_lock.h>
|
|
#include <sys/mm.h>
|
|
|
|
#if defined(__x86_64__)
|
|
#include <amd64/gdt.h> /* KSTACK_SIZE */
|
|
#include <amd64/proc.h> /* USTACK_SIZE */
|
|
#endif
|
|
|
|
/* process states */
|
|
#define PROC_READY 0
|
|
#define PROC_DEAD 1
|
|
#define PROC_SUSPENDED 2
|
|
#define PROC_PSEUDO 3
|
|
|
|
#define PROC_USTK_PREALLOC (1 << 0)
|
|
|
|
struct cpu;
|
|
|
|
struct proc_mapping {
|
|
struct list_node_link proc_mappings_link;
|
|
|
|
uintptr_t paddr;
|
|
uintptr_t vaddr;
|
|
size_t size;
|
|
};
|
|
|
|
struct proc_resources {
|
|
atomic_int refs;
|
|
atomic_int sys_rids;
|
|
struct rb_node_link* tree;
|
|
rw_spin_lock_t lock;
|
|
};
|
|
|
|
struct proc {
|
|
int pid;
|
|
struct rb_node_link proc_tree_link;
|
|
struct rb_node_link cpu_run_q_link;
|
|
struct rb_node_link suspension_link;
|
|
struct list_node_link reap_link;
|
|
|
|
struct list_node_link* mappings; /* pd.lock implicitly protects this field */
|
|
struct proc_platformdata pdata;
|
|
uint32_t flags;
|
|
struct pd* pd;
|
|
spin_lock_t lock;
|
|
struct cpu* cpu;
|
|
atomic_int state;
|
|
struct proc_suspension_q* suspension_q;
|
|
struct proc_resources* resources;
|
|
};
|
|
|
|
void proc_suspend (struct proc* proc, struct proc_suspension_q* sq);
|
|
void proc_resume (struct proc* proc);
|
|
void proc_sched (void* regs);
|
|
void proc_kill (struct proc* proc);
|
|
bool proc_map (struct proc* proc, uintptr_t start_paddr, uintptr_t start_vaddr, size_t pages,
|
|
uint32_t flags);
|
|
bool proc_unmap (struct proc* proc, uintptr_t start_vaddr, size_t pages);
|
|
struct elf_aux proc_load_segments (struct proc* proc, uint8_t* elf);
|
|
void proc_register (struct proc* proc, struct cpu* cpu);
|
|
struct proc* proc_find_pid (int pid);
|
|
void proc_init (void);
|
|
|
|
#endif // _KERNEL_PROC_PROC_H
|