libmsr  0.3.0
A friendlier interface to accessing MSRs on Intel platforms
 All Classes Files Functions Variables Enumerations Enumerator Macros Pages
Functions
csr_core.c File Reference
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include "csr_core.h"
#include "memhdlr.h"
#include "cpuid.h"
#include "libmsr_debug.h"
#include "libmsr_error.h"
Include dependency graph for csr_core.c:

Functions

int init_csr (void)
 Open the module file descriptors exposed in the /dev filesystem.
 
int finalize_csr (void)
 Close the module file descriptors exposed in the /dev filesystem.
 
int csr_batch_storage (struct csr_batch_array **batchsel, const int batchnum, unsigned **opssize)
 Allocate space for uncore batch arrays.
 
int allocate_csr_batch (const int batchnum, size_t bsize)
 Allocate space for new uncore batch operation.
 
int free_csr_batch (const int batchnum)
 Deallocate memory for specific set of uncore batch operations.
 
int create_csr_batch_op (off_t csr, uint8_t bus, uint8_t device, uint8_t function, uint8_t socket, uint8_t isread, size_t opsize, uint64_t **dest, const int batchnum)
 Create new uncore batch operation.
 
int do_csr_batch_op (const int batchnum)
 Execute read/write batch operation on a specific set of batch uncore registers.
 

Function Documentation

int allocate_csr_batch ( const int  batchnum,
size_t  bsize 
)

Allocate space for new uncore batch operation.

Parameters
[in]batchnumcsr_data_type_e data type of batch operation.
[in]bsizeSize of batch operation.
Returns
0 if allocation was a success, else -1 if csr_batch_storage() fails.
int create_csr_batch_op ( off_t  csr,
uint8_t  bus,
uint8_t  device,
uint8_t  function,
uint8_t  socket,
uint8_t  isread,
size_t  opsize,
uint64_t **  dest,
const int  batchnum 
)

Create new uncore batch operation.

Parameters
[in]csrAddress of uncore register for which operation will take place.
[in]busBus where batch operation will take place.
[in]deviceDevice where batch operation will take place.
[in]functionFunction where batch operation will take place.
[in]socketSocket where batch operation will take place.
[in]isreadIndicates read or write to uncore register.
[in]opsizeSize of operation.
[in]destStores data resulting from read or necessary for write to uncore register.
[in]batchnumcsr_data_type_e data type of batch operation.
Returns
0 if creation was a success, else -1 if csr_batch_storage() fails or if the number of batch operations exceeds the allocated size.
int csr_batch_storage ( struct csr_batch_array **  batchsel,
const int  batchnum,
unsigned **  opssize 
)

Allocate space for uncore batch arrays.

Parameters
[out]batchselStorage for uncore batch operations.
[in]batchnumcsr_data_type_e data type of batch operation.
[out]opssizeSize of specific set of batch operations.
Returns
0 if successful, else NULL pointer as a result of libmsr_calloc() or libmsr_realloc().
int do_csr_batch_op ( const int  batchnum)

Execute read/write batch operation on a specific set of batch uncore registers.

Parameters
[in]batchnumcsr_data_type_e data type of batch operation.
Returns
0 if successful, else -1 if csr_batch_storage() fails or if batch allocation is for 0 or less operations.
Todo:
Debug stuff here.
int finalize_csr ( void  )

Close the module file descriptors exposed in the /dev filesystem.

Returns
0 if finalization was a success, else -1 if could not close file descriptors.
int free_csr_batch ( const int  batchnum)

Deallocate memory for specific set of uncore batch operations.

Parameters
[in]batchnumcsr_data_type_e data type of batch operation.
Returns
0 if successful, else -1 if csr_batch_storage() fails.
int init_csr ( void  )

Open the module file descriptors exposed in the /dev filesystem.

Returns
0 if initialization was a success, else -1 if could not stat file descriptors or open any csr module.