SayoriOS  0.3.3
cpuid.h
1 //
2 // Created by ndraey on 03.10.23.
3 //
4 
5 #pragma once
6 
7 #define cpuid(in, a, b, c, d) \
8  __asm__ __volatile__("cpuid" \
9  : "=a" (a), \
10  "=b" (b), \
11  "=c" (c), \
12  "=d" (d) \
13  : "a" (in) \
14  )
15 
16 #define cpuid_count(in, count, a, b, c, d) \
17  __asm__ __volatile__("cpuid" \
18  : "=a" (a), \
19  "=b" (b), \
20  "=c" (c), \
21  "=d" (d) \
22  : "0" (in), \
23  "2" (count) \
24  )
25 
26 #define INTEL_MAGIC 0x756e6547
27 #define AMD_MAGIC 0x68747541
28 
29 
30 static const char* cpu_flag_edx_description[] = {
31  "fpu",
32  "vme",
33  "debugging",
34  "pse",
35  "rdtsc",
36  "msr",
37  "pae",
38  "mce",
39  "cx8",
40  "apic",
41  "'reserved 10'",
42  "'sysenter/sysexit'",
43  "mtrr",
44  "pge",
45  "mca",
46  "cmov",
47  "pat",
48  "pse-36",
49  "psn",
50  "clfsh",
51  "nx",
52  "ds",
53  "acpi",
54  "mmx",
55  "fxsr",
56  "sse",
57  "sse2",
58  "ss",
59  "htt",
60  "tm",
61  "ia64",
62  "pbe"
63 };
64 
65 struct cpu_info {
66  size_t manufacturer_id;
67  size_t model_id;
68  size_t family_id;
69  size_t extended_family_id;
70  size_t type_id;
71  size_t brand_id;
72  size_t stepping_id;
73 
74  const char* brand_string;
75  const char* model_string;
76  const char* type_string;
77 
78  size_t l1_i_size;
79  size_t l1_d_size;
80  size_t l2_size;
81  size_t l3_size;
82 
83  uint32_t feature_flags_ecx;
84  uint32_t feature_flags_edx;
85 };
86 
87 size_t cpu_get_id();
88 struct cpu_info cpu_get_basic_info();
89 bool is_long_mode_supported();
Definition: cpuid.h:65