From 321bb9902f61282a202076e06b74d84d094fdbbe Mon Sep 17 00:00:00 2001 From: acevest Date: Sun, 14 May 2023 23:04:08 +0800 Subject: [PATCH] =?utf8?q?=E6=94=AF=E6=8C=81=E9=80=9A=E8=BF=87iso=E5=90=AF?= =?utf8?q?=E5=8A=A8=E5=86=85=E6=A0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .clang-format | 2 ++ .gitignore | 1 + gdbscript | 1 + qemu.sh | 25 +++++++++++++++++++++++++ scripts/debug | 1 + scripts/iso | 3 +++ scripts/iso.grub.cfg | 8 ++++++++ scripts/mkiso.sh | 5 +++++ 8 files changed, 46 insertions(+) create mode 100644 gdbscript create mode 100755 qemu.sh create mode 100644 scripts/debug create mode 100644 scripts/iso create mode 100644 scripts/iso.grub.cfg create mode 100755 scripts/mkiso.sh 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 -- 2.44.0