|
@@ -1,10 +1,32 @@
|
|
|
#!/bin/sh
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
|
|
+directory="build/bin"
|
|
|
|
|
+if [ ! -d "$directory" ]; then
|
|
|
|
|
+ mkdir -p $directory
|
|
|
|
|
+fi
|
|
|
|
|
+
|
|
|
echo "Compiling mbr..."
|
|
echo "Compiling mbr..."
|
|
|
-nasm -I boot/include/ -o build/mbr.bin boot/mbr.S
|
|
|
|
|
|
|
+nasm -I boot/include/ -o $directory/mbr.bin boot/mbr.S
|
|
|
|
|
+if [ $? -eq 0 ]; then
|
|
|
|
|
+ echo "MBR compiled successfully."
|
|
|
|
|
+else
|
|
|
|
|
+ echo "MBR compiled failed."
|
|
|
|
|
+ exit
|
|
|
|
|
+fi
|
|
|
echo "Compiling loader..."
|
|
echo "Compiling loader..."
|
|
|
-nasm -I boot/include/ -o build/loader.bin boot/loader.S
|
|
|
|
|
|
|
+nasm -I boot/include/ -o $directory/loader.bin boot/loader.S
|
|
|
|
|
+if [ $? -eq 0 ]; then
|
|
|
|
|
+ echo "Bootloader compiled successfully."
|
|
|
|
|
+else
|
|
|
|
|
+ echo "Bootloader compiled failed."
|
|
|
|
|
+ exit
|
|
|
|
|
+fi
|
|
|
echo "Compiling kernel..."
|
|
echo "Compiling kernel..."
|
|
|
|
|
+directory="build"
|
|
|
|
|
+if [ ! -d "$directory" ]; then
|
|
|
|
|
+ mkdir $directory
|
|
|
|
|
+fi
|
|
|
|
|
+i386-elf-gcc -I lib/ -I lib/kernel/ -c -fno-builtin -o build/timer.o device/timer.c
|
|
|
i386-elf-gcc -I ./lib/ -I lib/kernel/ -I kernel/ -c -fno-builtin -o build/main.o kernel/main.c
|
|
i386-elf-gcc -I ./lib/ -I lib/kernel/ -I kernel/ -c -fno-builtin -o build/main.o kernel/main.c
|
|
|
nasm -f elf -o build/print.o lib/kernel/print.S
|
|
nasm -f elf -o build/print.o lib/kernel/print.S
|
|
|
nasm -f elf -o build/kernel.o kernel/kernel.S
|
|
nasm -f elf -o build/kernel.o kernel/kernel.S
|
|
@@ -12,19 +34,54 @@ nasm -f elf -o build/kernel.o kernel/kernel.S
|
|
|
i386-elf-gcc -I lib/kernel/ -I ./lib/ -I kernel/ -c -fno-builtin -o build/interrupt.o kernel/interrupt.c
|
|
i386-elf-gcc -I lib/kernel/ -I ./lib/ -I kernel/ -c -fno-builtin -o build/interrupt.o kernel/interrupt.c
|
|
|
i386-elf-gcc -I lib/kernel/ -I ./lib/ -I kernel/ -c -fno-builtin -o build/init.o kernel/init.c
|
|
i386-elf-gcc -I lib/kernel/ -I ./lib/ -I kernel/ -c -fno-builtin -o build/init.o kernel/init.c
|
|
|
|
|
|
|
|
-i386-elf-ld -Ttext 0xc0001500 -e main -o build/kernel.bin build/main.o build/init.o build/interrupt.o build/print.o build/kernel.o
|
|
|
|
|
|
|
+directory="build/bin"
|
|
|
|
|
+if [ ! -d "$directory" ]; then
|
|
|
|
|
+ mkdir $directory
|
|
|
|
|
+fi
|
|
|
|
|
+i386-elf-ld -Ttext 0xc0001500 -e main -o $directory/kernel.bin build/main.o build/init.o build/interrupt.o build/print.o build/kernel.o build/timer.o
|
|
|
|
|
+
|
|
|
|
|
+if [ $? -eq 0 ]; then
|
|
|
|
|
+ echo "Kernel compiled successfully."
|
|
|
|
|
+else
|
|
|
|
|
+ echo "Kernel compiled failed."
|
|
|
|
|
+ exit
|
|
|
|
|
+fi
|
|
|
|
|
|
|
|
echo "Creating disk image..."
|
|
echo "Creating disk image..."
|
|
|
bximage -q -func=create -hd=30M hd30M.img
|
|
bximage -q -func=create -hd=30M hd30M.img
|
|
|
|
|
+if [ $? -eq 0 ]; then
|
|
|
|
|
+ echo "Disk image created successfully."
|
|
|
|
|
+else
|
|
|
|
|
+ echo "Disk image created failed."
|
|
|
|
|
+ exit
|
|
|
|
|
+fi
|
|
|
|
|
|
|
|
echo "Installing to disk image..."
|
|
echo "Installing to disk image..."
|
|
|
echo " 0. Writing mbr to disk..."
|
|
echo " 0. Writing mbr to disk..."
|
|
|
-dd if=build/mbr.bin of=hd30M.img bs=512 count=1 conv=notrunc
|
|
|
|
|
|
|
+dd if=$directory/mbr.bin of=hd30M.img bs=512 count=1 conv=notrunc
|
|
|
|
|
+if [ $? -eq 0 ]; then
|
|
|
|
|
+ echo "Install mbr to disk image successfully."
|
|
|
|
|
+else
|
|
|
|
|
+ echo "Install mbr to disk image failed."
|
|
|
|
|
+ exit
|
|
|
|
|
+fi
|
|
|
echo " 1. Writing loader to disk..."
|
|
echo " 1. Writing loader to disk..."
|
|
|
-dd if=build/loader.bin of=hd30M.img bs=512 count=4 seek=2 conv=notrunc
|
|
|
|
|
|
|
+dd if=$directory/loader.bin of=hd30M.img bs=512 count=4 seek=2 conv=notrunc
|
|
|
|
|
+if [ $? -eq 0 ]; then
|
|
|
|
|
+ echo "Install loader to disk image successfully."
|
|
|
|
|
+else
|
|
|
|
|
+ echo "Install loader to disk image failed."
|
|
|
|
|
+ exit
|
|
|
|
|
+fi
|
|
|
echo " 2. Writing kernel to disk..."
|
|
echo " 2. Writing kernel to disk..."
|
|
|
-dd if=build/kernel.bin of=hd30M.img bs=512 count=200 seek=9 conv=notrunc
|
|
|
|
|
-echo "Disk image created successfully."
|
|
|
|
|
|
|
+dd if=$directory/kernel.bin of=hd30M.img bs=512 count=200 seek=9 conv=notrunc
|
|
|
|
|
+
|
|
|
|
|
+if [ $? -eq 0 ]; then
|
|
|
|
|
+ echo "Install kernel to disk image successfully."
|
|
|
|
|
+else
|
|
|
|
|
+ echo "Install kernel to disk image failed."
|
|
|
|
|
+ exit
|
|
|
|
|
+fi
|
|
|
|
|
|
|
|
echo "Now starting bochs ..."
|
|
echo "Now starting bochs ..."
|
|
|
bochs -f bochsrc -q
|
|
bochs -f bochsrc -q
|