static void allocate_co_memory(struct ion_platform_heap *heap, struct ion_platform_heap heap_data[], unsigned int nr_heaps) { struct ion_co_heap_pdata *co_heap_data = (struct ion_co_heap_pdata *) heap->extra_data; if (co_heap_data->adjacent_mem_id != INVALID_HEAP_ID) { struct ion_platform_heap *shared_heap = find_heap(heap_data, nr_heaps, co_heap_data->adjacent_mem_id); if (shared_heap) { } else { heap->base = msm_ion_get_base( heap->size + shared_heap->size, shared_heap->memory_type, co_heap_data->align); } if (heap->base) { shared_heap->base = heap->base + heap->size; } else { pr_err("%s: could not get memory for heap %s " "(id %x)\n", __func__, heap->name, heap->id); } } }
static void allocate_co_memory(struct ion_platform_heap *heap, struct ion_platform_heap heap_data[], unsigned int nr_heaps) { struct ion_co_heap_pdata *co_heap_data = (struct ion_co_heap_pdata *) heap->extra_data; if (co_heap_data->adjacent_mem_id != INVALID_HEAP_ID) { struct ion_platform_heap *shared_heap = find_heap(heap_data, nr_heaps, co_heap_data->adjacent_mem_id); if (shared_heap) { struct ion_cp_heap_pdata *cp_data = (struct ion_cp_heap_pdata *) shared_heap->extra_data; if (cp_data->fixed_position == FIXED_MIDDLE) { const struct fmem_data *fmem_info = fmem_get_info(); if (!fmem_info) { pr_err("fmem info pointer NULL!\n"); BUG(); } cp_data->virt_addr = fmem_info->virt; cp_data->secure_base = heap->base; cp_data->secure_size = heap->size + shared_heap->size; } else if (!heap->base) { ion_set_base_address(heap, shared_heap, co_heap_data, cp_data); } } } }
inline void deallocate(void* const ptr) throw() { heap* const h = find_heap(ptr); if (h) { if (h->deallocate()) { if (m_depth > m_max_depth) { destroy_heap(h); } } } else { std::free(ptr); } }
void BpMemoryHeap::assertMapped() const { if (mHeapId == -1) { sp<IBinder> binder(const_cast<BpMemoryHeap*>(this)->asBinder()); sp<BpMemoryHeap> heap(static_cast<BpMemoryHeap*>(find_heap(binder).get())); heap->assertReallyMapped(); if (heap->mBase != MAP_FAILED) { Mutex::Autolock _l(mLock); if (mHeapId == -1) { mBase = heap->mBase; mSize = heap->mSize; android_atomic_write( dup( heap->mHeapId ), &mHeapId ); } } else { // something went wrong free_heap(binder); } } }
static void allocate_co_memory(struct ion_platform_heap *heap, struct ion_platform_heap heap_data[], unsigned int nr_heaps) { struct ion_co_heap_pdata *co_heap_data = (struct ion_co_heap_pdata *) heap->extra_data; if (co_heap_data->adjacent_mem_id != INVALID_HEAP_ID) { struct ion_platform_heap *shared_heap = find_heap(heap_data, nr_heaps, co_heap_data->adjacent_mem_id); if (shared_heap) { struct ion_cp_heap_pdata *cp_data = (struct ion_cp_heap_pdata *) shared_heap->extra_data; if (cp_data->reusable) { const struct fmem_data *fmem_info = fmem_get_info(); heap->base = fmem_info->phys - fmem_info->reserved_size; cp_data->virt_addr = fmem_info->virt; pr_info("ION heap %s using FMEM\n", shared_heap->name); } else { heap->base = msm_ion_get_base( heap->size + shared_heap->size, shared_heap->memory_type, co_heap_data->align); } if (heap->base) { shared_heap->base = heap->base + heap->size; cp_data->secure_base = heap->base; cp_data->secure_size = heap->size + shared_heap->size; } else { pr_err("%s: could not get memory for heap %s " "(id %x)\n", __func__, heap->name, heap->id); } } } }
//Remove an arbitrary element, by value. //If there are multiple matches, this removes the first one it finds. //Returns number of items removed(either 0 or 1). OSCL_EXPORT_REF int OsclPriorityQueueBase::remove(const OsclAny* input) { //First find the element to remove OsclAny* pos = find_heap(input, pVec->begin(), pVec->end()); if (pos) { if (pVec->increment_T(pos, 1) == pVec->end()) { // It's the last element-- just remove it without any re-ordering. pVec->pop_back(); } else { // Move the element to the end & remove. pop_heap(pos, pVec->end()); pVec->pop_back(); // Re-order the front part of the queue. push_heap(pVec->begin(), pVec->increment_T(pos, 1)); } return 1; } return 0; }