Getting my Bootloader to load a second stage bootloader?
-
- Posts: 16
- Joined: Wed Aug 24, 2011 11:19 am
Getting my Bootloader to load a second stage bootloader?
hi, so i just started work on my two stage boot loader in ASM.
and after a bit of testing, i got a basic hello world boot-loader working.
however in my first boot-loader i cannot seem to figure out how to
load and give control to the second stage boot-loader.
Would you try and do this using a include in the asm code, or is there a different way?
a simple sample or snippet would be really helpful. and thank you for reading.
and after a bit of testing, i got a basic hello world boot-loader working.
however in my first boot-loader i cannot seem to figure out how to
load and give control to the second stage boot-loader.
Would you try and do this using a include in the asm code, or is there a different way?
a simple sample or snippet would be really helpful. and thank you for reading.
- Combuster
- 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: Getting my Bootloader to load a second stage bootloader?
How about reading the wiki? Did you try that?
-
- Posts: 16
- Joined: Wed Aug 24, 2011 11:19 am
Re: Getting my Bootloader to load a second stage bootloader?
yes i did, but it doesn't seem to tell how i would load a secondary file.
i get that you need to transfer control, or jump to its location, but i can't figure out how.
i get that you need to transfer control, or jump to its location, but i can't figure out how.
Re: Getting my Bootloader to load a second stage bootloader?
Assuming you have already loaded the second stage into memory, and are still in real mode, try something like this (shown in NASM):
RETF will pop CS:IP from the stack (0050:0000 in this case)
Hope this helps
Code: Select all
PUSH WORD 0x0050
PUSH WORD 0x0000
RETF
Hope this helps
-
- Posts: 16
- Joined: Wed Aug 24, 2011 11:19 am
Re: Getting my Bootloader to load a second stage bootloader?
thanks that useful, but as a question, when you load the second stage,
does it have to be loaded into a special place, like a certain memory address,
for this code, or can it be anywhere?
does it have to be loaded into a special place, like a certain memory address,
for this code, or can it be anywhere?
Re: Getting my Bootloader to load a second stage bootloader?
In real mode, it has to be below the 1MB mark. Also, don't overwrite anything you have already loaded (ie, stage 1)theelitenoob wrote: when you load the second stage,
does it have to be loaded into a special place, like a certain memory address,
for this code, or can it be anywhere?
Also remember not to write to the memory mapped I/O region.
If you're not sure, just write to 0050:0000 as I have done. I guarantee it works
Re: Getting my Bootloader to load a second stage bootloader?
To expand on my previous comment, apart from the restrictions listed, no, you don't have to load it to a specific area of memory.
Just make sure that where you pass control to is the same location in memory that you loaded to.
Just make sure that where you pass control to is the same location in memory that you loaded to.
-
- Posts: 16
- Joined: Wed Aug 24, 2011 11:19 am
Re: Getting my Bootloader to load a second stage bootloader?
ok, thanks for the input i'll test it out now.
Re: Getting my Bootloader to load a second stage bootloader?
http://www.google.nl/search?client=oper ... el=suggest
That is all the information you need to load your second stage.
That is all the information you need to load your second stage.
-
- Posts: 16
- Joined: Wed Aug 24, 2011 11:19 am
Re: Getting my Bootloader to load a second stage bootloader?
thanks, this is perfect!Bietje wrote:http://www.google.nl/search?client=opera&rls=en&q=bios+int+0x13&sourceid=opera&ie=utf-8&oe=utf-8&channel=suggest
That is all the information you need to load your second stage.
Re: Getting my Bootloader to load a second stage bootloader?
My suggestion is, try multiboot unless you have a real good reason to craft your own boot loader. If you want a 64-bit kernel, write a loader on top of multiboot. It's much easier.
-
- Posts: 16
- Joined: Wed Aug 24, 2011 11:19 am
Re: Getting my Bootloader to load a second stage bootloader?
my main reason is i want to try it myself, as well as it seems fun.