-
Notifications
You must be signed in to change notification settings - Fork 265
/
Makefile.emulators
93 lines (70 loc) · 1.97 KB
/
Makefile.emulators
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# Allow to run kernel on different emulators with different prebuilt rootfs
# Rootfs preparation
hda:
@make hda -C rootfs
flp:
@make flp -C rootfs
ramfs:
@make ramfs -C rootfs
# VM (Qemu/Bochs) Setting for different rootfs
ROOT_RAM = 0000
ROOT_FDB = 021d
ROOT_HDA = 0301
SETROOTDEV_CMD = $(SETROOTDEV) images/Image
SETROOTDEV_CMD_RAM = $(SETROOTDEV_CMD) $(ROOT_RAM) rootfs/$(RAM_IMG)
SETROOTDEV_CMD_FDB = $(SETROOTDEV_CMD) $(ROOT_FDB)
SETROOTDEV_CMD_HDA = $(SETROOTDEV_CMD) $(ROOT_HDA)
QEMU_CMD = $(QEMU) -m 16M -boot a -fda images/Image
QEMU_CMD_FDB = $(QEMU_CMD) -fdb rootfs/$(FLP_IMG)
QEMU_CMD_HDA = $(QEMU_CMD) -hda rootfs/$(HDA_IMG)
nullstring :=
QEMU_DBG = $(nullstring) -s -S #-nographic #-serial '/dev/ttyS0'"
BOCHS_CFG = tools/bochs/bochsrc/
BOCHS_CMD = $(BOCHS) -f $(BOCHS_CFG)/bochsrc-fda.bxrc
BOCHS_CMD_FDB = $(BOCHS) -f $(BOCHS_CFG)/bochsrc-fdb.bxrc
BOCHS_CMD_HDA = $(BOCHS) -f $(BOCHS_CFG)/bochsrc-hd.bxrc
BOCHS_DBG = .dbg
VM = $(shell cat $(VM_CFG))
ifeq ($(VM), bochs)
NEW_VM=qemu
else
NEW_VM=bochs
endif
switch:
@echo "Switch to use emulator: $(NEW_VM)"
@echo $(NEW_VM) > $(VM_CFG)
VM=$(shell cat $(VM_CFG))
ifeq ($(VM), bochs)
VM_CMD = $(BOCHS_CMD)
VM_CMD_FDB = $(BOCHS_CMD_FDB)
VM_CMD_HDA = $(BOCHS_CMD_HDA)
VM_DBG = $(BOCHS_DBG)
else
VM_CMD = $(QEMU_CMD)
VM_CMD_FDB = $(QEMU_CMD_FDB)
VM_CMD_HDA = $(QEMU_CMD_HDA)
VM_DBG = $(QEMU_DBG)
endif
# Running on emulators with differrent rootfs
ramdisk-boot:
@# Force init/main.o build with ramdisk support
make -B init/main.o RAMDISK=2048
start: ramdisk-boot Image
$(SETROOTDEV_CMD_RAM)
$(VM_CMD)
start-fd: Image flp
$(SETROOTDEV_CMD_FDB)
$(VM_CMD_FDB)
start-hd: Image hda
$(SETROOTDEV_CMD_HDA)
$(VM_CMD_HDA)
# Debugging the above targets
debug: ramdisk-boot Image
$(SETROOTDEV_CMD_RAM)
$(VM_CMD)$(VM_DBG)
debug-fd: Image flp
$(SETROOTDEV_CMD_FDB)
$(VM_CMD_FDB)$(VM_DBG)
debug-hd: Image hda
$(SETROOTDEV_CMD_HDA)
$(VM_CMD_HDA)$(VM_DBG)