예제 #1
0
static inline struct ggtt_entry *
ggtt_entry_next(struct ggtt_entry *entry)
{
   if (!entry)
      return NULL;
   struct rb_node *node = rb_node_next(&entry->node);
   if (!node)
      return NULL;
   return rb_node_data(struct ggtt_entry, node, node);
}
예제 #2
0
파일: vmm.c 프로젝트: korepwx/pcore
static void check_vma_struct(void) {
  ProcVM *mm = vm_create_proc();
  assert(mm != NULL);

  int step1 = 10, step2 = step1 * 10;

  int i;
  for (i = step1; i >= 1; i --) {
    ProcVMA *vma = vm_create_vma(i * 5, i * 5 + 2, 0);
    assert(vma != NULL);
    vm_insert_vma(mm, vma);
  }

  for (i = step1 + 1; i <= step2; i ++) {
    ProcVMA *vma = vm_create_vma(i * 5, i * 5 + 2, 0);
    assert(vma != NULL);
    vm_insert_vma(mm, vma);
  }

  RBNode *rbn = rb_leftmost(&(mm->mmap_root));

  for (i = 1; i <= step2; i ++) {
    assert(rbn != NULL);
    ProcVMA *mmap = rbn2vma(rbn, vm_link);
    assert(mmap->vm_start == i * 5 && mmap->vm_end == i * 5 + 2);
    rbn = rb_node_next(&(mm->mmap_root), rbn);
  }

  for (i = 5; i <= 5 * step2; i += 5) {
    ProcVMA *vma1 = vm_find_vma(mm, i);
    assert(vma1 != NULL);
    ProcVMA *vma2 = vm_find_vma(mm, i+1);
    assert(vma2 != NULL);
    ProcVMA *vma3 = vm_find_vma(mm, i+2);
    assert(vma3 == NULL);
    ProcVMA *vma4 = vm_find_vma(mm, i+3);
    assert(vma4 == NULL);
    ProcVMA *vma5 = vm_find_vma(mm, i+4);
    assert(vma5 == NULL);

    assert(vma1->vm_start == i && vma1->vm_end == i + 2);
    assert(vma2->vm_start == i && vma2->vm_end == i + 2);
  }

  for (i =4; i>=0; i--) {
    ProcVMA *vma_below_5 = vm_find_vma(mm,i);
    assert(vma_below_5 == NULL);
  }

  vm_destroy_proc(mm);
  printf("[vmm] Passes check_vma_struct test.\n");
}
예제 #3
0
파일: vmm.c 프로젝트: korepwx/pcore
static void print_vma_struct(ProcVM *proc) {
  // Find the left-most node.
  RBNode *start = rb_leftmost(&(proc->mmap_root));
  
  // Print every node.
  for (; start != NULL;) {
    ProcVMA *vma = rbn2vma(start, vm_link);
    printf("VMA start=%08u, end=%08u\n", vma->vm_start, vma->vm_end);
    start = rb_node_next(&(proc->mmap_root), start);
  }
  
  kfree(proc);
}
예제 #4
0
파일: vmm.c 프로젝트: korepwx/pcore
void vm_destroy_proc(ProcVM *proc)
{
  kassert(vm_get_proc_count(proc) == 0);
  
  // Find the left-most node.
  RBNode *start = rb_leftmost(&(proc->mmap_root));
  
  // Destroy every node.
  for (; start != NULL;) {
    RBNode *right = rb_node_next(&(proc->mmap_root), start);
    kfree(rbn2vma(start, vm_link));
    start = right;
  }
  
  kfree(proc);
}
예제 #5
0
파일: vmm.c 프로젝트: korepwx/pcore
void vm_insert_vma(ProcVM *proc, ProcVMA *vma) {
  kassert(vma->vm_start < vma->vm_end);
  rb_insert(&(proc->mmap_root), &(vma->vm_link));
  
#if defined(__PCORE_NO_OPTIMIZE__)
  // Check overlap.
  RBNode *x = rb_search(&(proc->mmap_root), vma_key_compare, &(vma->vm_start));
  kassert(x != NULL);
  
  RBNode *y = rb_node_prev(&(proc->mmap_root), x);
  if (y != NULL) {
    vma_check_overlap(rbn2vma(y, vm_link), vma);
  }
  
  y = rb_node_next(&(proc->mmap_root), x);
  if (y != NULL) {
    vma_check_overlap(vma, rbn2vma(y, vm_link));
  }
#endif  // __PCORE_NO_OPTIMIZE__
  atomic_add(&(proc->map_count), 1);
}