This repository has been archived on 2024-11-18. You can view files and clone it, but cannot push or open issues or pull requests.
kernel-dev-old/test/Makefile

51 lines
1.2 KiB
Makefile
Raw Normal View History

TARGET = ../src/metaverse.elf
2023-12-10 22:49:20 +08:00
ARCH := $(shell uname -m)
.PHONY: run debug load mount unmount
2023-12-13 02:25:06 +08:00
BIOS = bios/${ARCH}/OVMF_CODE.fd
run:
2023-12-29 22:54:46 +08:00
@doas modprobe nbd
@make load
2023-12-29 22:54:46 +08:00
@qemu-system-${ARCH} -m 4G metaverse.img -bios ${BIOS}
debug:
2023-12-03 17:42:38 +08:00
@echo "在gdb中连接远程目标'localhost:1234'即可"
2023-12-29 22:54:46 +08:00
@doas modprobe nbd
@make load
2023-12-29 22:54:46 +08:00
@qemu-system-${ARCH} -m 4G metaverse.img -bios ${BIOS} -s -S
create:
@qemu-img create -f qcow2 metaverse.img 512M
2023-12-29 22:54:46 +08:00
@doas modprobe nbd
@doas qemu-nbd --connect=/dev/nbd0 metaverse.img
@doas partprobe /dev/nbd0
@echo "你需要为这个虚拟磁盘写入一个GPT分区表并分出efi分区和根分区。"
2023-12-29 22:54:46 +08:00
@doas fdisk /dev/nbd0
@doas mkfs.fat -F 32 /dev/nbd0p1
@doas mkfs.fat -F 32 /dev/nbd0p2
@doas mount /dev/nbd0p2 mnt/
@doas mount -m /dev/nbd0p1 mnt/boot/
@doas mkdir mnt/boot/EFI/
@make unmount
load:
@echo loading kernel ...
@make mount
2023-12-29 22:54:46 +08:00
@doas cp ${TARGET} mnt/boot/
@make unmount
mount:
2023-12-29 22:54:46 +08:00
@doas modprobe nbd
@doas qemu-nbd --connect=/dev/nbd0 metaverse.img
@doas partprobe /dev/nbd0
@doas mount /dev/nbd0p2 mnt/
@doas mount /dev/nbd0p1 mnt/boot/
unmount:
@sync
2023-12-29 22:54:46 +08:00
@doas umount /dev/nbd0p1
@doas umount /dev/nbd0p2
@doas qemu-nbd --disconnect /dev/nbd0