You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.0 KiB
49 lines
1.0 KiB
#pragma once
|
|
|
|
#include "src/kernel/fs.h"
|
|
#include "src/kernel/path.h"
|
|
#include "src/kernel/stream.h"
|
|
#include "src/lib/util.h"
|
|
|
|
#define USER_RFLAGS 0x202
|
|
|
|
#define MAX_FDS 16
|
|
|
|
typedef enum {
|
|
PROCESS_RUNNING,
|
|
PROCESS_WAITING,
|
|
PROCESS_ZOMBIE,
|
|
} process_state_t;
|
|
|
|
typedef struct process {
|
|
const struct process *parent;
|
|
uint64_t *pml4;
|
|
void *kernel_stack;
|
|
void *kernel_rsp;
|
|
void *user_stack;
|
|
void *user_rsp;
|
|
uint64_t pid;
|
|
process_state_t state;
|
|
uint64_t waiting_for;
|
|
const fs_node_t *root;
|
|
const path_t *cwd;
|
|
stream_t *fds[MAX_FDS];
|
|
uint64_t free_fd;
|
|
exit_code_t code;
|
|
} process_t;
|
|
|
|
typedef void (*app_t)(process_t *proc, uint8_t argc, char **argv);
|
|
|
|
extern process_t *current_process;
|
|
|
|
extern void process_trampoline();
|
|
|
|
process_t *process_create(const process_t *parent, const uint8_t *code, uint64_t size);
|
|
|
|
process_t *process_get(uint64_t pid);
|
|
|
|
extern void process_switch_to(void **save_rsp, void *new_rsp, void *new_pml4_phys);
|
|
|
|
void process_next();
|
|
|
|
void process_destroy(process_t *proc);
|
|
|