Guest User

Untitled

a guest
Feb 21st, 2023
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.44 KB | Source Code | 0 0
  1. struct CPUIDinfo
  2. {
  3.     uint32_t EAX;
  4.     uint32_t EBX;
  5.     uint32_t ECX;
  6.     uint32_t EDX;
  7. };
  8. typedef struct CPUIDinfo CPUIDinfo;
  9.  
  10. void CpuId(unsigned int func, unsigned int subfunc, CPUIDinfo* info)
  11. {
  12.     __asm__ __volatile__ ( "cpuid" : "=a"(info->EAX), "=b"(info->EBX), "=c"(info->ECX), "=d"(info->EDX) : "a"(func), "c"(subfunc) : );
  13. }
  14.  
  15. uint8_t curr_cpu_apic_id()
  16. {
  17.     CPUIDinfo info;
  18.     CpuId(1, 0, &info);
  19.     return (uint8_t)(info.EBX >> 24);
  20. }
Add Comment
Please, Sign In to add comment