Boot sector

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
gizmostripe

Boot sector

Post by gizmostripe »

Ok, i have finally managed to get my OS to compile (yay) but im unsure on what i do with the boot sector. Do i still just link everything to one file or does the bootsector have to be an individual file and not linked. Heres my file structure to help.

Boot.asm (bootloader)
Init.asm (kernel jump + memory functions)
Kernel.c (main kernel with custom libraries)

when compiling my kernel in nasm i can only use bin format which screws the link, any other and it throws an error: "error: parser: instruction expected" on line 11 (line 11 including comments: "ORG [0x7C00]"
line 11 withou comments: "resetFloppy:"

and im totally lost with it :S

thanks in advance....
CodeSlasher

RE:Boot sector

Post by CodeSlasher »

hi,the boot sector is supposed to be seperate from the main os. it loads the main os kernel from a known position on the disk(ie starting from sector X and load Y sectors) if there is no file system or use the file system records on the disk to load the os(ie use FAT or alternetive structures to locate and load the kernel sector at a time etc). As a starter, i suggest just putting the kernel file at a fix position ie starting from the 2nd or 3rd sector on cylinder 0 Head 0.
you can use a program like PARTCOPY to write the boot sector to cylinder 0 head 0 sector 1 and also to write the kernel to the disk starting from cylinder 0 head 0 sector 2/3. remember that a floppy track has only 18 sectors so your kernel has to be less than or equal to 16 sectors (512bytes *16)if you start from sector 2 or 15 sectors if you start from sector 3.
drug5t0r3

RE:Boot sector

Post by drug5t0r3 »

first of all it would be nice to know what compilers you use to guide you.

And secondo, the boot loader is far from being the kernel.

anyways, something i see wrong here is that "ORG [0x7C00]" should be
[ORG 0x7C00] (I think) :P

And as the other guy responded you can't really link the bootloader with the kernel, you just have to load the kernel in the memory and do a sort of static jump into it.
carbonBased

RE:Boot sector

Post by carbonBased »

easiest way is to just ignore the org 7C00, and set your DS to 0x07C0.

Cheers,
Jeff
Post Reply