-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
162 lines (142 loc) · 3.92 KB
/
Makefile
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
.PHONY: FORCE
PROFILE=debug
QEMU=qemu-system-x86_64
QEMU_ARGS= \
-drive if=pflash,file=ovmf/OVMF_CODE.fd,format=raw \
-drive if=pflash,file=ovmf/lemola_os_ovmf_vars.fd,format=raw,readonly \
-drive file=disk.img,format=raw \
-device nec-usb-xhci,id=xhci \
-device usb-hub,bus=xhci.0,port=4 \
-device usb-mouse,bus=xhci.0,port=4.4 \
-device usb-kbd,bus=xhci.0,port=4.5 \
-serial telnet::5555,server,nowait \
-no-reboot \
-no-shutdown \
-monitor stdio
ifeq ($(PROFILE),release)
CARGO_FLAGS=--release
endif
kernel/target/x86_64-lemolaos-eabi/$(PROFILE)/kernel.elf: FORCE
cd kernel && \
cargo build $(CARGO_FLAGS)
bootloader/target/x86_64-unknown-uefi/$(PROFILE)/bootloader.efi: FORCE
cd bootloader && \
cargo build $(CARGO_FLAGS)
build: bootloader/target/x86_64-unknown-uefi/$(PROFILE)/bootloader.efi kernel/target/x86_64-lemolaos-eabi/$(PROFILE)/kernel.elf
disk.img: bootloader/target/x86_64-unknown-uefi/$(PROFILE)/bootloader.efi kernel/target/x86_64-lemolaos-eabi/$(PROFILE)/kernel.elf
# qemu-img create [-f format] [-o options] filename [size][preallocation]
# mkfs.fat [-n VOLUME-NAME] [-s SECTORS-PER-CLUSTER] [-f NUMBER-OF-FATS] [-R NUMBER-OF-RESERVED-SECTORS] [-F FAT-SIZE]
# ref.) `man mkfs.fat`
# mount [-o options] device dir
# loop -> mount as loop device
qemu-img create -f raw disk.img 200M && \
mkfs.fat -n "lemola_osv2" -s 2 -f 2 -R 32 -F 32 disk.img && \
mkdir -p mnt && \
sudo mount -o loop disk.img mnt && \
sudo mkdir -p mnt/EFI/BOOT && \
sudo cp bootloader/target/x86_64-unknown-uefi/$(PROFILE)/bootloader.efi mnt/EFI/BOOT/BOOTX64.EFI && \
sudo cp kernel/target/x86_64-lemolaos-eabi/$(PROFILE)/kernel.elf mnt/kernel.elf && \
sudo umount mnt
install: bootloader/target/x86_64-unknown-uefi/$(PROFILE)/bootloader.efi kernel/target/x86_64-lemolaos-eabi/$(PROFILE)/kernel.elf
mkdir -p mnt && \
sudo mount -t drvfs d: mnt && \
sudo mkdir -p mnt/EFI/BOOT && \
sudo cp bootloader/target/x86_64-unknown-uefi/$(PROFILE)/bootloader.efi mnt/EFI/BOOT/BOOTX64.EFI && \
sudo cp kernel/target/x86_64-lemolaos-eabi/$(PROFILE)/kernel.elf mnt/kernel.elf && \
sudo umount mnt
run: disk.img
$(QEMU) $(QEMU_ARGS)
# -device usb-mouse,bus=xhci.0
# -device usb-kbd,bus=xhci.0
# -device usb-mouse,bus=xhci.0
# for serial port
# telnet localhost 5555
run_gdb: disk.img
$(QEMU) $(QEMU_ARGS) \
-gdb tcp::12345 -S
# on gdb
# target remote localhost:12345
telnet:
while true; do \
telnet localhost 5555 2> /dev/null | grep -v "Trying 127.0.0.1..."; \
if [ "$$?" -eq 0 ]; then \
echo "===========disconnected==========="; \
fi; \
sleep 1; \
done;
test_kernel:
cd kernel-lib && \
cargo test --features "std"
test_font:
cd gen_font && \
cargo test
test_all: test_kernel test_font
fmt:
cd kernel && \
cargo fmt
cd common && \
cargo fmt
cd gen_font && \
cargo fmt
cd bootloader && \
cargo fmt
cd kernel-lib && \
cargo fmt
check:
cd kernel && \
cargo check
cd common && \
cargo check
cd gen_font && \
cargo check
cd bootloader && \
cargo check
cd kernel-lib && \
cargo check
fmt_ci:
cd kernel && \
cargo fmt --all -- --check
cd common && \
cargo fmt --all -- --check
cd gen_font && \
cargo fmt --all -- --check
cd bootloader && \
cargo fmt --all -- --check
cd kernel-lib && \
cargo fmt --all -- --check
clippy_ci:
cd kernel && \
cargo clippy -- -D warnings
cd common && \
cargo clippy -- -D warnings
cd gen_font && \
cargo clippy -- -D warnings
cd bootloader && \
cargo clippy -- -D warnings
cd kernel-lib && \
cargo clippy -- -D warnings
clippy:
cd kernel && \
cargo clippy
cd common && \
cargo clippy
cd gen_font && \
cargo clippy
cd bootloader && \
cargo clippy
cd kernel-lib && \
cargo clippy
clean:
cd kernel && \
cargo clean
cd common && \
cargo clean
cd gen_font && \
cargo clean
cd bootloader && \
cargo clean
cd kernel-lib && \
cargo clean
kill:
killall -9 qemu-system-x86_64
git checkout f249e14540fc9ea6cabe4bfd932db2888e0d97ee -- ovmf/lemola_os_ovmf_vars.fd