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
RevLine 
[595]1-include params.mk
[302]2
[595]3export # export all variable to applications sub-Makefile
4
[232]5CC = mipsel-unknown-elf-gcc
6AS = mipsel-unknown-elf-as
7LD = mipsel-unknown-elf-ld
8DU = mipsel-unknown-elf-objdump
[380]9AR = mipsel-unknown-elf-ar
[158]10
[595]11# Defaults values for hardware parameters and applications
[611]12# These parameters should be defined in the params.mk file
[595]13ARCH      ?= pathname
[581]14X_SIZE    ?= 1
15Y_SIZE    ?= 1
[595]16NB_PROCS  ?= 1
[580]17NB_TTYS   ?= 1
[595]18FBF_WIDTH ?= 256
19IOC_TYPE  ?= BDV
[611]20APPLIS    ?= shell
[326]21
[595]22# build the list of applications used as argument by genmap
23GENMAP_APPLIS := $(addprefix --,$(APPLIS))
[510]24
[649]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            \
[673]33                 applications/raycast/raycast.py        \
[649]34                 applications/router/router.py          \
35                 applications/shell/shell.py            \
36                 applications/sort/sort.py              \
37                 applications/transpose/transpose.py
[326]38
[595]39# build the list of applications to be executed (used in the all rule)
40APPLIS_ELF    := $(addsuffix /appli.elf,$(addprefix applications/,$(APPLIS)))
[204]41
[600]42# Build PYTHONPATH
[602]43PYTHONPATH := $(shell find . -name *.py | grep -o "\(.*\)/" | sort -u | tr '\n' :)
[600]44
[595]45# check hardware platform definition
46ifeq ($(wildcard $(ARCH)),)
47$(error please define in ARCH parameter the path to the platform)
48endif
[580]49
[608]50### Rules that don't build a target file
[662]51.PHONY: all dirs list extract clean clean-disk install-disk $(APPLIS_ELF)
[595]52
[463]53### Objects to be linked for the drivers library
[535]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      \
[380]68               build/drivers/pic_driver.o
69
70### Objects to be linked for kernel.elf
[510]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      \
[258]84               build/kernel/kernel_init.o
[162]85
[258]86### Objects to be linked for boot.elf
[510]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      \
[535]96               build/kernel/irq_handler.o      \
[595]97               build/kernel/sys_handler.o      \
[510]98               build/kernel/switch.o           \
99               build/boot/boot.o               \
[366]100               build/boot/boot_entry.o
[258]101
[585]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      \
[709]109                build/libs/user_lock.o
[585]110
[583]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        \
[667]126                build/libs/math/s_cos.o        \
[595]127                build/libs/math/e_sqrt.o       
[580]128
[162]129
[435]130CFLAGS = -Wall -ffreestanding -mno-gpopt -mips32 -g -O2 \
131                 -fno-delete-null-pointer-checks
[158]132
[258]133GIET_INCLUDE = -Igiet_boot    \
134               -Igiet_kernel  \
135               -Igiet_xml     \
136               -Igiet_fat32   \
137               -Igiet_drivers \
138               -Igiet_common  \
139               -Igiet_libs    \
140               -I.
[158]141
[302]142DISK_IMAGE  := hdd/virt_hdd.dmg
143
[595]144### The Mtools used to build the FAT32 disk image perform a few sanity checks,
[582]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
[595]150##################################
151### first rule executed (make all)
[599]152all: dirs                            \
[609]153     install-disk
[580]154        mdir -/ -b -i $(DISK_IMAGE) ::/
[160]155
[608]156#####################################################
157### create build directories
[599]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
[608]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
[694]183        rm -rf build/
[611]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 ../..
[673]191        cd applications/raycast      && $(MAKE) clean && cd ../..
[611]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 ../..
[608]196
197########################################
198### delete disk image
199clean-disk:
[694]200        rm -rf hdd/
[608]201
[609]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)
[611]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
[673]216        mmd -o -i $< ::/bin/raycast       || true
[611]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
[609]223        mcopy -o -i $< map.bin ::/
[611]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
[673]232        mcopy -o -i $< applications/raycast/appli.elf ::/bin/raycast          || true
[611]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
[609]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
[675]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
[609]246
[595]247#########################
248### Disk image generation
[582]249### This requires the generic LINUX/MacOS script "create_dmg" script
[258]250### written by C.Fuguet. (should be installed in GIET-VM root directory).
[609]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
[295]257
[595]258#########################################################################
[326]259### mapping generation: map.bin / map.xml / hard_config.h / giet_vsegs.ld
[701]260hard_config.h: $(ARCH)/arch.py $(APPLIS_PY)
[510]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) \
[553]267                       --ioc=$(IOC_TYPE)  \
[510]268                       --giet=.           \
[595]269                       $(GENMAP_APPLIS)   \
[510]270                       --xml=.
[158]271
[583]272################################
273### drivers library compilation
274build/drivers/%.o: giet_drivers/%.c \
275                   giet_drivers/%.h \
276                   hard_config.h    \
277                   giet_config.h
[295]278        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
279
[380]280build/drivers/libdrivers.a: $(DRIVERS_OBJS)
281        $(AR) -rcs $@ $(DRIVERS_OBJS)
282
[374]283##########################
[583]284### fat32 compilation
[258]285build/fat32/fat32.o: giet_fat32/fat32.c \
286                     giet_fat32/fat32.h \
[326]287                     hard_config.h      \
288                     giet_config.h
[258]289        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
290
[583]291##########################
292### common compilation
293build/common/%.o: giet_common/%.c   \
294                  giet_common/%.h   \
295                  hard_config.h     \
296                  giet_config.h
[258]297        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
298
[374]299########################
[177]300### boot compilation
[573]301### Copy bootloader into sector 2 of disk image
[326]302build/boot/boot.elf: $(BOOT_OBJS)            \
[380]303                     giet_boot/boot.ld       \
[583]304                     build/drivers/libdrivers.a
[582]305        $(LD) -o $@ -T giet_boot/boot.ld $(BOOT_OBJS) -Lbuild/drivers -ldrivers
[189]306        $(DU) -D $@ > $@.txt
[158]307
[258]308build/boot/boot.o: giet_boot/boot.c          \
309                   giet_common/utils.h       \
310                   giet_fat32/fat32.h        \
[289]311                   giet_common/vmem.h        \
[326]312                   hard_config.h             \
[366]313                   giet_config.h
[258]314        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
[158]315
[366]316build/boot/boot_entry.o: giet_boot/boot_entry.S \
317                         hard_config.h
318        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
319
[374]320#########################
[258]321### kernel compilation
[326]322build/kernel/kernel.elf: $(KERNEL_OBJS)        \
[380]323                         giet_kernel/kernel.ld \
324                         build/drivers/libdrivers.a
[582]325        $(LD) -o $@ -T giet_kernel/kernel.ld $(KERNEL_OBJS) -Lbuild/drivers -ldrivers
326        $(DU) -D $@ > $@.txt
[158]327
[326]328build/kernel/%.o: giet_kernel/%.c    \
329                  hard_config.h      \
[582]330                  giet_config.h
[258]331        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
332
[326]333build/kernel/%.o: giet_kernel/%.s    \
334                  hard_config.h      \
[582]335                  giet_config.h
[258]336        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
337
[374]338###########################
[585]339### user library compilation
[595]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 $@ $<
[258]345
[585]346build/libs/libuser.a: $(USER_OBJS)
347        $(AR) -rcs $@ $^
348
[583]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
[595]354        $(CC) $(CFLAGS) $(GIET_INCLUDE) -c -o $@ $<
[258]355
[583]356build/libs/libmath.a: $(MATH_OBJS)
[580]357        $(AR) -rcs $@ $^
358
[374]359########################################
[595]360### classif   application compilation
[609]361applications/classif/appli.elf: build/libs/libuser.a
[595]362        $(MAKE) -C applications/classif
[189]363
[595]364########################################
365### convol   application compilation
[609]366applications/convol/appli.elf: build/libs/libuser.a
[595]367        $(MAKE) -C applications/convol
[189]368
[374]369########################################
[595]370### coproc   application compilation
[609]371applications/coproc/appli.elf: build/libs/libuser.a
[595]372        $(MAKE) -C applications/coproc
[189]373
[595]374########################################
375### dhrystone   application compilation
[609]376applications/dhrystone/appli.elf: build/libs/libuser.a
[595]377        $(MAKE) -C applications/dhrystone
[189]378
[374]379########################################
[595]380### display  application compilation
[609]381applications/display/appli.elf: build/libs/libuser.a
[595]382        $(MAKE) -C applications/display
[189]383
[374]384########################################
[595]385### gameoflife  application compilation
[609]386applications/gameoflife/appli.elf: build/libs/libuser.a
[595]387        $(MAKE) -C applications/gameoflife
[251]388
[595]389########################################
390### ocean  application compilation
[609]391applications/ocean/appli.elf: build/libs/libmath.a  build/libs/libuser.a
[598]392        cd applications/ocean && $(MAKE) && cd ../..
[251]393
[374]394########################################
[673]395### raycast application compilation
396applications/raycast/appli.elf: build/libs/libmath.a build/libs/libuser.a
397        $(MAKE) -C applications/raycast
398
399########################################
[595]400### router  application compilation
[609]401applications/router/appli.elf: build/libs/libuser.a
[595]402        $(MAKE) -C applications/router
[241]403
[595]404########################################
405### shell  application compilation
[609]406applications/shell/appli.elf: build/libs/libuser.a
[595]407        $(MAKE) -C applications/shell
[241]408
[374]409########################################
[595]410### sort  application compilation
[609]411applications/sort/appli.elf: build/libs/libuser.a
[595]412        $(MAKE) -C applications/sort
[256]413
[374]414########################################
[295]415### transpose compilation
[609]416applications/transpose/appli.elf: build/libs/libuser.a
[595]417        $(MAKE) -C applications/transpose
[295]418
Note: See TracBrowser for help on using the repository browser.