diff options
author | ian <ian> | 2023-07-28 08:43:09 +0000 |
---|---|---|
committer | ian <ian> | 2023-07-28 08:43:09 +0000 |
commit | 01ed65f720a32e35d12c7f4d68297e3599157846 (patch) | |
tree | 94620eb25bdde9994834c2085a8c3b8f344f5bfd | |
parent | 1809fe87ad70cf537d110845dd57fdf20a6614fd (diff) |
kernel: Cleanup arch abstraction layer
git-svn-id: https://svn.vegaa.systems/svn/vega-Vega/trunk@29 a8a8aea2-181d-ee11-89e8-15fd0e089fc4
-rw-r--r-- | sys/arch/amd64/gdt.c | 6 | ||||
-rw-r--r-- | sys/arch/amd64/machdep.c | 12 | ||||
-rw-r--r-- | sys/include/arch/amd64/gdt.h | 4 | ||||
-rw-r--r-- | sys/include/sys/machdep.h | 39 | ||||
-rw-r--r-- | sys/kern/init_main.c | 6 |
5 files changed, 14 insertions, 53 deletions
diff --git a/sys/arch/amd64/gdt.c b/sys/arch/amd64/gdt.c index 446306a..cb32837 100644 --- a/sys/arch/amd64/gdt.c +++ b/sys/arch/amd64/gdt.c @@ -31,7 +31,7 @@ #include <machine/gdt.h> -struct gdt_entry g_dmmy_gdt[256] = { +struct gdt_entry g_gdt[256] = { /* Null */ {0}, @@ -76,7 +76,7 @@ struct gdt_entry g_dmmy_gdt[256] = { }, }; -struct gdtr g_early_gdtr = { +struct gdtr g_gdtr = { .limit = sizeof(struct gdt_entry) * 256 - 1, - .offset = (uintptr_t)&g_dmmy_gdt[0] + .offset = (uintptr_t)&g_gdt[0] }; diff --git a/sys/arch/amd64/machdep.c b/sys/arch/amd64/machdep.c index 747d23a..8203a07 100644 --- a/sys/arch/amd64/machdep.c +++ b/sys/arch/amd64/machdep.c @@ -33,13 +33,13 @@ #include <sys/cdefs.h> #include <machine/trap.h> #include <machine/idt.h> +#include <machine/gdt.h> #define ISR(func) ((uintptr_t)func) -__weak void -interrupts_init(struct processor *processor) +static void +interrupts_init(void) { - __USE(processor); idt_set_desc(0x0, IDT_TRAP_GATE_FLAGS, ISR(arith_err), 0); idt_set_desc(0x2, IDT_TRAP_GATE_FLAGS, ISR(nmi), 0); idt_set_desc(0x3, IDT_TRAP_GATE_FLAGS, ISR(breakpoint_handler), 0); @@ -61,8 +61,8 @@ processor_halt(void) } __weak void -processor_init(struct processor *processor) +processor_init(void) { - gdt_load(processor->machdep.gdtr); - interrupts_init(processor); + gdt_load(&g_gdtr); + interrupts_init(); } diff --git a/sys/include/arch/amd64/gdt.h b/sys/include/arch/amd64/gdt.h index 756e2a6..2b7f308 100644 --- a/sys/include/arch/amd64/gdt.h +++ b/sys/include/arch/amd64/gdt.h @@ -74,7 +74,7 @@ gdt_load(struct gdtr *gdtr) ); } -extern struct gdt_entry g_dmmy_gdt[256]; -extern struct gdtr g_early_gdtr; +extern struct gdt_entry g_gdt[256]; +extern struct gdtr g_gdtr; #endif /* !AMD64_GDT_H_ */ diff --git a/sys/include/sys/machdep.h b/sys/include/sys/machdep.h index f98b123..b9a6221 100644 --- a/sys/include/sys/machdep.h +++ b/sys/include/sys/machdep.h @@ -33,46 +33,11 @@ #define _SYS_MACHDEP_H_ #include <sys/types.h> -#if defined(_KERNEL) -#include <machine/gdt.h> -#endif /* defined(_KERNEL) */ +#include <sys/cdefs.h> #if defined(_KERNEL) -/* - * Arch specifics go here - * along with an #if defined(...) - * - * XXX: When porting more architectures this - * may get messy. Figure out a way to - * seperate this into a different header. - */ -struct processor_machdep { -#if defined(__x86_64__) - struct gdtr *gdtr; - struct gdt_entry *gdt; -#endif /* defined(__x86_64__) */ -}; - -/* - * Sets arch specifics to their - * defaults. - */ -#if defined(__x86_64__) -#define DEFAULT_PROCESSOR_MACHDEP \ - { \ - .gdtr = &g_early_gdtr, \ - .gdt = &g_dmmy_gdt[0] \ - } -#endif /* defined(__x86_64__) */ - -struct processor { - struct processor_machdep machdep; -}; - -__weak void processor_init(struct processor *processor); -__weak void interrupts_init(struct processor *processor); - +void processor_init(void); void processor_halt(void); #endif /* defined(_KERNEL) */ diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index e77b2ce..0e8d4b5 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -40,10 +40,6 @@ __KERNEL_META("$Vega$: init_main.c, Ian Marco Moffett, " "Where the Vega kernel first starts up"); -static struct processor bsp = { - .machdep = DEFAULT_PROCESSOR_MACHDEP -}; - void main(void) { @@ -55,7 +51,7 @@ main(void) VEGA_ARCH, VEGA_VERSION, VEGA_BUILDDATE, VEGA_BUILDBRANCH); - processor_init(&bsp); + processor_init(); vm_physseg_init(); acpi_init(); |