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