iPXE
Data Structures | Defines | Enumerations | Functions
mlx_icmd.h File Reference
#include "mlx_utils.h"

Go to the source code of this file.

Data Structures

struct  mlx_icmd_ocsd

Defines

#define MLX_ICMD_MB_ADDR   0x100000
#define MLX_ICMD_MB_SIZE_ADDR   0x1000
#define MLX_ICMD_CTRL_ADDR   0x0
#define MLX_ICMD_SEMAPHORE_ADDR   0x0
#define MLX_ICMD_SEMAPHORE_ID   1234

Enumerations

enum  {
  FLASH_REG_ACCESS = 0x9001, GET_FW_INFO = 0x8007, QUERY_VIRTUAL_MAC = 0x9003, SET_VIRTUAL_MAC = 0x9004,
  QUERY_WOL_ROL = 0x9005, SET_WOL_ROL = 0x9006, OCBB_INIT = 0x9007, OCBB_QUERY_HEADER_STATUS = 0x9008,
  OCBB_QUERY_ETOC_STATUS = 0x9009, OCBB_QUERY_SET_EVENT = 0x900A, OCSD_INIT = 0xf004
}

Functions

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

Define Documentation

#define MLX_ICMD_MB_ADDR   0x100000

Definition at line 27 of file mlx_icmd.h.

Referenced by mlx_icmd_read_buffer(), and mlx_icmd_write_buffer().

#define MLX_ICMD_MB_SIZE_ADDR   0x1000

Definition at line 28 of file mlx_icmd.h.

Referenced by mlx_icmd_init().

#define MLX_ICMD_CTRL_ADDR   0x0

Definition at line 29 of file mlx_icmd.h.

Referenced by mlx_icmd_get_status(), mlx_icmd_go(), and mlx_icmd_set_opcode().

#define MLX_ICMD_SEMAPHORE_ADDR   0x0

Definition at line 31 of file mlx_icmd.h.

Referenced by mlx_icmd_clear_semaphore(), and mlx_icmd_get_semaphore().

#define MLX_ICMD_SEMAPHORE_ID   1234

Definition at line 33 of file mlx_icmd.h.


Enumeration Type Documentation

anonymous enum
Enumerator:
FLASH_REG_ACCESS 
GET_FW_INFO 
QUERY_VIRTUAL_MAC 
SET_VIRTUAL_MAC 
QUERY_WOL_ROL 
SET_WOL_ROL 
OCBB_INIT 
OCBB_QUERY_HEADER_STATUS 
OCBB_QUERY_ETOC_STATUS 
OCBB_QUERY_SET_EVENT 
OCSD_INIT 

Definition at line 35 of file mlx_icmd.h.

     {
        FLASH_REG_ACCESS        = 0x9001,
        GET_FW_INFO                     = 0x8007,
        QUERY_VIRTUAL_MAC       = 0x9003,
        SET_VIRTUAL_MAC         = 0x9004,
        QUERY_WOL_ROL           = 0x9005,
        SET_WOL_ROL                     = 0x9006,
        OCBB_INIT                       = 0x9007,
        OCBB_QUERY_HEADER_STATUS        = 0x9008,
        OCBB_QUERY_ETOC_STATUS  = 0x9009,
        OCBB_QUERY_SET_EVENT    = 0x900A,
        OCSD_INIT                       = 0xf004,
};

Function Documentation

FILE_LICENCE ( GPL2_OR_LATER  )
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 at line 310 of file mlx_icmd.c.

References MLX_CHECK_STATUS, MLX_DEBUG_ERROR, MLX_FAILED, mlx_icmd_clear_semaphore(), mlx_icmd_get_semaphore(), mlx_icmd_get_status(), mlx_icmd_go(), mlx_icmd_init(), mlx_icmd_read_buffer(), mlx_icmd_set_opcode(), mlx_icmd_write_buffer(), MLX_INVALID_PARAMETER, MLX_SUCCESS, NULL, and status.

Referenced by mlx_reg_access(), mlx_vmac_query_virt_mac(), and mlx_vmac_set_virt_mac().

{
        mlx_status status = MLX_SUCCESS;
        mlx_uint32 icmd_status = 0;

        if (utils == NULL || data == NULL) {
                status = MLX_INVALID_PARAMETER;
                goto invalid_param;
        }
        status = mlx_icmd_init(utils);
        MLX_CHECK_STATUS(utils, status, open_err, "failed to open icmd");

        if (write_data_size > utils->icmd.max_cmd_size ||
                        read_data_size > utils->icmd.max_cmd_size) {
                status = MLX_INVALID_PARAMETER;
                goto size_err;
        }

        status = mlx_icmd_get_semaphore(utils);
        MLX_CHECK_STATUS(utils, status, semaphore_err, "failed to get icmd semaphore");

        status = mlx_icmd_set_opcode(utils, opcode);
        MLX_CHECK_STATUS(utils, status, opcode_err, "failed to set icmd opcode");

        if (write_data_size != 0) {
                status = mlx_icmd_write_buffer(utils, data, write_data_size);
                MLX_CHECK_STATUS(utils, status, opcode_err, "failed to write icmd MB");
        }

        status = mlx_icmd_go(utils);
        MLX_CHECK_STATUS(utils, status, go_err, "failed to activate icmd");

        status = mlx_icmd_get_status(utils, &icmd_status);
        MLX_CHECK_STATUS(utils, status, get_status_err, "failed to set icmd opcode");

        if (icmd_status != 0) {
                MLX_DEBUG_ERROR(utils, "icmd failed with status = %d\n", icmd_status);
                status = MLX_FAILED;
                goto icmd_failed;
        }
        if (read_data_size != 0) {
                status = mlx_icmd_read_buffer(utils, data, read_data_size);
                MLX_CHECK_STATUS(utils, status, read_err, "failed to read icmd MB");
        }
read_err:
icmd_failed:
get_status_err:
go_err:
opcode_err:
        mlx_icmd_clear_semaphore(utils);
semaphore_err:
size_err:
open_err:
invalid_param:
        return status;
}