Load OS into upper memory?

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
sjheiss
Posts: 5
Joined: Tue Jul 23, 2013 2:53 pm

Load OS into upper memory?

Post by sjheiss »

I am trying to boot the very first image from the Benu series of OSes, but I have run into a problem. With debugging information in the ISO the image is too big for lower memory and it fails to load (even though it's only 4kb bigger than without debug info). I allocate 16mb to the Qemu session, but I can't find anywhere online about how to load the OS in upper memory. Obviously it's possible since most operating systems are much larger than around 490kb, but none of the tutorials on this site seem to cover how to load a larger OS.

Thanks!
Nable
Member
Member
Posts: 453
Joined: Tue Nov 08, 2011 11:35 am

Re: Load OS into upper memory?

Post by Nable »

It's generally a good idea to use some multi-stage bootloader.
First stage is very small and loads second stage (or kernel) that enables protected mode and has enough device-specific routines to load full kernel to upper memory.

You can write your own implementations of these stages but I suggest you using GrUB or Yoda's OS Boot Tools.
Casm
Member
Member
Posts: 221
Joined: Sun Oct 17, 2010 2:21 pm
Location: United Kingdom

Re: Load OS into upper memory?

Post by Casm »

Your post begs a lot of questions, such as whther the operating system is running in real or protected mode, and, if protected mode, whether it uses segmentation or paging.

Most protected mode kernels need to be compiled and linked to run at a particular address in memory, so, once they have been compiled and linked, they can only successfully be loaded at that address.
sjheiss
Posts: 5
Joined: Tue Jul 23, 2013 2:53 pm

Re: Load OS into upper memory?

Post by sjheiss »

Nable wrote:It's generally a good idea to use some multi-stage bootloader.
First stage is very small and loads second stage (or kernel) that enables protected mode and has enough device-specific routines to load full kernel to upper memory.

You can write your own implementations of these stages but I suggest you using GrUB or Yoda's OS Boot Tools.
Well, the Benu OS's all use Grub, but the grub file (called "grub_file") is apparently obfuscated in some way, so I can't edit it myself, and I couldn't figure out how to edit it or create a new one. Actually, I'm not entirely sure what this "grub_file" is. Apparently the OS's at the Benu link use two stages, but for some reason I still get an error saying selected item cannot fit into memory.

I tried out the OS Boot Tools, but it seems that with that the OS can only be max 620kb. Not a whole lot...

Now, the Benu OS's have this option in the linker:

Code: Select all

-e arch_start -Ttext=0x100000
Which to me seems that the kernel would start at address 0x100000, which is apparently 14mb big, which is plenty. But apparently this doesn't work as the OS is loaded in lower memory. Why would this be?
Casm wrote:Your post begs a lot of questions, such as whether the operating system is running in real or protected mode, and, if protected mode, whether it uses segmentation or paging.

Most protected mode kernels need to be compiled and linked to run at a particular address in memory, so, once they have been compiled and linked, they can only successfully be loaded at that address.
I didn't write the OS's myself, so I am not sure yet which mode they run in.
Nable
Member
Member
Posts: 453
Joined: Tue Nov 08, 2011 11:35 am

Re: Load OS into upper memory?

Post by Nable »

sjheiss wrote:I didn't write the OS's myself, so I am not sure yet which mode they run in.
Oh, then it's definitely time to fill some gaps in your knowledge base before starting to do anything in this direction. Because when you're trying smth, it's always better to understand what are doing (even if you didn't write it by yourself).
http://wiki.osdev.org/Required_Knowledge
http://wiki.osdev.org/Getting_Started
http://wiki.osdev.org/Real_Mode , http://wiki.osdev.org/Protected_Mode
Post Reply