From: acevest Date: Sun, 14 May 2023 15:04:08 +0000 (+0800) Subject: 支持通过iso启动内核 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/zlib_tech.html?a=commitdiff_plain;h=321bb9902f61282a202076e06b74d84d094fdbbe;p=kernel.git 支持通过iso启动内核 --- diff --git a/.clang-format b/.clang-format index 8f9dc1a..3db5ed9 100644 --- a/.clang-format +++ b/.clang-format @@ -6,3 +6,5 @@ TabWidth: 4 IndentCaseLabels: false +# 行注释 "//" 前增加两个空格 +SpacesBeforeTrailingComments: 2 diff --git a/.gitignore b/.gitignore index eeddd02..c04f383 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,4 @@ bochsout.txt *.lock *.DS_Store .vscode +*.iso diff --git a/gdbscript b/gdbscript new file mode 100644 index 0000000..24efe1e --- /dev/null +++ b/gdbscript @@ -0,0 +1 @@ +target remote localhost:1234 diff --git a/qemu.sh b/qemu.sh new file mode 100755 index 0000000..d67e1b1 --- /dev/null +++ b/qemu.sh @@ -0,0 +1,25 @@ +qemu-system-i386 -s -S -drive file=HD.IMG,format=raw,index=0,media=disk -drive file=kernel.iso,index=1,media=cdrom & +pid=$! +echo "pid is ${pid}" + +i386-elf-gdb -x gdbscript; kill -9 $pid + + +# qemu-system-i386 -drive file=HD.IMG,format=raw,index=0,media=disk -cdrom kernel.iso + + +# -cdrom kernel.iso +# -drive file=kernel.iso,index=2,media=cdrom + +# connect a CDROM to the slave of ide0 +# -drive if=ide,index=1,media=cdrom + +# -hda,-hdb,-hdc,-hdd +# -drive file=file,index=0,media=disk +# -drive file=file,index=1,media=disk +# -drive file=file,index=2,media=disk +# -drive file=file,index=3,media=disk + + +# -s shorthand for -gdb tcp::1234 +# -S freeze CPU at startup (use 'c' to start execution) diff --git a/scripts/debug b/scripts/debug new file mode 100644 index 0000000..6ec523c --- /dev/null +++ b/scripts/debug @@ -0,0 +1 @@ +i386-elf-gdb diff --git a/scripts/iso b/scripts/iso new file mode 100644 index 0000000..9d3aae3 --- /dev/null +++ b/scripts/iso @@ -0,0 +1,3 @@ +dnf install grub2 +dnf install xorriso +grub2-mkrescue -o grub.iso iso diff --git a/scripts/iso.grub.cfg b/scripts/iso.grub.cfg new file mode 100644 index 0000000..8d13887 --- /dev/null +++ b/scripts/iso.grub.cfg @@ -0,0 +1,8 @@ +set default="0" + +set timeout=1 +menuentry 'Kernel' --class os { + #insmod ext2 + multiboot2 /boot/Kernel root=hda0 delay=2 + boot +} diff --git a/scripts/mkiso.sh b/scripts/mkiso.sh new file mode 100755 index 0000000..5390789 --- /dev/null +++ b/scripts/mkiso.sh @@ -0,0 +1,5 @@ +# 在父目录运行 +mkdir -p /tmp/iso/boot/grub/ +cp iso.grub.cfg /tmp/iso/boot/grub/ +cp KERNEL.BIN /tmp/iso/boot/Kernel +grub2-mkrescue -o kernel.iso /tmp/iso