diff options
author | Ian Moffett <ian@osmora.org> | 2025-09-19 23:29:18 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-09-19 23:29:18 -0400 |
commit | 50e1b103669a334d31bb27d7d858400c7a12e29e (patch) | |
tree | 6459d4bbfd32157be8b62ad64bd01a2a2916c395 /src/sys/include | |
parent | 69933fc75a701502f06fc30680fa6fa1f13b5ebb (diff) |
kern: proc: Keep track of mapped areas with ranges
This commit adds a virtual memory range queue to the process descriptor
in order to keep track of mapped pages and free their respective frames
upon program exit.
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'src/sys/include')
-rw-r--r-- | src/sys/include/sys/proc.h | 18 | ||||
-rw-r--r-- | src/sys/include/vm/vm.h | 16 |
2 files changed, 34 insertions, 0 deletions
diff --git a/src/sys/include/sys/proc.h b/src/sys/include/sys/proc.h index 200d5ce..cf00850 100644 --- a/src/sys/include/sys/proc.h +++ b/src/sys/include/sys/proc.h @@ -35,6 +35,7 @@ #include <sys/cdefs.h> #include <sys/param.h> #include <sys/queue.h> +#include <vm/vm.h> #include <machine/pcb.h> /* standard */ /* @@ -52,6 +53,7 @@ * @flags: State flags (see PROC_*) * @pcb: Process control block * @scdom: Syscall domain + * @maplist: List of mapped regions * @link: TAILQ link */ struct proc { @@ -59,6 +61,7 @@ struct proc { uint32_t flags; struct md_pcb pcb; struct syscall_domain scdom; + TAILQ_HEAD(, vm_range) maplist; TAILQ_ENTRY(proc) link; }; @@ -83,6 +86,21 @@ int proc_init(struct proc *procp, int flags); struct proc *proc_self(void); /* + * Allocate a range descriptor and add it to the + * process's range tracking list for cleanup upon + * exit. + * + * @procp: Process to initialize the range of + * @va: Virtual address to use + * @pa: Physical address to use + * @len: Length to use + * + * Returns zero on success, otherwise a less than + * zero value upon error. + */ +int proc_add_range(struct proc *procp, vaddr_t va, paddr_t pa, size_t len); + +/* * Kill a process with a specific status code * * @procp: Process to kill diff --git a/src/sys/include/vm/vm.h b/src/sys/include/vm/vm.h index 790fe0b..f5f7b16 100644 --- a/src/sys/include/vm/vm.h +++ b/src/sys/include/vm/vm.h @@ -31,6 +31,7 @@ #define _VM_H_ 1 #include <sys/types.h> +#include <sys/queue.h> #include <sys/bootvars.h> #define VM_HIGHER_HALF (get_kernel_base()) @@ -42,6 +43,21 @@ typedef uintptr_t vaddr_t; typedef uintptr_t paddr_t; +/* + * Describes a virtual memory range + * + * @pa_base: Physical memory base + * @va_base: Virtual memory base + * @len: Length of region + * @link: Queue link + */ +struct vm_range { + paddr_t pa_base; + vaddr_t va_base; + size_t len; + TAILQ_ENTRY(vm_range) link; +}; + void vm_init(void); #endif /* !_VM_H_ */ |