*参照元 [#nf6e140c] #backlinks *説明 [#t05467ca] -パス: [[linux-4.4.1/drivers/staging/android/ion/ion_heap.c]] -FIXME: これは何? --説明 **引数 [#r2d5f0f8] -struct ion_heap *heap -- --[[linux-4.4.1/ion_heap]] -struct ion_buffer *buffer -- --[[linux-4.4.1/ion_buffer]] **返り値 [#dc871c4d] -void * -- **参考 [#ta113385] *実装 [#ufa8a7d2] void *ion_heap_map_kernel(struct ion_heap *heap, struct ion_buffer *buffer) { struct scatterlist *sg; int i, j; void *vaddr; pgprot_t pgprot; struct sg_table *table = buffer->sg_table; int npages = PAGE_ALIGN(buffer->size) / PAGE_SIZE; struct page **pages = vmalloc(sizeof(struct page *) * npages); struct page **tmp = pages; - --[[linux-4.4.1/scatterlist]] --[[linux-4.4.1/pgprot_t]] --[[linux-4.4.1/sg_table]] --[[linux-4.4.1/PAGE_ALIGN()]] --[[linux-4.4.1/PAGE_SIZE]] --[[linux-4.4.1/page]] --[[linux-4.4.1/vmalloc()]] if (!pages) return NULL; if (buffer->flags & ION_FLAG_CACHED) pgprot = PAGE_KERNEL; else pgprot = pgprot_writecombine(PAGE_KERNEL); - --[[linux-4.4.1/PAGE_KERNEL]] --[[linux-4.4.1/ION_FLAG_CACHED]] --[[linux-4.4.1/pgprot_writecombine()]] for_each_sg(table->sgl, sg, table->nents, i) { int npages_this_entry = PAGE_ALIGN(sg->length) / PAGE_SIZE; struct page *page = sg_page(sg); - --[[linux-4.4.1/for_each_sg()]] --[[linux-4.4.1/sg_page()]] BUG_ON(i >= npages); for (j = 0; j < npages_this_entry; j++) *(tmp++) = page++; - --[[linux-4.4.1/BUG_ON()]] } vaddr = vmap(pages, npages, VM_MAP, pgprot); vfree(pages); - --[[linux-4.4.1/vmap()]] --[[linux-4.4.1/vfree()]] if (!vaddr) return ERR_PTR(-ENOMEM); - --[[linux-4.4.1/ERR_PTR()]] return vaddr; } *コメント [#c8f24fbf]