Linux 2.6 内存管理源码分析(1)

Linux 2.6 内存管理源码分析(1) 初始化

 

0. 代码路径

 

0.1 arch/x86/boot/header.s

                                                         |-->calll main

0.2 arch/x86/boot/Main.c中void main()

                                                         |-->detect_memory().

0.3 arch/x86/boot/Memory.c中int detect_memory()

                                                         |-->detect_memory_e820()

                                                         |-->detect_memory_e801()

                                                         |-->detect_memory_88()

 

1. 内存探测

 

1.1 E820探测

 

方法得名于其使用的功能号即AX的值是0xE820H.

 

AX=0x820H

 

int 0x15.

 

通过设置EBX进行迭代获取所有的e820entry。

 

struct e820entry {

__u64 addr; /* start of memory segment */

__u64 size; /* size of memory segment */

__u32 type; /* type of memory segment */

} __attribute__((packed));

 

其中type的取值如下

 

#define E820_RAM 1

#define E820_RESERVED 2

#define E820_ACPI 3

#define E820_NVS 4

#define E820_UNUSABLE 5

 

 

1.2 E801探测

 

AX=0xE801H

 

int 0x15

 

方法将返回1K块的方式返回1M到16M之间的内存,以64K块的方式返回16M之上的内存大小。

 

1.3 88探测

 

AX=0x88H

 

int 0x15

 

方法返回起始于绝对地址0x100000h的内存大小。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值