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