iPXE
Data Structures | Macros | Enumerations | Functions
mlx_reg_access.h File Reference
#include "../../include/public/mlx_icmd.h"

Go to the source code of this file.

Data Structures

struct  operation_tlv
 
struct  reg_tlv
 
struct  mail_box_tlv
 

Macros

#define MLX_REG_ACCESS_H_
 
#define REG_ACCESS_MAX_REG_SIZE   236
 
#define REG_ID_NVDA   0x9024
 
#define REG_ID_NVDI   0x9025
 
#define REG_ID_NVIA   0x9029
 
#define REG_ID_MLCR   0x902b
 
#define REG_ID_NVQC   0x9030
 
#define REG_ID_MFRL   0x9028
 
#define REG_ID_PTYS   0x5004
 
#define REG_ID_PMTU   0x5003
 

Enumerations

enum  REG_ACCESS_OPT { REG_ACCESS_READ = 1, REG_ACCESS_WRITE = 2 }
 

Functions

 FILE_LICENCE (GPL2_OR_LATER)
 
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

◆ MLX_REG_ACCESS_H_

#define MLX_REG_ACCESS_H_

Definition at line 23 of file mlx_reg_access.h.

◆ REG_ACCESS_MAX_REG_SIZE

#define REG_ACCESS_MAX_REG_SIZE   236

Definition at line 27 of file mlx_reg_access.h.

◆ REG_ID_NVDA

#define REG_ID_NVDA   0x9024

Definition at line 34 of file mlx_reg_access.h.

◆ REG_ID_NVDI

#define REG_ID_NVDI   0x9025

Definition at line 35 of file mlx_reg_access.h.

◆ REG_ID_NVIA

#define REG_ID_NVIA   0x9029

Definition at line 36 of file mlx_reg_access.h.

◆ REG_ID_MLCR

#define REG_ID_MLCR   0x902b

Definition at line 37 of file mlx_reg_access.h.

◆ REG_ID_NVQC

#define REG_ID_NVQC   0x9030

Definition at line 38 of file mlx_reg_access.h.

◆ REG_ID_MFRL

#define REG_ID_MFRL   0x9028

Definition at line 39 of file mlx_reg_access.h.

◆ REG_ID_PTYS

#define REG_ID_PTYS   0x5004

Definition at line 40 of file mlx_reg_access.h.

◆ REG_ID_PMTU

#define REG_ID_PMTU   0x5003

Definition at line 41 of file mlx_reg_access.h.

Enumeration Type Documentation

◆ REG_ACCESS_OPT

Enumerator
REG_ACCESS_READ 
REG_ACCESS_WRITE 

Definition at line 29 of file mlx_reg_access.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER  )

◆ 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().