Commit e694cb4a authored by Lucas Russo's avatar Lucas Russo

hal/sm_io/modules/acq/*: separate exported function descriptors

Step number 1 on fixing github issue #48
parent 5c5fa829
......@@ -2,6 +2,7 @@ sm_io_acq_DIR = hal/sm_io/modules/acq
sm_io_acq_OBJS = $(sm_io_acq_DIR)/sm_io_acq_core.o \
$(sm_io_acq_DIR)/sm_io_acq_exp.o \
$(sm_io_acq_DIR)/sm_io_acq_exports.o \
$(sm_io_acq_DIR)/ddr3_map.o
sm_io_acq_INCLUDE_DIRS = $(sm_io_acq_DIR)
......@@ -17,6 +17,8 @@
#include "board.h"
#include "rw_param.h"
#include "wb_acq_core_regs.h"
#include "sm_io_acq_exports.h"
#include "hal_stddef.h"
/* Undef ASSERT_ALLOC to avoid conflicting with other ASSERT_ALLOC */
#ifdef ASSERT_TEST
......@@ -147,19 +149,6 @@ static int _acq_data_acquire (void *owner, void *args, void *ret)
return -ACQ_OK;
}
disp_op_t acq_data_acquire_exp = {
.name = ACQ_NAME_DATA_ACQUIRE,
.opcode = ACQ_OPCODE_DATA_ACQUIRE,
.func_fp = _acq_data_acquire,
.retval = DISP_ARG_END,
.retval_owner = DISP_OWNER_OTHER,
.args = {
DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t),
DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t),
DISP_ARG_END
}
};
static int _acq_check_data_acquire (void *owner, void *args, void *ret)
{
(void) ret;
......@@ -188,17 +177,6 @@ static int _acq_check_data_acquire (void *owner, void *args, void *ret)
return -ACQ_OK;
}
disp_op_t acq_check_data_acquire_exp = {
.name = ACQ_NAME_CHECK_DATA_ACQUIRE,
.opcode = ACQ_OPCODE_CHECK_DATA_ACQUIRE,
.func_fp = _acq_check_data_acquire,
.retval = DISP_ARG_END,
.retval_owner = DISP_OWNER_OTHER,
.args = {
DISP_ARG_END
}
};
static int _acq_get_data_block (void *owner, void *args, void *ret)
{
assert (owner);
......@@ -298,19 +276,15 @@ static int _acq_get_data_block (void *owner, void *args, void *ret)
return sizeof (*data_block);
}
disp_op_t acq_get_data_block_exp = {
.name = ACQ_NAME_GET_DATA_BLOCK,
.opcode = ACQ_OPCODE_GET_DATA_BLOCK,
.func_fp = _acq_get_data_block,
.retval = DISP_ARG_ENCODE(DISP_ATYPE_STRUCT, smio_acq_data_block_t),
.retval_owner = DISP_OWNER_OTHER,
.args = {
DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t),
DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t),
DISP_ARG_END
}
/* Exported function pointers */
const disp_table_func_fp acq_exp_fp [] = {
_acq_data_acquire,
_acq_check_data_acquire,
_acq_get_data_block,
NULL
};
/* Exported function description */
const disp_op_t *acq_exp_ops [] = {
&acq_data_acquire_exp,
&acq_check_data_acquire_exp,
......@@ -395,6 +369,18 @@ smio_err_e acq_init (smio_t * self)
/* Set SMIO ops pointers */
self->ops = &acq_ops;
self->thsafe_client_ops = &smio_thsafe_client_zmq_ops;
/* Fill the disp_op_t description structure with the callbacks. */
/* disp_op_t structure is const and all of the functions performing on it
* obviously receives a const argument, but here (and only on the SMIO
* initialization) we need to make an exception if we want to keep the
* functions' description and the function pointers separate */
err = smio_init_exp_ops (self, (disp_op_t **) acq_exp_ops, acq_exp_fp,
ARRAY_SIZE(acq_exp_ops));
ASSERT_TEST(err == SMIO_SUCCESS, "Could not fill SMIO "
"function descriptors with the callbacks", err_fill_desc);
self->exp_ops = acq_exp_ops;
/* Initialize specific structure */
......@@ -404,6 +390,7 @@ smio_err_e acq_init (smio_t * self)
return err;
err_smio_handler_alloc:
err_fill_desc:
free (self->name);
err_name_alloc:
return err;
......
/*
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
*/
#include "sm_io_acq_exports.h"
#include "sm_io_acq_codes.h"
/* Description SMIO ACQ functions */
disp_op_t acq_data_acquire_exp = {
.name = ACQ_NAME_DATA_ACQUIRE,
.opcode = ACQ_OPCODE_DATA_ACQUIRE,
.retval = DISP_ARG_END,
.retval_owner = DISP_OWNER_OTHER,
.args = {
DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t),
DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t),
DISP_ARG_END
}
};
disp_op_t acq_check_data_acquire_exp = {
.name = ACQ_NAME_CHECK_DATA_ACQUIRE,
.opcode = ACQ_OPCODE_CHECK_DATA_ACQUIRE,
.retval = DISP_ARG_END,
.retval_owner = DISP_OWNER_OTHER,
.args = {
DISP_ARG_END
}
};
disp_op_t acq_get_data_block_exp = {
.name = ACQ_NAME_GET_DATA_BLOCK,
.opcode = ACQ_OPCODE_GET_DATA_BLOCK,
.retval = DISP_ARG_ENCODE(DISP_ATYPE_STRUCT, smio_acq_data_block_t),
.retval_owner = DISP_OWNER_OTHER,
.args = {
DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t),
DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t),
DISP_ARG_END
}
};
/*
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
*/
#ifndef _SM_IO_ACQ_EXPORTS_H_
#define _SM_IO_ACQ_EXPORTS_H_
#include "dispatch_table.h"
extern disp_op_t acq_data_acquire_exp;
extern disp_op_t acq_check_data_acquire_exp;
extern disp_op_t acq_get_data_block_exp;
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment