Android PMEM驱动研究(1)——如何将PMEM编入内核
PMEM并不像Ashmem和binder那样,选中就可以被Android系统使用,他是一个platform设备,需要注册才可以使用。
下面以S3C6410为例,描述使用流程:
1)选中内核选项
Device Drivers --->
[*] Misc devices --->
[*] Android pmem allocator
2)修改你的dev.c注册文件,添加如下内容:
#ifdef CONFIG_ANDROID_PMEM
static struct android_pmem_platform_data android_pmem_pdata = {
.name = "pmem",
.start = PMEM_BASE,
.size = PMEM_BASE_SIZE,
.no_allocator = 1,
.cached = 1,
};
static struct android_pmem_platform_data android_pmem_adsp_pdata = {
.name = "pmem_adsp",
.start = PMEM_ADSP_BASE,
.size = PMEM_ADSP_BASE_SIZE,
.no_allocator = 0,
.cached = 0,
};
struct platform_device android_pmem_device = {
.name = "android_pmem",
.id = 0,
.dev = { .platform_data = &android_pmem_pdata },
};
struct platform_device android_pmem_adsp_device = {
.name = "android_pmem",
.id = 1,
.dev = { .platform_data = &android_pmem_adsp_pdata },
};
#endif
3)在驱动注册列表中添加如下内容:
static struct platform_device *smdk6410_devices[] __initdata = {
#ifdef CONFIG_ANDROID_PMEM
&android_pmem_device,
&android_pmem_adsp_device,
#endif
};
4)分配物理地址我用了128MB的最后8MB
#define PMEM_BASE 0x57900000
#define PMEM_BASE_SIZE SZ_1M*4
#define PMEM_ADSP_BASE 0x57c00000
#define PMEM_ADSP_BASE_SIZE SZ_1M*4
5)重新编译内核
6)修改bootargs 减少Linux可管理的MEM
MEM=120MB
7)重新启动系统
启动信息:
pmem: 1 init
pmem_adsp: 0 init
8)查看dev目录,多了pmem和pmem_adsp
阅读(766) | 评论(0) | 转发(0) |