对linux预留内存的理解
linux的预留(保留)内存一般是通过3中方式去实现的,分为两类,一种是通过在boot kernel的时候由boot kernel传递bootcmd参数来实现,其依赖与’mem’节点的设置。另一类是设备树的方式来定义预留内存,而设备树又是通过设置
/memreserve/以及
reserved-memory这两种属性来设置预留内存的。
1 memreserve
/memreserve/这种方式当前使用的比较少,在xilinx 6.10内核上可以看到有下面这些板卡在使用/memreserve/去定义和声明预留内存。
./arch/arm64/boot/dts/broadcom/northstar2/ns2.dtsi:33:/memreserve/ 0x81000000 0x00200000;
./arch/arm64/boot/dts/toshiba/tmpv7708.dtsi:14:/memreserve/ 0x81000000 0x00300000; /* cpu-release-addr */
./arch/arm64/boot/dts/realtek/rtd139x.dtsi:8:/memreserve/ 0x0000000000000000 0x000000000002f000;
./arch/arm64/boot/dts/realtek/rtd139x.dtsi:9:/memreserve/ 0x000000000002f000 0x00000000000d1000;
./arch/arm64/boot/dts/realtek/rtd129x.dtsi:8:/memreserve/ 0x0000000000000000 0x000000000001f000;
./arch/arm64/boot/dts/realtek/rtd129x.dtsi:9:/memreserve/ 0x000000000001f000 0x00000000000e1000;
./arch/arm64/boot/dts/realtek/rtd129x.dtsi:10:/memreserve/ 0x0000000001b00000 0x00000000004be000;
./arch/arm64/boot/dts/freescale/s32v234.dtsi:9:/memreserve/ 0x80000000 0x00010000;
./arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi:12:/memreserve/ 0x80000000 0x00010000;
./arch/arm64/boot/dts/arm/foundation-v8.dtsi:12:/memreserve/ 0x80000000 0x00010000;
./arch/arm64/boot/dts/arm/rtsm_ve-aemv8a.dts:15:/memreserve/ 0x80000000 0x00010000;
./arch/arm64/boot/dts/arm/fvp-base-revc.dts:15:/memreserve/ 0x80000000 0x00010000;
2 reserved-memory
2.1 description
Reserved memory is specified as a node under the /reserved-memory node. The operating system shall exclude reserved memory from normal usage one can create child nodes describing particular reserved (excluded from normal use)
memory regions. Such memory regions are usually designed for the special usage by various device drivers.
Each child of the reserved-memory node specifies one or more regions of reserved memory. Each child node may either use a ‘reg’ property to specify a specific range of reserved memory, or a ‘size’ property with optional constraints to request a dynamically allocated block of memory.
Following the generic-names recommended practice, node names should reflect the purpose of the node (ie. “framebuffer” or “dma-pool”). Unit address (@
) should be appended to the name if the node is a static allocation.2.2 properties
2.2.1 size
description:
minItems: 1
maxItems: 2
Length based on parent's \#size-cells. Size in bytes of memory to
reserve.
2.2.2 alloc-ranges
description:
Address and Length pairs. Specifies regions of memory that are
acceptable to allocate from.
2.2.3 no-map
type: boolean
description: >
Indicates the operating system must not create a virtual mapping
of the region as part of its standard mapping of system memory,
nor permit speculative access to it under any circumstances other
than under the control of the device driver using the re




被折叠的 条评论
为什么被折叠?



