diff options
| author | Ian Moffett <ian@osmora.org> | 2025-12-23 01:44:33 -0500 |
|---|---|---|
| committer | Ian Moffett <ian@osmora.org> | 2025-12-23 01:44:33 -0500 |
| commit | 579b338ce43a0f084d22b082c82e341f81ed7e2f (patch) | |
| tree | a814336058ade1c879678bf43b50b00124af4f28 | |
| parent | 172a14db53beb6554e8a8019d08986d466cb68c8 (diff) | |
mos/x86_64+mu: Add processor control region
Signed-off-by: Ian Moffett <ian@osmora.org>
| -rw-r--r-- | mos/sys/arch/x86_64/cpu/cpu.c | 22 | ||||
| -rw-r--r-- | mos/sys/inc/mu/cpu.h | 17 | ||||
| -rw-r--r-- | mos/sys/kern/kern_init.c | 6 |
3 files changed, 45 insertions, 0 deletions
diff --git a/mos/sys/arch/x86_64/cpu/cpu.c b/mos/sys/arch/x86_64/cpu/cpu.c new file mode 100644 index 0000000..e5f7479 --- /dev/null +++ b/mos/sys/arch/x86_64/cpu/cpu.c @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2025, Ian Moffett. + * Provided under the BSD-3 clause. + */ + +#include <sdk/types.h> +#include <kern/trace.h> +#include <md/msr.h> +#include <mu/cpu.h> + +#define dtrace(fmt, ...) trace("cpu: " fmt, ##__VA_ARGS__) + +void +mu_cpu_conf(PCR *pcr) +{ + if (pcr == NULL) { + return; + } + + md_wrmsr(IA32_GS_BASE, (UPTR)pcr); + dtrace("pcr engaged\n"); +} diff --git a/mos/sys/inc/mu/cpu.h b/mos/sys/inc/mu/cpu.h index 9856df8..2fb4e6e 100644 --- a/mos/sys/inc/mu/cpu.h +++ b/mos/sys/inc/mu/cpu.h @@ -9,6 +9,16 @@ #include <sdk/types.h> /* + * The processor control region represents the currently + * running processor + * + * @logical_id: Assigned by us + */ +typedef struct { + UBYTE logical_id; +} PCR; + +/* * Get the current IRQ state * * (TRUE: IRQs unmasked, FALSE: IRQs masked) @@ -34,6 +44,13 @@ void mu_irq_setmask(BOOL mask); USIZE mu_cpu_aswap(USIZE *p, USIZE val); /* + * Configure the current processor + * + * @pcr: Processor control region + */ +void mu_cpu_conf(PCR *pcr); + +/* * Halt the current processor core */ void mu_cpu_halt(void); diff --git a/mos/sys/kern/kern_init.c b/mos/sys/kern/kern_init.c index 2502dc2..c8f9283 100644 --- a/mos/sys/kern/kern_init.c +++ b/mos/sys/kern/kern_init.c @@ -6,6 +6,7 @@ #include <kern/trace.h> #include <kern/bpt.h> #include <mu/uart.h> +#include <mu/cpu.h> #include <mm/pmm.h> #define write_boot_header() \ @@ -19,6 +20,8 @@ /* Forward declaration */ void kern_main(void); +static PCR bsp_pcr; + void kern_main(void) { @@ -33,4 +36,7 @@ kern_main(void) /* Initialize the physical memory manager */ pmm_init(); + + /* Initialize the BSP PCR */ + mu_cpu_conf(&bsp_pcr); } |
