/** * enum ion_heap_types - list of all possible types of heaps * @ION_HEAP_TYPE_SYSTEM: memory allocated via vmalloc * @ION_HEAP_TYPE_SYSTEM_CONTIG: memory allocated via kmalloc * @ION_HEAP_TYPE_CARVEOUT: memory allocated from a prereserved * carveout heap, allocations are physically * contiguous * @ION_HEAP_TYPE_DMA: memory allocated via DMA API * @ION_NUM_HEAPS: helper for iterating over heaps, a bit mask * is used to identify the heaps, so only 32 * total heap types are supported */ enumion_heap_type { ION_HEAP_TYPE_SYSTEM, ION_HEAP_TYPE_SYSTEM_CONTIG, ION_HEAP_TYPE_CARVEOUT, ION_HEAP_TYPE_CHUNK, ION_HEAP_TYPE_DMA, ION_HEAP_TYPE_CUSTOM, /* must be last so device specific heaps always are at the end of this enum */ ION_NUM_HEAPS = 16, };
ION_HEAP_TYPE_SYSTEM就是虚拟连续物理不连续的内存空间,come from vmalloc。
ION_HEAP_TYPE_SYSTEM_CONTIG就是物理连续内存空间,come from kmalloc。
/** * struct ion_heap_ops - ops to operate on a given heap * @allocate: allocate memory * @free: free memory. Will be called with * ION_PRIV_FLAG_SHRINKER_FREE set in buffer flags when * called from a shrinker. In that case, the pages being * free'd must be truly free'd back to the system, not put * in a page pool or otherwise cached. * @phys get physical address of a buffer (only define on * physically contiguous heaps) * @map_dma map the memory for dma to a scatterlist * @unmap_dma unmap the memory for dma * @map_kernel map memory to the kernel * @unmap_kernel unmap memory to the kernel * @map_user map memory to userspace * @unmap_user unmap memory to userspace * * allocate, phys, and map_user return 0 on success, -errno on error. * map_dma and map_kernel return pointer on success, ERR_PTR on * error. @free will be called with ION_PRIV_FLAG_SHRINKER_FREE set in * the buffer's private_flags when called from a shrinker. In that * case, the pages being free'd must be truly free'd back to the * system, not put in a page pool or otherwise cached. */ struction_heap_ops { int (*allocate)(struct ion_heap *heap, struct ion_buffer *buffer, unsignedlong len, unsignedlong align, unsignedlong flags); void (*free)(struct ion_buffer *buffer); int (*phys)(struct ion_heap *heap, struct ion_buffer *buffer, ion_phys_addr_t *addr, size_t *len); structsg_table * (*map_dma)(struction_heap *heap, struction_buffer *buffer); void (*unmap_dma)(struct ion_heap *heap, struct ion_buffer *buffer); void * (*map_kernel)(struct ion_heap *heap, struct ion_buffer *buffer); void (*unmap_kernel)(struct ion_heap *heap, struct ion_buffer *buffer); int (*map_user)(struct ion_heap *mapper, struct ion_buffer *buffer, struct vm_area_struct *vma); int (*shrink)(struct ion_heap *heap, gfp_t gfp_mask, int nr_to_scan); void (*unmap_user) (struct ion_heap *mapper, struct ion_buffer *buffer); int (*print_debug)(struct ion_heap *heap, struct seq_file *s, conststruct list_head *mem_map); };
/** * These are the only ids that should be used for Ion heap ids. * The ids listed are the order in which allocation will be attempted * if specified. Don't swap the order of heap ids unless you know what * you are doing! * Id's are spaced by purpose to allow new Id's to be inserted in-between (for * possible fallbacks) */
enum ion_heap_ids { INVALID_HEAP_ID = -1, ION_CP_MM_HEAP_ID = 8, ION_SECURE_HEAP_ID = 9, ION_SECURE_DISPLAY_HEAP_ID = 10, ION_CP_MFC_HEAP_ID = 12, ION_CP_WB_HEAP_ID = 16, /* 8660 only */ ION_CAMERA_HEAP_ID = 20, /* 8660 only */ ION_SYSTEM_CONTIG_HEAP_ID = 21, ION_ADSP_HEAP_ID = 22, ION_PIL1_HEAP_ID = 23, /* Currently used for other PIL images */ ION_SF_HEAP_ID = 24, ION_SYSTEM_HEAP_ID = 25, ION_PIL2_HEAP_ID = 26, /* Currently used for modem firmware images */ ION_QSECOM_HEAP_ID = 27, ION_AUDIO_HEAP_ID = 28,
ION_MM_FIRMWARE_HEAP_ID = 29,
ION_HEAP_ID_RESERVED = 31/** Bit reserved for ION_FLAG_SECURE flag */ };