Page 1 of 1

Ramdrive address

Posted: Tue Feb 23, 2021 7:18 am
by Robert
Hi!

How can I set the ramdrive's memory address?
Using QEMU without grub or grub on an actual machine.

Re: Ramdrive address

Posted: Tue Feb 23, 2021 8:48 am
by iansjack
What ramdrive are you talking about?

Re: Ramdrive address

Posted: Tue Feb 23, 2021 9:02 am
by Robert
iansjack wrote:What ramdrive are you talking about?
I'm developing my own OS and it is an initrd-like ramdrive.

Re: Ramdrive address

Posted: Tue Feb 23, 2021 9:58 am
by bzt
Robert wrote:Hi!

How can I set the ramdrive's memory address?
Using QEMU without grub or grub on an actual machine.
If I'm guessing right, you're using GRUB's module feature to load the ramdisk. In that case you cannot set the address, you must query it dynamically from GRUB's structures. First, get mods_addr from multiboot_info, and use it as a pointer to multiboot_module_t. Then from that struct, get mod_start, that will be your ramdisk's address (assuming your have only one module and that's your ramdisk).

Code: Select all

uint32_t ramdisk_addr = ((multiboot_module_t*)multiboot_info.mods_addr)->mod_start;
I also load the ramdisk as a GRUB module in my boot loader (that is, if you use it in Multiboot compatibility mode), here's the source (Assembly).

Cheers,
bzt

Re: Ramdrive address

Posted: Wed Feb 24, 2021 5:40 am
by Robert
Set the address, not get. I wanted to load the image to a fixed address, no matter how large is the kernel image. But I solved the issue another way (memory reordering).

Re: Ramdrive address

Posted: Wed Feb 24, 2021 11:18 am
by austanss
Robert wrote:Set the address, not get. I wanted to load the image to a fixed address, no matter how large is the kernel image. But I solved the issue another way (memory reordering).
Then simply map the ramdrive addresses to a specific address in virtual address space.