Page 1 of 2

0x100000

Posted: Wed Dec 26, 2007 10:37 pm
by hazardoxide
apologies. This is my last question for now. first, thanks for all the help. good site.ok. i have a bootable floppy with grub installed that loads the kernel from 0x100000. how do i write my kernel to that address?

Posted: Thu Dec 27, 2007 3:50 am
by ucosty
GRUB loads the kernel to 0x100000 not from it. That is a location in memory - the 1mb mark to be exact. All you do is point GRUB to your kernel image and it does the rest.

Posted: Thu Dec 27, 2007 4:40 am
by lukem95
you chose what image grub loads on the menu.lst file, then it simple passes control to it.

Posted: Thu Dec 27, 2007 5:32 am
by hazardoxide
But if i write an image to the disk, it will erase grub

Posted: Thu Dec 27, 2007 5:43 am
by lukem95
then you need to include GRUB in your image...

i have a very round-about way of making iso's, as im using a windows platform.

what i do:
+ Compile the source into kernel.bin
+ Use this + grub in VFD (virtual floppy driver) for testing
+ Save this as .img
+ Using MagicISO take the boot code from the .img, and add the boot folder for grub, along with kernel.bin to a new bootable .iso
+ Save and burn to disk using Nero

Posted: Thu Dec 27, 2007 7:51 am
by t0xic
hazardoxide,

First, make sure you use the Fat12 GRUB version. Follow what lukem says to do, then put the following in your "menu.cfg" file, substituting where you need to:

Code: Select all

title		OS
root		(fd0)
kernel    /kernel.bin

Posted: Thu Dec 27, 2007 1:59 pm
by hazardoxide
well, im not sure what to do with vfd. i downloaded it. installed and started the driver, set it to A:, now what? i got a floppy with grub installed, and in the menu.lst, i have it setup to look for: kernel (fd0)/boot/kernel.bin but when i out my bin there, it says it's an unreconized or unsupported format. and i also tried moving all the files from the real grub floppy with kernel.bin to virtual floppy A: in "my computer" and with an empty 1.44 img file created in it, but when i try to save from vfd, is says "device not ready" formatting too, it always says to me, device not ready.

Posted: Thu Dec 27, 2007 2:02 pm
by t0xic
What executable format is your kernel? If it is ELF, make sure the linker script works

Posted: Thu Dec 27, 2007 2:05 pm
by hazardoxide
what is the default output format of ld if i leave it alone

Posted: Thu Dec 27, 2007 10:59 pm
by ucosty
hazardoxide wrote:what is the default output format of ld if i leave it alone
That depends on your build environment. An ELF cross compiler, like the one described in the wiki, will output an ELF file by default but will (probably) barf on the lack of a linker script. OS Specific toolchains (for user code) have an included linker script specific to that platform.

Posted: Fri Dec 28, 2007 2:23 am
by Combuster
ucosty wrote:
hazardoxide wrote:what is the default output format of ld if i leave it alone
That depends on your build environment. An ELF cross compiler, like the one described in the wiki, will output an ELF file by default but will (probably) barf on the lack of a linker script. OS Specific toolchains (for user code) have an included linker script specific to that platform.
The cross-compiler on the wiki comes with a builtin linker script that does pretty much of the default things (if you want to link applications, it will probably be good enough). There is a commandline switch that makes ld dump its builtin linker script.

Posted: Sat Dec 29, 2007 2:24 pm
by hazardoxide
I'm trying to compile james M'S tut using djgpp and nasm. I made boot.asm (compiled ok) I compiled main.c (with warnings) but when i try to like them (using link.ld) i get the following errors:

Code: Select all

C:\os\main.o:crt0.s:(.text+0x0): multiple definition of 'start'
C:\os\boot.o:C:\os\boot.o:(.text+0x20): first defined here
C:\os\boot.o:C:\os\boot.o:(.text+0x30): undefined reference to 'main'
using: ld -T C:\os\link.ld -o C:\os\kernel.bin C:\os\boot.o C:\os\main.o

when compiling main.c i get the following warnings:

Code: Select all

C:\os\main.c:1: warning: 'struct multiboot' declared inside parameter list
C:\os\main.c:1: warning: its scope is only this definition or declaration, which is probably not what you want
C:\os\main.c:4:2: warning: no newline at end of file
Whats going on here?

thanks,

Posted: Sat Dec 29, 2007 4:39 pm
by Combuster
Whats going on here?
Its your toolchain, you should know what it does.

You're probably not using a GCC Cross-Compiler, no?

Posted: Sat Dec 29, 2007 5:31 pm
by lukem95
well if your following the tut you should have read that there is no actual definition for the multiboot struct till the last chapter... so thats that warning taken care of.

and as for the multiple start definitions... isnt that obvious? you have used "start" as a function name twice

Posted: Sat Dec 29, 2007 10:13 pm
by hazardoxide
combuster, im using djgpp, so yes. gcc.

use, though common logic i have depicted that i did infact use "start" twice. but the tutorial has it like that, so what can i change to fix said problem.
:?