-
Notifications
You must be signed in to change notification settings - Fork 129
/
cpuid.h
57 lines (42 loc) · 1.71 KB
/
cpuid.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
///////////////////////////////////////////////////////////////////////////////
// cpuid.h - 2023
//
/// This module contains multi-platform, non-privlidged code that utilizes the
/// CPUID instruction to discover & report SGX capabilities.
///
/// @file cpuid.h
/// @author Lars Luhr <[email protected]>
/// @author Mark Nelson <[email protected]>
///////////////////////////////////////////////////////////////////////////////
#pragma once
#include <inttypes.h> // For PRIx64 uint64_t PRIx32 uint32_t
/// Call `CPUID`, passing `eax`, `ebx`, `ecx` and `eax` in & out
void native_cpuid32( uint32_t* eax
,uint32_t* ebx
,uint32_t* ecx
,uint32_t* edx );
// Print the register set:
// eax: 80000008 ebx: 00000000 ecx: 00000000 edx: 00000000
void print_registers32( uint32_t eax
,uint32_t ebx
,uint32_t ecx
,uint32_t edx );
/// Does this CPU support the CPUID instruction?
///
/// gcc supports intrisics to detect certain CPU features:
/// https://gcc.gnu.org/onlinedocs/gcc-13.2.0/gcc/x86-Built-in-Functions.html
/// ... however, as of GCC 13.2, the detection does not support SGX, so
/// we'll do it old school.
///
extern void doesCPUIDwork( void );
// If this is a genuine Intel CPU, then print that fact.
// If not, tell the user what it is and exit.
//
// If it is a genuine Intel CPU, make sure it's capapble of examining SGX
// features.
void isIntelCPU( void );
// Print the CPU Brand String. This will look like this:
// CPU: Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
void printCPUBrandString( void );
void supportsSGXInstructions( void );
void enumerateEPCsections( void );