MicrOS
cpuid.c File Reference
#include "cpuid.h"
#include "drivers/vga/vga.h"

Classes

union  magic_union
 

Functions

uint8_t cpuid_init ()
 Initialization of CPUID. More...
 
uint32_t cpuid_get_highest_function_parameter ()
 Get highest function parameter. More...
 
char * cpuid_get_vendor_string (char *buffer)
 Get vendor string. More...
 
uint8_t cpuid_get_stepping_id ()
 Get stepping id. More...
 
uint8_t cpuid_get_model_id ()
 Get model id. More...
 
uint8_t cpuid_get_family_id ()
 Get family id. More...
 
uint8_t cpuid_get_processor_type ()
 Get processor type. More...
 
uint8_t cpuid_is_hyperthreading_available ()
 Check if Hyper-Threading is available. More...
 
uint8_t cpuid_number_of_logical_processors ()
 Get number of logical processors. More...
 
uint8_t cpuid_number_of_physical_processors_cores ()
 Get number of physical processors cores. More...
 
uint8_t cpuid_get_valid_number_cache_entries ()
 Get number of valid cache entries. More...
 
uint32_t cpuid_get_cache_size_in_bytes (uint8_t cache_index)
 Get cache size in bytes. More...
 
cpuid_cache_struct cpuid_get_cache_data (uint8_t cache_index)
 Get cache data. More...
 
const cpuid_0x00hcpuid_get_0x00h_fields ()
 Get 0x00h fields. More...
 
const cpuid_0x01hcpuid_get_0x01h_fields ()
 Get 0x01h fields. More...
 
const cpuid_0x04hcpuid_get_0x04h_fields (uint8_t index)
 Get 0x04h fields. More...
 
void __cpuid_get_manufacturer_string ()
 Helper function to get manufacturer id. More...
 
char * __cpuid_get_processor_brand (char *buffer)
 Get prcessor brand. More...
 

Variables

cpuid_0x00h __cpuid_0x00h
 
unsigned char __cpuid_vendor_string [13]
 
cpuid_0x01h __cpuid_0x01h
 
cpuid_0x04h __cpuid_0x04h [10]
 
uint8_t __cpuid_0x04h_vaild_index = 0
 

Function Documentation

◆ __cpuid_get_manufacturer_string()

void __cpuid_get_manufacturer_string ( )

Helper function to get manufacturer id.

Put vendor string in __cpuid_vendor_string variable.

◆ __cpuid_get_processor_brand()

char* __cpuid_get_processor_brand ( char *  buffer)

Get prcessor brand.

Function copy procesor brand to buffer and terminate string with /0.

Parameters
bufferBuffer for vendor string with size at least 48.
Returns
Pointer to buffer where serial number is stored.

◆ cpuid_get_0x00h_fields()

const cpuid_0x00h* cpuid_get_0x00h_fields ( )

Get 0x00h fields.

Returns
CPUID 0x00h fields.

◆ cpuid_get_0x01h_fields()

const cpuid_0x01h* cpuid_get_0x01h_fields ( )

Get 0x01h fields.

Result will be valid only if cpuid_get_highest_function_parameter() returns value 1 or higher.

Returns
CPUID 0x01h fields.

◆ cpuid_get_0x04h_fields()

const cpuid_0x04h* cpuid_get_0x04h_fields ( uint8_t  index)

Get 0x04h fields.

Result will be valid only if cpuid_get_highest_function_parameter() returns value 4 or higher.

Parameters
indexIndex of struct to return.
Returns
CPUID 0x04h fields.

◆ cpuid_get_cache_data()

cpuid_cache_struct cpuid_get_cache_data ( uint8_t  cache_index)

Get cache data.

Result will be valid only if cpuid_get_highest_function_parameter() returns value 4 or higher.

Parameters
cache_indexIndex of cache to return. To get max number use cpuid_get_valid_number_cache_entries(). If invalid 0 will be returned.
Returns
Cache data.

◆ cpuid_get_cache_size_in_bytes()

uint32_t cpuid_get_cache_size_in_bytes ( uint8_t  cache_index)

Get cache size in bytes.

Result will be valid only if cpuid_get_highest_function_parameter() returns value 4 or higher.

Parameters
cache_indexIndex of cache to return. To get max number use cpuid_get_valid_number_cache_entries(). If invalid 0 will be returned.
Returns
Cache size in bytes.

◆ cpuid_get_family_id()

uint8_t cpuid_get_family_id ( )

Get family id.

Result will be valid only if cpuid_get_highest_function_parameter() returns value 1 or higher.

Returns
CPU family id.

◆ cpuid_get_highest_function_parameter()

uint32_t cpuid_get_highest_function_parameter ( )

Get highest function parameter.

Indicates how many function parameters CPUID supports. You should use it to determine how much data you can aquire from CPUID functions.

Returns
Highest parameter function.

◆ cpuid_get_model_id()

uint8_t cpuid_get_model_id ( )

Get model id.

Result will be valid only if cpuid_get_highest_function_parameter() returns value 1 or higher.

Returns
CPU model id.

◆ cpuid_get_processor_type()

uint8_t cpuid_get_processor_type ( )

Get processor type.

Result will be valid only if cpuid_get_highest_function_parameter() returns value 1 or higher.

Returns
CPU processor type.

◆ cpuid_get_stepping_id()

uint8_t cpuid_get_stepping_id ( )

Get stepping id.

Result will be valid only if cpuid_get_highest_function_parameter() returns value 1 or higher.

Returns
CPU stepping id.

◆ cpuid_get_valid_number_cache_entries()

uint8_t cpuid_get_valid_number_cache_entries ( )

Get number of valid cache entries.

Number that determines how much cache entries are stored. Used in function cpuid_get_cache_size_in_bytes(uint8_t cache_index), cpuid_get_cache_data(uint8_t cache_index).
Result will be valid only if cpuid_get_highest_function_parameter() returns value 4 or higher.

Returns
Number of valid cache entries.

◆ cpuid_get_vendor_string()

char* cpuid_get_vendor_string ( char *  buffer)

Get vendor string.

Function copy vendor string to buffer and terminate string with /0.

Parameters
bufferBuffer for vendor string with size at least 13.
Returns
Pointer to buffer where serial number is stored.

◆ cpuid_init()

uint8_t cpuid_init ( )

Initialization of CPUID.

Sets internal variables.

Returns
1 is success, 0 is failure.

◆ cpuid_is_hyperthreading_available()

uint8_t cpuid_is_hyperthreading_available ( )

Check if Hyper-Threading is available.

Result will be valid only if cpuid_get_highest_function_parameter() returns value 1 or higher.

Returns
1 if yes, 0 if no.

◆ cpuid_number_of_logical_processors()

uint8_t cpuid_number_of_logical_processors ( )

Get number of logical processors.

Addressable IDs for logical processors in the same Package. Valid if Hyper-Threading is enabled.
Result will be valid only if cpuid_get_highest_function_parameter() returns value 1 or higher.

Returns
Number of addressable logical processors.

◆ cpuid_number_of_physical_processors_cores()

uint8_t cpuid_number_of_physical_processors_cores ( )

Get number of physical processors cores.

Addressable IDs for physical processors cores in a physical package. Result will be valid only if cpuid_get_highest_function_parameter() returns value 4 or higher.

Returns
Number of addressable physical processors cores.

Variable Documentation

◆ __cpuid_0x00h

cpuid_0x00h __cpuid_0x00h

◆ __cpuid_0x01h

cpuid_0x01h __cpuid_0x01h

◆ __cpuid_0x04h

cpuid_0x04h __cpuid_0x04h[10]

◆ __cpuid_0x04h_vaild_index

uint8_t __cpuid_0x04h_vaild_index = 0

◆ __cpuid_vendor_string

unsigned char __cpuid_vendor_string[13]