基于64位ARMv8的一些AP芯片,支持32位和64位代码之间无缝运行(比如有芯片在用CortexA53 OCTA core)。
以之前做过的项目为例,说明64位芯片的寄存器,以及说明在64为模式下的内存地址表示和整个Linux系统的Memory Map。
以下是整个物理内存块的大小-起始地址,这个项目的内存地址是2GB。
ATAG_MEM: 4 54410002 20000000 40000000 //大小为20000000,开始地址为40000000 以此类推
ATAG_MEM: 4 54410002 20000000 60000000
ATAG_MEM: 4 54410002 20000000 80000000
ATAG_MEM: 4 54410002 1EE00000 A0000000
项目的reserve memory,定义如下:
/memreserve/ 0xBEE00000 0x1200000; /* EL3 monitor, secure intepreter */
/memreserve/ 0xB0000000 0x7800000; /* CP memory(128MB) + AP-CP shared memory(8MB) */
/ {
memory@40000000 {
device_type = "memory";
reg = <0x0 0x40000000 0x0 0x80000000>;
};
reserved-memory {
#address-cells = <2>;
#size-cells = <2>;
ranges;
fimc_is_fd_reserved: fimc_is_fd {
compatible = "fd-lib-shmem";
reg = <0x0 0xbe200000 0x0 0x100000>;
};
common {
compatible = "exynos5433-ion,common";
reg = <0x0 0xbdc00000 0x0 0x600000>;
id = <0>;
};
video {
compatible = "exynos5433-ion,video";
secure;
reusable;
reg = <0x0 0xb8400000 0x0 0x5800000>;
id = <11>;
compat-id = <4 5 6 7>;
};
video_ext {
compatible = "exynos5433-ion,video_ext";
secure;
reusable;
reg = <0x0 0xaec00000 0x0 0x1400000>;
id = <1>;
};
mfc_nfw {
compatible = "exynos5433-ion,mfc_nfw";
reg = <0x0 0xb8200000 0x0 0x110000>;
id = <12>;
};
mfc_fw {
compatible = "exynos5433-ion,mfc_fw";
secure;
reg = <0x0 0xb8000000 0x0 0x200000>;
id = <8>;
};
secdma {
compatible = "exynos5433-ion,secdma";
size = <0 0x20000>;
alignment = <0 0x10000>;
id = <13>;
};
};
};
modem的reserve memory范围:
/ {
/* over-riding shared memory reserved map */
/* DRAM 2GB + CP reserved map 116+4MB */
shmem: shmem@0xB0000000 {
reg = <0x0 0xB0000000 0x0 0x7800000>;
shmem,ipc_offset = <0x7400000>;
shmem,ipc_size = <0x400000>;
};
};
这些部分在哪里读取以及怎么设置需要再仔细分析。先来看一下输出的log。
<6>[0.000000][0:swapper:0] fimc_is_fd reserved memory: fimc_is_fd=0x100000@0x00000000be200000
<7>[0.000000][0:swapper:0] [@][FD] vaddr: 0xffffffc07e200000
<6>[0.000000][0:swapper:0] Reserved memory[1]: common:0x600000
<6>[0.000000][0:swapper:0] Reserved memory: initialized node common, compatible id exynos5433-ion,common
<6>[0.000000][0:swapper:0] cma: CMA: reserved 88 MiB at b8400000
<6>[0.000000][0:swapper:0] CMA memory[12]: video:0x5800000
<6>[0.000000][0:swapper:0] Reserved memory: initialized node video, compatible id exynos5433-ion,video
<6>[0.000000][0:swapper:0] cma: CMA: reserved 20 MiB at aec00000
<6>[0.000000][0:swapper:0] CMA memory[2]: video_ext:0x1400000
<6>[0.000000][0:swapper:0] Reserved memory: initialized node video_ext, compatible id exynos5433-ion,video_ext
<6>[0.000000][0:swapper:0] Reserved memory[13]: mfc_nfw:0x110000
<6>[0.000000][0:swapper:0] Reserved memory: initialized node mfc_nfw, compatible id exynos5433-ion,mfc_nfw
<6>[0.000000][0:swapper:0] Reserved memory[9]: mfc_fw:0x200000
<6>[0.000000][0:swapper:0] Reserved memory: initialized node mfc_fw, compatible id exynos5433-ion,mfc_fw
<6>[0.000000][0:swapper:0] Reserved memory[14]: secdma:0x20000
<6>[0.000000][0:swapper:0] Reserved memory: initialized node secdma, compatible id exynos5433-ion,secdma
Virtual kernel memory layout如下:
<6>[0.000000][0:swapper:0] Memory: 2030MB = 2030MB total
<5>[0.000000][0:swapper:0] Memory: 1754160k/1754160k available, 324560k reserved
<5>[0.000000][0:swapper:0] Virtual kernel memory layout:
<5>[0.000000][0:swapper:0] vmalloc : 0xffffff8000000000 - 0xffffffbbffff0000 (245759 MB)
<5>[0.000000][0:swapper:0] vmemmap : 0xffffffbc00e00000 - 0xffffffbc029c1000 ( 27 MB)
<5>[0.000000][0:swapper:0] modules : 0xffffffbffc000000 - 0xffffffc000000000 ( 64 MB)
<5>[0.000000][0:swapper:0] memory : 0xffffffc000000000 - 0xffffffc07ee00000 ( 2030 MB)
<5>[0.000000][0:swapper:0] .init : 0xffffffc000cf8000 - 0xffffffc000da42c0 ( 689 kB)
<5>[0.000000][0:swapper:0] .text : 0xffffffc000205000 - 0xffffffc000cf8000 ( 11212 kB)
//Starting kernel at 0x40205000... 对应的虚拟内存是0xffffffc000205000
<5>[0.000000][0:swapper:0] .data : 0xffffffc000da5000 - 0xffffffc000ea8140 ( 1037 kB)
ion memory配置错误会导致panic,比如:
<1>[0.833825] [0:swapper/0:1] Unable to handle kernel paging request at virtual address ffffffc07f000000
<1>[0.833864] [0:swapper/0:1] pgd = ffffffc000202000
<1>[0.833898] [0:swapper/0:1] [ffffffc07f000000] *pgd=000000007ffff003, *pmd=0000000000000000
<4>[0.834028] [0:swapper/0:1] ------------[ cut here ]------------
<2>[0.834062] [0swapper/0: 1] Kernel BUG at ffffffc0002175fc [verbose debug info unavailable]
paging request错误的地址为ffffffc07f000000。算一下对应的物理地址是0xbf000000。但看一下atag信息,物理地址最大不能超过0xbee00000(ATAG_MEM: 4 54410002 1EE00000 A0000000)。看一下ion memory的配置,发现如下配置,改一下起始地址,保证不要超过物理地址范围即可:
reserved-memory {
...
common {
compatible = "exynos5433-ion,common";
reg = <0x0 0xbf000000 0x0 0x600000>;
id = <0>;
};
...
}