source: trunk/Makefile @ 15

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

This version executed sucessfully the kernel_init on a TSAR_2_2_2 (4 clusters / 2 cores) architecture.

File size: 15.6 KB
Line 
1#############################################################################
2#                                               ALMOS-MK  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
12# Export all variables to applications sub-Makefile.
13export
14CC = mipsel-unknown-elf-gcc
15AS = mipsel-unknown-elf-as
16LD = mipsel-unknown-elf-ld
17DU = mipsel-unknown-elf-objdump
18AR = mipsel-unknown-elf-ar
19
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        \
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_xcu.o  \
71               build/kernel/drivers/soclib_pic.o  \
72               build/kernel/drivers/soclib_nic.o  \
73               build/kernel/drivers/soclib_dma.o  \
74               build/kernel/drivers/soclib_iob.o
75
76# Objects to be linked for kernel.elf generation
77KERN_OBJS       = build/kernel/kern/kernel_init.o     \
78              build/kernel/kern/printk.o          \
79              build/kernel/kern/thread.o          \
80              build/kernel/kern/process.o         \
81              build/kernel/kern/chdev.o           \
82              build/kernel/kern/cluster.o         \
83              build/kernel/kern/scheduler.o       \
84              build/kernel/kern/core.o            \
85              build/kernel/kern/dqdt.o            \
86              build/kernel/kern/remote_sem.o      \
87              build/kernel/kern/rpc.o
88
89HAL_OBJS    = build/kernel/hal/hal_special.o      \
90              build/kernel/hal/hal_context.o      \
91              build/kernel/hal/hal_atomic.o       \
92              build/kernel/hal/hal_remote.o       \
93              build/kernel/hal/hal_uspace.o       \
94              build/kernel/hal/hal_irqmask.o      \
95              build/kernel/hal/hal_gpt.o       
96
97DEV_OBJS    = build/kernel/devices/dev_txt.o      \
98              build/kernel/devices/dev_ioc.o      \
99              build/kernel/devices/dev_icu.o      \
100              build/kernel/devices/dev_mmc.o      \
101              build/kernel/devices/dev_nic.o      \
102              build/kernel/devices/dev_pic.o      \
103              build/kernel/devices/dev_dma.o      \
104              build/kernel/devices/dev_fbf.o      \
105              build/kernel/devices/dev_iob.o
106
107MM_OBJS     = build/kernel/mm/ppm.o               \
108              build/kernel/mm/vmm.o               \
109              build/kernel/mm/vseg.o              \
110              build/kernel/mm/page.o              \
111              build/kernel/mm/kcm.o               \
112              build/kernel/mm/khm.o               \
113              build/kernel/mm/mapper.o            \
114              build/kernel/mm/kmem.o
115
116LIBK_OBJS   = build/kernel/libk/grdxt.o           \
117              build/kernel/libk/bits.o            \
118              build/kernel/libk/elf.o             \
119              build/kernel/libk/string.o          \
120              build/kernel/libk/ctype.o           \
121              build/kernel/libk/rwlock.o          \
122              build/kernel/libk/spinlock.o        \
123              build/kernel/libk/remote_barrier.o  \
124              build/kernel/libk/remote_spinlock.o \
125              build/kernel/libk/remote_rwlock.o   \
126              build/kernel/libk/remote_fifo.o     \
127              build/kernel/libk/memcpy.o          \
128              build/kernel/libk/xhtab.o
129
130SYS_OBJS    = build/kernel/syscalls/sys_exec.o          \
131              build/kernel/syscalls/sys_thread_create.o
132
133VFS_OBJS    = build/kernel/vfs/vfs.o              \
134              build/kernel/vfs/fatfs.o            \
135              build/kernel/vfs/ramfs.o
136
137# List of directories to be searched for included files
138# when compiling for kernel.elf generation
139KERNEL_INCLUDE = -Ikernel                \
140                 -Ikernel/kern           \
141                 -Ikernel/devices        \
142                 -Ikernel/drivers/soclib \
143                 -Ikernel/syscalls       \
144                 -Ikernel/libk           \
145                 -Ikernel/mm             \
146                 -Ikernel/vfs            \
147                 -Ikernel/fs/fatfs       \
148                 -Ikernel/fs/sysfs       \
149                 -Ikernel/fs/ramfs       \
150                 -Ikernel/fs/devfs       \
151                 -Itools/arch_info       \
152                 -Ihal/tsar_mips32       \
153                 -I.
154
155# Macros to be processed by the C preprocessor.
156MACROS           = -DARCHINFO_PATHNAME="\"arch_info.bin\""              \
157                           -DKERNEL_PATHNAME="\"/bin/kernel/kernel.elf\""
158
159# Virtual disk path
160DISK_IMAGE      := hdd/virt_hdd.dmg
161
162# The Mtools used to build the FAT32 disk image perfom a few sanity checks, to
163# make sure that the disk is indeed an MS-DOS disk. However, the size of the
164# disk image used by ALMOS-VM is not MS-DOS compliant.
165# Setting this variable prevents these checks.
166MTOOLS_SKIP_CHECK := 1
167
168# Rule to compile boot.elf, kernel.elf, and update virtual disk.
169compile: dirs                               \
170                 hard_config.h              \
171                 build/boot/boot.elf        \
172         build/kernel/kernel.elf    \
173         list
174
175# Rule to create the build directories.
176dirs:
177        @mkdir -p build/boot
178        @mkdir -p build/kernel
179        @mkdir -p build/kernel/kern
180        @mkdir -p build/kernel/hal
181        @mkdir -p build/kernel/devices
182        @mkdir -p build/kernel/mm
183        @mkdir -p build/kernel/libk
184        @mkdir -p build/kernel/drivers
185        @mkdir -p build/kernel/vfs
186        @mkdir -p hdd
187
188# Rule to make a recursive list of the virtual disk content.
189list:
190        mdir -/ -w -i $(DISK_IMAGE) ::/
191
192# Rule to make a file system check for the virtual disk.
193fsck:
194        fsck.msdos $(DISK_IMAGE)
195
196##############################################################
197# Rule to copy the files generated by the virtual prototype
198# from the virtual disk 'home' directory to the current directory.
199extract:
200        mcopy -o -i $(DISK_IMAGE) ::/home .
201
202# Rules to delete all binary files from Unix File System
203# without modifying the virtual disk.
204clean:
205        rm -f *.o *.elf *.bin *.txt core
206        rm -f hard_config.h arch_info.xml arch_info.bin
207        rm -rf build
208
209####################################################   
210# Rule for building a new virtual disk from scratch.
211# It creates the bin / home directories.
212# This requires the generic Linux/MacOS 'create_dmg' script, that should be
213# placed in the same directory as this Makefile.
214build-disk:
215        rm -f $(DISK_IMAGE)
216        ./create_dmg    create $(basename $(DISK_IMAGE))
217        dd                              if=$(DISK_IMAGE) of=temp.dmg count=65536
218        mv                              temp.dmg $(DISK_IMAGE)
219        mmd                     -o -i $(DISK_IMAGE) ::/bin         || true
220        mmd                     -o -i $(DISK_IMAGE) ::/bin/kernel  || true
221        mmd                     -o -i $(DISK_IMAGE) ::/home        || true
222        mdir             -/ -b -i $(DISK_IMAGE) ::/
223       
224##############################################################
225# Rules to generate hardware description files (hard_config.h,
226# arch_info.bin and arch_info.xml), and update the virtual disk.
227hard_config.h: $(ARCH)/arch_info.py
228        tools/arch_info/genarch.py      --arch=$(ARCH)                  \
229                                                                --x_size=$(X_SIZE)              \
230                                                                --y_size=$(Y_SIZE)              \
231                                                                --nb_cores=$(NB_PROCS)  \
232                                                                --nb_ttys=$(NB_TTYS)    \
233                                                                --fbf_size=$(FBF_WIDTH) \
234                                                                --ioc_type=$(IOC_TYPE)  \
235                                                                --hard=.                                \
236                                                                --bin=.                                 \
237                                                                --xml=.                                 
238        mcopy -o -i $(DISK_IMAGE) arch_info.bin ::/   || true
239
240################################################
241# Rules to compile boot drivers used by boot.elf
242build/boot/boot_tty_driver.o:   tools/bootloader_tsar/boot_tty_driver.c \
243                                                                tools/bootloader_tsar/boot_tty_driver.h \
244                                                                tools/bootloader_tsar/boot_utils.h      \
245                                                                tools/bootloader_tsar/boot_config.h     \
246                                                                hal/tsar_mips32/hal_types.h             \
247                                                                hard_config.h
248        $(CC) $(BOOT_INCLUDE) $(CFLAGS) -c -o $@ $<
249        $(DU) -D $@ > $@.txt
250
251build/boot/boot_bdv_driver.o:   tools/bootloader_tsar/boot_bdv_driver.c \
252                                                                tools/bootloader_tsar/boot_bdv_driver.h \
253                                                                tools/bootloader_tsar/boot_utils.h      \
254                                                                tools/bootloader_tsar/boot_config.h     \
255                                                                hal/tsar_mips32/hal_types.h             \
256                                                                hard_config.h
257        $(CC) $(BOOT_INCLUDE) $(CFLAGS) -c -o $@ $<
258        $(DU) -D $@ > $@.txt
259
260build/boot/boot_hba_driver.o:   tools/bootloader_tsar/boot_hba_driver.c \
261                                                                tools/bootloader_tsar/boot_hba_driver.h \
262                                                                tools/bootloader_tsar/boot_utils.h      \
263                                                                tools/bootloader_tsar/boot_config.h     \
264                                                                hal/tsar_mips32/hal_types.h             \
265                                                                hard_config.h
266        $(CC) $(BOOT_INCLUDE) $(CFLAGS) -c -o $@ $<
267        $(DU) -D $@ > $@.txt
268
269build/boot/boot_mmc_driver.o:   tools/bootloader_tsar/boot_mmc_driver.c \
270                                                                tools/bootloader_tsar/boot_mmc_driver.h \
271                                                                tools/bootloader_tsar/boot_utils.h      \
272                                                                tools/bootloader_tsar/boot_config.h     \
273                                                                hal/tsar_mips32/hal_types.h             \
274                                                                hard_config.h
275        $(CC) $(BOOT_INCLUDE) $(CFLAGS) -c -o $@ $<
276        $(DU) -D $@ > $@.txt
277
278##############################
279# Rule to compile boot_fat32.o
280build/boot/boot_fat32.o:                tools/bootloader_tsar/boot_fat32.c      \
281                                                                tools/bootloader_tsar/boot_fat32.h      \
282                                                                tools/bootloader_tsar/boot_utils.h      \
283                                                                tools/bootloader_tsar/boot_config.h     \
284                                                                hal/tsar_mips32/hal_types.h             \
285                                                                hard_config.h                   
286        $(CC) $(BOOT_INCLUDE) $(CFLAGS) -c -o $@ $<
287        $(DU) -D $@ > $@.txt
288
289##############################
290# Rule to compile boot_utils.o
291build/boot/boot_utils.o:                tools/bootloader_tsar/boot_utils.c       \
292                                                                tools/bootloader_tsar/boot_utils.h       \
293                                                                tools/bootloader_tsar/boot_tty_driver.h  \
294                                                                hal/tsar_mips32/hal_types.h              \
295                                                                hard_config.h
296        $(CC) $(BOOT_INCLUDE) $(CFLAGS) -c -o $@ $<
297        $(DU) -D $@ > $@.txt
298
299########################
300# Rule to compile boot.o
301build/boot/boot.o:                              tools/bootloader_tsar/boot.c             \
302                                                                tools/bootloader_tsar/boot_utils.h       \
303                                                                tools/bootloader_tsar/boot_fat32.h       \
304                                                                tools/bootloader_tsar/boot_tty_driver.h  \
305                                                                tools/bootloader_tsar/boot_hba_driver.h  \
306                                                                tools/bootloader_tsar/boot_bdv_driver.h  \
307                                                                tools/bootloader_tsar/boot_mmc_driver.h  \
308                                                                tools/bootloader_tsar/boot_config.h      \
309                                                                hal/tsar_mips32/hal_types.h              \
310                                                                hard_config.h                           
311        $(CC) $(BOOT_INCLUDE) $(CFLAGS) $(MACROS) -c -o $@ $<
312        $(DU) -D $@ > $@.txt
313
314##############################
315# Rule to compile boot_entry.o
316build/boot/boot_entry.o:                tools/bootloader_tsar/boot_entry.S   \
317                                                                tools/bootloader_tsar/boot_config.h  \
318                                                                hard_config.h
319        $(CC) $(BOOT_INCLUDE) $(CFLAGS) -c -o $@ $<
320        $(DU) -D $@ > $@.txt
321
322#####################################################################
323# Rule to generate boot.elf and place it in sector #2 of virtual disk
324build/boot/boot.elf:                            $(BOOT_OBJS) \
325                                                                        tools/bootloader_tsar/boot.ld                                   
326        $(LD) -o $@ -T tools/bootloader_tsar/boot.ld $(BOOT_OBJS) 
327        $(DU) -D $@ > $@.txt
328        dd if=build/boot/boot.elf of=$(DISK_IMAGE) seek=2 conv=notrunc
329
330
331##############################
332# rules to compile the drivers
333build/kernel/drivers/%.o:       kernel/drivers/soclib/%.c   \
334                                kernel/drivers/soclib/%.h   \
335                                almos_config.h              \
336                                hal/tsar_mips32/hal_types.h
337        $(CC) $(KERNEL_INCLUDE) $(CFLAGS)  -c -o $@ $<
338        $(DU) -D $@ > $@.txt
339
340#######################################
341# Rules to generate kernel/kern objects
342build/kernel/kern/%.o:              kernel/kern/%.c             \
343                                kernel/kern/%.h             \
344                                almos_config.h              \
345                                hal/tsar_mips32/hal_types.h
346        $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $<
347        $(DU) -D $@ > $@.txt
348
349######################################
350# Rules to generate kernel/hal objects
351build/kernel/hal/%.o:           hal/tsar_mips32/%.c         \
352                                hal/tsar_mips32/%.h         \
353                                almos_config.h              \
354                                hal/tsar_mips32/hal_types.h
355        $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $<
356        $(DU) -D $@ > $@.txt
357
358######################################
359# Rules to generate kernel/dev objects
360build/kernel/devices/%.o:       kernel/devices/%.c          \
361                                kernel/devices/%.h          \
362                                almos_config.h              \
363                                hal/tsar_mips32/hal_types.h
364        $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $<
365        $(DU) -D $@ > $@.txt
366
367#####################################
368# Rules to generate kernel/mm objects
369build/kernel/mm/%.o:            kernel/mm/%.c               \
370                                kernel/mm/%.h               \
371                                almos_config.h              \
372                                hal/tsar_mips32/hal_types.h
373        $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $<
374        $(DU) -D $@ > $@.txt
375
376#######################################
377# Rules to generate kernel/libk objects
378build/kernel/libk/%.o:          kernel/libk/%.c             \
379                                kernel/libk/%.h             \
380                                almos_config.h              \
381                                hal/tsar_mips32/hal_types.h
382        $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $<
383        $(DU) -D $@ > $@.txt
384
385#######################################
386# Rules to generate kernel/vfs objects
387build/kernel/vfs/%.o:           kernel/vfs/%.c              \
388                                kernel/vfs/vfs.h            \
389                                almos_config.h              \
390                                hal/tsar_mips32/hal_types.h
391        $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $<
392        $(DU) -D $@ > $@.txt
393
394###########################################################
395# Rule to generate kernel.elf and place it on virtual disk
396build/kernel/kernel.elf:            $(KERN_OBJS)                \
397                                $(HAL_OBJS)                 \
398                                $(DEV_OBJS)                 \
399                                $(MM_OBJS)                  \
400                                $(LIBK_OBJS)                \
401                                $(DRIVERS_OBJS)             \
402                                $(VFS_OBJS)                 \
403                                                                kernel/kernel.ld           
404        $(LD) -o $@ -T kernel/kernel.ld                         \
405          $(KERN_OBJS) $(HAL_OBJS) $(DEV_OBJS) $(MM_OBJS)   \
406          $(LIBK_OBJS) $(DRIVERS_OBJS) $(VFS_OBJS)
407        $(DU) -D $@ > $@.txt
408        mcopy -o -i $(DISK_IMAGE) build/kernel/kernel.elf ::/bin/kernel
409
Note: See TracBrowser for help on using the repository browser.