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