iPXE
Macros | Functions
mlx_reg_access.c File Reference
#include "../../mlx_lib/mlx_reg_access/mlx_reg_access.h"
#include "../../include/public/mlx_icmd.h"
#include "../../include/public/mlx_bail.h"
#include "../../include/public/mlx_memory.h"

Go to the source code of this file.

Macros

#define TLV_OPERATION   1
 
#define MAD_CLASS_REG_ACCESS   1
 
#define TLV_OPERATION_SIZE   4
 
#define REG_ACCESS_TLV_REG   3
 
#define REG_TLV_HEADER_LEN   4
 
#define OP_TLV_SIZE   16
 

Functions

 FILE_LICENCE (GPL2_OR_LATER)
 
static mlx_status init_operation_tlv (IN struct mail_box_tlv *mail_box_tlv, IN mlx_uint16 reg_id, IN REG_ACCESS_OPT reg_opt)
 
mlx_status mlx_reg_access (IN mlx_utils *utils, IN mlx_uint16 reg_id, IN REG_ACCESS_OPT reg_opt, IN OUT mlx_void *reg_data, IN mlx_size reg_size, OUT mlx_uint32 *reg_status)
 

Macro Definition Documentation

◆ TLV_OPERATION

#define TLV_OPERATION   1

◆ MAD_CLASS_REG_ACCESS

#define MAD_CLASS_REG_ACCESS   1

◆ TLV_OPERATION_SIZE

#define TLV_OPERATION_SIZE   4

◆ REG_ACCESS_TLV_REG

#define REG_ACCESS_TLV_REG   3

◆ REG_TLV_HEADER_LEN

#define REG_TLV_HEADER_LEN   4

◆ OP_TLV_SIZE

#define OP_TLV_SIZE   16

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER  )

◆ init_operation_tlv()

static mlx_status init_operation_tlv ( IN struct mail_box_tlv mail_box_tlv,
IN mlx_uint16  reg_id,
IN REG_ACCESS_OPT  reg_opt 
)
static

Definition at line 29 of file mlx_reg_access.c.

34 {
35 #define TLV_OPERATION 1
37 #define MAD_CLASS_REG_ACCESS 1
39 #define TLV_OPERATION_SIZE 4
43  return MLX_SUCCESS;
44 }
mlx_uint32 register_id
#define MAD_CLASS_REG_ACCESS
#define TLV_OPERATION_SIZE
#define MLX_SUCCESS
struct operation_tlv operation_tlv
mlx_uint32 cls
mlx_uint32 len
mlx_uint32 method
mlx_uint32 Type
#define TLV_OPERATION

References operation_tlv::cls, operation_tlv::len, MAD_CLASS_REG_ACCESS, operation_tlv::method, MLX_SUCCESS, mail_box_tlv::operation_tlv, operation_tlv::register_id, TLV_OPERATION, TLV_OPERATION_SIZE, and operation_tlv::Type.

Referenced by mlx_reg_access().

◆ mlx_reg_access()

mlx_status mlx_reg_access ( IN mlx_utils utils,
IN mlx_uint16  reg_id,
IN REG_ACCESS_OPT  reg_opt,
IN OUT mlx_void reg_data,
IN mlx_size  reg_size,
OUT mlx_uint32 reg_status 
)

Definition at line 47 of file mlx_reg_access.c.

55 {
58 
59  if (utils == NULL || reg_data == NULL || reg_status == NULL
60  || reg_size > REG_ACCESS_MAX_REG_SIZE) {
62  goto bad_param;
63  }
64 
65  mlx_memory_set(utils, &mail_box_tlv, 0, sizeof(mail_box_tlv));
66 
67  init_operation_tlv(&mail_box_tlv, reg_id, reg_opt);
68 
69 #define REG_ACCESS_TLV_REG 3
70 #define REG_TLV_HEADER_LEN 4
71 #define OP_TLV_SIZE 16
73  mail_box_tlv.reg_tlv.len = ((reg_size + REG_TLV_HEADER_LEN + 3) >> 2); // length is in dwords round up
74  mlx_memory_cpy(utils, &mail_box_tlv.reg_tlv.data, reg_data, reg_size);
75 
76  reg_size += OP_TLV_SIZE + REG_TLV_HEADER_LEN;
77 
78  status = mlx_icmd_send_command(utils, FLASH_REG_ACCESS, &mail_box_tlv, reg_size, reg_size);
79  MLX_CHECK_STATUS(utils, status, icmd_err, "failed to send icmd");
80 
81  mlx_memory_cpy(utils, reg_data, &mail_box_tlv.reg_tlv.data,
82  reg_size - (OP_TLV_SIZE + REG_TLV_HEADER_LEN));
83 
84  *reg_status = mail_box_tlv.operation_tlv.status;
85 icmd_err:
86 bad_param:
87  return status;
88 }
static mlx_status init_operation_tlv(IN struct mail_box_tlv *mail_box_tlv, IN mlx_uint16 reg_id, IN REG_ACCESS_OPT reg_opt)
#define MLX_INVALID_PARAMETER
#define REG_TLV_HEADER_LEN
mlx_status mlx_icmd_send_command(IN mlx_utils *utils, IN mlx_uint16 opcode, IN OUT mlx_void *data, IN mlx_uint32 write_data_size, IN mlx_uint32 read_data_size)
Definition: mlx_icmd.c:310
#define REG_ACCESS_MAX_REG_SIZE
uint8_t status
Status.
Definition: ena.h:16
mlx_status mlx_memory_set(IN mlx_utils *utils, IN mlx_void *block, IN mlx_int32 value, IN mlx_size size)
Definition: mlx_memory.c:171
mlx_uint32 len
mlx_uint32 status
struct reg_tlv reg_tlv
#define MLX_SUCCESS
struct operation_tlv operation_tlv
#define REG_ACCESS_TLV_REG
mlx_uint32 Type
mlx_uint8 data[REG_ACCESS_MAX_REG_SIZE]
mlx_status mlx_memory_cpy(IN mlx_utils *utils, OUT mlx_void *destination_buffer, IN mlx_void *source_buffer, IN mlx_size length)
Definition: mlx_memory.c:189
int mlx_status
#define MLX_CHECK_STATUS(id, status, label, message)
Definition: mlx_bail.h:37
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
#define OP_TLV_SIZE

References reg_tlv::data, FLASH_REG_ACCESS, init_operation_tlv(), reg_tlv::len, MLX_CHECK_STATUS, mlx_icmd_send_command(), MLX_INVALID_PARAMETER, mlx_memory_cpy(), mlx_memory_set(), MLX_SUCCESS, NULL, OP_TLV_SIZE, mail_box_tlv::operation_tlv, REG_ACCESS_MAX_REG_SIZE, REG_ACCESS_TLV_REG, mail_box_tlv::reg_tlv, REG_TLV_HEADER_LEN, status, operation_tlv::status, and reg_tlv::Type.

Referenced by mlx_blink_leds(), mlx_get_max_mtu(), mlx_get_max_speed(), mlx_set_admin_mtu(), mlx_set_link_speed(), nvconfig_nvdata_access(), nvconfig_nvdata_invalidate(), nvconfig_query_capability(), and nvconfig_set_fw_reset_level().