From 81f7351fe6d243770731d07bffa71c09b73d9800 Mon Sep 17 00:00:00 2001 From: Nigel Date: Mon, 20 Feb 2023 01:03:46 +0100 Subject: [PATCH] Created a few shell scripts to update and create an build of the Kernel/Operating System. A python script can be run to run the scripts in the correct order and immediatly try the build. --- kernel/Makefile | 1 - scripts/build.py | 23 +++++++++---------- ...eate-filesystem.sh => create_harddrive.sh} | 0 scripts/create_iso.sh | 5 ++++ scripts/create_symbol_lookup.sh | 3 +++ scripts/hooks/pre-commit.hook.sh | 3 --- scripts/run_qemu.sh | 12 ++++++++++ scripts/run_virtualbox.sh | 2 ++ scripts/test.sh | 5 ---- scripts/update_harddrive.sh | 11 +++++++++ 10 files changed, 44 insertions(+), 21 deletions(-) rename scripts/{create-filesystem.sh => create_harddrive.sh} (100%) create mode 100755 scripts/create_iso.sh create mode 100755 scripts/create_symbol_lookup.sh create mode 100755 scripts/run_qemu.sh create mode 100755 scripts/run_virtualbox.sh delete mode 100755 scripts/test.sh create mode 100755 scripts/update_harddrive.sh diff --git a/kernel/Makefile b/kernel/Makefile index 96ccbb1..97e6d43 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -1,4 +1,3 @@ -EMULATOR = qemu-system-i386 AS = ${HOME}/opt/cross/bin/i686-elf-as CC = ${HOME}/opt/cross/bin/i686-elf-gcc CPP = ${HOME}/opt/cross/bin/i686-elf-g++ diff --git a/scripts/build.py b/scripts/build.py index cd06dc4..8183b1a 100755 --- a/scripts/build.py +++ b/scripts/build.py @@ -2,24 +2,23 @@ import os import subprocess - -print("Building BarinkOS") - +print("Give BarinkOS A Test Run") # list and run build scripts print("Running build-scripts") os.chdir("scripts") - scripts=os.listdir() currentScript=os.path.basename(__file__) -if currentScript in scripts: - scripts.remove(currentScript) +os.chdir("../CoreLib") +print("Building CoreLib") +subprocess.call("make") +os.chdir("../kernel") +print("Building kernel") +subprocess.call("make") -for script in scripts: - print(os.getcwd()) - print("Running:" + script) - subprocess.call(script, cwd=os.getcwd()) - -os.chdir("..") \ No newline at end of file +os.chdir("..") +subprocess.call("scripts/update_harddrive.sh", cwd=os.getcwd()) +subprocess.call("scripts/create_symbol_lookup.sh", cwd=os.getcwd()) +subprocess.call("scripts/run_qemu.sh", cwd=os.getcwd()) \ No newline at end of file diff --git a/scripts/create-filesystem.sh b/scripts/create_harddrive.sh similarity index 100% rename from scripts/create-filesystem.sh rename to scripts/create_harddrive.sh diff --git a/scripts/create_iso.sh b/scripts/create_iso.sh new file mode 100755 index 0000000..356fdf3 --- /dev/null +++ b/scripts/create_iso.sh @@ -0,0 +1,5 @@ +#!/bin/bash +mkdir -p root/boot/grub +cp build/kernel/myos.bin root/boot/myos.bin +cp kernel/grub.cfg root/boot/grub/grub.cfg +grub-mkrescue -o barinkOS.iso root \ No newline at end of file diff --git a/scripts/create_symbol_lookup.sh b/scripts/create_symbol_lookup.sh new file mode 100755 index 0000000..a150d4a --- /dev/null +++ b/scripts/create_symbol_lookup.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +objcopy --only-keep-debug build/kernel/myos.bin kernel.sym \ No newline at end of file diff --git a/scripts/hooks/pre-commit.hook.sh b/scripts/hooks/pre-commit.hook.sh index 8a905bf..5bad261 100644 --- a/scripts/hooks/pre-commit.hook.sh +++ b/scripts/hooks/pre-commit.hook.sh @@ -1,5 +1,2 @@ #!/bin/bash - - # Run clang-tidy - diff --git a/scripts/run_qemu.sh b/scripts/run_qemu.sh new file mode 100755 index 0000000..072a4bd --- /dev/null +++ b/scripts/run_qemu.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# Run from harddisk +qemu-system-i386 -boot d -drive format=raw,file=disk.img -serial stdio -vga std -display gtk -m 2G -cpu core2duo + +# Run disk version +# qemu-system-i386 -cdrom barinkOS.iso -serial stdio -vga std -display gtk -m 2G -cpu core2duo -s -d int -no-shutdown -no-reboot + +# Run the raw kernel image +# qemu-system-i386 -kernel build/kernel/myos.bin -serial stdio -vga std -display gtk -m 2G -cpu core2duo -d int -no-shutdown -no-reboot + + diff --git a/scripts/run_virtualbox.sh b/scripts/run_virtualbox.sh new file mode 100755 index 0000000..db37ed2 --- /dev/null +++ b/scripts/run_virtualbox.sh @@ -0,0 +1,2 @@ +#!/bin/bash +virtualboxvm --startvm "BarinkOS_test" \ No newline at end of file diff --git a/scripts/test.sh b/scripts/test.sh deleted file mode 100755 index cb84bbe..0000000 --- a/scripts/test.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -start=`date +%s` -end=`date +%s` -echo That took $((end-start)) seconds -date +"%c" -d195440409 diff --git a/scripts/update_harddrive.sh b/scripts/update_harddrive.sh new file mode 100755 index 0000000..8295420 --- /dev/null +++ b/scripts/update_harddrive.sh @@ -0,0 +1,11 @@ +#!/bin/bash +echo "Mount harddrive image as block device" +sudo losetup /dev/loop9 disk.img +sudo mount /dev/loop9 /mnt + +echo "Copy over kernel binary" +sudo cp build/kernel/myos.bin /mnt/boot/myos.bin + +echo "unmount image" +sudo umount /mnt +sudo losetup -d /dev/loop9 \ No newline at end of file