source: trunk/Makefile @ 188

Last change on this file since 188 was 188, checked in by alain, 7 years ago

Redefine the PIC device API.

File size: 19.6 KB
Line 
1#############################################################################
2#                       ALMOS-MKH  Makefile for TSAR                        #
3#############################################################################
4
5-include params.mk
6
7# Compilation flags.
8CFLAGS = -Wall -ffreestanding -mno-gpopt -mips32 -g -O2 \
9                 -fno-delete-null-pointer-checks
10#                -fno-delete-null-pointer-checks -std=c99
11
12export
13CC = mipsel-unknown-elf-gcc
14AS = mipsel-unknown-elf-as
15LD = mipsel-unknown-elf-ld
16DU = mipsel-unknown-elf-objdump
17AR = mipsel-unknown-elf-ar
18
19LIBGCC = -L$(shell $(CC) -print-libgcc-file-name | sed 's/libgcc.a//')
20# Default values for hardware parameters.
21# These parameters should be defined in the 'params.mk' file.
22ARCH            ?= /users/alain/soc/tsar-trunk-svn-2013/platforms/tsar_generic_iob
23X_SIZE          ?= 2
24Y_SIZE          ?= 2
25NB_PROCS        ?= 2
26NB_TTYS         ?= 1
27FBF_WIDTH       ?= 256
28IOC_TYPE        ?= IOC_BDV
29
30
31# Checking hardware platform definition.
32ifeq ($(wildcard $(ARCH)),)
33$(error Please define in ARCH parameter the path to the hardware platform!)
34endif
35
36# Rules that don't build target files
37# always out-of-date, need to be regenerated everytime they are called
38.PHONY: compile                         \
39                dirs                                \
40                list                                \
41                extract                             \
42                fsck                                \
43                clean                               \
44                build-disk                          \
45                build/boot/boot.elf         \
46                build/kernel/kernel.elf
47
48# Objects to be linked for boot.elf generation
49BOOT_OBJS       = build/boot/boot.o            \
50                          build/boot/boot_fat32.o      \
51                          build/boot/boot_utils.o      \
52                          build/boot/boot_entry.o      \
53              build/boot/boot_tty_driver.o \
54              build/boot/boot_hba_driver.o \
55                          build/boot/boot_bdv_driver.o \
56                          build/boot/boot_mmc_driver.o 
57
58# List of directories to be searched for included files
59# when compiling for boot.elf generation
60BOOT_INCLUDE = -Itools/bootloader_tsar  \
61                       -Itools/arch_info        \
62               -Ihal/tsar_mips32/core   \
63               -I.
64
65# Objects to be linked for the soclib drivers library
66DRIVERS_OBJS = build/kernel/drivers/soclib_tty.o  \
67               build/kernel/drivers/soclib_bdv.o  \
68               build/kernel/drivers/soclib_hba.o  \
69               build/kernel/drivers/soclib_mmc.o  \
70               build/kernel/drivers/soclib_pic.o  \
71               build/kernel/drivers/soclib_nic.o  \
72               build/kernel/drivers/soclib_dma.o  \
73               build/kernel/drivers/soclib_iob.o
74
75# Objects to be linked for kernel.elf generation
76KERN_OBJS       = build/kernel/kern/kernel_init.o     \
77              build/kernel/kern/printk.o          \
78              build/kernel/kern/thread.o          \
79              build/kernel/kern/process.o         \
80              build/kernel/kern/chdev.o           \
81              build/kernel/kern/cluster.o         \
82              build/kernel/kern/scheduler.o       \
83              build/kernel/kern/core.o            \
84              build/kernel/kern/dqdt.o            \
85              build/kernel/kern/do_syscall.o      \
86              build/kernel/kern/do_interrupt.o    \
87              build/kernel/kern/do_exception.o    \
88              build/kernel/kern/rpc.o             \
89              build/kernel/kern/signal.o
90
91HAL_OBJS    = build/kernel/hal/hal_special.o      \
92              build/kernel/hal/hal_context.o      \
93              build/kernel/hal/hal_atomic.o       \
94              build/kernel/hal/hal_remote.o       \
95              build/kernel/hal/hal_uspace.o       \
96              build/kernel/hal/hal_irqmask.o      \
97              build/kernel/hal/hal_gpt.o          \
98              build/kernel/hal/hal_ppm.o          \
99              build/kernel/hal/hal_exception.o    \
100              build/kernel/hal/hal_interrupt.o    \
101              build/kernel/hal/hal_syscall.o      \
102              build/kernel/hal/hal_kentry.o
103
104DEV_OBJS    = build/kernel/devices/dev_txt.o      \
105              build/kernel/devices/dev_ioc.o      \
106              build/kernel/devices/dev_mmc.o      \
107              build/kernel/devices/dev_nic.o      \
108              build/kernel/devices/dev_pic.o      \
109              build/kernel/devices/dev_dma.o      \
110              build/kernel/devices/dev_fbf.o      \
111              build/kernel/devices/dev_iob.o
112
113MM_OBJS     = build/kernel/mm/ppm.o               \
114              build/kernel/mm/vmm.o               \
115              build/kernel/mm/vseg.o              \
116              build/kernel/mm/page.o              \
117              build/kernel/mm/kcm.o               \
118              build/kernel/mm/khm.o               \
119              build/kernel/mm/mapper.o            \
120              build/kernel/mm/kmem.o
121
122LIBK_OBJS   = build/kernel/libk/grdxt.o           \
123              build/kernel/libk/bits.o            \
124              build/kernel/libk/elf.o             \
125              build/kernel/libk/string.o          \
126              build/kernel/libk/ctype.o           \
127              build/kernel/libk/rwlock.o          \
128              build/kernel/libk/spinlock.o        \
129              build/kernel/libk/barrier.o         \
130              build/kernel/libk/remote_barrier.o  \
131              build/kernel/libk/remote_spinlock.o \
132              build/kernel/libk/remote_rwlock.o   \
133              build/kernel/libk/remote_fifo.o     \
134              build/kernel/libk/remote_mutex.o    \
135              build/kernel/libk/remote_sem.o      \
136              build/kernel/libk/remote_condvar.o  \
137              build/kernel/libk/memcpy.o          \
138              build/kernel/libk/htab.o            \
139              build/kernel/libk/xhtab.o
140
141SYS_OBJS_0  = build/kernel/syscalls/sys_thread_exit.o     \
142              build/kernel/syscalls/sys_mmap.o            \
143              build/kernel/syscalls/sys_thread_create.o   \
144              build/kernel/syscalls/sys_thread_join.o     \
145              build/kernel/syscalls/sys_thread_detach.o   \
146              build/kernel/syscalls/sys_thread_yield.o    \
147              build/kernel/syscalls/sys_sem.o             \
148              build/kernel/syscalls/sys_condvar.o         \
149              build/kernel/syscalls/sys_barrier.o         \
150              build/kernel/syscalls/sys_mutex.o
151
152SYS_OBJS_1  = build/kernel/syscalls/sys_thread_sleep.o    \
153              build/kernel/syscalls/sys_thread_wakeup.o   \
154              build/kernel/syscalls/sys_open.o            \
155              build/kernel/syscalls/sys_creat.o           \
156              build/kernel/syscalls/sys_read.o            \
157              build/kernel/syscalls/sys_write.o           \
158              build/kernel/syscalls/sys_lseek.o           \
159              build/kernel/syscalls/sys_close.o           \
160              build/kernel/syscalls/sys_unlink.o          \
161              build/kernel/syscalls/sys_pipe.o
162
163SYS_OBJS_2  = build/kernel/syscalls/sys_chdir.o           \
164              build/kernel/syscalls/sys_mkdir.o           \
165              build/kernel/syscalls/sys_mkfifo.o          \
166              build/kernel/syscalls/sys_opendir.o         \
167              build/kernel/syscalls/sys_readdir.o         \
168              build/kernel/syscalls/sys_closedir.o        \
169              build/kernel/syscalls/sys_getcwd.o          \
170              build/kernel/syscalls/sys_clock.o           \
171              build/kernel/syscalls/sys_alarm.o           \
172              build/kernel/syscalls/sys_rmdir.o
173
174SYS_OBJS_3  = build/kernel/syscalls/sys_utls.o            \
175              build/kernel/syscalls/sys_chmod.o           \
176              build/kernel/syscalls/sys_signal.o          \
177              build/kernel/syscalls/sys_timeofday.o       \
178              build/kernel/syscalls/sys_kill.o            \
179              build/kernel/syscalls/sys_getpid.o          \
180              build/kernel/syscalls/sys_fork.o            \
181              build/kernel/syscalls/sys_exec.o            \
182              build/kernel/syscalls/sys_stat.o            \
183              build/kernel/syscalls/sys_trace.o
184
185VFS_OBJS    = build/kernel/vfs/vfs.o              \
186              build/kernel/vfs/fatfs.o            \
187              build/kernel/vfs/devfs.o            \
188              build/kernel/vfs/ramfs.o
189
190# List of directories to be searched for included files
191# when compiling for kernel.elf generation
192KERNEL_INCLUDE = -Ikernel                \
193                 -Ikernel/kern           \
194                 -Ikernel/devices        \
195                 -Ikernel/syscalls       \
196                 -Ihal/tsar_mips32/drivers \
197                 -Ikernel/syscalls       \
198                 -Ikernel/libk           \
199                 -Ikernel/mm             \
200                 -Ikernel/vfs            \
201                 -Ikernel/fatfs          \
202                 -Ikernel/sysfs          \
203                 -Ikernel/ramfs          \
204                 -Ikernel/devfs          \
205                 -Itools/arch_info       \
206                 -Ihal/generic           \
207                 -Ihal/tsar_mips32/core  \
208                 -I.
209
210# Macros to be processed by the C preprocessor.
211MACROS           = -DARCHINFO_PATHNAME="\"arch_info.bin\""              \
212                           -DKERNEL_PATHNAME="\"/bin/kernel/kernel.elf\""
213
214# Virtual disk path
215DISK_IMAGE      := hdd/virt_hdd.dmg
216
217# The Mtools used to build the FAT32 disk image perfom a few sanity checks, to
218# make sure that the disk is indeed an MS-DOS disk. However, the size of the
219# disk image used by ALMOS-VM is not MS-DOS compliant.
220# Setting this variable prevents these checks.
221MTOOLS_SKIP_CHECK := 1
222
223# Rule to compile boot.elf, kernel.elf, and update virtual disk.
224compile: dirs                               \
225                 hard_config.h              \
226                 build/boot/boot.elf        \
227         build/kernel/kernel.elf    \
228         list
229
230# Rule to create the build directories.
231dirs:
232        @mkdir -p build/boot
233        @mkdir -p build/kernel
234        @mkdir -p build/kernel/kern
235        @mkdir -p build/kernel/hal
236        @mkdir -p build/kernel/devices
237        @mkdir -p build/kernel/mm
238        @mkdir -p build/kernel/libk
239        @mkdir -p build/kernel/drivers
240        @mkdir -p build/kernel/vfs
241        @mkdir -p build/kernel/syscalls
242        @mkdir -p hdd
243
244# Rule to make a recursive list of the virtual disk content.
245list:
246        mdir -/ -w -i $(DISK_IMAGE) ::/
247
248# Rule to make a file system check for the virtual disk.
249fsck:
250        fsck.msdos $(DISK_IMAGE)
251
252##############################################################
253# Rule to copy the files generated by the virtual prototype
254# from the virtual disk 'home' directory to the current directory.
255extract:
256        mcopy -o -i $(DISK_IMAGE) ::/home .
257
258# Rules to delete all binary files from Unix File System
259# without modifying the virtual disk.
260clean:
261        rm -f *.o *.elf *.bin *.txt core
262        rm -f hard_config.h arch_info.xml arch_info.bin
263        rm -rf build
264
265####################################################   
266# Rule for building a new virtual disk from scratch.
267# It creates the bin / home directories.
268# This requires the generic Linux/MacOS 'create_dmg' script, that should be
269# placed in the same directory as this Makefile.
270build-disk:
271        rm -f $(DISK_IMAGE)
272        ./create_dmg    create $(basename $(DISK_IMAGE))
273        dd                              if=$(DISK_IMAGE) of=temp.dmg count=65536
274        mv                              temp.dmg $(DISK_IMAGE)
275        mmd                     -o -i $(DISK_IMAGE) ::/bin         || true
276        mmd                     -o -i $(DISK_IMAGE) ::/bin/kernel  || true
277        mmd                     -o -i $(DISK_IMAGE) ::/home        || true
278        mdir             -/ -b -i $(DISK_IMAGE) ::/
279       
280##############################################################
281# Rules to generate hardware description files (hard_config.h,
282# arch_info.bin and arch_info.xml), and update the virtual disk.
283hard_config.h: $(ARCH)/arch_info.py
284        tools/arch_info/genarch.py      --arch=$(ARCH)                  \
285                                                                --x_size=$(X_SIZE)              \
286                                                                --y_size=$(Y_SIZE)              \
287                                                                --nb_cores=$(NB_PROCS)  \
288                                                                --nb_ttys=$(NB_TTYS)    \
289                                                                --fbf_size=$(FBF_WIDTH) \
290                                                                --ioc_type=$(IOC_TYPE)  \
291                                                                --hard=.                                \
292                                                                --bin=.                                 \
293                                                                --xml=.                                 
294        mcopy -o -i $(DISK_IMAGE) arch_info.bin ::/   || true
295
296################################################
297# Rules to compile boot drivers used by boot.elf
298build/boot/boot_tty_driver.o:   tools/bootloader_tsar/boot_tty_driver.c \
299                                                                tools/bootloader_tsar/boot_tty_driver.h \
300                                                                tools/bootloader_tsar/boot_utils.h      \
301                                                                tools/bootloader_tsar/boot_config.h     \
302                                                                hal/tsar_mips32/core/hal_types.h        \
303                                                                hard_config.h
304        $(CC) $(BOOT_INCLUDE) $(CFLAGS) -c -o $@ $<
305        $(DU) -D $@ > $@.txt
306
307build/boot/boot_bdv_driver.o:   tools/bootloader_tsar/boot_bdv_driver.c \
308                                                                tools/bootloader_tsar/boot_bdv_driver.h \
309                                                                tools/bootloader_tsar/boot_utils.h      \
310                                                                tools/bootloader_tsar/boot_config.h     \
311                                                                hal/tsar_mips32/core/hal_types.h        \
312                                                                hard_config.h
313        $(CC) $(BOOT_INCLUDE) $(CFLAGS) -c -o $@ $<
314        $(DU) -D $@ > $@.txt
315
316build/boot/boot_hba_driver.o:   tools/bootloader_tsar/boot_hba_driver.c \
317                                                                tools/bootloader_tsar/boot_hba_driver.h \
318                                                                tools/bootloader_tsar/boot_utils.h      \
319                                                                tools/bootloader_tsar/boot_config.h     \
320                                                                hal/tsar_mips32/core/hal_types.h        \
321                                                                hard_config.h
322        $(CC) $(BOOT_INCLUDE) $(CFLAGS) -c -o $@ $<
323        $(DU) -D $@ > $@.txt
324
325build/boot/boot_mmc_driver.o:   tools/bootloader_tsar/boot_mmc_driver.c \
326                                                                tools/bootloader_tsar/boot_mmc_driver.h \
327                                                                tools/bootloader_tsar/boot_utils.h      \
328                                                                tools/bootloader_tsar/boot_config.h     \
329                                                                hal/tsar_mips32/core/hal_types.h        \
330                                                                hard_config.h
331        $(CC) $(BOOT_INCLUDE) $(CFLAGS) -c -o $@ $<
332        $(DU) -D $@ > $@.txt
333
334##############################
335# Rule to compile boot_fat32.o
336build/boot/boot_fat32.o:                tools/bootloader_tsar/boot_fat32.c      \
337                                                                tools/bootloader_tsar/boot_fat32.h      \
338                                                                tools/bootloader_tsar/boot_utils.h      \
339                                                                tools/bootloader_tsar/boot_config.h     \
340                                                                hal/tsar_mips32/core/hal_types.h        \
341                                                                hard_config.h                   
342        $(CC) $(BOOT_INCLUDE) $(CFLAGS) -c -o $@ $<
343        $(DU) -D $@ > $@.txt
344
345##############################
346# Rule to compile boot_utils.o
347build/boot/boot_utils.o:                tools/bootloader_tsar/boot_utils.c       \
348                                                                tools/bootloader_tsar/boot_utils.h       \
349                                                                tools/bootloader_tsar/boot_tty_driver.h  \
350                                                                hal/tsar_mips32/core/hal_types.h         \
351                                                                hard_config.h
352        $(CC) $(BOOT_INCLUDE) $(CFLAGS) -c -o $@ $<
353        $(DU) -D $@ > $@.txt
354
355########################
356# Rule to compile boot.o
357build/boot/boot.o:                              tools/bootloader_tsar/boot.c             \
358                                                                tools/bootloader_tsar/boot_utils.h       \
359                                                                tools/bootloader_tsar/boot_fat32.h       \
360                                                                tools/bootloader_tsar/boot_tty_driver.h  \
361                                                                tools/bootloader_tsar/boot_hba_driver.h  \
362                                                                tools/bootloader_tsar/boot_bdv_driver.h  \
363                                                                tools/bootloader_tsar/boot_mmc_driver.h  \
364                                                                tools/bootloader_tsar/boot_config.h      \
365                                                                hal/tsar_mips32/core/hal_types.h         \
366                                                                hard_config.h                           
367        $(CC) $(BOOT_INCLUDE) $(CFLAGS) $(MACROS) -c -o $@ $<
368        $(DU) -D $@ > $@.txt
369
370##############################
371# Rule to compile boot_entry.o
372build/boot/boot_entry.o:                tools/bootloader_tsar/boot_entry.S   \
373                                                                tools/bootloader_tsar/boot_config.h  \
374                                                                hard_config.h
375        $(CC) $(BOOT_INCLUDE) $(CFLAGS) -c -o $@ $<
376        $(DU) -D $@ > $@.txt
377
378#####################################################################
379# Rule to generate boot.elf and place it in sector #2 of virtual disk
380build/boot/boot.elf:                            $(BOOT_OBJS) \
381                                                                        tools/bootloader_tsar/boot.ld                                   
382        $(LD) -o $@ -T tools/bootloader_tsar/boot.ld $(BOOT_OBJS)
383        $(DU) -D $@ > $@.txt
384        dd if=build/boot/boot.elf of=$(DISK_IMAGE) seek=2 conv=notrunc
385
386
387##############################
388# rules to compile the drivers
389build/kernel/drivers/%.o:       hal/tsar_mips32/drivers/%.c \
390                                hal/tsar_mips32/drivers/%.h \
391                                kernel_config.h             \
392                                hal/tsar_mips32/core/hal_types.h
393        $(CC) $(KERNEL_INCLUDE) $(CFLAGS)  -c -o $@ $<
394        $(DU) -D $@ > $@.txt
395
396#######################################
397# Rules to generate kernel/kern objects
398build/kernel/kern/%.o:              kernel/kern/%.c             \
399                                kernel/kern/%.h             \
400                                kernel_config.h             \
401                                hal/tsar_mips32/core/hal_types.h
402        $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $<
403        $(DU) -D $@ > $@.txt
404
405######################################
406# Rules to generate kernel/hal objects
407build/kernel/hal/%.o:           hal/tsar_mips32/core/%.c    \
408                                hal/generic/%.h             \
409                                kernel_config.h             \
410                                hal/tsar_mips32/core/hal_types.h
411        $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $<
412        $(DU) -D $@ > $@.txt
413
414build/kernel/hal/hal_kentry.o:  hal/tsar_mips32/core/hal_kentry.S \
415                                hal/tsar_mips32/core/hal_kentry.h \
416                                kernel_config.h              \
417                                hal/tsar_mips32/core/hal_types.h
418        $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $<
419        $(DU) -D $@ > $@.txt
420
421######################################
422# Rules to generate kernel/dev objects
423build/kernel/devices/%.o:       kernel/devices/%.c          \
424                                kernel/devices/%.h          \
425                                kernel_config.h             \
426                                hal/tsar_mips32/core/hal_types.h
427        $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $<
428        $(DU) -D $@ > $@.txt
429
430#####################################
431# Rules to generate kernel/mm objects
432build/kernel/mm/%.o:            kernel/mm/%.c               \
433                                kernel/mm/%.h               \
434                                kernel_config.h             \
435                                hal/tsar_mips32/core/hal_types.h
436        $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $<
437        $(DU) -D $@ > $@.txt
438
439#######################################
440# Rules to generate kernel/libk objects
441build/kernel/libk/%.o:          kernel/libk/%.c             \
442                                kernel/libk/%.h             \
443                                kernel_config.h             \
444                                hal/tsar_mips32/core/hal_types.h
445        $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $<
446        $(DU) -D $@ > $@.txt
447
448###########################################
449# Rules to generate kernel/syscalls objects
450build/kernel/syscalls/%.o:      kernel/syscalls/%.c         \
451                                kernel/syscalls/syscalls.h  \
452                                kernel_config.h             \
453                                hal/tsar_mips32/core/hal_types.h
454        $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $<
455        $(DU) -D $@ > $@.txt
456
457#######################################
458# Rules to generate kernel/vfs objects
459build/kernel/vfs/%.o:           kernel/vfs/%.c              \
460                                kernel/vfs/%.h              \
461                                kernel_config.h             \
462                                hal/tsar_mips32/core/hal_types.h
463        $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $<
464        $(DU) -D $@ > $@.txt
465
466###########################################################
467# Rule to generate kernel.elf and place it on virtual disk
468build/kernel/kernel.elf:            $(KERN_OBJS)                \
469                                $(HAL_OBJS)                 \
470                                $(DEV_OBJS)                 \
471                                $(MM_OBJS)                  \
472                                $(LIBK_OBJS)                \
473                                $(DRIVERS_OBJS)             \
474                                $(VFS_OBJS)                 \
475                                $(SYS_OBJS_0)               \
476                                $(SYS_OBJS_1)               \
477                                $(SYS_OBJS_2)               \
478                                $(SYS_OBJS_3)               \
479                                                                hal/tsar_mips32/kernel.ld
480        $(LD) -o $@ -T hal/tsar_mips32/kernel.ld $(LIBGCC)      \
481          $(KERN_OBJS) $(HAL_OBJS) $(DEV_OBJS) $(MM_OBJS)   \
482          $(LIBK_OBJS) $(DRIVERS_OBJS) $(VFS_OBJS)          \
483          $(SYS_OBJS_0) $(SYS_OBJS_1) $(SYS_OBJS_2)         \
484          $(SYS_OBJS_3) -lgcc
485
486        $(DU) -D $@ > $@.txt
487        mcopy -o -i $(DISK_IMAGE) build/kernel/kernel.elf ::/bin/kernel
488
Note: See TracBrowser for help on using the repository browser.