summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mos/sys/arch/x86_64/cpu/cpu.c22
-rw-r--r--mos/sys/inc/mu/cpu.h17
-rw-r--r--mos/sys/kern/kern_init.c6
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);
}