This is done by what your topic says code.google.com/p/mytos
First compile the kernle(e.g. boot.bin,kernel.bin),and write a main program to read this 2 file ,write into a new file floppy.img(1.44M). You can control where the 2 bin file locate in the floppy file,and correspoding the boot program should also use this structure to load the kernel.
Copying kernel to a floppy without a filesystem?
Re: Copying kernel to a floppy without a filesystem?
What I did for my floppy Image was (linux, root/su):
First, create image file with flat 0s:
bind the loop dev:
You can use losetup /f to look for the first unused loop device
Format loop0 with ext2 fs:
Mount loop0 so you can write files to it:
Copy anything needed by your boot-load into floppy (image file). Then umount the image. Write a simple C program to read boot.bin and write to first 512 byte of the image, then read kernel.bin (or second stage loader) and write to the second sector (512th-1023th byte).
All done, point the bochs or virtualbox floppy drive to this image file, then start it.
Hope this help.
P.S. I wrote this in office, so, not too sure about the syntax of command, I actually put this all into the C program and I've throw it out of my brain. But I guess you should get the concept. I learn this from one of the other OS dev website, can't remember which...
First, create image file with flat 0s:
Code: Select all
dd if=/dev/zero of=floppy.img bs=512 count=2880
Code: Select all
losetup /dev/loop0 floppy.img
Format loop0 with ext2 fs:
Code: Select all
mkfs -t ext2 /dev/loop0
Code: Select all
mount -t ext2 /mnt/floppy
All done, point the bochs or virtualbox floppy drive to this image file, then start it.
Hope this help.
P.S. I wrote this in office, so, not too sure about the syntax of command, I actually put this all into the C program and I've throw it out of my brain. But I guess you should get the concept. I learn this from one of the other OS dev website, can't remember which...