source: soft/giet_vm/Makefile @ 669

Last change on this file since 669 was 667, checked in by guerin, 9 years ago

math: add cos()

File size: 15.3 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            \
33                 applications/router/router.py          \
34                 applications/shell/shell.py            \
35                 applications/sort/sort.py              \
36                 applications/transpose/transpose.py
[326]37
[595]38# build the list of applications to be executed (used in the all rule)
39APPLIS_ELF    := $(addsuffix /appli.elf,$(addprefix applications/,$(APPLIS)))
[204]40
[600]41# Build PYTHONPATH
[602]42PYTHONPATH := $(shell find . -name *.py | grep -o "\(.*\)/" | sort -u | tr '\n' :)
[600]43
[595]44# check hardware platform definition
45ifeq ($(wildcard $(ARCH)),)
46$(error please define in ARCH parameter the path to the platform)
47endif
[580]48
[608]49### Rules that don't build a target file
[662]50.PHONY: all dirs list extract clean clean-disk install-disk $(APPLIS_ELF)
[595]51
[463]52### Objects to be linked for the drivers library
[535]53DRIVERS_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      \
[380]67               build/drivers/pic_driver.o
68
69### Objects to be linked for kernel.elf
[510]70KERNEL_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      \
[258]83               build/kernel/kernel_init.o
[162]84
[258]85### Objects to be linked for boot.elf
[510]86BOOT_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      \
[535]95               build/kernel/irq_handler.o      \
[595]96               build/kernel/sys_handler.o      \
[510]97               build/kernel/switch.o           \
98               build/boot/boot.o               \
[366]99               build/boot/boot_entry.o
[258]100
[585]101### Objects to be linked for the user library
102USER_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         \
[595]109                build/libs/user_sqt_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                            \
[573]153     map.bin                         \
[326]154     hard_config.h                   \
155     giet_vsegs.ld                   \
[609]156     install-disk
[580]157        mdir -/ -b -i $(DISK_IMAGE) ::/
[160]158
[608]159#####################################################
160### create build directories
[599]161dirs:
162        @mkdir -p build/boot
163        @mkdir -p build/common
164        @mkdir -p build/drivers
165        @mkdir -p build/fat32
166        @mkdir -p build/kernel
167        @mkdir -p build/libs/math
168        @mkdir -p hdd
169
[608]170#####################################################
171### make a recursive list of the virtual disk content
172list:
173         mdir -/ -w -i $(DISK_IMAGE) ::/
174
175########################################################
176### copy the files generated by the virtual prototype on
177### the virtual disk "home" directory to the giet_vm home directory
178extract:
179        mcopy -o -i $(DISK_IMAGE) ::/home .
180
181########################################
182### clean all binary files
183clean:
184        rm -f *.o *.elf *.bin *.txt core
185        rm -f hard_config.h giet_vsegs.ld map.bin map.xml
186        rm -rf build/kernel/*
187        rm -rf build/boot/*
188        rm -rf build/libs/*
[611]189        cd applications/classif      && $(MAKE) clean && cd ../..
190        cd applications/convol       && $(MAKE) clean && cd ../..
191        cd applications/coproc       && $(MAKE) clean && cd ../..
192        cd applications/display      && $(MAKE) clean && cd ../..
193        cd applications/dhrystone    && $(MAKE) clean && cd ../..
194        cd applications/gameoflife   && $(MAKE) clean && cd ../..
195        cd applications/ocean        && $(MAKE) clean && cd ../..
196        cd applications/router       && $(MAKE) clean && cd ../..
197        cd applications/shell        && $(MAKE) clean && cd ../..
198        cd applications/sort         && $(MAKE) clean && cd ../..
199        cd applications/transpose    && $(MAKE) clean && cd ../..
[608]200
201########################################
202### delete disk image
203clean-disk:
204        rm -f $(DISK_IMAGE)
205
[609]206########################################
207### Copy content in the disk image
208### create the three build / misc / home directories
209### store the images files into misc
210install-disk: $(DISK_IMAGE) build/kernel/kernel.elf $(APPLIS_ELF)
[611]211        mmd -o -i $< ::/bin               || true
212        mmd -o -i $< ::/bin/kernel        || true
213        mmd -o -i $< ::/bin/classif       || true
214        mmd -o -i $< ::/bin/convol        || true
215        mmd -o -i $< ::/bin/coproc        || true
216        mmd -o -i $< ::/bin/dhrystone     || true
217        mmd -o -i $< ::/bin/display       || true
218        mmd -o -i $< ::/bin/gameoflife    || true
219        mmd -o -i $< ::/bin/ocean         || true
220        mmd -o -i $< ::/bin/router        || true
221        mmd -o -i $< ::/bin/shell         || true
222        mmd -o -i $< ::/bin/sort          || true
223        mmd -o -i $< ::/bin/transpose     || true
224        mmd -o -i $< ::/misc              || true
225        mmd -o -i $< ::/home              || true
[609]226        mcopy -o -i $< map.bin ::/
[611]227        mcopy -o -i $< build/kernel/kernel.elf ::/bin/kernel
228        mcopy -o -i $< applications/classif/appli.elf ::/bin/classif          || true
229        mcopy -o -i $< applications/convol/appli.elf ::/bin/convol            || true
230        mcopy -o -i $< applications/coproc/appli.elf ::/bin/coproc            || true
231        mcopy -o -i $< applications/dhrystone/appli.elf ::/bin/dhrystone      || true
232        mcopy -o -i $< applications/display/appli.elf ::/bin/display          || true
233        mcopy -o -i $< applications/gameoflife/appli.elf ::/bin/gameoflife    || true
234        mcopy -o -i $< applications/ocean/appli.elf ::/bin/ocean              || true
235        mcopy -o -i $< applications/router/appli.elf ::/bin/router            || true
236        mcopy -o -i $< applications/shell/appli.elf ::/bin/shell              || true
237        mcopy -o -i $< applications/sort/appli.elf ::/bin/sort                || true
238        mcopy -o -i $< applications/transpose/appli.elf ::/bin/transpose      || true
[609]239        mcopy -o -i $< images/images_128.raw ::/misc
240        mcopy -o -i $< images/philips_1024.raw ::/misc
241        mcopy -o -i $< images/lena_256.raw ::/misc
242        mcopy -o -i $< images/bridge_256.raw ::/misc
243        mcopy -o -i $< images/couple_512.raw ::/misc
244
[595]245#########################
246### Disk image generation
[582]247### This requires the generic LINUX/MacOS script "create_dmg" script
[258]248### written by C.Fuguet. (should be installed in GIET-VM root directory).
[609]249$(DISK_IMAGE): build/boot/boot.elf
250        rm -f $@
251        ./create_dmg create $(basename $@)
252        dd if=$@ of=temp.dmg count=65536
253        mv temp.dmg $@
254        dd if=build/boot/boot.elf of=$@ seek=2 conv=notrunc
[295]255
[595]256#########################################################################
[326]257### mapping generation: map.bin / map.xml / hard_config.h / giet_vsegs.ld
[595]258### TODO add dépendancies on appli.py files : $(APPLIS_DEPS)
[600]259map.bin hard_config.h giet_vsegs.ld: $(ARCH)/arch.py $(APPLIS_PY)
[510]260        giet_python/genmap --arch=$(ARCH)     \
261                       --x=$(X_SIZE)      \
262                       --y=$(Y_SIZE)      \
263                       --p=$(NB_PROCS)    \
264                       --tty=$(NB_TTYS)   \
265                       --fbf=$(FBF_WIDTH) \
[553]266                       --ioc=$(IOC_TYPE)  \
[510]267                       --giet=.           \
[595]268                       $(GENMAP_APPLIS)   \
[510]269                       --xml=.
[158]270
[583]271################################
272### drivers library compilation
273build/drivers/%.o: giet_drivers/%.c \
274                   giet_drivers/%.h \
275                   hard_config.h    \
276                   giet_config.h
[295]277        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
278
[380]279build/drivers/libdrivers.a: $(DRIVERS_OBJS)
280        $(AR) -rcs $@ $(DRIVERS_OBJS)
281
[374]282##########################
[583]283### fat32 compilation
[258]284build/fat32/fat32.o: giet_fat32/fat32.c \
285                     giet_fat32/fat32.h \
[326]286                     hard_config.h      \
287                     giet_config.h
[258]288        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
289
[583]290##########################
291### common compilation
292build/common/%.o: giet_common/%.c   \
293                  giet_common/%.h   \
294                  hard_config.h     \
295                  giet_config.h
[258]296        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
297
[374]298########################
[177]299### boot compilation
[573]300### Copy bootloader into sector 2 of disk image
[326]301build/boot/boot.elf: $(BOOT_OBJS)            \
[380]302                     giet_boot/boot.ld       \
[583]303                     build/drivers/libdrivers.a
[582]304        $(LD) -o $@ -T giet_boot/boot.ld $(BOOT_OBJS) -Lbuild/drivers -ldrivers
[189]305        $(DU) -D $@ > $@.txt
[158]306
[258]307build/boot/boot.o: giet_boot/boot.c          \
308                   giet_common/utils.h       \
309                   giet_fat32/fat32.h        \
[289]310                   giet_common/vmem.h        \
[326]311                   hard_config.h             \
[366]312                   giet_config.h
[258]313        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
[158]314
[366]315build/boot/boot_entry.o: giet_boot/boot_entry.S \
316                         hard_config.h
317        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
318
[374]319#########################
[258]320### kernel compilation
[326]321build/kernel/kernel.elf: $(KERNEL_OBJS)        \
[380]322                         giet_kernel/kernel.ld \
323                         build/drivers/libdrivers.a
[582]324        $(LD) -o $@ -T giet_kernel/kernel.ld $(KERNEL_OBJS) -Lbuild/drivers -ldrivers
325        $(DU) -D $@ > $@.txt
[158]326
[326]327build/kernel/%.o: giet_kernel/%.c    \
328                  hard_config.h      \
[582]329                  giet_config.h
[258]330        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
331
[326]332build/kernel/%.o: giet_kernel/%.s    \
333                  hard_config.h      \
[582]334                  giet_config.h
[258]335        $(CC) $(GIET_INCLUDE) $(CFLAGS)  -c -o $@ $<
336
[374]337###########################
[585]338### user library compilation
[595]339build/libs/%.o: giet_libs/%.c        \
340                     giet_libs/%.h   \
341                     hard_config.h   \
342                     giet_config.h
343        $(CC) $(CFLAGS) $(GIET_INCLUDE) -c -o $@ $<
[258]344
[585]345build/libs/libuser.a: $(USER_OBJS)
346        $(AR) -rcs $@ $^
347
[583]348################################
349### math library compilation
350build/libs/math/%.o: giet_libs/math/%.c             \
351                     giet_libs/math/math_private.h  \
352                     giet_libs/math.h
[595]353        $(CC) $(CFLAGS) $(GIET_INCLUDE) -c -o $@ $<
[258]354
[583]355build/libs/libmath.a: $(MATH_OBJS)
[580]356        $(AR) -rcs $@ $^
357
[374]358########################################
[595]359### classif   application compilation
[609]360applications/classif/appli.elf: build/libs/libuser.a
[595]361        $(MAKE) -C applications/classif
[189]362
[595]363########################################
364### convol   application compilation
[609]365applications/convol/appli.elf: build/libs/libuser.a
[595]366        $(MAKE) -C applications/convol
[189]367
[374]368########################################
[595]369### coproc   application compilation
[609]370applications/coproc/appli.elf: build/libs/libuser.a
[595]371        $(MAKE) -C applications/coproc
[189]372
[595]373########################################
374### dhrystone   application compilation
[609]375applications/dhrystone/appli.elf: build/libs/libuser.a
[595]376        $(MAKE) -C applications/dhrystone
[189]377
[374]378########################################
[595]379### display  application compilation
[609]380applications/display/appli.elf: build/libs/libuser.a
[595]381        $(MAKE) -C applications/display
[189]382
[374]383########################################
[595]384### gameoflife  application compilation
[609]385applications/gameoflife/appli.elf: build/libs/libuser.a
[595]386        $(MAKE) -C applications/gameoflife
[251]387
[595]388########################################
389### ocean  application compilation
[609]390applications/ocean/appli.elf: build/libs/libmath.a  build/libs/libuser.a
[598]391        cd applications/ocean && $(MAKE) && cd ../..
[251]392
[374]393########################################
[595]394### router  application compilation
[609]395applications/router/appli.elf: build/libs/libuser.a
[595]396        $(MAKE) -C applications/router
[241]397
[595]398########################################
399### shell  application compilation
[609]400applications/shell/appli.elf: build/libs/libuser.a
[595]401        $(MAKE) -C applications/shell
[241]402
[374]403########################################
[595]404### sort  application compilation
[609]405applications/sort/appli.elf: build/libs/libuser.a
[595]406        $(MAKE) -C applications/sort
[256]407
[374]408########################################
[295]409### transpose compilation
[609]410applications/transpose/appli.elf: build/libs/libuser.a
[595]411        $(MAKE) -C applications/transpose
[295]412
Note: See TracBrowser for help on using the repository browser.