where to go from here

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
ChrisSkura
Member
Member
Posts: 33
Joined: Sat Nov 07, 2009 2:47 am

where to go from here

Post by ChrisSkura »

k, I just wrote a boot program which prints out some text and draws a couple of lines but I've been told I shouldn't put graphics in my boot loader. I need help trying to make and link a kernel to my bootloader but I don't know where to start. when linking do I link the bootloader and kernel into one binary file or do I write both files to the floppy disk?
Grunt
Member
Member
Posts: 37
Joined: Fri Nov 06, 2009 1:05 am

Re: where to go from here

Post by Grunt »

A bootloader can only be 512 bytes long, which really limits your possibilities. The preferred method is to write the bootloader onto the MBR, then have it load the kernel into the memory. Using GRUB really helps in this case.

You can take a look at some examples, maybe this one. Googling around will lead you to numerous other examples.
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: where to go from here

Post by neon »

Hello,

You cannot link a program to your boot code. (Well, maybe you can, if you compile the C project to flat binary somehow. Not a good idea though sense you are limited to 512 bytes.) In any case, you will want your boot loader to parse the filesystem and load another, bigger program. This can be your kernel, or another, bigger, bootloader.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Re: where to go from here

Post by jal »

ChrisSkura wrote:k, I just wrote a boot program which prints out some text and draws a couple of lines but I've been told I shouldn't put graphics in my boot loader.
By whom? There's nothing wrong with graphics in your bootloader, if they are bootloader specific.


JAL
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: where to go from here

Post by neon »

jal wrote:
ChrisSkura wrote:k, I just wrote a boot program which prints out some text and draws a couple of lines but I've been told I shouldn't put graphics in my boot loader.
By whom? There's nothing wrong with graphics in your bootloader, if they are bootloader specific
There is when it is boot code that is limited to 512 bytes. Of course, if he decides to load a bigger program, ie, a kernel or "2nd stage" there isnt a problem. Graphics in boot code is not recommended do to being limited to 512 bytes.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
ChrisSkura
Member
Member
Posts: 33
Joined: Sat Nov 07, 2009 2:47 am

Re: where to go from here

Post by ChrisSkura »

k, I don't really want to use grub because I want to write EVERYTHING in my os. I need to know how to set up the gdt and how to load the kernel.
smeezekitty
Member
Member
Posts: 50
Joined: Sat Mar 21, 2009 9:42 pm

Re: where to go from here

Post by smeezekitty »

you will ether load the sectors direct into memory or parse a filesystem with the kernel on it
and load it into memory then do a far jump to it.
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: where to go from here

Post by Combuster »

I suggest you look up your keywords in the wiki - Bootloader - GDT - <insert random link> - there is a lot waiting to be found.

It also helps you ask more specific questions, and by doing so, yield better answers.
"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 ]
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Re: where to go from here

Post by jal »

neon wrote:Graphics in boot code is not recommended do to being limited to 512 bytes.
Again, why not? Of course the boot code is limited to that, but if you manage to put it in there anyway, why not? The OP didn't ask "I've got graphics in my bootloader, and now I've hit the 510 byte limit", right? If I remember correctly Dex has a bootsector CD player including graphics, so one can do it.


JAL
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Re: where to go from here

Post by Dex »

jal wrote:
neon wrote:Graphics in boot code is not recommended do to being limited to 512 bytes.
Again, why not? Of course the boot code is limited to that, but if you manage to put it in there anyway, why not? The OP didn't ask "I've got graphics in my bootloader, and now I've hit the 510 byte limit", right? If I remember correctly Dex has a bootsector CD player including graphics, so one can do it.


JAL
JAL is right its possable, http://www.dex4u.com/ASMcompo512b/CdPod.zip
This demo fits sets vesa 640x480 32bpp, sets up a basic ATAPI driver, goes to pmode, sets up a simple menu driven gui and vesa fonts, and a cdplayer, all in less than 512bytes.
You will also find full games that fit in boot sector from that compo
CdPod
Image
Tetris game
Image
Scroll game
Image

See here for the rest:
http://www.dex4u.com/ASMcompo512b/
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: where to go from here

Post by neon »

Just because something is possible does not make it a good idea. I suppose its fine if he can fit it along with the necessary code to load a bigger program (kernel or "2nd stage").
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
Post Reply