Page 1 of 1
Grub and RAMFS (initrd)
Posted: Sat Sep 04, 2010 12:17 pm
by narke
Hello,
I'm trying to get a RAMFS for my kernel.
I load my ramfs's content as a Grub module.
But the issue is that the RAMFS data get corrupted because it's loaded in between the kernel start and the kernel end addresses.
Maybe it's a problem related with the memory manager which allocates pages.
Kernel start address: 0x201000
Kernel end address: 0x21b000
RAMFS start address: 0x20d000
RAMFS end address: 0x20d081
The code is here:
http://versatile.git.sourceforge.net/gi ... -index.cgi
Can someone point out where is the problem?
Thank you.
Re: Grub and RAMFS (initrd)
Posted: Sat Sep 04, 2010 3:46 pm
by gerryg400
Code: Select all
/** Physical pages descriptors array's address */
#define PAGE_DESCRIPTORS_ARRAY_ADDRESS \
PAGE_ALIGN_UPPER_ADDRESS((uint32) (& __e_kernel))
then later ...
Code: Select all
*out_kernel_top = PAGE_DESCRIPTORS_ARRAY_ADDRESS
+ PAGE_ALIGN_UPPER_ADDRESS( (arg_ram_size >> X86_PAGE_SHIFT)
* sizeof(struct physical_page_descriptor));
You are putting your page descriptor array right after your kernel and overwriting the ramfs.
Re: Grub and RAMFS (initrd)
Posted: Sat Sep 04, 2010 5:58 pm
by narke
Thank for your response but the RAMFS isn't placed after the kernel but between the start address and the end address of the kernel.
That's why I am confused.
Re: Grub and RAMFS (initrd)
Posted: Sat Sep 04, 2010 6:37 pm
by gerryg400
narke wrote:Thank for your response but the RAMFS isn't placed after the kernel but between the start address and the end address of the kernel.
That's why I am confused.
Look at how you are calculating the end address of the kernel. Try printing & __e_kernel, PAGE_DESCRIPTORS_ARRAY_ADDRESS and out_kernel_top and you will see the answer.
EDIT: To be more specific, the RAMFS is being placed after the kernel, but then you are putting the PAGE_DESCRIPTORS_ARRAY_ADDRESS at the end of the kernel. This means that the PAGE_DESCRIPTORS_ARRAY_ADDRESS and the RAMFS are at the same place and one overwites the other. The code that returns the out_kernel_top is returning the end of PAGE_DESCRIPTORS_ARRAY_ADDRESS array, NOT the end of kernel.
Re: Grub and RAMFS (initrd)
Posted: Sun Sep 05, 2010 4:43 pm
by narke
You got it right, now I am able to read the correct number of files that are present in the RAMFS passed as a module to the kernel.
Now I place the PAGE_DESCRIPTORS_ARRAY_ADDRESS after the RAMSFS end address.
Many thanks
Re: Grub and RAMFS (initrd)
Posted: Sun Sep 05, 2010 5:00 pm
by gerryg400
narke wrote:You got it right, now I am able to read the correct number of files that are present in the RAMFS passed as a module to the kernel.
Now I place the PAGE_DESCRIPTORS_ARRAY_ADDRESS after the RAMSFS end address.
Many thanks
Actually it was easy to spot the bug because your physical memory manager is
very similar to mine. It took less than 5 mins of browsing the source tree. It's interesting that we have a similar implementation.