chore: Add patch for qemu

Removed patch "Replace GDB exit calls with proper shutdown" so when we stop debugging in vscode, the qemu process is automatically killed.

Signed-off-by: EnderIce2 <enderice2@protonmail.com>
This commit is contained in:
EnderIce2 2024-12-28 08:49:12 +02:00
parent eb7c13dd45
commit 9ea2f4266e
No known key found for this signature in database
GPG Key ID: 2EE20AF089811A5A
3 changed files with 56 additions and 7 deletions

View File

@ -2,7 +2,7 @@ WORKING_DIR = $(CURDIR)
CROSS_DIR=$(WORKING_DIR)/cross
export PATH := $(CROSS_DIR):$(PATH)
QEMU_VERSION = 9.1.2
QEMU_VERSION = 9.2.0
default:
$(error Please specify a target)
@ -11,6 +11,9 @@ all: do_tools do_limine __clone_all do_binutils do_gcc do_qemu
clean:
rm -f rep ep
rm -rf binutils-gdb
rm -rf gcc
rm -rf qemu
do_tools:
gcc -w ReadEthernetPackets.c -o rep
@ -27,12 +30,14 @@ endif
__clone_qemu:
ifeq ("$(wildcard ./qemu)", "")
wget https://download.qemu.org/qemu-${QEMU_VERSION}.tar.xz
tar xvJf qemu-${QEMU_VERSION}.tar.xz
rm -f qemu-${QEMU_VERSION}.tar.xz
mv qemu-${QEMU_VERSION} qemu
git clone --depth 1 -b v${QEMU_VERSION} --single-branch https://gitlab.com/qemu-project/qemu.git qemu
else
$(info > TOOLS: Skipping downloading qemu because directory already exists.)
$(info > TOOLS: Reseting qemu...)
cd qemu && \
git fetch origin && \
git reset --hard v${QEMU_VERSION} && \
git clean -dfx
$(info > TOOLS: Operation completed for qemu)
endif
.PHONY: all clean __clone_binutils __clone_gcc __prep_cross __patch_cross __patch_cross_binutils __patch_cross_gcc
@ -74,6 +79,10 @@ __patch_cross_gcc: __clone_gcc
$(info > TOOLS: Running autoconf for gcc/libstdc++-v3)
cd gcc/libstdc++-v3 && autoconf
__patch_cross_qemu: __clone_qemu
$(info > TOOLS: Patching qemu)
cd qemu && git apply ../qemu.patch
__patch_cross: __patch_cross_binutils __patch_cross_gcc
__prep_cross:
@ -86,6 +95,8 @@ __clone_all_no_qemu: __clone_binutils __clone_gcc
__clone_all: __clone_qemu __clone_all_no_qemu
do_qemu: __prep_cross
$(MAKE) __patch_cross_qemu
$(MAKE) __prep_cross
cd qemu && \
bash ./configure --target-list=x86_64-softmmu,i386-softmmu,aarch64-softmmu \
--prefix="$(CROSS_DIR)" \

View File

@ -5,5 +5,21 @@
In this directory, you will find:
- An error parser for qemu debug output.
- Ethernet packet reader for testing network connection.
- A makefile script to clone and build gcc, binutils and qemu.
- A Makefile script to clone, patch and build gcc, binutils and qemu for you.
- `website` directory containing the source code for the website.
## Reasons for the following patches
- `gcc.patch`
- Required for cross-compiling the OS.
- `binutils-gdb.patch`
- Same as above.
- `qemu.patch`
- Removed patch "Replace GDB exit calls with proper shutdown" so when we stop debugging in vscode, the qemu process is automatically killed.
## Useful links
- [Create git patches](https://stackoverflow.com/a/15438863/9352057)
- [QEMU git tags](https://gitlab.com/qemu-project/qemu/-/tags)

22
tools/qemu.patch Normal file
View File

@ -0,0 +1,22 @@
diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c
index b1def7e..a02b29a 100644
--- a/gdbstub/gdbstub.c
+++ b/gdbstub/gdbstub.c
@@ -1438,7 +1438,7 @@ static void handle_v_kill(GArray *params, void *user_ctx)
gdb_put_packet("OK");
error_report("QEMU: Terminated via GDBstub");
gdb_exit(0);
- gdb_qemu_exit(0);
+ exit(0);
}
static const GdbCmdParseEntry gdb_v_commands_table[] = {
@@ -2091,7 +2091,7 @@ static int gdb_handle_packet(const char *line_buf)
/* Kill the target */
error_report("QEMU: Terminated via GDBstub");
gdb_exit(0);
- gdb_qemu_exit(0);
+ exit(0);
break;
case 'D':
{