1 #include <lunaix/mm/region.h>
2 #include <lunaix/mm/kalloc.h>
3 #include <lunaix/process.h>
5 void region_add(struct proc_info* proc,unsigned long start, unsigned long end, unsigned int attr) {
6 struct mm_region* region = lxmalloc(sizeof(struct mm_region));
8 *region = (struct mm_region) {
14 if (!proc->mm.regions) {
15 llist_init_head(®ion->head);
16 proc->mm.regions = region;
19 llist_append(&proc->mm.regions->head, ®ion->head);
23 void region_release_all(struct proc_info* proc) {
24 struct mm_region* head = proc->mm.regions;
25 struct mm_region *pos, *n;
27 llist_for_each(pos, n, &head->head, head) {
31 proc->mm.regions = NULL;
34 struct mm_region* region_get(struct proc_info* proc, unsigned long vaddr) {
35 struct mm_region* head = proc->mm.regions;
41 struct mm_region *pos, *n;
43 llist_for_each(pos, n, &head->head, head) {
44 if (vaddr >= pos->start && vaddr < pos->end) {