pmem杂记

来源:互联网 发布:js添加css3动画 编辑:程序博客网 时间:2024/06/01 07:16

froyo:

drivers/misc/pmem.c

frameworks/base/libs/binder:

 

这是一个简单的使用:

pmem_fd = open("/dev/pmem_adsp", O_RDWR, 0);//打开设备,为了操作硬件引擎,要noncache的
ioctl(pmem_fd, PMEM_GET_TOTAL_SIZE, &region)  //获取全部空间

pmem_base = mmap(0, size, PROT_READ|PROT_WRITE, MAP_SHARED, pmem_fd, 0);//mmap操作

ioctl(pmem_fd, PMEM_GET_PHYS, &region) //获取物理地址

munmap

 

考虑使用PMEM_CONNECT的话,有
1。 multiple references with multiple allocations

fd0 = open("/dev/pmem_xxx", ...)

mmap();

...

fd1 = open("/dev/pmem_xxx", ...)

mmap();

 

2。 multiple references with one allocation in oneprocess or one process group

 

fd0 = open("/dev/pmem_xxx", ...)

mmap();

...

 

fd1 = open("/dev/pmem_xxx", ...);

ret = ioctl(fd1, PMEM_CONNECT, fd0);

if (ret != 0) goto error;

struct pmem_region region1 = { offset1, size1 };

ret = ioctl(fd1, PMEM_MAP, &region1);

...

 

3. multiple references with one allocation inmultiple processes

a think it's a little tricky 

 

 

 

MemoryHeapBase

MemoryHeapBase :BnMemoryHeap

 

MemoryHeapPmem :MemoryHeapBase

MemoryHeapPmem ::MemoryPmem :BnMemory :BnInterface<IMemory>