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