Linux kernel boot to retain large memory method summary

  

Searched on the Internet for a long time, only slowly understand the method of retaining memory at boot, now summarize the learning process at this stage! (I am experimenting on the arm board, the kernel version is 2.6.38)

There are three ways to reserve memory at boot:

1. reserve_bootmem(addr,size, Flag)

This method, I have not succeeded in doing experiments …

If there is success, I hope the message of God, ask for guidance!

2. alloc_bootmem(size)

In fact, it is relatively simple, in int/main.c:

//Set global variable

char * reserve_memory;

EXPORT_SYMBOL_GPL(reserve_memory);

void __init start_kernel()

{


trap_init();

//Add code here, keep 40M of memory in the zone

reserve_memory=alloc_bootmem(0x2800000);

mem_init();


}

But after getting reserve_memory in the kernel, how to map to kernel space, there is no clue and …

Someone said on the Internet,

With the address returned by allco_bootmem,

In the kernel mode, find the task_struct to use this memory;

and then force the page table to be created;

If there is a god Understand this sentence, or better mapping method, please leave a message, thank you!

3. Set Linux kernel parameters at boot time

mem=180M /* Only 180M memory space is given to the system when booting, and the rest are reserved*/

Simple, but when set up and used, it needs to be compatible with the physical size of the hardware memory.

In the kernel driver, you can map to kernel space in the form of ioremap(), or mmap() to read and write in user space.

Copyright © Windows knowledge All Rights Reserved