1 | -include params.mk |
---|
2 | |
---|
3 | export # export all variable to applications sub-Makefile |
---|
4 | |
---|
5 | CC = mipsel-unknown-elf-gcc |
---|
6 | AS = mipsel-unknown-elf-as |
---|
7 | LD = mipsel-unknown-elf-ld |
---|
8 | DU = mipsel-unknown-elf-objdump |
---|
9 | AR = mipsel-unknown-elf-ar |
---|
10 | |
---|
11 | # Defaults values for hardware parameters and applications |
---|
12 | # These parameters should be defined in the params.mk file |
---|
13 | ARCH ?= pathname |
---|
14 | X_SIZE ?= 1 |
---|
15 | Y_SIZE ?= 1 |
---|
16 | NB_PROCS ?= 1 |
---|
17 | NB_TTYS ?= 1 |
---|
18 | FBF_WIDTH ?= 256 |
---|
19 | IOC_TYPE ?= BDV |
---|
20 | MWR_TYPE ?= CPY |
---|
21 | APPLIS ?= shell |
---|
22 | |
---|
23 | # build the list of applications used as argument by genmap |
---|
24 | GENMAP_APPLIS := $(addprefix --,$(APPLIS)) |
---|
25 | |
---|
26 | # build the list of application.py (used as dependencies by genmap) |
---|
27 | APPLIS_PY = applications/classif/classif.py \ |
---|
28 | applications/convol/convol.py \ |
---|
29 | applications/coproc/coproc.py \ |
---|
30 | applications/display/display.py \ |
---|
31 | applications/dhrystone/dhrystone.py \ |
---|
32 | applications/gameoflife/gameoflife.py \ |
---|
33 | applications/mjpeg/mjpeg.py \ |
---|
34 | applications/ocean/ocean.py \ |
---|
35 | applications/raycast/raycast.py \ |
---|
36 | applications/router/router.py \ |
---|
37 | applications/shell/shell.py \ |
---|
38 | applications/sort/sort.py \ |
---|
39 | applications/transpose/transpose.py \ |
---|
40 | applications/coremark/coremark.py |
---|
41 | |
---|
42 | # build the list of applications to be executed (used in the all rule) |
---|
43 | APPLIS_ELF := $(addsuffix /appli.elf,$(addprefix applications/,$(APPLIS))) |
---|
44 | |
---|
45 | # Build PYTHONPATH |
---|
46 | PYTHONPATH := $(shell find . -name *.py | grep -o "\(.*\)/" | sort -u | tr '\n' :) |
---|
47 | |
---|
48 | # check hardware platform definition |
---|
49 | ifeq ($(wildcard $(ARCH)),) |
---|
50 | $(error please define in ARCH parameter the path to the platform) |
---|
51 | endif |
---|
52 | |
---|
53 | ### Rules that don't build a target file |
---|
54 | .PHONY: all dirs list extract clean clean-disk install-disk $(APPLIS_ELF) |
---|
55 | |
---|
56 | ### Objects to be linked for the drivers library |
---|
57 | DRIVERS_OBJS = build/drivers/dma_driver.o \ |
---|
58 | build/drivers/cma_driver.o \ |
---|
59 | build/drivers/xcu_driver.o \ |
---|
60 | build/drivers/bdv_driver.o \ |
---|
61 | build/drivers/hba_driver.o \ |
---|
62 | build/drivers/sdc_driver.o \ |
---|
63 | build/drivers/spi_driver.o \ |
---|
64 | build/drivers/rdk_driver.o \ |
---|
65 | build/drivers/iob_driver.o \ |
---|
66 | build/drivers/mmc_driver.o \ |
---|
67 | build/drivers/mwr_driver.o \ |
---|
68 | build/drivers/nic_driver.o \ |
---|
69 | build/drivers/tim_driver.o \ |
---|
70 | build/drivers/tty_driver.o \ |
---|
71 | build/drivers/pic_driver.o |
---|
72 | |
---|
73 | ### Objects to be linked for kernel.elf |
---|
74 | KERNEL_OBJS = build/common/utils.o \ |
---|
75 | build/common/kernel_locks.o \ |
---|
76 | build/common/kernel_barriers.o \ |
---|
77 | build/common/tty0.o \ |
---|
78 | build/common/vmem.o \ |
---|
79 | build/common/kernel_malloc.o \ |
---|
80 | build/fat32/fat32.o \ |
---|
81 | build/kernel/giet.o \ |
---|
82 | build/kernel/switch.o \ |
---|
83 | build/kernel/ctx_handler.o \ |
---|
84 | build/kernel/exc_handler.o \ |
---|
85 | build/kernel/sys_handler.o \ |
---|
86 | build/kernel/irq_handler.o \ |
---|
87 | build/kernel/kernel_init.o |
---|
88 | |
---|
89 | ### Objects to be linked for boot.elf |
---|
90 | BOOT_OBJS = build/common/utils.o \ |
---|
91 | build/common/kernel_locks.o \ |
---|
92 | build/common/kernel_barriers.o \ |
---|
93 | build/common/tty0.o \ |
---|
94 | build/common/pmem.o \ |
---|
95 | build/common/vmem.o \ |
---|
96 | build/common/kernel_malloc.o \ |
---|
97 | build/fat32/fat32.o \ |
---|
98 | build/kernel/ctx_handler.o \ |
---|
99 | build/kernel/irq_handler.o \ |
---|
100 | build/kernel/sys_handler.o \ |
---|
101 | build/kernel/switch.o \ |
---|
102 | build/boot/boot.o \ |
---|
103 | build/boot/boot_entry.o |
---|
104 | |
---|
105 | ### Objects to be linked for the user library |
---|
106 | USER_OBJS = build/libs/malloc.o \ |
---|
107 | build/libs/mwmr_channel.o \ |
---|
108 | build/libs/stdio.o \ |
---|
109 | build/libs/stdlib.o \ |
---|
110 | build/libs/string.o \ |
---|
111 | build/libs/user_barrier.o \ |
---|
112 | build/libs/user_lock.o |
---|
113 | |
---|
114 | ### Objects to be linked for the math library |
---|
115 | MATH_OBJS = build/libs/math/e_pow.o \ |
---|
116 | build/libs/math/e_rem_pio2.o \ |
---|
117 | build/libs/math/k_cos.o \ |
---|
118 | build/libs/math/k_rem_pio2.o \ |
---|
119 | build/libs/math/k_sin.o \ |
---|
120 | build/libs/math/s_copysign.o \ |
---|
121 | build/libs/math/s_fabs.o \ |
---|
122 | build/libs/math/s_finite.o \ |
---|
123 | build/libs/math/s_floor.o \ |
---|
124 | build/libs/math/s_isnan.o \ |
---|
125 | build/libs/math/sqrt.o \ |
---|
126 | build/libs/math/s_rint.o \ |
---|
127 | build/libs/math/s_scalbn.o \ |
---|
128 | build/libs/math/s_sin.o \ |
---|
129 | build/libs/math/s_cos.o \ |
---|
130 | build/libs/math/e_sqrt.o |
---|
131 | |
---|
132 | |
---|
133 | CFLAGS = -Wall -ffreestanding -mno-gpopt -mips32 -g -O2 \ |
---|
134 | -fno-delete-null-pointer-checks $(XCFLAGS) |
---|
135 | |
---|
136 | GIET_INCLUDE = -Igiet_boot \ |
---|
137 | -Igiet_kernel \ |
---|
138 | -Igiet_xml \ |
---|
139 | -Igiet_fat32 \ |
---|
140 | -Igiet_drivers \ |
---|
141 | -Igiet_common \ |
---|
142 | -Igiet_libs \ |
---|
143 | -I. |
---|
144 | |
---|
145 | DISK_IMAGE := hdd/virt_hdd.dmg |
---|
146 | |
---|
147 | ### The Mtools used to build the FAT32 disk image perform a few sanity checks, |
---|
148 | ### to make sure that the disk is indeed an MS-DOS disk. However, the size |
---|
149 | ### of the disk image used by the Giet-VM is not MS-DOS compliant. |
---|
150 | ### Setting this variable prevents these checks. |
---|
151 | MTOOLS_SKIP_CHECK := 1 |
---|
152 | |
---|
153 | ################################## |
---|
154 | ### first rule executed (make all) |
---|
155 | all: dirs \ |
---|
156 | install-disk |
---|
157 | mdir -/ -b -i $(DISK_IMAGE) ::/ |
---|
158 | |
---|
159 | ##################################################### |
---|
160 | ### create build directories |
---|
161 | dirs: |
---|
162 | @mkdir -p build/boot |
---|
163 | @mkdir -p build/common |
---|
164 | @mkdir -p build/drivers |
---|
165 | @mkdir -p build/fat32 |
---|
166 | @mkdir -p build/kernel |
---|
167 | @mkdir -p build/libs/math |
---|
168 | @mkdir -p hdd |
---|
169 | |
---|
170 | ##################################################### |
---|
171 | ### make a recursive list of the virtual disk content |
---|
172 | list: |
---|
173 | mdir -/ -w -i $(DISK_IMAGE) ::/ |
---|
174 | |
---|
175 | ######################################################## |
---|
176 | ### copy the files generated by the virtual prototype on |
---|
177 | ### the virtual disk "home" directory to the giet_vm home directory |
---|
178 | extract: |
---|
179 | mcopy -o -i $(DISK_IMAGE) ::/home . |
---|
180 | |
---|
181 | ######################################## |
---|
182 | ### clean all binary files |
---|
183 | clean: |
---|
184 | rm -f *.o *.elf *.bin *.txt core |
---|
185 | rm -f hard_config.h giet_vsegs.ld map.bin map.xml |
---|
186 | rm -rf build/ |
---|
187 | cd applications/classif && $(MAKE) clean && cd ../.. |
---|
188 | cd applications/convol && $(MAKE) clean && cd ../.. |
---|
189 | cd applications/coproc && $(MAKE) clean && cd ../.. |
---|
190 | cd applications/display && $(MAKE) clean && cd ../.. |
---|
191 | cd applications/dhrystone && $(MAKE) clean && cd ../.. |
---|
192 | cd applications/gameoflife && $(MAKE) clean && cd ../.. |
---|
193 | cd applications/mjpeg && $(MAKE) clean && cd ../.. |
---|
194 | cd applications/ocean && $(MAKE) clean && cd ../.. |
---|
195 | cd applications/raycast && $(MAKE) clean && cd ../.. |
---|
196 | cd applications/router && $(MAKE) clean && cd ../.. |
---|
197 | cd applications/shell && $(MAKE) clean && cd ../.. |
---|
198 | cd applications/sort && $(MAKE) clean && cd ../.. |
---|
199 | cd applications/transpose && $(MAKE) clean && cd ../.. |
---|
200 | cd applications/coremark && $(MAKE) clean && cd ../.. |
---|
201 | |
---|
202 | ######################################## |
---|
203 | ### delete disk image |
---|
204 | clean-disk: |
---|
205 | rm -rf $(DISK_IMAGE) |
---|
206 | |
---|
207 | ######################################## |
---|
208 | ### Copy content in the disk image |
---|
209 | ### create the three build / misc / home directories |
---|
210 | ### store the images files into misc |
---|
211 | install-disk: $(DISK_IMAGE) build/kernel/kernel.elf $(APPLIS_ELF) |
---|
212 | mmd -o -i $< ::/bin || true |
---|
213 | mmd -o -i $< ::/bin/kernel || true |
---|
214 | mmd -o -i $< ::/bin/classif || true |
---|
215 | mmd -o -i $< ::/bin/convol || true |
---|
216 | mmd -o -i $< ::/bin/coproc || true |
---|
217 | mmd -o -i $< ::/bin/dhrystone || true |
---|
218 | mmd -o -i $< ::/bin/display || true |
---|
219 | mmd -o -i $< ::/bin/gameoflife || true |
---|
220 | mmd -o -i $< ::/bin/mjpeg || true |
---|
221 | mmd -o -i $< ::/bin/ocean || true |
---|
222 | mmd -o -i $< ::/bin/raycast || true |
---|
223 | mmd -o -i $< ::/bin/router || true |
---|
224 | mmd -o -i $< ::/bin/shell || true |
---|
225 | mmd -o -i $< ::/bin/sort || true |
---|
226 | mmd -o -i $< ::/bin/transpose || true |
---|
227 | mmd -o -i $< ::/bin/coremark || true |
---|
228 | mmd -o -i $< ::/misc || true |
---|
229 | mmd -o -i $< ::/home || true |
---|
230 | mcopy -o -i $< map.bin ::/ |
---|
231 | mcopy -o -i $< build/kernel/kernel.elf ::/bin/kernel |
---|
232 | mcopy -o -i $< applications/classif/appli.elf ::/bin/classif || true |
---|
233 | mcopy -o -i $< applications/convol/appli.elf ::/bin/convol || true |
---|
234 | mcopy -o -i $< applications/coproc/appli.elf ::/bin/coproc || true |
---|
235 | mcopy -o -i $< applications/dhrystone/appli.elf ::/bin/dhrystone || true |
---|
236 | mcopy -o -i $< applications/display/appli.elf ::/bin/display || true |
---|
237 | mcopy -o -i $< applications/gameoflife/appli.elf ::/bin/gameoflife || true |
---|
238 | mcopy -o -i $< applications/mjpeg/appli.elf ::/bin/mjpeg || true |
---|
239 | mcopy -o -i $< applications/ocean/appli.elf ::/bin/ocean || true |
---|
240 | mcopy -o -i $< applications/raycast/appli.elf ::/bin/raycast || true |
---|
241 | mcopy -o -i $< applications/router/appli.elf ::/bin/router || true |
---|
242 | mcopy -o -i $< applications/shell/appli.elf ::/bin/shell || true |
---|
243 | mcopy -o -i $< applications/sort/appli.elf ::/bin/sort || true |
---|
244 | mcopy -o -i $< applications/transpose/appli.elf ::/bin/transpose || true |
---|
245 | mcopy -o -i $< applications/coremark/appli.elf ::/bin/coremark || true |
---|
246 | mcopy -o -i $< images/images_128.raw ::/misc |
---|
247 | mcopy -o -i $< images/philips_1024.raw ::/misc |
---|
248 | mcopy -o -i $< images/lena_256.raw ::/misc |
---|
249 | mcopy -o -i $< images/bridge_256.raw ::/misc |
---|
250 | mcopy -o -i $< images/couple_512.raw ::/misc |
---|
251 | mcopy -o -i $< images/door_32.raw ::/misc |
---|
252 | mcopy -o -i $< images/handle_32.raw ::/misc |
---|
253 | mcopy -o -i $< images/rock_32.raw ::/misc |
---|
254 | mcopy -o -i $< images/wood_32.raw ::/misc |
---|
255 | mcopy -o -i $< images/wood_32.raw ::/misc |
---|
256 | mcopy -o -i $< images/plan_48.mjpg ::/misc |
---|
257 | mcopy -o -i $< images/mandel_128.mjpg ::/misc |
---|
258 | mcopy -o -i $< images/video_160_120.mjpg ::/misc |
---|
259 | |
---|
260 | ######################### |
---|
261 | ### Disk image generation |
---|
262 | ### This requires the generic LINUX/MacOS script "create_dmg" script |
---|
263 | ### written by C.Fuguet. (should be installed in GIET-VM root directory). |
---|
264 | $(DISK_IMAGE): build/boot/boot.elf |
---|
265 | rm -f $@ |
---|
266 | ./create_dmg create $(basename $@) |
---|
267 | dd if=$@ of=temp.dmg count=65536 |
---|
268 | mv temp.dmg $@ |
---|
269 | dd if=build/boot/boot.elf of=$@ seek=2 conv=notrunc |
---|
270 | |
---|
271 | ######################################################################### |
---|
272 | ### mapping generation: map.bin / map.xml / hard_config.h / giet_vsegs.ld |
---|
273 | hard_config.h: $(ARCH)/arch.py $(APPLIS_PY) |
---|
274 | giet_python/genmap --arch=$(ARCH) \ |
---|
275 | --x=$(X_SIZE) \ |
---|
276 | --y=$(Y_SIZE) \ |
---|
277 | --p=$(NB_PROCS) \ |
---|
278 | --tty=$(NB_TTYS) \ |
---|
279 | --fbf=$(FBF_WIDTH) \ |
---|
280 | --ioc=$(IOC_TYPE) \ |
---|
281 | --mwr=$(MWR_TYPE) \ |
---|
282 | --giet=. \ |
---|
283 | $(GENMAP_APPLIS) \ |
---|
284 | --xml=. |
---|
285 | |
---|
286 | ################################ |
---|
287 | ### drivers library compilation |
---|
288 | build/drivers/%.o: giet_drivers/%.c \ |
---|
289 | giet_drivers/%.h \ |
---|
290 | hard_config.h \ |
---|
291 | giet_config.h |
---|
292 | $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
293 | |
---|
294 | build/drivers/libdrivers.a: $(DRIVERS_OBJS) |
---|
295 | $(AR) -rcs $@ $(DRIVERS_OBJS) |
---|
296 | |
---|
297 | ########################## |
---|
298 | ### fat32 compilation |
---|
299 | build/fat32/fat32.o: giet_fat32/fat32.c \ |
---|
300 | giet_fat32/fat32.h \ |
---|
301 | hard_config.h \ |
---|
302 | giet_config.h |
---|
303 | $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
304 | |
---|
305 | ########################## |
---|
306 | ### common compilation |
---|
307 | build/common/%.o: giet_common/%.c \ |
---|
308 | giet_common/%.h \ |
---|
309 | hard_config.h \ |
---|
310 | giet_config.h |
---|
311 | $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
312 | |
---|
313 | ######################## |
---|
314 | ### boot compilation |
---|
315 | ### Copy bootloader into sector 2 of disk image |
---|
316 | build/boot/boot.elf: $(BOOT_OBJS) \ |
---|
317 | giet_boot/boot.ld \ |
---|
318 | build/drivers/libdrivers.a |
---|
319 | $(LD) -o $@ -T giet_boot/boot.ld $(BOOT_OBJS) -Lbuild/drivers -ldrivers |
---|
320 | $(DU) -D $@ > $@.txt |
---|
321 | |
---|
322 | build/boot/boot.o: giet_boot/boot.c \ |
---|
323 | giet_common/utils.h \ |
---|
324 | giet_fat32/fat32.h \ |
---|
325 | giet_common/vmem.h \ |
---|
326 | hard_config.h \ |
---|
327 | giet_config.h |
---|
328 | $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
329 | |
---|
330 | build/boot/boot_entry.o: giet_boot/boot_entry.S \ |
---|
331 | hard_config.h |
---|
332 | $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
333 | |
---|
334 | ######################### |
---|
335 | ### kernel compilation |
---|
336 | build/kernel/kernel.elf: $(KERNEL_OBJS) \ |
---|
337 | giet_kernel/kernel.ld \ |
---|
338 | build/drivers/libdrivers.a |
---|
339 | $(LD) -o $@ -T giet_kernel/kernel.ld $(KERNEL_OBJS) -Lbuild/drivers -ldrivers |
---|
340 | $(DU) -D $@ > $@.txt |
---|
341 | |
---|
342 | build/kernel/%.o: giet_kernel/%.c \ |
---|
343 | hard_config.h \ |
---|
344 | giet_config.h |
---|
345 | $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
346 | |
---|
347 | build/kernel/%.o: giet_kernel/%.s \ |
---|
348 | hard_config.h \ |
---|
349 | giet_config.h |
---|
350 | $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
351 | |
---|
352 | ########################### |
---|
353 | ### user library compilation |
---|
354 | build/libs/%.o: giet_libs/%.c \ |
---|
355 | giet_libs/%.h \ |
---|
356 | hard_config.h \ |
---|
357 | giet_config.h |
---|
358 | $(CC) $(CFLAGS) $(GIET_INCLUDE) -c -o $@ $< |
---|
359 | |
---|
360 | build/libs/libuser.a: $(USER_OBJS) |
---|
361 | $(AR) -rcs $@ $^ |
---|
362 | |
---|
363 | ################################ |
---|
364 | ### math library compilation |
---|
365 | build/libs/math/%.o: giet_libs/math/%.c \ |
---|
366 | giet_libs/math/math_private.h \ |
---|
367 | giet_libs/math.h |
---|
368 | $(CC) $(CFLAGS) $(GIET_INCLUDE) -c -o $@ $< |
---|
369 | |
---|
370 | build/libs/libmath.a: $(MATH_OBJS) |
---|
371 | $(AR) -rcs $@ $^ |
---|
372 | |
---|
373 | ######################################## |
---|
374 | ### classif application compilation |
---|
375 | applications/classif/appli.elf: build/libs/libuser.a |
---|
376 | $(MAKE) -C applications/classif |
---|
377 | |
---|
378 | ######################################## |
---|
379 | ### convol application compilation |
---|
380 | applications/convol/appli.elf: build/libs/libuser.a |
---|
381 | $(MAKE) -C applications/convol |
---|
382 | |
---|
383 | ######################################## |
---|
384 | ### coproc application compilation |
---|
385 | applications/coproc/appli.elf: build/libs/libuser.a |
---|
386 | $(MAKE) -C applications/coproc |
---|
387 | |
---|
388 | ######################################## |
---|
389 | ### dhrystone application compilation |
---|
390 | applications/dhrystone/appli.elf: build/libs/libuser.a |
---|
391 | $(MAKE) -C applications/dhrystone |
---|
392 | |
---|
393 | ######################################## |
---|
394 | ### display application compilation |
---|
395 | applications/display/appli.elf: build/libs/libuser.a |
---|
396 | $(MAKE) -C applications/display |
---|
397 | |
---|
398 | ######################################## |
---|
399 | ### gameoflife application compilation |
---|
400 | applications/gameoflife/appli.elf: build/libs/libuser.a |
---|
401 | $(MAKE) -C applications/gameoflife |
---|
402 | |
---|
403 | ######################################## |
---|
404 | ### mjpeg application compilation |
---|
405 | applications/mjpeg/appli.elf: build/libs/libuser.a |
---|
406 | $(MAKE) -C applications/mjpeg |
---|
407 | |
---|
408 | ######################################## |
---|
409 | ### ocean application compilation |
---|
410 | applications/ocean/appli.elf: build/libs/libmath.a build/libs/libuser.a |
---|
411 | cd applications/ocean && $(MAKE) && cd ../.. |
---|
412 | |
---|
413 | ######################################## |
---|
414 | ### raycast application compilation |
---|
415 | applications/raycast/appli.elf: build/libs/libmath.a build/libs/libuser.a |
---|
416 | $(MAKE) -C applications/raycast |
---|
417 | |
---|
418 | ######################################## |
---|
419 | ### router application compilation |
---|
420 | applications/router/appli.elf: build/libs/libuser.a |
---|
421 | $(MAKE) -C applications/router |
---|
422 | |
---|
423 | ######################################## |
---|
424 | ### shell application compilation |
---|
425 | applications/shell/appli.elf: build/libs/libuser.a |
---|
426 | $(MAKE) -C applications/shell |
---|
427 | |
---|
428 | ######################################## |
---|
429 | ### sort application compilation |
---|
430 | applications/sort/appli.elf: build/libs/libuser.a |
---|
431 | $(MAKE) -C applications/sort |
---|
432 | |
---|
433 | ######################################## |
---|
434 | ### transpose compilation |
---|
435 | applications/transpose/appli.elf: build/libs/libuser.a |
---|
436 | $(MAKE) -C applications/transpose |
---|
437 | |
---|
438 | ######################################## |
---|
439 | ### coremark compilation |
---|
440 | applications/coremark/appli.elf: build/libs/libuser.a |
---|
441 | $(MAKE) -C applications/coremark |
---|
442 | |
---|