what is ION?
- ION 内存管理从android4.0开始被引入
- ION模块是可扩展的(API都是统一的),支持各种形式的内存分配方式,可以表述不同的硬件资源和他们的一些限制
- ION 支持连续与不连续内存的分配
- ION 给Kernel and User space processes提供了相应的APIs
当前支持的memory type
- ION_HEAP_TYPE_CARVEOUT - memory (PMEM style) for larger physically contiguous allocations
- ION_HEAP_TYPE_SYSTEM_CONTIG - physically contiguous for small physical allocations
- ION_HEAP_TYPE_SYSTEM - virtually contiguous but physically discontiguous memory
- ION_HEAP_TYPE_IOMMU - memory region allocated through IOMMU API.
ION heap 的大小根据每个设备自身的内存情况而定,但是都要实现下面的回调:
struct ion_heap_ops {
int (*allocate) (struct ion_heap *heap,
struct ion_buffer *buffer, unsigned long len,
unsigned long align, unsigned long 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);
struct scatterlist *(*map_dma) (struct ion_heap *heap,
struct ion_buffer *buffer);
v