对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
上一篇: 动态规划-最少的硬币数目
下一篇: 动态规划-最长递增子序列
田园诗人之园
博客等级 码龄13年 7087粉丝 607原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值