6

I have tried to search this topic on google and this site but I can't find a proper answer.

I am trying to allocate a big continuous block of memory (a few MB) at a set physical address during the Linux booting process. But I am still not clear where I should place my "alloc_bootmem" function. I am running Linux on an ARM processor.

  1. AFAIK, there is a way to create a driver which contains a call to "alloc_bootmem" and then compile that driver directly to into the kernel.

  2. Another method is to add "alloc_bootmem" somewhere in the Linux kernel source.

  3. The last method that I think exists is to create a settings file like boot.rc?(not sure) so that during booting Linux will reserve the memory I want allocated.

If there is a clear way or a link to an answer to this question, I really would appreciate everyone's help. The basic question is "where should I call "alloc_bootmem" so it will work during booting?"

Thanks, Shahril

Benjamin Leinweber
  • 2,774
  • 1
  • 24
  • 41
Shahril
  • 65
  • 1
  • 7
  • If the "set" physical address is dictated by hardware, then there's a fourth method to ensure that the kernel never considers that memory as general purpose RAM. Have the bootloader (e.g. U-Boot) exclude this physical memory region from the memory list(s) provided to the kernel in the ATAGs (or DT) and/or kernel command line. Create a new ATAG (or DT entry) to pass this reserved memory resource to the device driver that will use it. A bit more detail is [here](http://stackoverflow.com/questions/11580285/pass-large-amount-of-binary-data-from-u-boot-to-linux-kernel/12137511#12137511). – sawdust Sep 04 '13 at 20:28

1 Answers1

2

Take a look at: http://lwn.net/Kernel/LDD3/ chapter 8 it explains the memory allocation for early booting stages.

Further information about booting memory allocation can be found here:

https://www.kernel.org/doc/gorman/html/understand/understand022.html

This feature is used for allocating large memory chunks during the system boot up and it uses the physical rather than virtual memory. After MMU is up and running there is no possible way of accessing the memory AFAIK

If you are looking for a large continues memory allocation you should probably use different allocator take a look at:

http://lwn.net/Articles/396702/

cerkiewny
  • 2,761
  • 18
  • 36