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

来源:互联网 发布:计算器程序单片机 编辑:程序博客网 时间:2024/04/28 09:38

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

 

0. 代码路径

 

0.1 arch/x86/boot/header.s

                                                         |-->calllmain

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_RAM1

#define E820_RESERVED2

#define E820_ACPI3

#define E820_NVS4

#define E820_UNUSABLE5

 

 

1.2 E801探测

 

AX=0xE801H

 

int 0x15

 

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

 

1.3 88探测

 

AX=0x88H

 

int 0x15

 

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

 

原创粉丝点击