aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.nvim.lua34
-rw-r--r--.vscode/tasks.json36
-rwxr-xr-xscripts/qemu-wrapper.sh30
3 files changed, 42 insertions, 58 deletions
diff --git a/.nvim.lua b/.nvim.lua
index 1cec8af..ba8f78b 100644
--- a/.nvim.lua
+++ b/.nvim.lua
@@ -49,39 +49,19 @@ local function launch_qemu(artifact_path, is_debug)
end
local paths = resolve_build_paths(artifact_path)
+ local debug_flag = is_debug and "1" or "0"
+ local shell_cmd = string.format("%s/scripts/qemu-wrapper.sh '%s' '%s' '%s' '%s'",
+ workspace_folder, workspace_folder, paths.build_type, paths.iso, debug_flag)
- local cmd = {
- "qemu-system-x86_64",
- "-m", "32M",
- "-machine", "q35",
- "-smp", "4,sockets=1,cores=4,threads=1",
- "-display", "curses",
- "-debugcon", string.format("file:%s/qemu-debugcon-%s.log", workspace_folder, paths.build_type),
- "-cdrom", paths.iso
- }
-
- if is_debug then
- table.insert(cmd, 2, "-s")
- table.insert(cmd, 3, "-no-reboot")
- table.insert(cmd, 4, "-d")
- table.insert(cmd, 5, "int,cpu_reset")
- end
-
- local shell_cmd = string.format("%s 2>%s/qemu-stderr-%s.log", table.concat(cmd, " "), workspace_folder, paths.build_type)
-
- vim.cmd("botright vsplit")
- vim.cmd("enew")
+ vim.cmd("botright vsplit | enew")
qemu_bufnr = vim.api.nvim_get_current_buf()
-
- vim.api.nvim_buf_set_name(qemu_bufnr, "TeachOS QEMU")
+ vim.api.nvim_buf_set_name(qemu_bufnr, "TeachOS QEMU (" .. paths.build_type .. ")")
vim.opt_local.number = false
vim.opt_local.relativenumber = false
vim.opt_local.signcolumn = "no"
- qemu_job_id = vim.fn.termopen({ "bash", "-c", shell_cmd }, {
- on_exit = function()
- qemu_job_id = nil
- end
+ qemu_job_id = vim.fn.termopen(shell_cmd, {
+ on_exit = function() qemu_job_id = nil end
})
vim.cmd("wincmd p")
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
index d673a7a..1aa53d9 100644
--- a/.vscode/tasks.json
+++ b/.vscode/tasks.json
@@ -6,23 +6,10 @@
"command": "${workspaceFolder}/scripts/qemu-wrapper.sh",
"type": "shell",
"args": [
- "-s",
- "-m",
- "32M",
- "-machine",
- "q35",
- "-smp",
- "4,sockets=1,cores=4,threads=1",
- "-display",
- "curses",
- "-debugcon",
- "file:${workspaceFolder}/qemu-debugcon-${command:cmake.buildType}.log",
- "-no-reboot",
- "-d",
- "int,cpu_reset",
- "-cdrom",
+ "${workspaceFolder}",
+ "${command:cmake.buildType}",
"${command:cmake.buildDirectory}/bin/${command:cmake.buildType}/kernel.iso",
- "2>${workspaceFolder}/qemu-stderr-${command:cmake.buildType}.log"
+ "1"
],
"isBackground": true,
"presentation": {
@@ -47,22 +34,13 @@
},
{
"label": "QEMU",
- "command": "qemu-system-x86_64",
+ "command": "${workspaceFolder}/scripts/qemu-wrapper.sh",
"type": "shell",
"args": [
- "-m",
- "32M",
- "-machine",
- "q35",
- "-smp",
- "4,sockets=1,cores=4,threads=1",
- "-display",
- "curses",
- "-debugcon",
- "file:${workspaceFolder}/qemu-debugcon-${command:cmake.buildType}.log",
- "-cdrom",
+ "${workspaceFolder}",
+ "${command:cmake.buildType}",
"${command:cmake.buildDirectory}/bin/${command:cmake.buildType}/kernel.iso",
- "2>${workspaceFolder}/qemu-stderr-${command:cmake.buildType}.log"
+ "0"
],
"isBackground": true,
"presentation": {
diff --git a/scripts/qemu-wrapper.sh b/scripts/qemu-wrapper.sh
index fa89ac5..49c01ec 100755
--- a/scripts/qemu-wrapper.sh
+++ b/scripts/qemu-wrapper.sh
@@ -1,4 +1,30 @@
#!/bin/bash
+# scripts/qemu-wrapper.sh
-echo "QEMU WRAPPER"
-qemu-system-x86_64 $@
+WORKSPACE_DIR=${1:-.}
+BUILD_TYPE=${2:-Debug}
+ISO_PATH=$3
+IS_DEBUG=${4:-0}
+
+if [ -z "$ISO_PATH" ]; then
+ echo "Usage: $0 <workspace_dir> <build_type> <iso_path> [is_debug]"
+ exit 1
+fi
+
+ARGS=(
+ "-m" "32M"
+ "-machine" "q35"
+ "-smp" "4,sockets=1,cores=4,threads=1"
+ "-display" "curses"
+ "-debugcon" "file:${WORKSPACE_DIR}/qemu-debugcon-${BUILD_TYPE}.log"
+ "-cdrom" "${ISO_PATH}"
+)
+
+if [ "$IS_DEBUG" == "1" ]; then
+ ARGS=( "-s" "-no-reboot" "-d" "int,cpu_reset" "${ARGS[@]}" )
+fi
+
+echo "QEMU WRAPPER: Executing TeachOS"
+echo "Arguments: ${ARGS[@]}"
+
+qemu-system-x86_64 "${ARGS[@]}" 2> "${WORKSPACE_DIR}/qemu-stderr-${BUILD_TYPE}.log"