Call 32-bit or 64-bit program from bootloader
Posted
by
user1002358
on Stack Overflow
See other posts from Stack Overflow
or by user1002358
Published on 2012-10-29T04:49:50Z
Indexed on
2012/10/29
5:00 UTC
Read the original article
Hit count: 161
There seems to be quite a lot of identical information on the Internet about writing the following 3 bootloaders:
- Infinite loop
jmp $
- Print a single character
- Print "Hello World".
This is fantastic, and I've gone through these 3 variations with very little trouble.
I'd like to write some 32- or 64-bit code in C and compile it, and call that code from the bootloader... basically a bootloader that, for example, sets the computer up to run some simple numerical simulation. I'll start by listing primes, for example, and then maybe some input/output from the user to maybe compute a Fourier transform. I don't know.
I haven't found any information on how to do this, but I can already foresee some problems before I even begin.
First of all, compiling a C program compiles it into one of several different files, depending on the target. For Windows, it's a PE file. For Linux, it's a .out file. These files are both quite different. In my instance, the target isn't Windows or Linux, it's just whatever I have written in the bootloader.
Secondly, where would the actual code reside? The bootloader is exactly 512 bytes, but the program I write in C will certainly compile to something much larger. It will need to sit on my (virtual) hard disk, probably in some sort of file system (which I haven't even defined!) and I will need to load the information from this file into memory before I can even think about executing it. But from my understanding, all this is many, many orders of magnitude more complex than a 12-line "Hello World" bootloader.
So my question is: How do I call a large 32- or 64-bit program (written in C/C++) from my 16-bit bootloader.
© Stack Overflow or respective owner