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