From c7aa4d882ff6b1eb1e3c19bdfd772057817ff10c Mon Sep 17 00:00:00 2001 From: ian Date: Sat, 8 Jul 2023 00:02:21 +0000 Subject: kernel/amd64: Abstract architecture specifics git-svn-id: https://svn.vegaa.systems/svn/vega-Vega/trunk@9 a8a8aea2-181d-ee11-89e8-15fd0e089fc4 --- sys/arch/amd64/machdep.c | 2 +- sys/include/sys/machdep.h | 28 +++++++++++++++++++++++++++- sys/kern/init_main.c | 3 +-- 3 files changed, 29 insertions(+), 4 deletions(-) (limited to 'sys') diff --git a/sys/arch/amd64/machdep.c b/sys/arch/amd64/machdep.c index dd2cdc7..747d23a 100644 --- a/sys/arch/amd64/machdep.c +++ b/sys/arch/amd64/machdep.c @@ -63,6 +63,6 @@ processor_halt(void) __weak void processor_init(struct processor *processor) { - gdt_load(processor->gdtr); + gdt_load(processor->machdep.gdtr); interrupts_init(processor); } diff --git a/sys/include/sys/machdep.h b/sys/include/sys/machdep.h index 5f2112c..f98b123 100644 --- a/sys/include/sys/machdep.h +++ b/sys/include/sys/machdep.h @@ -39,9 +39,35 @@ #if defined(_KERNEL) -struct processor { +/* + * 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); diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index 2ae2a09..f4db156 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -40,8 +40,7 @@ __KERNEL_META("$Vega$: init_main.c, Ian Marco Moffett, " "Where the Vega kernel first starts up"); static struct processor bsp = { - .gdtr = &g_early_gdtr, - .gdt = &g_dmmy_gdt[0] + .machdep = DEFAULT_PROCESSOR_MACHDEP }; void -- cgit v1.2.3