/* * @author xamidev * @brief Process definition * @license GPL-3.0-only */ #ifndef PROCESS_H #define PROCESS_H #include #include #include #include #include typedef enum { READY, RUNNING, DEAD } status_t; struct process_fd { bool used; unsigned int drive_id; int fs_fd; }; struct process { size_t pid; char name[PROCESS_NAME_MAX]; status_t status; struct cpu_status* context; void* root_page_table; // Process PML4 (should contain kernel PML4 in higher half [256-511] void* kernel_stack; // Used for interrupts (syscall: int 0x80), defines the TSS RSP0 struct process_fd fds[PROCESS_FD_MAX]; struct process* next; }; void process_init(void); struct process* process_create(char* name, void(*function)(void*), void* arg); void process_add(struct process** processes_list, struct process* process); void process_delete(struct process** processes_list, struct process* process); struct process* process_get_next(struct process* process); void process_exit(void); void process_display_list(struct process* processes_list); void process_create_user(struct limine_file* file, char* name); void process_fd_init(struct process* proc); int process_fd_alloc(struct process* proc, unsigned int drive_id, int fs_fd); int process_fd_get_fsfd(struct process* proc, int fd, unsigned int* drive_id, int* fs_fd); int process_fd_release(struct process* proc, int fd); #endif