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的内存大小。