MentOS  0.8.0
The Mentoring Operating System
cpuid.h
Go to the documentation of this file.
1 
10 #pragma once
11 
12 #include "stdint.h"
13 #include "kernel.h"
14 
16 #define ECX_FLAGS_SIZE 24
17 
19 #define EDX_FLAGS_SIZE 32
20 
22 typedef struct cpuinfo_t {
24  char cpu_vendor[13];
26  char *cpu_type;
41  char *brand_string;
43 
46 
49 void get_cpuid(cpuinfo_t *cpuinfo);
50 
53 void call_cpuid(pt_regs *registers);
54 
58 void cpuid_write_vendor(cpuinfo_t *cpuinfo, pt_regs *registers);
59 
60 // TODO: doxygen documentation.
69 void cpuid_write_proctype(cpuinfo_t *cpuinfo, pt_regs *registers);
70 
71 // TODO: doxygen documentation.
75 void cpuid_feature_ecx(cpuinfo_t *cpuinfo, uint32_t ecx);
76 
77 // TODO: doxygen documentation.
81 void cpuid_feature_edx(cpuinfo_t *cpuinfo, uint32_t edx);
82 
83 // TODO: doxygen documentation.
89 uint32_t cpuid_get_byte(uint32_t reg, uint32_t position, uint32_t value);
90 
94 char *cpuid_brand_index(pt_regs *f);
95 
99 char *cpuid_brand_string(pt_regs *f);
struct cpuinfo_t cpuinfo_t
Contains the information concerning the CPU.
#define EDX_FLAGS_SIZE
Dimension of the edx flags.
Definition: cpuid.h:19
void cpuid_write_proctype(cpuinfo_t *cpuinfo, pt_regs *registers)
Definition: cpuid.c:48
void cpuid_feature_ecx(cpuinfo_t *cpuinfo, uint32_t ecx)
EAX=1, ECX contains a list of supported features.
Definition: cpuid.c:96
char * cpuid_brand_index(pt_regs *f)
Index of brand strings. TODO: Document.
Definition: cpuid.c:125
void get_cpuid(cpuinfo_t *cpuinfo)
Main CPUID procedure.
Definition: cpuid.c:9
void call_cpuid(pt_regs *registers)
Actual CPUID call.
Definition: cpuid.c:21
#define ECX_FLAGS_SIZE
Dimension of the exc flags.
Definition: cpuid.h:16
cpuinfo_t sinfo
This will be populated with the information concerning the CPU.
Definition: cpuid.h:45
void cpuid_write_vendor(cpuinfo_t *cpuinfo, pt_regs *registers)
Extract vendor string.
Definition: cpuid.c:29
char * cpuid_brand_string(pt_regs *f)
Brand string is contained in EAX, EBX, ECX and EDX.
Definition: cpuid.c:158
uint32_t cpuid_get_byte(uint32_t reg, uint32_t position, uint32_t value)
Extract single byte from a register.
Definition: cpuid.c:120
void cpuid_feature_edx(cpuinfo_t *cpuinfo, uint32_t edx)
EAX=1, EDX contains a list of supported features.
Definition: cpuid.c:108
Kernel generic data structure and functions.
Standard integer data-types.
unsigned int uint32_t
Define the unsigned 32-bit integer.
Definition: stdint.h:18
Contains the information concerning the CPU.
Definition: cpuid.h:22
uint32_t cpuid_edx_flags[EDX_FLAGS_SIZE]
Edx flags.
Definition: cpuid.h:37
char * brand_string
TODO: Comment.
Definition: cpuid.h:41
uint32_t apic_id
Definition: cpuid.h:33
uint32_t cpuid_ecx_flags[ECX_FLAGS_SIZE]
Ecx flags.
Definition: cpuid.h:35
uint32_t cpu_family
The family of the CPU.
Definition: cpuid.h:28
uint32_t cpu_model
The model of the CPU.
Definition: cpuid.h:30
int is_brand_string
TODO: Comment.
Definition: cpuid.h:39
char * cpu_type
The type of the CPU.
Definition: cpuid.h:26
char cpu_vendor[13]
The name of the vendor.
Definition: cpuid.h:24
Interrupt stack frame.
Definition: kernel.h:24