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