2014-02-12 21:47:13 +00:00
|
|
|
import sys
|
|
|
|
|
|
|
|
Import('env')
|
|
|
|
|
|
|
|
kern_env = env.Clone()
|
|
|
|
|
|
|
|
src = [ ]
|
|
|
|
|
|
|
|
src_amd64 = [
|
|
|
|
# Multiboot requires multiboot.S to be the first file
|
|
|
|
"amd64/multiboot.S",
|
|
|
|
"amd64/mbentry.c",
|
|
|
|
# AMD64
|
2014-07-13 20:36:43 +00:00
|
|
|
"amd64/debug.c",
|
2014-07-13 23:52:18 +00:00
|
|
|
"amd64/disasm.c",
|
2014-07-24 01:07:07 +00:00
|
|
|
"amd64/ioapic.c",
|
|
|
|
"amd64/irq.c",
|
|
|
|
"amd64/lapic.c",
|
2014-02-12 21:47:13 +00:00
|
|
|
"amd64/machine.c",
|
2015-02-16 01:00:55 +00:00
|
|
|
"amd64/mp.c",
|
|
|
|
"amd64/mpboot.S",
|
2014-06-30 22:52:35 +00:00
|
|
|
"amd64/pci.c",
|
|
|
|
"amd64/pmap.c",
|
2014-10-12 20:17:18 +00:00
|
|
|
"amd64/support.S",
|
2014-07-24 01:07:07 +00:00
|
|
|
"amd64/switch.S",
|
|
|
|
"amd64/thread.c",
|
2014-07-25 03:25:17 +00:00
|
|
|
"amd64/time.c",
|
2014-07-24 01:07:07 +00:00
|
|
|
"amd64/trap.c",
|
|
|
|
"amd64/trapentry.S",
|
2014-07-17 00:21:18 +00:00
|
|
|
# Devices
|
2014-07-02 21:06:00 +00:00
|
|
|
"dev/x86/debugcons.c",
|
2014-08-20 02:05:57 +00:00
|
|
|
"dev/x86/ide.c",
|
|
|
|
"dev/x86/ps2.c",
|
2014-11-22 22:35:18 +00:00
|
|
|
"dev/x86/rtc.c",
|
2014-07-13 20:04:14 +00:00
|
|
|
"dev/x86/sercons.c",
|
2014-07-06 01:46:59 +00:00
|
|
|
"dev/x86/vgacons.c",
|
2014-02-12 21:47:13 +00:00
|
|
|
]
|
|
|
|
|
2023-10-24 02:28:10 +00:00
|
|
|
src_arm64 = [
|
|
|
|
# Multiboot requires multiboot.S to be the first file
|
2023-11-09 16:54:56 +00:00
|
|
|
"arm64/locore.S",
|
2023-10-24 02:28:10 +00:00
|
|
|
"arm64/mbentry.c",
|
2023-11-09 16:54:56 +00:00
|
|
|
# ARM64
|
2023-10-24 02:28:10 +00:00
|
|
|
"arm64/debug.c",
|
|
|
|
"arm64/disasm.c",
|
|
|
|
"arm64/irq.c",
|
|
|
|
"arm64/machine.c",
|
|
|
|
"arm64/mp.c",
|
|
|
|
"arm64/pci.c",
|
|
|
|
"arm64/pmap.c",
|
|
|
|
"arm64/support.S",
|
|
|
|
"arm64/switch.S",
|
|
|
|
"arm64/thread.c",
|
|
|
|
"arm64/time.c",
|
|
|
|
"arm64/trap.c",
|
|
|
|
"arm64/trapentry.S",
|
2023-11-30 21:28:53 +00:00
|
|
|
"arm64/gic.c",
|
2023-10-24 02:28:10 +00:00
|
|
|
# Devices
|
2023-11-30 21:28:53 +00:00
|
|
|
"dev/arm64/uart.c",
|
2024-09-25 20:07:50 +00:00
|
|
|
# Metal
|
|
|
|
"arm64/metal.c",
|
|
|
|
"arm64/paging.c",
|
|
|
|
"arm64/mrt/init.c",
|
|
|
|
"arm64/mrt/paging.c",
|
2023-10-24 02:28:10 +00:00
|
|
|
]
|
|
|
|
|
2014-02-12 21:47:13 +00:00
|
|
|
src_common = [
|
2014-10-14 20:58:34 +00:00
|
|
|
"kern/copy.c",
|
2023-10-20 20:57:02 +00:00
|
|
|
"kern/critical.c",
|
2022-12-10 04:51:45 +00:00
|
|
|
"kern/bufcache.c",
|
2023-09-02 21:51:10 +00:00
|
|
|
"kern/cv.c",
|
2014-07-04 00:36:31 +00:00
|
|
|
"kern/debug.c",
|
2014-07-24 23:38:35 +00:00
|
|
|
"kern/disk.c",
|
2014-08-08 20:55:12 +00:00
|
|
|
"kern/handle.c",
|
2014-11-25 00:17:17 +00:00
|
|
|
"kern/ktime.c",
|
2015-01-17 21:52:04 +00:00
|
|
|
"kern/ktimer.c",
|
2014-02-12 21:47:13 +00:00
|
|
|
"kern/libc.c",
|
2014-07-28 00:09:31 +00:00
|
|
|
"kern/loader.c",
|
2023-09-02 21:51:10 +00:00
|
|
|
"kern/mutex.c",
|
2015-01-01 03:31:25 +00:00
|
|
|
"kern/nic.c",
|
2014-02-12 21:47:13 +00:00
|
|
|
"kern/palloc.c",
|
|
|
|
"kern/printf.c",
|
2023-08-21 22:39:26 +00:00
|
|
|
"kern/process.c",
|
|
|
|
"kern/sched.c",
|
2015-01-18 21:48:16 +00:00
|
|
|
"kern/semaphore.c",
|
2014-07-31 00:19:24 +00:00
|
|
|
"kern/sga.c",
|
2014-09-05 06:26:02 +00:00
|
|
|
"kern/slab.c",
|
2014-07-10 22:55:32 +00:00
|
|
|
"kern/spinlock.c",
|
2014-07-28 21:35:00 +00:00
|
|
|
"kern/syscall.c",
|
2014-11-25 20:07:14 +00:00
|
|
|
"kern/sysctl.c",
|
2014-07-24 01:07:07 +00:00
|
|
|
"kern/thread.c",
|
2014-08-01 21:15:06 +00:00
|
|
|
"kern/vfs.c",
|
2014-12-05 08:25:20 +00:00
|
|
|
"kern/vfsuio.c",
|
2023-08-30 16:49:23 +00:00
|
|
|
"kern/waitchannel.c",
|
2023-10-20 20:57:02 +00:00
|
|
|
"kern/xmem.c",
|
2014-07-02 21:06:00 +00:00
|
|
|
"dev/ahci.c",
|
|
|
|
"dev/console.c",
|
2014-12-30 05:32:00 +00:00
|
|
|
"dev/e1000.c",
|
2014-07-02 21:06:00 +00:00
|
|
|
"dev/pci.c",
|
2014-08-01 21:15:06 +00:00
|
|
|
"fs/o2fs/o2fs.c",
|
2014-02-12 21:47:13 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
if (env["ARCH"] == "amd64"):
|
|
|
|
src.append(src_amd64)
|
2014-07-18 20:37:46 +00:00
|
|
|
ldscript = "#sys/amd64/kernel.lds"
|
2023-10-24 02:28:10 +00:00
|
|
|
elif (env["ARCH"] == "arm64"):
|
|
|
|
src.append(src_arm64)
|
|
|
|
ldscript = "#sys/arm64/kernel.lds"
|
2014-08-08 00:58:41 +00:00
|
|
|
src.append(src_common)
|
2014-02-12 21:47:13 +00:00
|
|
|
|
2015-02-25 00:58:08 +00:00
|
|
|
kern_env.Append(LINKFLAGS = ['-T', ldscript[1:], '-nostdlib'])
|
2014-10-14 19:39:26 +00:00
|
|
|
kern_env.Append(CPPFLAGS = ['-D_KERNEL'])
|
2014-02-12 21:47:13 +00:00
|
|
|
kern_env.Append(CPPFLAGS = ['-ffreestanding', '-fno-builtin', '-nostdinc',
|
2024-09-25 20:07:50 +00:00
|
|
|
'-mno-red-zone', '-std=c11', "-Wno-c2x-extensions"])
|
2023-10-24 02:28:10 +00:00
|
|
|
|
|
|
|
if env["ARCH"] == "amd64":
|
|
|
|
kern_env.Append(CPPFLAGS = ['-mno-mmx', '-mno-sse', '-mcmodel=large'])
|
|
|
|
# '-target', 'amd64-orion-eabi'
|
|
|
|
elif env["ARCH"] == "arm64":
|
2023-11-07 17:45:19 +00:00
|
|
|
kern_env.Append(CPPFLAGS = ['-mcmodel=large', '-arch', 'armv8.1+nofp'])
|
2023-10-24 02:28:10 +00:00
|
|
|
|
2014-07-22 06:43:01 +00:00
|
|
|
kern_env.Append(CPPPATH = ['#build/include'])
|
2014-02-12 21:47:13 +00:00
|
|
|
|
2014-07-18 20:37:46 +00:00
|
|
|
kernel = kern_env.Program("castor", src)
|
|
|
|
Depends(kernel, ldscript)
|
2014-02-12 21:47:13 +00:00
|
|
|
|