-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathMakefile
More file actions
182 lines (159 loc) · 3.83 KB
/
Makefile
File metadata and controls
182 lines (159 loc) · 3.83 KB
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
init:
@ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
@. "${HOME}/.cargo/env" && \
rustup install nightly && \
rustup default nightly && \
rustup target add x86_64-unknown-none && \
rustup component add rust-src llvm-tools-preview && \
cargo install bootimage
#
# BUILD
#
build: compile_kernel build_iso
#@cargo rustc --release --target x86_64-r2.json -- -C relocation-model=static --emit=obj
compile_kernel:
@cargo build \
--features kernel_text \
--target-dir target/kernel_text \
--release \
-Z build-std=core,compiler_builtins \
--target x86_64-r2.json
@cp target/kernel_text/x86_64-r2/release/kernel.elf iso/boot/kernel_text.elf
@cargo build \
--features kernel_graphics \
--target-dir target/kernel_graphics \
--release \
-Z build-std=core,compiler_builtins \
--target x86_64-r2.json
@cp target/kernel_graphics/x86_64-r2/release/kernel.elf iso/boot/kernel_graphics.elf
# To enable rprint!/rprintn!/rprintb! on COM1 (serial debug mode, breaks SLIP networking):
# make build EXTRA_FEATURES=serial_debug
EXTRA_FEATURES ?=
compile_kernel_debug:
@cargo build \
--features "kernel_text,serial_debug,$(EXTRA_FEATURES)" \
--target-dir target/kernel_text_debug \
--release \
-Z build-std=core,compiler_builtins \
--target x86_64-r2.json
@cp target/kernel_text_debug/x86_64-r2/release/kernel.elf iso/boot/kernel_text.elf
build_iso:
@grub2-mkrescue \
-o r2.iso iso/ \
--modules="multiboot2 video video_bochs video_cirrus gfxterm all_video"
build_floppy:
@dd \
if=/dev/zero \
of=fat.img \
bs=512 \
count=2880
@mkfs.fat \
-F 12 \
fat.img
@echo "Hello from floppy!" > /tmp/hello.txt
@mcopy -i fat.img /tmp/hello.txt ::HELLO.TXT
@mcopy -i fat.img ../r2_app/c/icmpresp/icmpresp.elf ::ICMPR.ELF
@mcopy -i fat.img ../r2_app/c/garn/garn.elf ::GARN.ELF
@mcopy -i fat.img ../r2_app/c/them/prg0.bin ::PRG0.BIN
@mcopy -i fat.img ../r2_app/c/them/them.elf ::THEM.ELF
#
# RUN
#
run:
@qemu-system-x86_64 \
-serial pty \
-drive format=raw,file=target/x86_64-r2/debug/bootimage-x86_64-r2.bin
run_iso:
@qemu-system-x86_64 \
-boot d \
-m 2G \
-vga std \
-cdrom r2.iso \
-serial pty
run_iso_usb:
@qemu-system-x86_64 \
-m 2G \
-vga std \
-hdb /dev/sdb \
-serial pty
run_iso_net:
@qemu-system-x86_64 \
-boot d \
-m 2G \
-vga std \
-cdrom r2.iso \
-netdev tap,id=net0,ifname=tap0,script=no,downscript=no \
-device rtl8139,netdev=net0 \
-serial pty
PTY_NUMBER ?= pty
run_iso_pty:
@qemu-system-x86_64 \
-boot d \
-m 2G \
-vga std \
-cdrom r2.iso \
-serial ${PTY_NUMBER}
run_iso_floppy: build_floppy
@qemu-system-x86_64 \
-boot d \
-m 2G \
-vga std \
-cdrom r2.iso \
-fda fat.img \
-serial pty \
-audiodev pa,id=snd0 \
-machine pcspk-audiodev=snd0
run_iso_floppy_drive:
@sudo qemu-system-x86_64 \
-boot d \
-m 2G \
-vga std \
-cdrom r2.iso \
-serial pty \
-blockdev host_device,node-name=floppy1,filename=/dev/sda \
-device floppy,drive=floppy1
run_iso_debug:
@qemu-system-x86_64 \
-boot d \
-m 4G \
-cdrom r2.iso \
-fda fat.img \
-no-reboot \
-no-shutdown \
-serial stdio \
-audiodev pa,id=snd0 \
-machine pcspk-audiodev=snd0
run_iso_debug_int:
@qemu-system-x86_64 \
-boot d \
-m 4G \
-cdrom r2.iso \
-fda fat.img \
-no-reboot \
-no-shutdown \
-serial stdio \
-d int,cpu_reset,page \
-audiodev pa,id=snd0 \
-machine pcspk-audiodev=snd0
#
# HELPERS
#
clean:
@cargo clean
clippy:
@cargo clippy \
--release \
--target x86_64-r2.json \
--no-default-features \
-- -D warnings
ifeq (${SONAR_HOST_URL}${SONAR_TOKEN},)
sonar_check:
else
sonar_check:
@docker run --rm \
--dns ${DNS_NAMESERVER} \
-e SONAR_HOST_URL="${SONAR_HOST_URL}" \
-e SONAR_TOKEN="${SONAR_TOKEN}" \
-v ".:/usr/src" \
sonarsource/sonar-scanner-cli
endif