OpenBIC
OpenSource Bridge-IC
libutil.h File Reference
#include <stdint.h>
#include "ipmb.h"
#include "hal_i2c.h"
Include dependency graph for libutil.h:

Go to the source code of this file.

Macros

#define SAFE_FREE(p)
 
#define SETBIT(x, y)   (x | (1ULL << y))
 
#define SETBITS(x, y, z)   (x | (y << z))
 
#define GETBIT(x, y)   ((x & (1ULL << y)) > y)
 
#define CLEARBIT(x, y)   (x & (~(1ULL << y)))
 
#define CLEARBITS(x, y, z)
 
#define SHELL_CHECK_NULL_ARG(arg_ptr)
 
#define SHELL_CHECK_NULL_ARG_WITH_RETURN(arg_ptr, ret_val)
 
#define CHECK_NULL_ARG(arg_ptr)
 
#define CHECK_NULL_ARG_WITH_RETURN(arg_ptr, ret_val)
 
#define CHECK_ARG_WITH_RETURN(cmp, ret_val)
 
#define CHECK_MSGQ_INIT(msgq)   CHECK_NULL_ARG((msgq)->buffer_start);
 
#define CHECK_MSGQ_INIT_WITH_RETURN(msgq, ret_val)    CHECK_NULL_ARG_WITH_RETURN((msgq)->buffer_start, ret_val);
 
#define CHECK_MUTEX_INIT(mutex)   CHECK_NULL_ARG((mutex)->wait_q.waitq.head);
 
#define CHECK_MUTEX_INIT_WITH_RETURN(mutex, ret_val)    CHECK_NULL_ARG_WITH_RETURN((mutex)->wait_q.waitq.head, ret_val);
 
#define SET_FLAG_WITH_RETURN(flag, set_val, ret_val)
 

Typedefs

typedef uint_least16_t char16_t
 

Enumerations

enum  BIT_SETTING_READING { BIT_CLEAR = 0 , BIT_SET = 1 , BIT_GET = 2 }
 
enum  BIT_SETTING_READING_N { BIT_SET_N = 0 , BIT_CLEAR_N = 1 }
 
enum  BYTE_ENDIAN { SMALL_ENDIAN = 0 , BIG_ENDIAN = 1 }
 

Functions

ipmi_msg construct_ipmi_message (uint8_t seq_source, uint8_t netFn, uint8_t command, uint8_t source_inft, uint8_t target_inft, uint16_t data_len, uint8_t *data)
 
I2C_MSG construct_i2c_message (uint8_t bus_id, uint8_t address, uint8_t tx_len, uint8_t *data, uint8_t rx_len)
 
void reverse_array (uint8_t arr[], uint8_t size)
 
int ascii_to_val (uint8_t ascii_byte)
 
uint32_t uint32_t_byte_reverse (uint32_t data)
 
void convert_uint32_t_to_uint8_t_pointer (uint32_t data_32, uint8_t *data_8, uint8_t len, uint8_t endian)
 
void convert_uint8_t_pointer_to_uint32_t (uint32_t *data_32, const uint8_t *data_8, uint8_t len, uint8_t endian)
 
double power (double x, int y)
 
int uint8_t_to_dec_ascii_pointer (uint8_t val, uint8_t *result, uint8_t len)
 
int find_byte_data_in_buf (const uint8_t *buf, uint8_t byte_data, int start_index, int end_index)
 
void clear_bits (uint32_t *value, int start_bit, int end_bit)
 
void sort_bubble (int *array, int len)
 
size_t strlen16 (const char16_t *str)
 
char16_tstrcpy16 (char16_t *dest, const char16_t *src)
 
char16_tch16_strcat_char (char16_t *dest)
 

Macro Definition Documentation

◆ CHECK_ARG_WITH_RETURN

#define CHECK_ARG_WITH_RETURN (   cmp,
  ret_val 
)
Value:
if (cmp) { \
LOG_DBG("Parameter \"" #cmp "\" true"); \
return ret_val; \
}

◆ CHECK_MSGQ_INIT

#define CHECK_MSGQ_INIT (   msgq)    CHECK_NULL_ARG((msgq)->buffer_start);

◆ CHECK_MSGQ_INIT_WITH_RETURN

#define CHECK_MSGQ_INIT_WITH_RETURN (   msgq,
  ret_val 
)     CHECK_NULL_ARG_WITH_RETURN((msgq)->buffer_start, ret_val);

◆ CHECK_MUTEX_INIT

#define CHECK_MUTEX_INIT (   mutex)    CHECK_NULL_ARG((mutex)->wait_q.waitq.head);

◆ CHECK_MUTEX_INIT_WITH_RETURN

#define CHECK_MUTEX_INIT_WITH_RETURN (   mutex,
  ret_val 
)     CHECK_NULL_ARG_WITH_RETURN((mutex)->wait_q.waitq.head, ret_val);

◆ CHECK_NULL_ARG

#define CHECK_NULL_ARG (   arg_ptr)
Value:
if (arg_ptr == NULL) { \
LOG_DBG("Parameter \"" #arg_ptr "\" passed in as NULL"); \
return; \
}

◆ CHECK_NULL_ARG_WITH_RETURN

#define CHECK_NULL_ARG_WITH_RETURN (   arg_ptr,
  ret_val 
)
Value:
if (arg_ptr == NULL) { \
LOG_DBG("Parameter \"" #arg_ptr "\" passed in as NULL"); \
return ret_val; \
}

◆ CLEARBIT

#define CLEARBIT (   x,
 
)    (x & (~(1ULL << y)))

◆ CLEARBITS

#define CLEARBITS (   x,
  y,
 
)
Value:
for (int i = y; i <= z; ++i) { \
x = CLEARBIT(x, i); \
}
#define CLEARBIT(x, y)
Definition: libutil.h:33

◆ GETBIT

#define GETBIT (   x,
 
)    ((x & (1ULL << y)) > y)

◆ SAFE_FREE

#define SAFE_FREE (   p)
Value:
if (p) { \
free(p); \
p = NULL; \
}

◆ SET_FLAG_WITH_RETURN

#define SET_FLAG_WITH_RETURN (   flag,
  set_val,
  ret_val 
)
Value:
if (flag != true) { \
LOG_DBG("Set parameter \"" #flag "\" to true"); \
flag = set_val; \
return ret_val; \
}

◆ SETBIT

#define SETBIT (   x,
 
)    (x | (1ULL << y))

◆ SETBITS

#define SETBITS (   x,
  y,
 
)    (x | (y << z))

◆ SHELL_CHECK_NULL_ARG

#define SHELL_CHECK_NULL_ARG (   arg_ptr)
Value:
if (arg_ptr == NULL) { \
shell_error(shell, "Parameter \"" #arg_ptr "\" passed in as NULL"); \
return; \
}

◆ SHELL_CHECK_NULL_ARG_WITH_RETURN

#define SHELL_CHECK_NULL_ARG_WITH_RETURN (   arg_ptr,
  ret_val 
)
Value:
if (arg_ptr == NULL) { \
shell_error(shell, "Parameter \"" #arg_ptr "\" passed in as NULL"); \
return ret_val; \
}

Typedef Documentation

◆ char16_t

typedef uint_least16_t char16_t

Enumeration Type Documentation

◆ BIT_SETTING_READING

Enumerator
BIT_CLEAR 
BIT_SET 
BIT_GET 

◆ BIT_SETTING_READING_N

Enumerator
BIT_SET_N 
BIT_CLEAR_N 

◆ BYTE_ENDIAN

Enumerator
SMALL_ENDIAN 
BIG_ENDIAN 

Function Documentation

◆ ascii_to_val()

int ascii_to_val ( uint8_t  ascii_byte)

◆ ch16_strcat_char()

char16_t * ch16_strcat_char ( char16_t dest)
Here is the call graph for this function:

◆ clear_bits()

void clear_bits ( uint32_t *  value,
int  start_bit,
int  end_bit 
)

◆ construct_i2c_message()

I2C_MSG construct_i2c_message ( uint8_t  bus_id,
uint8_t  address,
uint8_t  tx_len,
uint8_t *  data,
uint8_t  rx_len 
)

◆ construct_ipmi_message()

ipmi_msg construct_ipmi_message ( uint8_t  seq_source,
uint8_t  netFn,
uint8_t  command,
uint8_t  source_inft,
uint8_t  target_inft,
uint16_t  data_len,
uint8_t *  data 
)

◆ convert_uint32_t_to_uint8_t_pointer()

void convert_uint32_t_to_uint8_t_pointer ( uint32_t  data_32,
uint8_t *  data_8,
uint8_t  len,
uint8_t  endian 
)

◆ convert_uint8_t_pointer_to_uint32_t()

void convert_uint8_t_pointer_to_uint32_t ( uint32_t *  data_32,
const uint8_t *  data_8,
uint8_t  len,
uint8_t  endian 
)

◆ find_byte_data_in_buf()

int find_byte_data_in_buf ( const uint8_t *  buf,
uint8_t  byte_data,
int  start_index,
int  end_index 
)

◆ power()

double power ( double  x,
int  y 
)

◆ reverse_array()

void reverse_array ( uint8_t  arr[],
uint8_t  size 
)

◆ sort_bubble()

void sort_bubble ( int *  array,
int  len 
)

◆ strcpy16()

char16_t * strcpy16 ( char16_t dest,
const char16_t src 
)

◆ strlen16()

size_t strlen16 ( const char16_t str)

◆ uint32_t_byte_reverse()

uint32_t uint32_t_byte_reverse ( uint32_t  data)

◆ uint8_t_to_dec_ascii_pointer()

int uint8_t_to_dec_ascii_pointer ( uint8_t  val,
uint8_t *  result,
uint8_t  len 
)