/* SPDX-License-Identifier: GPL-2.0-only */ #ifndef _PROC_H_ #define _PROC_H_ #include #include #include #include #include #include "elf.h" #define PROC_STATE_RUNNING 0 #define PROC_STATE_WAITING 1 #define PROC_STATE_DNS 2 /* do not schedule */ typedef u64 pid_t; typedef u64 tid_t; struct vm_area { vaddr_t start; vaddr_t end; u64 flags; }; struct proc; struct thread { tid_t tid; vaddr_t stack_addr; u64 state; bool in_kernel; u64 tls_base; struct proc *proc; struct thread *next; }; struct proc { pid_t pid; struct thread main_thread; char *name; pgd_t *pgd; spinlock_t sched_lock; spinlock_t mem_lock; rbtree_t memmap; struct ehdr *ehdr; struct phdrs *phdrs; size_t n_phdrs; }; int proc_kill(struct proc *proc, int signal); void proc_mmap(struct proc *proc, paddr_t p, vaddr_t v, size_t len, u64 flags); struct proc *proc_create(struct proc *parent); void proc_free(struct proc *proc); void switch_to(struct thread *from, struct thread *to); void proc_init(); #endif /* _PROC_H_ */