README.md 2.7 KB

os_kernel

An OS kernel for study

make 编译过程

make all make run make clean

(base) ➜  os_kernel git:(master) ✗ make mk_dir
(base) ➜  os_kernel git:(master) ✗ make mbr
nasm -I boot/include/ boot/mbr.S -o Build/bin/mbr.bin
(base) ➜  os_kernel git:(master) ✗ make loader
nasm -I boot/include/ boot/loader.S -o Build/bin/loader.bin
(base) ➜  os_kernel git:(master) ✗ make kernel
i386-elf-gcc -Wall -I lib/ -I lib/kernel -I lib/user/ -I kernel/ -I device/ -c -fno-builtin -W -Wstrict-prototypes -Wmissing-prototypes kernel/main.c -o Build/main.o
i386-elf-gcc -Wall -I lib/ -I lib/kernel -I lib/user/ -I kernel/ -I device/ -c -fno-builtin -W -Wstrict-prototypes -Wmissing-prototypes kernel/init.c -o Build/init.o
i386-elf-gcc -Wall -I lib/ -I lib/kernel -I lib/user/ -I kernel/ -I device/ -c -fno-builtin -W -Wstrict-prototypes -Wmissing-prototypes kernel/interrupt.c -o Build/interrupt.o
i386-elf-gcc -Wall -I lib/ -I lib/kernel -I lib/user/ -I kernel/ -I device/ -c -fno-builtin -W -Wstrict-prototypes -Wmissing-prototypes device/timer.c -o Build/timer.o
nasm -f elf kernel/kernel.S -o Build/kernel.o
nasm -f elf lib/kernel/print.S -o Build/print.o
i386-elf-gcc -Wall -I lib/ -I lib/kernel -I lib/user/ -I kernel/ -I device/ -c -fno-builtin -W -Wstrict-prototypes -Wmissing-prototypes kernel/debug.c -o Build/debug.o
i386-elf-ld -Ttext 0xc0001500 -e main Build/main.o Build/init.o Build/interrupt.o Build/timer.o Build/kernel.o Build/print.o Build/debug.o -o Build/bin/kernel.bin
(base) ➜  os_kernel git:(master) ✗ make create_img
bximage -q -func=create -hd=30M ./hd30M.img
========================================================================
                                bximage
  Disk Image Creation / Conversion / Resize and Commit Tool for Bochs
                                  $Id$
========================================================================

The disk image './hd30M.img' already exists.  Are you sure you want to replace it?
Please type yes or no. [no] yes

Creating hard disk image './hd30M.img' with CHS=60/16/63 (sector size = 512)

The following line should appear in your bochsrc:
  ata0-master: type=disk, path="./hd30M.img", mode=flat
(base) ➜  os_kernel git:(master) ✗ make hd
dd if=./Build/bin/mbr.bin of=./hd30M.img bs=512 count=1 conv=notrunc
1+0 records in
1+0 records out
512 bytes transferred in 0.001023 secs (500462 bytes/sec)
dd if=./Build/bin/loader.bin of=./hd30M.img bs=512 count=4 seek=2 conv=notrunc
2+1 records in
2+1 records out
1462 bytes transferred in 0.002619 secs (558222 bytes/sec)
dd if=./Build/bin/kernel.bin of=./hd30M.img bs=512 count=200 seek=9 conv=notrunc
16+1 records in
16+1 records out
8418 bytes transferred in 0.000408 secs (20635682 bytes/sec)
(base) ➜  os_kernel git:(master) ✗ make run