int ion_alloc(int fd, size_t len, size_t align, unsigned int heap_mask, unsigned int flags, ion_user_handle_t *handle); int ion_alloc_fd(int fd, size_t len, size_t align, unsigned int heap_mask, unsigned int flags, int *handle_fd); int ion_sync_fd(int fd, int handle_fd)...
fd =ion_alloc(mIonClient, size,0, ION_HEAP_SYSTEM_MASK, ION_FLAG_CACHED | ION_FLAG_CACHED_NEEDS_SYNC | ION_FLAG_PRESERVE_KMAP); } } }else{ fd =ion_alloc(mIonClient, size,0, ION_HEAP_SYSTEM_MASK, ION_FLAG_CACHED | ION_FLAG_CACHED_NEEDS_SYNC | ION_FLAG_PRESERVE_KMAP); ALOGD("...
int ion_alloc(int fd, size_t len, size_t align, unsigned int heap_mask, unsigned int flags, ion_user_handle_t *handle); int ion_alloc_fd(int fd, size_t len, size_t align, unsigned int heap_mask, unsigned int flags, int *handle_fd); int ion_sync_fd(int fd, int handle_fd)...
可以看到调用了ion_alloc_fd函数产生了一个fd,ion_alloc_fd函数有三个参数,第一个参数时分配的buffer长度,第二个时heap的选择,ion中有很多heap类型,本文只将system heap(其他heap 代码看起来比较难),第三个参数时标志位,在分配buffer的时候还有很多属性通过这个标志位来判断,比如分配的是否时camer内存,是否需要安全...
->alloc_pages() ->ion_buffer_add(dev, buffer); ->dmabuf = dma_buf_export(&exp_info); ->fd = dma_buf_fd(dmabuf, O_CLOEXEC); ion memory释放 ion_system_heap_free(struct ion_buffer *buffer) ->ion_heap_buffer_zero ->free_buffer_page(sys_heap, buffer, sg_page(sg)); ...
fd = open("/dev/ion") // 打开文件设备 "/dev/ion" ioctl(fd, ION_IOC_ALLOC, alloc_data) //分配内存 ioctl(fd, ION_IOC_MAP/ION_IOC_SHARE, fd_data) //把buff映射为文件 mmap(fd_data.fd) // 将映射为文件的buffer,映射为内存地址 ...
ion_alloc函数: 从ion dev设备中查找用户想从哪个heap中分配内存 分配成功后,将ion_buffer转换并导出成dma_buf,再讲dma_buf转换成文件fd intion_alloc(size_tlen, unsignedintheap_id_mask, unsignedintflags) {struction_device *dev = internal_dev;struction_buffer *buffer = NULL;struction_heap *heap; ...
在client填充ion_allocatoin_data结构之后,就可以通过调用int ioctl(int client_fd, ION_IOC_ALLOC, struct ion_allocation_data *allocation_data)来allocate a buffer。这个调用介绍之后,分配的buffer会通过ion_allocatoin_data的handle来返回,但是CPU不可以访问这个buffer。这个handle只可以通过调用int ioctl(int ...
ion_fd = open("/dev/ion", O_ RDONLY | O_SYNC); ioctl(ion_fd, ION_IOC_ALLOC, alloc); alloc为struct ion_allocation_data,len是申请buffer的长度,flags是heap id。 [html]view plaincopy /** * struct ion_allocation_data - metadata passed from userspace for allocations ...
内核中ioctl调⽤ion_alloc函数进⾏分配:long ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg){ ...省略 union ion_ioctl_arg data;...省略 switch (cmd) { case ION_IOC_ALLOC:{ int fd;//调⽤ion_alloc,传⼊⽤户层参数。分配成功则返回dma_buf转换后的fd到⽤户层。f...