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, ®ion) //获取全部空间
pmem_base = mmap(0, size, PROT_READ|PROT_WRITE, MAP_SHARED, pmem_fd, 0);//mmap操作
ioctl(pmem_fd, PMEM_GET_PHYS, ®ion) //获取物理地址
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 one process 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, ®ion1);
...
3. multiple references with one allocation in multiple processes
a think it's a little tricky
MemoryHeapBase
MemoryHeapBase :BnMemoryHeap
MemoryHeapPmem :MemoryHeapBase
MemoryHeapPmem ::MemoryPmem :BnMemory :BnInterface<IMemory>