From 14cc577adffe009d29601b9e944746830fa02f17 Mon Sep 17 00:00:00 2001 From: Ali Mashtizadeh Date: Fri, 20 Oct 2023 16:57:02 -0400 Subject: [PATCH] Cleanup to prepare for ARM64 + Metal --- lib/libc/SConscript | 11 ++++++++--- lib/libc/{ => amd64}/crti.S | 0 lib/libc/{ => amd64}/crtn.S | 0 sys/SConscript | 4 ++-- sys/{amd64 => kern}/critical.c | 4 +++- sys/{amd64 => kern}/xmem.c | 0 6 files changed, 13 insertions(+), 6 deletions(-) rename lib/libc/{ => amd64}/crti.S (100%) rename lib/libc/{ => amd64}/crtn.S (100%) rename sys/{amd64 => kern}/critical.c (92%) rename sys/{amd64 => kern}/xmem.c (100%) diff --git a/lib/libc/SConscript b/lib/libc/SConscript index f8aa670..a52a1bb 100644 --- a/lib/libc/SConscript +++ b/lib/libc/SConscript @@ -25,12 +25,17 @@ src_common = [ ] src_amd64 = [ -# "amd64/entry.S", "amd64/syscall.S", ] +src_arm64 = [ + "arm64/syscall.S", +] + if (env["ARCH"] == "amd64"): src.append(src_amd64) +elif (env["ARCH"] == "arm64"): + src.append(src_arm64) src.append(src_common) libc_env.Append(CPPFLAGS = ['-nostdinc']) @@ -38,6 +43,6 @@ libc_env.Append(CPPPATH = ['#build/include']) libc_env.StaticLibrary("libc", src) libc_env.StaticObject("crt1", "crt1.c") -libc_env.StaticObject("crti", "crti.S") -libc_env.StaticObject("crtn", "crtn.S") +libc_env.StaticObject("crti", "${ARCH}/crti.S") +libc_env.StaticObject("crtn", "${ARCH}/crtn.S") diff --git a/lib/libc/crti.S b/lib/libc/amd64/crti.S similarity index 100% rename from lib/libc/crti.S rename to lib/libc/amd64/crti.S diff --git a/lib/libc/crtn.S b/lib/libc/amd64/crtn.S similarity index 100% rename from lib/libc/crtn.S rename to lib/libc/amd64/crtn.S diff --git a/sys/SConscript b/sys/SConscript index 4d82a61..fb018de 100644 --- a/sys/SConscript +++ b/sys/SConscript @@ -11,7 +11,6 @@ src_amd64 = [ "amd64/multiboot.S", "amd64/mbentry.c", # AMD64 - "amd64/critical.c", "amd64/debug.c", "amd64/disasm.c", "amd64/ioapic.c", @@ -28,7 +27,6 @@ src_amd64 = [ "amd64/time.c", "amd64/trap.c", "amd64/trapentry.S", - "amd64/xmem.c", # Devices "dev/x86/debugcons.c", "dev/x86/ide.c", @@ -40,6 +38,7 @@ src_amd64 = [ src_common = [ "kern/copy.c", + "kern/critical.c", "kern/bufcache.c", "kern/cv.c", "kern/debug.c", @@ -65,6 +64,7 @@ src_common = [ "kern/vfs.c", "kern/vfsuio.c", "kern/waitchannel.c", + "kern/xmem.c", "dev/ahci.c", "dev/console.c", "dev/e1000.c", diff --git a/sys/amd64/critical.c b/sys/kern/critical.c similarity index 92% rename from sys/amd64/critical.c rename to sys/kern/critical.c index 95afd72..4164b2a 100644 --- a/sys/amd64/critical.c +++ b/sys/kern/critical.c @@ -27,7 +27,9 @@ Critical_Init() void Critical_Enter() { - disable_interrupts(); + if (lockLevel[CPU()] == 0) { + disable_interrupts(); + } lockLevel[CPU()]++; } diff --git a/sys/amd64/xmem.c b/sys/kern/xmem.c similarity index 100% rename from sys/amd64/xmem.c rename to sys/kern/xmem.c