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