2025-05-28 14:41:02 -05:00
|
|
|
#include <stdint.h>
|
|
|
|
|
#include <string.h>
|
2025-10-20 21:57:30 -05:00
|
|
|
#include <cpuid.h>
|
|
|
|
|
#include <stdlib.h>
|
2025-05-28 14:41:02 -05:00
|
|
|
|
|
|
|
|
#include <kernel/boot.h>
|
2025-06-13 18:03:39 -05:00
|
|
|
|
|
|
|
|
|
2025-10-20 21:57:30 -05:00
|
|
|
extern uint8_t __bss_start;
|
|
|
|
|
extern uint8_t __bss_end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void clear_bss(void)
|
|
|
|
|
{
|
|
|
|
|
/*memset(&__bss_start, 0, &__bss_end - &__bss_start);*/
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < ((&__bss_end) - (&__bss_start)); i++)
|
|
|
|
|
{
|
|
|
|
|
(&(__bss_start))[i] = 0x0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char* get_cpu_vendor_string(void)
|
2025-05-28 14:41:02 -05:00
|
|
|
{
|
2025-10-20 21:57:30 -05:00
|
|
|
unsigned int eax, ebx, ecx, edx;
|
|
|
|
|
char vendor[13];
|
|
|
|
|
|
|
|
|
|
if (!__get_cpuid(0, &eax, &ebx, &ecx, &edx))
|
2025-05-28 14:41:02 -05:00
|
|
|
{
|
2025-10-20 21:57:30 -05:00
|
|
|
return strdup("Unknown");
|
2025-05-28 14:41:02 -05:00
|
|
|
}
|
2025-10-20 21:57:30 -05:00
|
|
|
|
|
|
|
|
memcpy(&vendor[0], &ebx, 4);
|
|
|
|
|
memcpy(&vendor[4], &edx, 4);
|
|
|
|
|
memcpy(&vendor[8], &ecx, 4);
|
|
|
|
|
vendor[12] = '\0';
|
|
|
|
|
|
|
|
|
|
return strdup(vendor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char* get_cpu_brand_string(void)
|
|
|
|
|
{
|
|
|
|
|
unsigned int eax = 0, ebx = 0, ecx = 0, edx = 0;
|
2025-05-28 14:41:02 -05:00
|
|
|
|
2025-10-20 21:57:30 -05:00
|
|
|
int k = __get_cpuid_max(0x80000000, NULL);
|
|
|
|
|
|
|
|
|
|
if (k >= (int) 0x80000005)
|
|
|
|
|
{
|
|
|
|
|
return strdup("Unknown");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char brand[49];
|
|
|
|
|
unsigned int* brand_ptr = (unsigned int*) brand;
|
|
|
|
|
|
|
|
|
|
for (unsigned int i = 0; i < 3; ++i)
|
|
|
|
|
{
|
|
|
|
|
__get_cpuid(0x80000002 + i, &eax, &ebx, &ecx, &edx);
|
|
|
|
|
brand_ptr[i * 4 + 0] = eax;
|
|
|
|
|
brand_ptr[i * 4 + 1] = ebx;
|
|
|
|
|
brand_ptr[i * 4 + 2] = ecx;
|
|
|
|
|
brand_ptr[i * 4 + 3] = edx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
brand[48] = '\0';
|
|
|
|
|
return strdup(brand);
|
2025-05-28 14:41:02 -05:00
|
|
|
}
|