2022-12-13 20:21:28 +00:00
|
|
|
QEMU := qemu-system-x86_64
|
2022-12-14 21:45:24 +00:00
|
|
|
QEMU_FLAGS := -m 64M -smp 4
|
2022-12-13 20:21:28 +00:00
|
|
|
|
2022-12-21 08:30:23 +00:00
|
|
|
ARCH_TEMP_FILES := $(BUILD_DIR)/$(KERNEL_EXEC).elf32
|
2022-12-13 20:21:28 +00:00
|
|
|
|
|
|
|
|
# qemu refuses to boot ELF64 binaries. this creates a patched version of the kernel
|
|
|
|
|
# binary to trick qemu into thinking its an ELF32.
|
|
|
|
|
# this has no effect on the kernel itself; the x86_64 kernel's
|
|
|
|
|
# entry point is 32-bit machine code.
|
2022-12-21 08:30:23 +00:00
|
|
|
$(BUILD_DIR)/$(KERNEL_EXEC).elf32: $(BUILD_DIR)/$(KERNEL_EXEC)
|
|
|
|
|
@cp $(BUILD_DIR)/$(KERNEL_EXEC) $(BUILD_DIR)/$(KERNEL_EXEC).elf32
|
|
|
|
|
@printf '\x03\x00' | dd of=$(BUILD_DIR)/$(KERNEL_EXEC).elf32 bs=1 seek=18 count=2 conv=notrunc 2> /dev/null
|
2022-12-13 20:21:28 +00:00
|
|
|
|
2022-12-21 08:30:23 +00:00
|
|
|
run: $(BUILD_DIR)/$(KERNEL_EXEC) $(BUILD_DIR)/$(KERNEL_EXEC).elf32
|
2022-12-24 17:42:33 +00:00
|
|
|
@printf " \033[1;93mQEMU\033[0m $<\n"
|
2022-12-13 20:21:28 +00:00
|
|
|
|
2022-12-24 10:28:28 +00:00
|
|
|
@$(QEMU) -kernel $(BUILD_DIR)/$(KERNEL_EXEC).elf32 -monitor stdio
|
2022-12-13 20:21:28 +00:00
|
|
|
|
2022-12-21 08:30:23 +00:00
|
|
|
debug: $(BUILD_DIR)/$(KERNEL_EXEC) $(BUILD_DIR)/$(KERNEL_EXEC).elf32
|
2022-12-14 21:45:24 +00:00
|
|
|
@./tools/kernel-debug/debug_session.sh \
|
|
|
|
|
tools/kernel-debug/gdb_session_init \
|
|
|
|
|
tools/kernel-debug/lldb_session_init \
|
|
|
|
|
$(QEMU) \
|
2022-12-21 08:30:23 +00:00
|
|
|
-kernel $(BUILD_DIR)/$(KERNEL_EXEC).elf32 -S -s \
|
2022-12-24 17:42:33 +00:00
|
|
|
-display curses -serial file:$(BUILD_DIR)/socks.log $(QEMU_FLAGS)
|
2022-12-14 21:45:24 +00:00
|
|
|
|
2022-12-13 20:21:28 +00:00
|
|
|
|