[MODERN FEATURES] CPUID and MSR
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
.intel_syntax noprefix
|
||||
#include <mem.h>
|
||||
#include <cpuid.h>
|
||||
|
||||
.section .data
|
||||
// Some room to store the bootloader return values
|
||||
@@ -84,6 +85,26 @@ long_mode_start:
|
||||
mov rax, 0x0
|
||||
mov [V2P(BootP4)], rax
|
||||
|
||||
// CPUID
|
||||
#define CPUID(function) mov rax, (function); cpuid;
|
||||
#define STORE(reg, variable) movabs r8, offset (variable); mov dword ptr [r8], (reg);
|
||||
// Store max CPUID function numbers
|
||||
CPUID(CPUID_FUNCTION_VENDOR)
|
||||
STORE(eax, cpuid_max)
|
||||
CPUID(CPUID_FUNCTIONX_VENDOR)
|
||||
STORE(eax, cpuid_maxx)
|
||||
// Store CPUID features
|
||||
CPUID(CPUID_FUNCTION_FEATURES)
|
||||
STORE(eax, cpuid_signature)
|
||||
STORE(ebx, cpuid_features_b)
|
||||
STORE(ecx, cpuid_features_c)
|
||||
STORE(edx, cpuid_features_d)
|
||||
// ...and extended features
|
||||
CPUID(CPUID_FUNCTIONX_FEATURES)
|
||||
STORE(ebx, cpuid_featuresx_b)
|
||||
STORE(ecx, cpuid_featuresx_c)
|
||||
STORE(edx, cpuid_featuresx_d)
|
||||
|
||||
// Get the saved bootloader data and pass to kmain
|
||||
movabs rax, MultiBootMagic
|
||||
mov rdi, rax
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <scheduler.h>
|
||||
#include <thread.h>
|
||||
#include <process.h>
|
||||
#include <cpuid.h>
|
||||
|
||||
void thread_function()
|
||||
{
|
||||
@@ -31,6 +32,11 @@ int kmain(uint64_t multiboot_magic, void *multiboot_data)
|
||||
scheduler_init();
|
||||
pic_init();
|
||||
|
||||
debug_info("CPUID - max function number: Normal:%x, Extended:%x\n", cpuid_max, cpuid_maxx);
|
||||
debug_info("CPUID - has MSR:%d\n", CPUID_FEATURE_MSR);
|
||||
debug_info("CPUID - has APIC:%d\n", CPUID_FEATURE_APIC);
|
||||
debug_info("CPUID - has SYSCALL:%d\n", CPUID_FEATURE_SYSCALL);
|
||||
|
||||
process_t *p1 = process_spawn(0);
|
||||
process_t *p2 = process_spawn(p1);
|
||||
|
||||
@@ -52,7 +58,6 @@ int kmain(uint64_t multiboot_magic, void *multiboot_data)
|
||||
scheduler_insert(t2);
|
||||
scheduler_insert(t3);
|
||||
|
||||
IRQ_UNMASK(IRQ_TIMER);
|
||||
asm("sti");
|
||||
debug_info("BOOT COMPLETE\n");
|
||||
schedule();
|
||||
|
||||
Reference in New Issue
Block a user