source: soft/giet_vm/Makefile @ 709

Last change on this file since 709 was 709, checked in by alain, 9 years ago

Major release: Change the task model to implement the POSIX threads API.

  • The shell "exec" and "kill" commands can be used to activate/de-activate the applications.
  • The "pause", "resume", and "context" commands can be used to stop, restart, a single thtead or to display the thread context.

This version has been tested on the following multi-threaded applications,
that have been modified to use the POSIX threads:

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