5 void cpu_get_model(char* model_out) {
6 uint32_t* out = (uint32_t*)model_out;
7 reg32 eax = 0, ebx = 0, edx = 0, ecx = 0;
9 __get_cpuid(0, &eax, &ebx, &ecx, &edx);
17 #define BRAND_LEAF 0x80000000UL
19 int cpu_brand_string_supported() {
20 reg32 supported = __get_cpuid_max(BRAND_LEAF, 0);
21 return (supported >= 0x80000004UL);
24 void cpu_get_brand(char* brand_out) {
25 if(!cpu_brand_string_supported()) {
29 uint32_t* out = (uint32_t*) brand_out;
30 reg32 eax = 0, ebx = 0, edx = 0, ecx = 0;
31 for (uint32_t i = 2, j = 0; i < 5; i++)
33 __get_cpuid(BRAND_LEAF + i, &eax, &ebx, &ecx, &edx);
46 // reference: Intel manual, section 10.4.2
47 reg32 eax = 0, ebx = 0, edx = 0, ecx = 0;
48 __get_cpuid(1, &eax, &ebx, &ecx, &edx);
54 cpu_rdmsr(uint32_t msr_idx, uint32_t* reg_high, uint32_t* reg_low)
56 uint32_t h = 0, l = 0;
57 asm volatile("rdmsr" : "=d"(h), "=a"(l) : "c"(msr_idx));
64 cpu_wrmsr(uint32_t msr_idx, uint32_t reg_high, uint32_t reg_low)
66 asm volatile("wrmsr" : : "d"(reg_high), "a"(reg_low), "c"(msr_idx));