Init ram disk QEMU

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.
Locked
costa90sm
Posts: 13
Joined: Sat Jun 22, 2013 3:06 am

Init ram disk QEMU

Post by costa90sm »

Hi,
after the launch of QEMU, initializing the ram:

Code: Select all

qemu -kernel build/boot -initrd build/sistema
I need to know the address of the 'sistema' module.
Which field of the multiboot_info structure contains this address?
User avatar
xenos
Member
Member
Posts: 1121
Joined: Thu Aug 11, 2005 11:00 pm
Libera.chat IRC: xenos1984
Location: Tartu, Estonia
Contact:

Re: Init ram disk QEMU

Post by xenos »

I'm not quite sure about QEMU's multiboot implementation (it seems to be a bit faulty, so I recommend GRUB instead of the (albeit convenient) -kernel option), but I would have a look at the modules section of the multiboot structure.
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS
costa90sm
Posts: 13
Joined: Sat Jun 22, 2013 3:06 am

Re: Init ram disk QEMU

Post by costa90sm »

I have to use QEMU because is a project and I can not do otherwise.

standard multiboot is described here:
http://www.gnu.org/software/grub/manual ... iboot.html

A field of the multiboot_info structure should be the address of 'sistema' (ELF format), loaded by -initrd.
Kevin
Member
Member
Posts: 1071
Joined: Sun Feb 01, 2009 6:11 am
Location: Germany
Contact:

Re: Init ram disk QEMU

Post by Kevin »

XenOS wrote:I'm not quite sure about QEMU's multiboot implementation (it seems to be a bit faulty, so I recommend GRUB instead of the (albeit convenient) -kernel option)
Do you have any specific problems with it? Depending on how hard it turns out I might take a look at fixing it.

Multiboot modules generally work with it, I've often used them myself.
Developer of tyndur - community OS of Lowlevel (German)
User avatar
xenos
Member
Member
Posts: 1121
Joined: Thu Aug 11, 2005 11:00 pm
Libera.chat IRC: xenos1984
Location: Tartu, Estonia
Contact:

Re: Init ram disk QEMU

Post by xenos »

Kevin wrote:Do you have any specific problems with it? Depending on how hard it turns out I might take a look at fixing it.
I hadn't tried it for a while. One thing I remember is that the "upper memory" field in the multiboot info shows the total memory instead of the upper one, i.e., 1 MB too much - at least that's what I thought. But now I tried it again and just saw that it's not 1 MB more, but instead it included the memory used by ACPI in the "upper memory" value (in this case 8 kB more). Instead, GRUB only shows the size of the first free memory block. I don't know which behavior is correct, or whether both are correct. It seems that the spec is not very clear about this, it only mentions the "first memory hole". The problem I encountered with my kernel is that it assumes that the region indicated by the "upper memory" field is completely usable, and uses this a a scratch area before making use of the complete memory map - thereby trashing the ACPI tables.

Just for comparison, the output from my kernel when I boot it with GRUB (or GRUB2, "Base contiguous memory" means upper memory + 1 MB):

Code: Select all

Memory map of length 0x00000090 at address 0x000100c0
Mem: 0x0000000000000000-0x000000000009fbff, Type: 0x01
Mem: 0x000000000009fc00-0x000000000009ffff, Type: 0x02
Mem: 0x00000000000f0000-0x00000000000fffff, Type: 0x02
Mem: 0x0000000000100000-0x0000000003ffdfff, Type: 0x01
Mem: 0x0000000003ffe000-0x0000000003ffffff, Type: 0x02
Mem: 0x00000000fffc0000-0x00000000ffffffff, Type: 0x02
Base contiguous memory:	65528 kB
And QEMU's -kernel option:

Code: Select all

Memory map of length 0x00000078 at address 0x00009000
Mem: 0x0000000000000000-0x000000000009fbff, Type: 0x01
Mem: 0x000000000009fc00-0x000000000009ffff, Type: 0x02
Mem: 0x00000000000f0000-0x00000000000fffff, Type: 0x02
Mem: 0x0000000000100000-0x0000000003ffdfff, Type: 0x01
Mem: 0x0000000003ffe000-0x0000000003ffffff, Type: 0x02
Base contiguous memory:	65536 kB
The last entry in the memory map is missing here as well, compared to the one provided by GRUB (which in turn comes from the BIOS).
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS
costa90sm
Posts: 13
Joined: Sat Jun 22, 2013 3:06 am

Re: Init ram disk QEMU

Post by costa90sm »

And what about my problem?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Init ram disk QEMU

Post by Combuster »

The point was to run a proper bootloader (GRUB) inside qemu instead of relying on a proven broken multiboot implementation. Have you tried that (and the other suggestions) yet?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
costa90sm
Posts: 13
Joined: Sat Jun 22, 2013 3:06 am

Re: Init ram disk QEMU

Post by costa90sm »

My project is porting a 32-bit kernel in a 64-bit one. The 32-bit version worked and the 64-bit one too; my problem is just finding the "sistema"'s address.
The bootloader leaves in ebx register the address of multiboot_info structure, so I just to know which its field I need.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Init ram disk QEMU

Post by Combuster »

boot module
Other auxiliary files that a boot loader loads into memory along with an OS image, but does not interpret in any way other than passing their locations to the operating system when it is invoked.
Do your own homework?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
dozniak
Member
Member
Posts: 723
Joined: Thu Jul 12, 2012 7:29 am
Location: Tallinn, Estonia

Re: Init ram disk QEMU

Post by dozniak »

costa90sm wrote:And what about my problem?
You may solve it by actually reading the multiboot spec.
Learn to read.
costa90sm
Posts: 13
Joined: Sat Jun 22, 2013 3:06 am

Re: Init ram disk QEMU

Post by costa90sm »

dozniak wrote:
costa90sm wrote:And what about my problem?
You may solve it by actually reading the multiboot spec.
Yes, I did it, but I don't understand which field I need if "sistema" is loaded with -initrd setting
User avatar
dozniak
Member
Member
Posts: 723
Joined: Thu Jul 12, 2012 7:29 am
Location: Tallinn, Estonia

Re: Init ram disk QEMU

Post by dozniak »

You may continue by reading QEMU manual.

It can either be a multiboot module or linux kernel-specific boot protocol.
Learn to read.
Kevin
Member
Member
Posts: 1071
Joined: Sun Feb 01, 2009 6:11 am
Location: Germany
Contact:

Re: Init ram disk QEMU

Post by Kevin »

XenOS wrote:Just for comparison, the output from my kernel when I boot it with GRUB (or GRUB2, "Base contiguous memory" means upper memory + 1 MB)
Thanks for the detailed explanation. I sent patches [1] for both problems, so hopefully qemu 1.6 will get it right. :)

[1] http://lists.nongnu.org/archive/html/qe ... 03997.html
Developer of tyndur - community OS of Lowlevel (German)
User avatar
xenos
Member
Member
Posts: 1121
Joined: Thu Aug 11, 2005 11:00 pm
Libera.chat IRC: xenos1984
Location: Tartu, Estonia
Contact:

Re: Init ram disk QEMU

Post by xenos »

Kevin wrote:Thanks for the detailed explanation. I sent patches [1] for both problems, so hopefully qemu 1.6 will get it right. :)

[1] http://lists.nongnu.org/archive/html/qe ... 03997.html
Great, thanks a lot! :)
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS
Locked