]> Zhao Yanbai Git Server - kernel.git/commitdiff
支持通过iso启动内核
authoracevest <zhaoyanbai@126.com>
Sun, 14 May 2023 15:04:08 +0000 (23:04 +0800)
committeracevest <zhaoyanbai@126.com>
Sun, 14 May 2023 15:04:08 +0000 (23:04 +0800)
.clang-format
.gitignore
gdbscript [new file with mode: 0644]
qemu.sh [new file with mode: 0755]
scripts/debug [new file with mode: 0644]
scripts/iso [new file with mode: 0644]
scripts/iso.grub.cfg [new file with mode: 0644]
scripts/mkiso.sh [new file with mode: 0755]

index 8f9dc1abdb6559a840175425088b7255b795b8b1..3db5ed9c18157f6f76ad16c150232d8f19d31efb 100644 (file)
@@ -6,3 +6,5 @@ TabWidth: 4
 
 IndentCaseLabels: false
 
+# 行注释 "//" 前增加两个空格
+SpacesBeforeTrailingComments: 2
index eeddd022c4ecc3e8948e61f9f2b7bdb426235827..c04f383149227711c97827bb02eb89da96d0e43d 100644 (file)
@@ -34,3 +34,4 @@ bochsout.txt
 *.lock
 *.DS_Store
 .vscode
+*.iso
diff --git a/gdbscript b/gdbscript
new file mode 100644 (file)
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 (executable)
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 (file)
index 0000000..6ec523c
--- /dev/null
@@ -0,0 +1 @@
+i386-elf-gdb
diff --git a/scripts/iso b/scripts/iso
new file mode 100644 (file)
index 0000000..9d3aae3
--- /dev/null
@@ -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 (file)
index 0000000..8d13887
--- /dev/null
@@ -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 (executable)
index 0000000..5390789
--- /dev/null
@@ -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