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