summaryrefslogtreecommitdiff
path: root/sys/arch/amd64/cpu
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-11-18 01:02:27 -0500
committerIan Moffett <ian@osmora.org>2025-11-18 01:12:21 -0500
commit6ed636b8efe4d50ab013cf337ad634513eddbb6d (patch)
tree11ac37b13d41c4f5ce98c774b610979bd7c523c1 /sys/arch/amd64/cpu
parent635f680d45a58a4248f6dc6c833552836c1abed0 (diff)
kern/amd64: Do low-level processor configuration
This commit seperates low-level processor configuration into the cpu_loinit() function. This is to be called for the BSP and per AP. Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/arch/amd64/cpu')
-rw-r--r--sys/arch/amd64/cpu/boot.S28
-rw-r--r--sys/arch/amd64/cpu/mp.c2
2 files changed, 30 insertions, 0 deletions
diff --git a/sys/arch/amd64/cpu/boot.S b/sys/arch/amd64/cpu/boot.S
index 0cda6a7..737092f 100644
--- a/sys/arch/amd64/cpu/boot.S
+++ b/sys/arch/amd64/cpu/boot.S
@@ -27,6 +27,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+#include <md/msr.h>
+
.text
.globl _start
.extern uart_init
@@ -44,6 +46,7 @@ _start:
lea GDTR(%rip), %rdi /* Our GDTR */
call gdt_load /* Load our GDT */
call idt_load /* Load our IDT */
+ call cpu_loinit /* Initialize processor state */
/*
* RV7 will default to APIC operation, as per a section
@@ -62,6 +65,31 @@ _start:
hlt
jmp 1b
+ .globl cpu_loinit
+cpu_loinit:
+ /*
+ * Initialize low-level CPU state
+ */
+ push %r12
+ push %r13
+ push %r14
+ push %r15
+ push %rbx
+ push %rbp
+
+ mov $IA32_EFER, %ecx /* IA32_EFER */
+ rdmsr /* -> EAX */
+ or $1<<11, %eax /* EFER.NXE */
+ wrmsr /* Write it back */
+
+ pop %rbp
+ pop %rbx
+ pop %r15
+ pop %r14
+ pop %r13
+ pop %r12
+ retq
+
.section .rodata
bootmsg:
.ascii "[ preparing since 2025 ]\n"
diff --git a/sys/arch/amd64/cpu/mp.c b/sys/arch/amd64/cpu/mp.c
index 09a4249..5ab7815 100644
--- a/sys/arch/amd64/cpu/mp.c
+++ b/sys/arch/amd64/cpu/mp.c
@@ -38,6 +38,7 @@
#include <lib/string.h>
#include <md/lapic.h>
#include <md/msr.h>
+#include <md/cpu.h>
#include <mu/cpu.h>
#include <vm/vm.h>
#include <vm/phys.h>
@@ -261,6 +262,7 @@ cpu_lm_entry(void)
: "rax", "rbx"
);
+ cpu_loinit();
for (;;) {
__asmv("cli; hlt");
}