From 3bdd71c82e64428a03650bf3d00150020e217c53 Mon Sep 17 00:00:00 2001 From: Lunaixsky Date: Sun, 6 Oct 2024 18:23:02 +0100 Subject: [PATCH] clean-up left-over arch-depend code from kernel base * ref: restructure the trace related arch-dependent stuff to make it less redundant * ref: rename the boot_end/boot_start section markers so it will not conflict with out in name (in particular the boot_end() function) * ref: remove the reference to port-io thing from ahci driver base * ref: only compile the pmio vairant of uart when the correspond, arch-related feature is turned on. * ref: temporary disable the vga module, as it is incompleted and buggy * fix: add back a missing #include to asm/cpu.h --- .../arch/generic/includes/sys-generic/trace_arch.h | 7 +++++++ lunaix-os/hal/ahci/ahci.c | 4 +--- lunaix-os/hal/char/uart/LBuild | 11 ++++++++--- lunaix-os/hal/char/uart/LConfig | 5 ++++- lunaix-os/hal/gfxa/LBuild | 2 +- lunaix-os/includes/lunaix/hart_state.h | 2 +- lunaix-os/includes/lunaix/sections.h | 4 ++-- lunaix-os/includes/lunaix/syscall.h | 4 ++-- lunaix-os/kernel/debug/trace.c | 1 - lunaix-os/kernel/spike.c | 2 ++ 10 files changed, 28 insertions(+), 14 deletions(-) diff --git a/lunaix-os/arch/generic/includes/sys-generic/trace_arch.h b/lunaix-os/arch/generic/includes/sys-generic/trace_arch.h index 83953d1..4ff75b2 100644 --- a/lunaix-os/arch/generic/includes/sys-generic/trace_arch.h +++ b/lunaix-os/arch/generic/includes/sys-generic/trace_arch.h @@ -3,6 +3,13 @@ #include +static inline bool +arch_valid_fp(ptr_t ptr) { + extern int __bsskstack_end[]; + extern int __bsskstack_start[]; + return ((ptr_t)__bsskstack_start <= ptr && ptr <= (ptr_t)__bsskstack_end); +} + void trace_print_transistion_short(struct hart_state* hstate); diff --git a/lunaix-os/hal/ahci/ahci.c b/lunaix-os/hal/ahci/ahci.c index f40ae24..2de7e98 100644 --- a/lunaix-os/hal/ahci/ahci.c +++ b/lunaix-os/hal/ahci/ahci.c @@ -14,8 +14,6 @@ #include #include -#include - #include #include #include @@ -71,7 +69,7 @@ __hba_reset_port(hba_reg_t* port_reg) } // 如果port未响应,则继续执行重置 port_reg[HBA_RPxSCTL] = (port_reg[HBA_RPxSCTL] & ~0xf) | 1; - port_delay(100000); // 等待至少一毫秒,差不多就行了 + port_reg[HBA_RPxSCTL] &= ~0xf; } diff --git a/lunaix-os/hal/char/uart/LBuild b/lunaix-os/hal/char/uart/LBuild index 83088c6..ebbb849 100644 --- a/lunaix-os/hal/char/uart/LBuild +++ b/lunaix-os/hal/char/uart/LBuild @@ -1,11 +1,16 @@ sources([ "16x50_base.c", - "16x50_pmio.c", "16x50_mmio.c", ]) if config("xt_16x50"): - sources("16x50_isa.c") + sources([ + "16x50_pmio.c", + "16x50_isa.c" + ]) if config("pci_16x50"): - sources("16x50_pci.c") \ No newline at end of file + sources([ + "16x50_pmio.c", + "16x50_pci.c" + ]) \ No newline at end of file diff --git a/lunaix-os/hal/char/uart/LConfig b/lunaix-os/hal/char/uart/LConfig index 9ed1f09..4b59141 100644 --- a/lunaix-os/hal/char/uart/LConfig +++ b/lunaix-os/hal/char/uart/LConfig @@ -13,7 +13,10 @@ def uart_16x50(): type(bool) is_x86 = v(arch) in ["i386", "x86_64"] - default(is_x86) + if not is_x86: + set_value(False) + else: + default(is_x86) return is_x86 diff --git a/lunaix-os/hal/gfxa/LBuild b/lunaix-os/hal/gfxa/LBuild index 54d50d1..d43f935 100644 --- a/lunaix-os/hal/gfxa/LBuild +++ b/lunaix-os/hal/gfxa/LBuild @@ -1,4 +1,4 @@ -use("vga") +# use("vga") sources([ "gfxm.c" diff --git a/lunaix-os/includes/lunaix/hart_state.h b/lunaix-os/includes/lunaix/hart_state.h index 5ec53bf..e9d0f1c 100644 --- a/lunaix-os/includes/lunaix/hart_state.h +++ b/lunaix-os/includes/lunaix/hart_state.h @@ -14,7 +14,7 @@ struct hart_transition struct { struct hart_state state; struct exec_param eret; - } compact transfer; + } transfer; }; bool diff --git a/lunaix-os/includes/lunaix/sections.h b/lunaix-os/includes/lunaix/sections.h index daa5ccc..1fe6604 100644 --- a/lunaix-os/includes/lunaix/sections.h +++ b/lunaix-os/includes/lunaix/sections.h @@ -27,8 +27,8 @@ #define reclaimable_start __section_mark(bssreclaim, start) #define reclaimable_end __section_mark(bssreclaim, end) -#define boot_start __section_mark(kboot, start) -#define boot_end __section_mark(kboot, end) +#define bootsec_start __section_mark(kboot, start) +#define bootsec_end __section_mark(kboot, end) #define kernel_start __section_mark(kexec, start) #define kernel_load_end __section_mark(kexec, end) diff --git a/lunaix-os/includes/lunaix/syscall.h b/lunaix-os/includes/lunaix/syscall.h index 1b9778f..3884f2a 100644 --- a/lunaix-os/includes/lunaix/syscall.h +++ b/lunaix-os/includes/lunaix/syscall.h @@ -5,9 +5,9 @@ #ifndef __ASM__ -#define SYSCALL_ESTATUS(errno) -((errno) != 0) +#include -#define asmlinkage __attribute__((regparm(0))) +#define SYSCALL_ESTATUS(errno) -((errno) != 0) #define __PARAM_MAP1(t1, p1) t1 p1 #define __PARAM_MAP2(t1, p1, ...) t1 p1, __PARAM_MAP1(__VA_ARGS__) diff --git a/lunaix-os/kernel/debug/trace.c b/lunaix-os/kernel/debug/trace.c index 77b3320..f5c4675 100644 --- a/lunaix-os/kernel/debug/trace.c +++ b/lunaix-os/kernel/debug/trace.c @@ -7,7 +7,6 @@ #include #include -#include #include diff --git a/lunaix-os/kernel/spike.c b/lunaix-os/kernel/spike.c index e1983df..ba8f804 100644 --- a/lunaix-os/kernel/spike.c +++ b/lunaix-os/kernel/spike.c @@ -5,6 +5,8 @@ #include #include +#include + LOG_MODULE("spike") void noret -- 2.27.0