Page 2 of 2
Re:Getting started....
Posted: Mon Oct 02, 2006 1:21 pm
by Candy
shell wrote:
I'm setting the target to i386-unknown-gnu. Sound good?
Sorry for the late reaction. I think the compiler is expecting its own libraries as base, which you don't have. Try i386-pc-elf (since you do know the machine but don't have any other guarantee but that you want elf as a target).
Re:Getting started....
Posted: Mon Oct 02, 2006 1:25 pm
by shell
Well, the reason I selected i386-unknown-gnu was because I saw it in some tutorial from a university. But can you tell me what's causing the GCC make error?
Re:Getting started....
Posted: Mon Oct 02, 2006 1:39 pm
by Candy
shell wrote:
Well, the reason I selected i386-unknown-gnu was because I saw it in some tutorial from a university. But can you tell me what's causing the GCC make error?
Pretty good guess, yeah. It's like my errors when I chose x86_64-pc-linux which went wrong since it tried to compile assuming linux libraries which my OS didn't have (and probably still doesn't). Did you read the messy info on the crosscompiler page? this should be on it... not sure whether I've left it after cleaning up the page for the new x86_64-pc-elf target which fixes about all errors.
You can also choose my old solution,
Re:Getting started....
Posted: Mon Oct 02, 2006 1:44 pm
by shell
Ok. Just one last question then. Using my source above. What can I do to compile all of that into a bootable image (floppy, etc. w/e as long as Bochs can boot it)
Re:Getting started....
Posted: Mon Oct 02, 2006 2:18 pm
by Candy
shell wrote:
Ok. Just one last question then. Using my source above. What can I do to compile all of that into a bootable image (floppy, etc. w/e as long as Bochs can boot it)
I have no idea.
Put better, there are so many options that it's almost like asking me exactly which type of food is the best for you. All I can really advise you is to try a few until you succeed, but that the most important thing is to cook it yourself.
I would advise making a multiboot kernel at 1MB for initial simplicity and getting it to shout "hello world" at you. Then, add bits & pieces. End up with something on the order of Windows.
I'm working on the same thing more or less. I'm hacking my own kernel to boot too. I'm not sure what I'm getting out of my makefile process but it's about a meg too large and it doesn't work. Not alone because of a dozen or so TODO's. And I'm trying to get the makefiles to compile a few programs for both the host and the target.
Re:Getting started....
Posted: Mon Oct 02, 2006 2:23 pm
by shell
I mean. I have my code. If you scroll up to the first post in this thread. I just want to know how to compile all of that and make it into a bootable image
Re:Getting started....
Posted: Mon Oct 02, 2006 2:34 pm
by Candy
shell wrote:
I mean. I have my code. If you scroll up to the first post in this thread. I just want to know how to compile all of that and make it into a bootable image
1. Your comment on bright white isn't right.
2. Your clear screen function has a loop-induced variable that isn't used (pos). Also, you're incrementing i in the loop, which is pretty ugly. Index with i and i+1 and then increase it by 2.
3. Your printf function doesn't comply with the default printf signature. It's better for clarity toward others to call it different. Also, C++ compilers might trip over the use of "string", although they shouldn't. My mind sure did.
4. Your pos/line handling isn't consistent at all places. At least at the start of colorch, you're increasing line without resetting pos.
5. Your code assumes you start up in protected mode. You need a bootloader that allows you to do that.
6. You also assume a leading underscore, which most platforms lack.
The quickest way would be to fix the errors and to add a multiboot header. Then, compile to flat binary with the multiboot header after the main bit. Add the binary to your grub installation (assuming you have one - get the grub disk from the OS FAQ if you don't) and try to boot it. Alternative to grub would be my very experimental boot loader, that just allows you to write your kernel to a given sector on a (virtual) harddisk and boots it from there. You need a recent bochs for that though, 2.3pre2 or newer.
Re:Getting started....
Posted: Mon Oct 02, 2006 2:39 pm
by shell
1. Your comment on bright white isn't right.
> ok
2. Your clear screen function has a loop-induced variable that isn't used (pos). Also, you're incrementing i in the loop, which is pretty ugly. Index with i and i+1 and then increase it by 2.
> ok
3. Your printf function doesn't comply with the default printf signature. It's better for clarity toward others to call it different. Also, C++ compilers might trip over the use of "string", although they shouldn't. My mind sure did.
> i don't have a printf function... just a generic print
4. Your pos/line handling isn't consistent at all places. At least at the start of colorch, you're increasing line without resetting pos.
> yes, yes. I know
5. Your code assumes you start up in protected mode. You need a bootloader that allows you to do that.
> How do I do this?
6. You also assume a leading underscore, which most platforms lack.
> But can't you take care of this using one of the binutils utils to "unjumble" c++ functions or something like that
The quickest way would be to fix the errors and to add a multiboot header. Then, compile to flat binary with the multiboot header after the main bit. Add the binary to your grub installation (assuming you have one - get the grub disk from the OS FAQ if you don't) and try to boot it. Alternative to grub would be my very experimental boot loader, that just allows you to write your kernel to a given sector on a (virtual) harddisk and boots it from there. You need a recent bochs for that though, 2.3pre2 or newer.
> Excuse me, can you explain that. How do I add a multiboot header? What if I just want to boot the image in Bochs?
Re:Getting started....
Posted: Mon Oct 02, 2006 10:39 pm
by Candy
shell wrote:
> Excuse me, can you explain that. How do I add a multiboot header? What if I just want to boot the image in Bochs?
Bochs simulates a real computer in all aspects. You have a simulated PIC to reprogram, a simulated real-mode to switch to a simulated protected-mode, so you'll have to do everything a normal OS does too.
For the grub-way, try
http://www.mega-tokyo.com/osfaq/BareBones. For the other way, use
http://www.mega-tokyo.com/osfaq/ProtectedMode for a short intro to what it is.
Nobody said it would be easy.