Commit 329aa2e7 authored by Lucas Russo's avatar Lucas Russo

Merge branch 'smio-devel'

parents c9ca6619 c6efdcff
sm_io_fmc130m_4ch_DIR = hal/sm_io/modules/fmc130m_4ch
sm_io_fmc130m_4ch_OBJS = $(sm_io_fmc130m_4ch_DIR)/sm_io_fmc130m_4ch.o
sm_io_fmc130m_4ch_OBJS = $(sm_io_fmc130m_4ch_DIR)/sm_io_fmc130m_4ch_core.o \
$(sm_io_fmc130m_4ch_DIR)/sm_io_fmc130m_4ch_exp.o
sm_io_fmc130m_4ch_INCLUDE_DIRS = $(sm_io_fmc130m_4ch_DIR)
/*
* 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 <stdlib.h>
#include <assert.h>
#include <czmq.h>
#include "sm_io_fmc130m_4ch_core.h"
#include "sm_io_err.h"
#include "hal_assert.h"
/* Undef ASSERT_ALLOC to avoid conflicting with other ASSERT_ALLOC */
#ifdef ASSERT_TEST
#undef ASSERT_TEST
#endif
#define ASSERT_TEST(test_boolean, err_str, err_goto_label) \
ASSERT_HAL_TEST(test_boolean, SM_IO, "[sm_io_fmc130m_4ch_core]", \
err_str, err_goto_label)
#ifdef ASSERT_ALLOC
#undef ASSERT_ALLOC
#endif
#define ASSERT_ALLOC(ptr, err_goto_label) \
ASSERT_HAL_ALLOC(ptr, SM_IO, "[sm_io_fmc130m_4ch_core]", \
smio_err_str(SMIO_ERR_ALLOC), \
err_goto_label)
#ifdef CHECK_ERR
#undef CHECK_ERR
#endif
#define CHECK_ERR(err, err_type) \
CHECK_HAL_ERR(err, SM_IO, "[sm_io_fmc130m_4ch_core]", \
smio_err_str (err_type))
/* Creates a new instance of Device Information */
smio_fmc130m_4ch_t * smio_fmc130m_4ch_new (uint32_t dummy)
{
smio_fmc130m_4ch_t *self = (smio_fmc130m_4ch_t *) zmalloc (sizeof *self);
ASSERT_ALLOC(self, err_self_alloc);
self->dummy = dummy;
return self;
err_self_alloc:
return NULL;
}
/* Destroy an instance of the Device Information */
smio_err_e smio_fmc130m_4ch_destroy (smio_fmc130m_4ch_t **self_p)
{
assert (self_p);
if (*self_p) {
smio_fmc130m_4ch_t *self = *self_p;
free (self);
*self_p = NULL;
}
return SMIO_SUCCESS;
}
/*
* 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_FMC130M_4CH_CORE_H_
#define _SM_IO_FMC130M_4CH_CORE_H_
#include <inttypes.h>
#include "sm_io_err.h"
struct _smio_fmc130m_4ch_t {
uint32_t dummy; /* Just a dummy value to illustrate the idea */
};
/* Opaque class structure */
typedef struct _smio_fmc130m_4ch_t smio_fmc130m_4ch_t;
/***************** Our methods *****************/
/* Creates a new instance of the smio realizationn */
smio_fmc130m_4ch_t * smio_fmc130m_4ch_new (uint32_t dummy);
/* Destroys the smio realizationn */
smio_err_e smio_fmc130m_4ch_destroy (smio_fmc130m_4ch_t **self_p);
#endif
......@@ -7,7 +7,7 @@
#include <stdlib.h>
#include "sm_io_fmc130m_4ch.h"
#include "sm_io_fmc130m_4ch_exp.h"
#include "sm_io.h"
#include "dev_io.h"
#include "hal_assert.h"
......@@ -17,14 +17,14 @@
#undef ASSERT_TEST
#endif
#define ASSERT_TEST(test_boolean, err_str, err_goto_label) \
ASSERT_HAL_TEST(test_boolean, SM_IO, "[sm_io:fmc130m_4ch]",\
ASSERT_HAL_TEST(test_boolean, SM_IO, "[sm_io:fmc130m_4ch_exp]", \
err_str, err_goto_label)
#ifdef ASSERT_ALLOC
#undef ASSERT_ALLOC
#endif
#define ASSERT_ALLOC(ptr, err_goto_label) \
ASSERT_HAL_ALLOC(ptr, SM_IO, "[sm_io:fmc130m_4ch]", \
ASSERT_HAL_ALLOC(ptr, SM_IO, "[sm_io:fmc130m_4ch_exp]", \
smio_err_str(SMIO_ERR_ALLOC), \
err_goto_label)
......@@ -32,7 +32,7 @@
#undef CHECK_ERR
#endif
#define CHECK_ERR(err, err_type) \
CHECK_HAL_ERR(err, SM_IO, "[sm_io:fmc130m_4ch]", \
CHECK_HAL_ERR(err, SM_IO, "[sm_io:fmc130m_4ch_exp]", \
smio_err_str (err_type))
/************************************************************/
......@@ -63,11 +63,11 @@ static void *_fmc130m_4ch_leds (void *owner, void *args)
exp_msg_zmq_t *exp_msg = (exp_msg_zmq_t *) args;
assert (zmsg_size (*exp_msg->msg) > 0);
DBE_DEBUG (DBG_SM_IO | DBG_LVL_TRACE, "[sm_io:fmc130m_4ch] Calling _fmc130m_4ch_leds\n");
DBE_DEBUG (DBG_SM_IO | DBG_LVL_TRACE, "[sm_io:fmc130m_4ch_exp] Calling _fmc130m_4ch_leds\n");
uint32_t leds = *(uint32_t *) zframe_data (zmsg_pop (*exp_msg->msg));
smio_thsafe_client_write_32 (self, BAR4_ADDR | FMC1_ADDR | FMC_MONITOR_REG,
&leds);
DBE_DEBUG (DBG_SM_IO | DBG_LVL_TRACE, "[sm_io:fmc130m_4ch_boot] Led write: 0x%08x\n",
DBE_DEBUG (DBG_SM_IO | DBG_LVL_TRACE, "[sm_io:fmc130m_4ch_exp] Led write: 0x%08x\n",
leds);
/* Don't send any response, for now... */
......@@ -151,7 +151,7 @@ const smio_ops_t fmc130m_4ch_ops = {
smio_err_e fmc130m_4ch_init (smio_t * self)
{
DBE_DEBUG (DBG_SM_IO | DBG_LVL_TRACE, "[sm_io:fmc130m_4ch] Initializing fmc130m_4ch\n");
DBE_DEBUG (DBG_SM_IO | DBG_LVL_TRACE, "[sm_io:fmc130m_4ch_exp] Initializing fmc130m_4ch\n");
smio_err_e err = SMIO_ERR_ALLOC;
......@@ -163,8 +163,16 @@ smio_err_e fmc130m_4ch_init (smio_t * self)
self->ops = &fmc130m_4ch_ops;
self->thsafe_client_ops = &smio_thsafe_client_zmq_ops;
self->exp_ops = fmc130m_exp_ops;
/* Initialize specific structure */
self->smio_handler = smio_fmc130m_4ch_new (0);
ASSERT_ALLOC(self->smio_handler, err_smio_handler_alloc);
err = SMIO_SUCCESS;
return err;
err_smio_handler_alloc:
free (self->name);
err_name_alloc:
return err;
}
......@@ -172,8 +180,9 @@ err_name_alloc:
/* Destroy sm_io instance of fmc130m_4ch */
smio_err_e fmc130m_4ch_shutdown (smio_t *self)
{
DBE_DEBUG (DBG_SM_IO | DBG_LVL_TRACE, "[sm_io:fmc130m_4ch] Shutting down fmc130m_4ch\n");
DBE_DEBUG (DBG_SM_IO | DBG_LVL_TRACE, "[sm_io:fmc130m_4ch_exp] Shutting down fmc130m_4ch\n");
smio_fmc130m_4ch_destroy (self->smio_handler);
self->exp_ops = NULL;
self->thsafe_client_ops = NULL;
self->ops = NULL;
......
......@@ -11,6 +11,7 @@
#include "sm_io_bootstrap.h"
#include "smio_thsafe_zmq_client.h"
#include "exp_ops_codes.h"
#include "sm_io_fmc130m_4ch_core.h"
/* Known modules IDs (from SDB records defined in FPGA) */
#define FMC130M_4CH_SDB_DEVID 0x7085ef15
......
......@@ -7,7 +7,7 @@
#include "sm_io_mod_dispatch.h"
/* Include all available module we can handle */
#include "sm_io_fmc130m_4ch.h"
#include "sm_io_fmc130m_4ch_exp.h"
/* Table of all known modules we can handle */
const smio_mod_dispatch_t smio_mod_dispatch[MOD_DISPATCH_END] = {
......
......@@ -37,6 +37,9 @@ struct _smio_t {
/* int verbose; */ /* Print activity to stdout */
mdp_worker_t *worker; /* zeroMQ Majordomo worker */
struct _devio_t *parent; /* Pointer back to parent dev_io */
void *smio_handler; /* Generic pointer to a device handler. This
must be cast to a specific type by the
devices functions */
zctx_t *ctx; /* Our context */
void *pipe; /* Pipe back to parent to exchange messages */
......
......@@ -165,6 +165,7 @@ static struct _smio_t *_smio_new (struct _devio_t *parent, struct _zctx_t *ctx,
self->exp_ops_dtable = disp_table_new ();
ASSERT_ALLOC(self->exp_ops_dtable, err_exp_ops_dtable_alloc);
self->smio_handler = NULL; /* This is set by the device functions */
self->ctx = ctx;
self->pipe = pipe;
......
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