Well, if you're interested in doing kernel development yourself, there are plenty of resources around to help you get started. The not-so-easy thing is getting your development environment in order, so that you can actually run and debug the kernel. Here's a set of commands that help you do that. I'm using qemu as a VM emulator, gcc and nasm for development and Ubuntu as a host development system.
- qemu-img create myos.img 32M
- losetup /dev/loop1 ./myos.img
- fdisk -u -C65 -S63 -H16 /dev/loop1
- ( create a primary bootable partition across the entire disk)
- losetup -d /dev/loop1
- losetup -o32256 /dev/loop1 ./myos.img
- mkfs -t ext3 /dev/loop1
- mount -t ext3 /dev/loop1 /mnt/image
- df -Th
- losetup /dev/loop2 ./myos.img
- ln -s /dev/loop2 /dev/loop
- cd /mnt/image
- mkdir boot
- mkdir boot/grub
- cd boot/grub
- cp /boot/grub/stage1 ./
- cp /boot/grub/stage2 ./
- cp /boot/grub/e2fs_stage1_5 ./
- grub
- grub>device (hd0) /dev/loop
- grub>root (hd0,0)
- grub>setup (hd0)
- grub>quit
- vi /mnt/image/boot/grub/menu.lst
- menu.lst:
timeout 0
default 0
title minimalkernel
root (hd0,0)
kernel (hd0,0)/minimalkernel - rm /dev/loop
- losetup -d /dev/loop0
- losetup -d /dev/loop1
- mbchk kernel.bin
- cp kernel.bin /mnt/image/minimal-kernel
- umount /mnt/image
qemu -m 100 -hda myos.img -boot c -no-kqemu
There you go! Of course, once the image is created and sorted, for development you only need to repeat step 30. You can remount the image in a build script:
mount -o loop,offset=32256 ./myos.img /mnt/image
Here are more resources:
- http://www.osdever.net
- http://www.jamesmolloy.co.uk/tutorial_html/
- http://www.osdever.net/bkerndev/index.php (Bran's kernel development tutorial)
- Intel Architecture Software Developer’s Manual (search Google)
- http://oreilly.com/catalog/linuxdrive3/book/index.csp (Linux device drivers, 3rd edition. FREE as in beer!)
- http://tldp.org/LDP/tlk/tlk.html
- http://www.ibm.com/developerworks/linux/library/l-linuxboot
No comments:
Post a Comment