[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 \ |
---|
[667] | 85 | build/kern/ksocket.o \ |
---|
[569] | 86 | build/kern/cluster.o \ |
---|
| 87 | build/kern/scheduler.o \ |
---|
| 88 | build/kern/core.o \ |
---|
| 89 | build/kern/dqdt.o \ |
---|
| 90 | build/kern/do_syscall.o \ |
---|
[576] | 91 | build/kern/rpc.o |
---|
[439] | 92 | |
---|
[569] | 93 | DEV_OBJS = build/devices/dev_txt.o \ |
---|
| 94 | build/devices/dev_ioc.o \ |
---|
| 95 | build/devices/dev_mmc.o \ |
---|
| 96 | build/devices/dev_nic.o \ |
---|
| 97 | build/devices/dev_pic.o \ |
---|
| 98 | build/devices/dev_dma.o \ |
---|
| 99 | build/devices/dev_fbf.o \ |
---|
[439] | 100 | build/devices/dev_iob.o |
---|
| 101 | |
---|
[569] | 102 | MM_OBJS = build/mm/ppm.o \ |
---|
| 103 | build/mm/vmm.o \ |
---|
| 104 | build/mm/vseg.o \ |
---|
| 105 | build/mm/page.o \ |
---|
| 106 | build/mm/kcm.o \ |
---|
| 107 | build/mm/khm.o \ |
---|
| 108 | build/mm/mapper.o \ |
---|
[439] | 109 | build/mm/kmem.o |
---|
| 110 | |
---|
[569] | 111 | LIBK_OBJS = build/libk/grdxt.o \ |
---|
| 112 | build/libk/bits.o \ |
---|
| 113 | build/libk/elf.o \ |
---|
| 114 | build/libk/string.o \ |
---|
| 115 | build/libk/ctype.o \ |
---|
| 116 | build/libk/rwlock.o \ |
---|
| 117 | build/libk/busylock.o \ |
---|
| 118 | build/libk/queuelock.o \ |
---|
| 119 | build/libk/barrier.o \ |
---|
| 120 | build/libk/xbarrier.o \ |
---|
| 121 | build/libk/remote_busylock.o \ |
---|
| 122 | build/libk/remote_queuelock.o \ |
---|
| 123 | build/libk/remote_rwlock.o \ |
---|
| 124 | build/libk/remote_fifo.o \ |
---|
| 125 | build/libk/remote_mutex.o \ |
---|
| 126 | build/libk/remote_sem.o \ |
---|
| 127 | build/libk/remote_condvar.o \ |
---|
| 128 | build/libk/remote_barrier.o \ |
---|
[657] | 129 | build/libk/remote_buf.o \ |
---|
[569] | 130 | build/libk/memcpy.o \ |
---|
| 131 | build/libk/htab.o \ |
---|
[612] | 132 | build/libk/xhtab.o \ |
---|
| 133 | build/libk/user_dir.o |
---|
[439] | 134 | |
---|
| 135 | SYS_OBJS_0 = build/syscalls/sys_thread_exit.o \ |
---|
| 136 | build/syscalls/sys_thread_yield.o \ |
---|
| 137 | build/syscalls/sys_thread_create.o \ |
---|
| 138 | build/syscalls/sys_thread_join.o \ |
---|
| 139 | build/syscalls/sys_thread_detach.o \ |
---|
| 140 | build/syscalls/sys_thread_cancel.o \ |
---|
| 141 | build/syscalls/sys_sem.o \ |
---|
| 142 | build/syscalls/sys_condvar.o \ |
---|
| 143 | build/syscalls/sys_barrier.o \ |
---|
[610] | 144 | build/syscalls/sys_mutex.o |
---|
[439] | 145 | |
---|
[610] | 146 | SYS_OBJS_1 = build/syscalls/sys_rename.o \ |
---|
[439] | 147 | build/syscalls/sys_munmap.o \ |
---|
| 148 | build/syscalls/sys_open.o \ |
---|
| 149 | build/syscalls/sys_mmap.o \ |
---|
| 150 | build/syscalls/sys_read.o \ |
---|
| 151 | build/syscalls/sys_write.o \ |
---|
| 152 | build/syscalls/sys_lseek.o \ |
---|
| 153 | build/syscalls/sys_close.o \ |
---|
| 154 | build/syscalls/sys_unlink.o \ |
---|
| 155 | build/syscalls/sys_pipe.o |
---|
| 156 | |
---|
| 157 | SYS_OBJS_2 = build/syscalls/sys_chdir.o \ |
---|
| 158 | build/syscalls/sys_mkdir.o \ |
---|
| 159 | build/syscalls/sys_mkfifo.o \ |
---|
| 160 | build/syscalls/sys_opendir.o \ |
---|
| 161 | build/syscalls/sys_readdir.o \ |
---|
| 162 | build/syscalls/sys_closedir.o \ |
---|
| 163 | build/syscalls/sys_getcwd.o \ |
---|
| 164 | build/syscalls/sys_isatty.o \ |
---|
| 165 | build/syscalls/sys_alarm.o \ |
---|
| 166 | build/syscalls/sys_rmdir.o |
---|
| 167 | |
---|
| 168 | SYS_OBJS_3 = build/syscalls/sys_utls.o \ |
---|
| 169 | build/syscalls/sys_chmod.o \ |
---|
| 170 | build/syscalls/sys_signal.o \ |
---|
| 171 | build/syscalls/sys_timeofday.o \ |
---|
| 172 | build/syscalls/sys_kill.o \ |
---|
| 173 | build/syscalls/sys_getpid.o \ |
---|
| 174 | build/syscalls/sys_fork.o \ |
---|
| 175 | build/syscalls/sys_exec.o \ |
---|
| 176 | build/syscalls/sys_stat.o \ |
---|
| 177 | build/syscalls/sys_wait.o |
---|
| 178 | |
---|
| 179 | SYS_OBJS_4 = build/syscalls/sys_get_config.o \ |
---|
[637] | 180 | build/syscalls/sys_get_core_id.o \ |
---|
[439] | 181 | build/syscalls/sys_get_cycle.o \ |
---|
| 182 | build/syscalls/sys_display.o \ |
---|
[590] | 183 | build/syscalls/sys_place_fork.o \ |
---|
[439] | 184 | build/syscalls/sys_thread_sleep.o \ |
---|
| 185 | build/syscalls/sys_thread_wakeup.o \ |
---|
| 186 | build/syscalls/sys_trace.o \ |
---|
[457] | 187 | build/syscalls/sys_fg.o \ |
---|
| 188 | build/syscalls/sys_is_fg.o |
---|
[439] | 189 | |
---|
[626] | 190 | SYS_OBJS_5 = build/syscalls/sys_exit.o \ |
---|
| 191 | build/syscalls/sys_sync.o \ |
---|
[637] | 192 | build/syscalls/sys_fsync.o \ |
---|
| 193 | build/syscalls/sys_get_best_core.o \ |
---|
[641] | 194 | build/syscalls/sys_get_nb_cores.o \ |
---|
[647] | 195 | build/syscalls/sys_get_thread_info.o \ |
---|
[657] | 196 | build/syscalls/sys_fbf.o \ |
---|
| 197 | build/syscalls/sys_socket.o |
---|
[610] | 198 | |
---|
[439] | 199 | VFS_OBJS = build/fs/vfs.o \ |
---|
| 200 | build/fs/fatfs.o \ |
---|
| 201 | build/fs/devfs.o \ |
---|
| 202 | build/fs/ramfs.o |
---|
| 203 | |
---|
| 204 | # List of directories to be searched for included files |
---|
| 205 | # when compiling for kernel.elf generation |
---|
[626] | 206 | KERNEL_INCLUDE = -I. \ |
---|
| 207 | -Ikern \ |
---|
| 208 | -Idevices \ |
---|
| 209 | -Isyscalls \ |
---|
| 210 | -I$(SHARED_INCLUDE) \ |
---|
[439] | 211 | -I$(HAL_ARCH)/drivers \ |
---|
[440] | 212 | -Isyscalls \ |
---|
| 213 | -Ilibk \ |
---|
| 214 | -Imm \ |
---|
| 215 | -Ifs \ |
---|
| 216 | -I../tools/arch_info \ |
---|
| 217 | -I$(HAL)/generic \ |
---|
[439] | 218 | -I$(HAL_ARCH)/core \ |
---|
| 219 | -I.. |
---|
| 220 | |
---|
| 221 | # Rule to generate kernel.elf. |
---|
| 222 | compile: dirs \ |
---|
| 223 | build/kernel.elf |
---|
| 224 | |
---|
| 225 | # Rule to create the build directories. |
---|
| 226 | dirs: |
---|
| 227 | @mkdir -p build |
---|
| 228 | @mkdir -p build/kern |
---|
| 229 | @mkdir -p build/hal |
---|
| 230 | @mkdir -p build/devices |
---|
| 231 | @mkdir -p build/mm |
---|
| 232 | @mkdir -p build/libk |
---|
| 233 | @mkdir -p build/drivers |
---|
| 234 | @mkdir -p build/fs |
---|
| 235 | @mkdir -p build/syscalls |
---|
| 236 | |
---|
| 237 | |
---|
[647] | 238 | ###################################### |
---|
[439] | 239 | # rules to compile the drivers and hal |
---|
| 240 | $(HAL_ARCH)/build/%: |
---|
| 241 | $(MAKE) -C $(HAL_ARCH) |
---|
| 242 | |
---|
| 243 | ####################################### |
---|
| 244 | # Rules to generate kernel/kern objects |
---|
[440] | 245 | build/kern/%.o: kern/%.c \ |
---|
| 246 | kern/%.h \ |
---|
| 247 | kernel_config.h \ |
---|
[457] | 248 | $(HAL_ARCH)/core/hal_kernel_types.h |
---|
[439] | 249 | $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
| 250 | |
---|
| 251 | |
---|
| 252 | ###################################### |
---|
| 253 | # Rules to generate kernel/dev objects |
---|
[440] | 254 | build/devices/%.o: devices/%.c \ |
---|
| 255 | devices/%.h \ |
---|
| 256 | kernel_config.h \ |
---|
[457] | 257 | $(HAL_ARCH)/core/hal_kernel_types.h |
---|
[439] | 258 | $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
| 259 | |
---|
| 260 | ##################################### |
---|
| 261 | # Rules to generate kernel/mm objects |
---|
[440] | 262 | build/mm/%.o: mm/%.c \ |
---|
| 263 | mm/%.h \ |
---|
| 264 | kernel_config.h \ |
---|
[457] | 265 | $(HAL_ARCH)/core/hal_kernel_types.h |
---|
[439] | 266 | $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
| 267 | |
---|
| 268 | ####################################### |
---|
| 269 | # Rules to generate kernel/libk objects |
---|
[440] | 270 | build/libk/%.o: libk/%.c \ |
---|
| 271 | libk/%.h \ |
---|
| 272 | kernel_config.h \ |
---|
[457] | 273 | $(HAL_ARCH)/core/hal_kernel_types.h |
---|
[439] | 274 | $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
| 275 | |
---|
| 276 | ########################################### |
---|
| 277 | # Rules to generate kernel/syscalls objects |
---|
[440] | 278 | build/syscalls/%.o: syscalls/%.c \ |
---|
| 279 | syscalls/syscalls.h \ |
---|
| 280 | kernel_config.h \ |
---|
[457] | 281 | $(HAL_ARCH)/core/hal_kernel_types.h |
---|
[439] | 282 | $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
| 283 | |
---|
| 284 | ####################################### |
---|
| 285 | # Rules to generate kernel/fs objects |
---|
[440] | 286 | build/fs/%.o: fs/%.c \ |
---|
| 287 | fs/%.h \ |
---|
| 288 | kernel_config.h \ |
---|
[457] | 289 | $(HAL_ARCH)/core/hal_kernel_types.h |
---|
[439] | 290 | $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
| 291 | |
---|
[440] | 292 | ############################## |
---|
[439] | 293 | # Rule to generate kernel.elf |
---|
[633] | 294 | build/kernel.elf: $(KERN_OBJS) \ |
---|
[667] | 295 | $(HAL_OBJS_0) \ |
---|
| 296 | $(HAL_OBJS_1) \ |
---|
| 297 | $(DEV_OBJS) \ |
---|
| 298 | $(MM_OBJS) \ |
---|
| 299 | $(LIBK_OBJS) \ |
---|
| 300 | $(DRIVERS_OBJS) \ |
---|
| 301 | $(VFS_OBJS) \ |
---|
| 302 | $(SYS_OBJS_0) \ |
---|
| 303 | $(SYS_OBJS_1) \ |
---|
| 304 | $(SYS_OBJS_2) \ |
---|
| 305 | $(SYS_OBJS_3) \ |
---|
| 306 | $(SYS_OBJS_4) \ |
---|
| 307 | $(SYS_OBJS_5) \ |
---|
| 308 | $(HAL_ARCH)/kernel.ld |
---|
[440] | 309 | $(LD) -o $@ -T $(HAL_ARCH)/kernel.ld $(LIBGCC) \ |
---|
| 310 | $(KERN_OBJS) $(HAL_OBJS) $(DEV_OBJS) $(MM_OBJS) \ |
---|
| 311 | $(LIBK_OBJS) $(DRIVERS_OBJS) $(VFS_OBJS) \ |
---|
| 312 | $(SYS_OBJS_0) $(SYS_OBJS_1) $(SYS_OBJS_2) \ |
---|
[610] | 313 | $(SYS_OBJS_3) $(SYS_OBJS_4) $(SYS_OBJS_5) -lgcc |
---|
[439] | 314 | $(DU) -D $@ > $@.txt |
---|
| 315 | |
---|
| 316 | clean: |
---|
| 317 | rm -rf build/* |
---|