Ramdrive address

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
Robert
Member
Member
Posts: 25
Joined: Wed Jan 13, 2021 8:49 am

Ramdrive address

Post by Robert »

Hi!

How can I set the ramdrive's memory address?
Using QEMU without grub or grub on an actual machine.
User avatar
iansjack
Member
Member
Posts: 4703
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Ramdrive address

Post by iansjack »

What ramdrive are you talking about?
User avatar
Robert
Member
Member
Posts: 25
Joined: Wed Jan 13, 2021 8:49 am

Re: Ramdrive address

Post by Robert »

iansjack wrote:What ramdrive are you talking about?
I'm developing my own OS and it is an initrd-like ramdrive.
User avatar
bzt
Member
Member
Posts: 1584
Joined: Thu Oct 13, 2016 4:55 pm
Contact:

Re: Ramdrive address

Post 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
User avatar
Robert
Member
Member
Posts: 25
Joined: Wed Jan 13, 2021 8:49 am

Re: Ramdrive address

Post 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).
User avatar
austanss
Member
Member
Posts: 377
Joined: Sun Oct 11, 2020 9:46 pm
Location: United States

Re: Ramdrive address

Post 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.
Skylight: https://github.com/austanss/skylight

I make stupid mistakes and my vision is terrible. Not a good combination.

NOTE: Never respond to my posts with "it's too hard".
Post Reply