[439] | 1 | ############################################################################# |
---|
| 2 | # ALMOS-MKH Makefile for Kernel # |
---|
| 3 | ############################################################################# |
---|
| 4 | |
---|
| 5 | -include ../params-soft.mk |
---|
| 6 | ifeq ($(ARCH_NAME),) |
---|
| 7 | $(error Please define in ARCH_NAME parameter in params-soft.mk!) |
---|
| 8 | endif |
---|
| 9 | |
---|
[569] | 10 | # We choose drivers and hal file to be linked with kernel.elf |
---|
[439] | 11 | ifeq ($(ARCH_NAME), tsar_mips32) |
---|
[440] | 12 | |
---|
[439] | 13 | DRIVERS_OBJS = $(HAL_ARCH)/build/drivers/soclib_tty.o \ |
---|
[569] | 14 | $(HAL_ARCH)/build/drivers/soclib_mty.o \ |
---|
[440] | 15 | $(HAL_ARCH)/build/drivers/soclib_bdv.o \ |
---|
| 16 | $(HAL_ARCH)/build/drivers/soclib_hba.o \ |
---|
| 17 | $(HAL_ARCH)/build/drivers/soclib_mmc.o \ |
---|
| 18 | $(HAL_ARCH)/build/drivers/soclib_pic.o \ |
---|
| 19 | $(HAL_ARCH)/build/drivers/soclib_nic.o \ |
---|
| 20 | $(HAL_ARCH)/build/drivers/soclib_dma.o \ |
---|
[647] | 21 | $(HAL_ARCH)/build/drivers/soclib_fbf.o \ |
---|
[440] | 22 | $(HAL_ARCH)/build/drivers/soclib_iob.o |
---|
[439] | 23 | |
---|
[440] | 24 | HAL_OBJS = $(HAL_ARCH)/build/core/hal_special.o \ |
---|
| 25 | $(HAL_ARCH)/build/core/hal_context.o \ |
---|
| 26 | $(HAL_ARCH)/build/core/hal_atomic.o \ |
---|
| 27 | $(HAL_ARCH)/build/core/hal_remote.o \ |
---|
| 28 | $(HAL_ARCH)/build/core/hal_uspace.o \ |
---|
| 29 | $(HAL_ARCH)/build/core/hal_irqmask.o \ |
---|
| 30 | $(HAL_ARCH)/build/core/hal_gpt.o \ |
---|
| 31 | $(HAL_ARCH)/build/core/hal_ppm.o \ |
---|
| 32 | $(HAL_ARCH)/build/core/hal_vmm.o \ |
---|
| 33 | $(HAL_ARCH)/build/core/hal_kentry.o \ |
---|
| 34 | $(HAL_ARCH)/build/core/hal_switch.o \ |
---|
| 35 | $(HAL_ARCH)/build/core/hal_syscall.o \ |
---|
| 36 | $(HAL_ARCH)/build/core/hal_exception.o \ |
---|
| 37 | $(HAL_ARCH)/build/core/hal_interrupt.o \ |
---|
| 38 | $(HAL_ARCH)/build/core/hal_drivers.o |
---|
[439] | 39 | endif |
---|
| 40 | |
---|
| 41 | ifeq ($(ARCH_NAME), x86_64) |
---|
| 42 | |
---|
| 43 | DRIVERS_OBJS = $(HAL_ARCH)/build/drivers/ioc_ata.o \ |
---|
[440] | 44 | $(HAL_ARCH)/build/drivers/pic_apic.o \ |
---|
| 45 | $(HAL_ARCH)/build/drivers/txt_rs232.o |
---|
[439] | 46 | |
---|
[440] | 47 | HAL_OBJS = $(HAL_ARCH)/build/core/hal_boot.o \ |
---|
| 48 | $(HAL_ARCH)/build/core/hal_smpboot.o \ |
---|
| 49 | $(HAL_ARCH)/build/core/hal_init.o \ |
---|
| 50 | $(HAL_ARCH)/build/core/hal_cpu.o \ |
---|
| 51 | $(HAL_ARCH)/build/core/hal_kentry.o \ |
---|
| 52 | $(HAL_ARCH)/build/core/hal_acpi.o \ |
---|
| 53 | $(HAL_ARCH)/build/core/hal_apic.o \ |
---|
| 54 | $(HAL_ARCH)/build/core/x86_printf.o \ |
---|
| 55 | $(HAL_ARCH)/build/core/hal_drivers.o \ |
---|
| 56 | $(HAL_ARCH)/build/core/hal_special.o \ |
---|
| 57 | $(HAL_ARCH)/build/core/hal_context.o \ |
---|
| 58 | $(HAL_ARCH)/build/core/hal_atomic.o \ |
---|
| 59 | $(HAL_ARCH)/build/core/hal_remote.o \ |
---|
| 60 | $(HAL_ARCH)/build/core/hal_uspace.o \ |
---|
| 61 | $(HAL_ARCH)/build/core/hal_irqmask.o \ |
---|
| 62 | $(HAL_ARCH)/build/core/hal_gpt.o \ |
---|
| 63 | $(HAL_ARCH)/build/core/hal_ppm.o \ |
---|
| 64 | $(HAL_ARCH)/build/core/hal_exception.o \ |
---|
| 65 | $(HAL_ARCH)/build/core/hal_interrupt.o \ |
---|
| 66 | $(HAL_ARCH)/build/core/hal_syscall.o |
---|
[439] | 67 | endif |
---|
| 68 | |
---|
| 69 | LIBGCC = -L$(shell $(CC) -print-libgcc-file-name | sed 's/libgcc.a//') #todo ? |
---|
| 70 | |
---|
| 71 | # Rules that don't build target files |
---|
| 72 | # always out-of-date, need to be regenerated everytime they are called |
---|
| 73 | .PHONY: compile \ |
---|
| 74 | dirs \ |
---|
| 75 | clean \ |
---|
| 76 | build/kernel.elf |
---|
| 77 | |
---|
| 78 | |
---|
| 79 | # Objects to be linked for kernel.elf generation |
---|
[569] | 80 | KERN_OBJS = build/kern/kernel_init.o \ |
---|
| 81 | build/kern/printk.o \ |
---|
| 82 | build/kern/thread.o \ |
---|
| 83 | build/kern/process.o \ |
---|
| 84 | build/kern/chdev.o \ |
---|
| 85 | build/kern/cluster.o \ |
---|
| 86 | build/kern/scheduler.o \ |
---|
| 87 | build/kern/core.o \ |
---|
| 88 | build/kern/dqdt.o \ |
---|
| 89 | build/kern/do_syscall.o \ |
---|
[576] | 90 | build/kern/rpc.o |
---|
[439] | 91 | |
---|
[569] | 92 | DEV_OBJS = build/devices/dev_txt.o \ |
---|
| 93 | build/devices/dev_ioc.o \ |
---|
| 94 | build/devices/dev_mmc.o \ |
---|
| 95 | build/devices/dev_nic.o \ |
---|
| 96 | build/devices/dev_pic.o \ |
---|
| 97 | build/devices/dev_dma.o \ |
---|
| 98 | build/devices/dev_fbf.o \ |
---|
[439] | 99 | build/devices/dev_iob.o |
---|
| 100 | |
---|
[569] | 101 | MM_OBJS = build/mm/ppm.o \ |
---|
| 102 | build/mm/vmm.o \ |
---|
| 103 | build/mm/vseg.o \ |
---|
| 104 | build/mm/page.o \ |
---|
| 105 | build/mm/kcm.o \ |
---|
| 106 | build/mm/khm.o \ |
---|
| 107 | build/mm/mapper.o \ |
---|
[439] | 108 | build/mm/kmem.o |
---|
| 109 | |
---|
[569] | 110 | LIBK_OBJS = build/libk/grdxt.o \ |
---|
| 111 | build/libk/bits.o \ |
---|
| 112 | build/libk/elf.o \ |
---|
| 113 | build/libk/string.o \ |
---|
| 114 | build/libk/ctype.o \ |
---|
| 115 | build/libk/rwlock.o \ |
---|
| 116 | build/libk/busylock.o \ |
---|
| 117 | build/libk/queuelock.o \ |
---|
| 118 | build/libk/barrier.o \ |
---|
| 119 | build/libk/xbarrier.o \ |
---|
| 120 | build/libk/remote_busylock.o \ |
---|
| 121 | build/libk/remote_queuelock.o \ |
---|
| 122 | build/libk/remote_rwlock.o \ |
---|
| 123 | build/libk/remote_fifo.o \ |
---|
| 124 | build/libk/remote_mutex.o \ |
---|
| 125 | build/libk/remote_sem.o \ |
---|
| 126 | build/libk/remote_condvar.o \ |
---|
| 127 | build/libk/remote_barrier.o \ |
---|
| 128 | build/libk/memcpy.o \ |
---|
| 129 | build/libk/htab.o \ |
---|
[612] | 130 | build/libk/xhtab.o \ |
---|
| 131 | build/libk/user_dir.o |
---|
[439] | 132 | |
---|
| 133 | SYS_OBJS_0 = build/syscalls/sys_thread_exit.o \ |
---|
| 134 | build/syscalls/sys_thread_yield.o \ |
---|
| 135 | build/syscalls/sys_thread_create.o \ |
---|
| 136 | build/syscalls/sys_thread_join.o \ |
---|
| 137 | build/syscalls/sys_thread_detach.o \ |
---|
| 138 | build/syscalls/sys_thread_cancel.o \ |
---|
| 139 | build/syscalls/sys_sem.o \ |
---|
| 140 | build/syscalls/sys_condvar.o \ |
---|
| 141 | build/syscalls/sys_barrier.o \ |
---|
[610] | 142 | build/syscalls/sys_mutex.o |
---|
[439] | 143 | |
---|
[610] | 144 | SYS_OBJS_1 = build/syscalls/sys_rename.o \ |
---|
[439] | 145 | build/syscalls/sys_munmap.o \ |
---|
| 146 | build/syscalls/sys_open.o \ |
---|
| 147 | build/syscalls/sys_mmap.o \ |
---|
| 148 | build/syscalls/sys_read.o \ |
---|
| 149 | build/syscalls/sys_write.o \ |
---|
| 150 | build/syscalls/sys_lseek.o \ |
---|
| 151 | build/syscalls/sys_close.o \ |
---|
| 152 | build/syscalls/sys_unlink.o \ |
---|
| 153 | build/syscalls/sys_pipe.o |
---|
| 154 | |
---|
| 155 | SYS_OBJS_2 = build/syscalls/sys_chdir.o \ |
---|
| 156 | build/syscalls/sys_mkdir.o \ |
---|
| 157 | build/syscalls/sys_mkfifo.o \ |
---|
| 158 | build/syscalls/sys_opendir.o \ |
---|
| 159 | build/syscalls/sys_readdir.o \ |
---|
| 160 | build/syscalls/sys_closedir.o \ |
---|
| 161 | build/syscalls/sys_getcwd.o \ |
---|
| 162 | build/syscalls/sys_isatty.o \ |
---|
| 163 | build/syscalls/sys_alarm.o \ |
---|
| 164 | build/syscalls/sys_rmdir.o |
---|
| 165 | |
---|
| 166 | SYS_OBJS_3 = build/syscalls/sys_utls.o \ |
---|
| 167 | build/syscalls/sys_chmod.o \ |
---|
| 168 | build/syscalls/sys_signal.o \ |
---|
| 169 | build/syscalls/sys_timeofday.o \ |
---|
| 170 | build/syscalls/sys_kill.o \ |
---|
| 171 | build/syscalls/sys_getpid.o \ |
---|
| 172 | build/syscalls/sys_fork.o \ |
---|
| 173 | build/syscalls/sys_exec.o \ |
---|
| 174 | build/syscalls/sys_stat.o \ |
---|
| 175 | build/syscalls/sys_wait.o |
---|
| 176 | |
---|
| 177 | SYS_OBJS_4 = build/syscalls/sys_get_config.o \ |
---|
[637] | 178 | build/syscalls/sys_get_core_id.o \ |
---|
[439] | 179 | build/syscalls/sys_get_cycle.o \ |
---|
| 180 | build/syscalls/sys_display.o \ |
---|
[590] | 181 | build/syscalls/sys_place_fork.o \ |
---|
[439] | 182 | build/syscalls/sys_thread_sleep.o \ |
---|
| 183 | build/syscalls/sys_thread_wakeup.o \ |
---|
| 184 | build/syscalls/sys_trace.o \ |
---|
[457] | 185 | build/syscalls/sys_fg.o \ |
---|
| 186 | build/syscalls/sys_is_fg.o |
---|
[439] | 187 | |
---|
[626] | 188 | SYS_OBJS_5 = build/syscalls/sys_exit.o \ |
---|
| 189 | build/syscalls/sys_sync.o \ |
---|
[637] | 190 | build/syscalls/sys_fsync.o \ |
---|
| 191 | build/syscalls/sys_get_best_core.o \ |
---|
[641] | 192 | build/syscalls/sys_get_nb_cores.o \ |
---|
[647] | 193 | build/syscalls/sys_get_thread_info.o \ |
---|
| 194 | build/syscalls/sys_fbf.o |
---|
[610] | 195 | |
---|
[439] | 196 | VFS_OBJS = build/fs/vfs.o \ |
---|
| 197 | build/fs/fatfs.o \ |
---|
| 198 | build/fs/devfs.o \ |
---|
| 199 | build/fs/ramfs.o |
---|
| 200 | |
---|
| 201 | # List of directories to be searched for included files |
---|
| 202 | # when compiling for kernel.elf generation |
---|
[626] | 203 | KERNEL_INCLUDE = -I. \ |
---|
| 204 | -Ikern \ |
---|
| 205 | -Idevices \ |
---|
| 206 | -Isyscalls \ |
---|
| 207 | -I$(SHARED_INCLUDE) \ |
---|
[439] | 208 | -I$(HAL_ARCH)/drivers \ |
---|
[440] | 209 | -Isyscalls \ |
---|
| 210 | -Ilibk \ |
---|
| 211 | -Imm \ |
---|
| 212 | -Ifs \ |
---|
| 213 | -I../tools/arch_info \ |
---|
| 214 | -I$(HAL)/generic \ |
---|
[439] | 215 | -I$(HAL_ARCH)/core \ |
---|
| 216 | -I.. |
---|
| 217 | |
---|
| 218 | # Rule to generate kernel.elf. |
---|
| 219 | compile: dirs \ |
---|
| 220 | build/kernel.elf |
---|
| 221 | |
---|
| 222 | # Rule to create the build directories. |
---|
| 223 | dirs: |
---|
| 224 | @mkdir -p build |
---|
| 225 | @mkdir -p build/kern |
---|
| 226 | @mkdir -p build/hal |
---|
| 227 | @mkdir -p build/devices |
---|
| 228 | @mkdir -p build/mm |
---|
| 229 | @mkdir -p build/libk |
---|
| 230 | @mkdir -p build/drivers |
---|
| 231 | @mkdir -p build/fs |
---|
| 232 | @mkdir -p build/syscalls |
---|
| 233 | |
---|
| 234 | |
---|
[647] | 235 | ###################################### |
---|
[439] | 236 | # rules to compile the drivers and hal |
---|
| 237 | $(HAL_ARCH)/build/%: |
---|
| 238 | $(MAKE) -C $(HAL_ARCH) |
---|
| 239 | |
---|
| 240 | ####################################### |
---|
| 241 | # Rules to generate kernel/kern objects |
---|
[440] | 242 | build/kern/%.o: kern/%.c \ |
---|
| 243 | kern/%.h \ |
---|
| 244 | kernel_config.h \ |
---|
[457] | 245 | $(HAL_ARCH)/core/hal_kernel_types.h |
---|
[439] | 246 | $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
| 247 | |
---|
| 248 | |
---|
| 249 | ###################################### |
---|
| 250 | # Rules to generate kernel/dev objects |
---|
[440] | 251 | build/devices/%.o: devices/%.c \ |
---|
| 252 | devices/%.h \ |
---|
| 253 | kernel_config.h \ |
---|
[457] | 254 | $(HAL_ARCH)/core/hal_kernel_types.h |
---|
[439] | 255 | $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
| 256 | |
---|
| 257 | ##################################### |
---|
| 258 | # Rules to generate kernel/mm objects |
---|
[440] | 259 | build/mm/%.o: mm/%.c \ |
---|
| 260 | mm/%.h \ |
---|
| 261 | kernel_config.h \ |
---|
[457] | 262 | $(HAL_ARCH)/core/hal_kernel_types.h |
---|
[439] | 263 | $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
| 264 | |
---|
| 265 | ####################################### |
---|
| 266 | # Rules to generate kernel/libk objects |
---|
[440] | 267 | build/libk/%.o: libk/%.c \ |
---|
| 268 | libk/%.h \ |
---|
| 269 | kernel_config.h \ |
---|
[457] | 270 | $(HAL_ARCH)/core/hal_kernel_types.h |
---|
[439] | 271 | $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
| 272 | |
---|
| 273 | ########################################### |
---|
| 274 | # Rules to generate kernel/syscalls objects |
---|
[440] | 275 | build/syscalls/%.o: syscalls/%.c \ |
---|
| 276 | syscalls/syscalls.h \ |
---|
| 277 | kernel_config.h \ |
---|
[457] | 278 | $(HAL_ARCH)/core/hal_kernel_types.h |
---|
[439] | 279 | $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
| 280 | |
---|
| 281 | ####################################### |
---|
| 282 | # Rules to generate kernel/fs objects |
---|
[440] | 283 | build/fs/%.o: fs/%.c \ |
---|
| 284 | fs/%.h \ |
---|
| 285 | kernel_config.h \ |
---|
[457] | 286 | $(HAL_ARCH)/core/hal_kernel_types.h |
---|
[439] | 287 | $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
| 288 | |
---|
[440] | 289 | ############################## |
---|
[439] | 290 | # Rule to generate kernel.elf |
---|
[633] | 291 | build/kernel.elf: $(KERN_OBJS) \ |
---|
[440] | 292 | $(HAL_OBJS_0) \ |
---|
| 293 | $(HAL_OBJS_1) \ |
---|
| 294 | $(DEV_OBJS) \ |
---|
| 295 | $(MM_OBJS) \ |
---|
| 296 | $(LIBK_OBJS) \ |
---|
| 297 | $(DRIVERS_OBJS) \ |
---|
| 298 | $(VFS_OBJS) \ |
---|
| 299 | $(SYS_OBJS_0) \ |
---|
| 300 | $(SYS_OBJS_1) \ |
---|
| 301 | $(SYS_OBJS_2) \ |
---|
| 302 | $(SYS_OBJS_3) \ |
---|
| 303 | $(SYS_OBJS_4) \ |
---|
[610] | 304 | $(SYS_OBJS_5) \ |
---|
[440] | 305 | $(HAL_ARCH)/kernel.ld |
---|
| 306 | $(LD) -o $@ -T $(HAL_ARCH)/kernel.ld $(LIBGCC) \ |
---|
| 307 | $(KERN_OBJS) $(HAL_OBJS) $(DEV_OBJS) $(MM_OBJS) \ |
---|
| 308 | $(LIBK_OBJS) $(DRIVERS_OBJS) $(VFS_OBJS) \ |
---|
| 309 | $(SYS_OBJS_0) $(SYS_OBJS_1) $(SYS_OBJS_2) \ |
---|
[610] | 310 | $(SYS_OBJS_3) $(SYS_OBJS_4) $(SYS_OBJS_5) -lgcc |
---|
[439] | 311 | $(DU) -D $@ > $@.txt |
---|
| 312 | |
---|
| 313 | clean: |
---|
| 314 | rm -rf build/* |
---|