+void
+__heap_copied(struct mm_region* region)
+{
+ mm_index((void**)®ion->proc_vms->heap, region);
+}
+
+int
+create_heap(struct proc_mm* pvms, ptr_t addr)
+{
+ struct mmap_param map_param = { .pvms = pvms,
+ .vms_mnt = VMS_SELF,
+ .flags = MAP_ANON | MAP_PRIVATE,
+ .type = REGION_TYPE_HEAP,
+ .proct = PROT_READ | PROT_WRITE,
+ .mlen = PAGE_SIZE };
+ int status = 0;
+ struct mm_region* heap;
+ if ((status = mmap_user(NULL, &heap, addr, NULL, &map_param))) {
+ return status;
+ }
+
+ heap->region_copied = __heap_copied;
+ mm_index((void**)&pvms->heap, heap);
+
+ return status;
+}
+