Commit 5981696a authored by Lucas Russo's avatar Lucas Russo

Merge branch 'smio-table-linker' into devel

parents 68971496 aed79199
......@@ -46,6 +46,9 @@ export CFG
# Config filename
CFG_FILENAME = bpm_sw.cfg
# Linker script
LD_SCRIPT = linker/bpm-sw.ld
# Init sripts
INIT_SCRIPTS =
......@@ -158,7 +161,7 @@ CFLAGS_DEBUG += -g
# Specific platform Flags
CFLAGS_PLATFORM = -Wall -Wextra -Werror
LDFLAGS_PLATFORM =
LDFLAGS_PLATFORM = -T $(LD_SCRIPT)
# Libraries
LIBS = -lm -lzmq -lczmq -lmlm
......
......@@ -30,6 +30,7 @@ extern "C" {
#define SMIO_DISPATCH_FUNC_WRAPPER_GEN(func_name, ...) \
({ \
volatile const smio_mod_dispatch_t *smio_mod_dispatch = &_smio_mod_dispatch; \
smio_err_e local_err = SMIO_ERR_FUNC_NOT_IMPL; \
if (smio_mod_dispatch[th_args->smio_id].bootstrap_ops && \
smio_mod_dispatch[th_args->smio_id].bootstrap_ops->func_name) { \
......
......@@ -18,9 +18,28 @@ typedef struct {
uint32_t id;
const char *name;
const smio_bootstrap_ops_t *bootstrap_ops;
} smio_mod_dispatch_t;
} __attribute__ ((aligned (16))) smio_mod_dispatch_t;
extern const smio_mod_dispatch_t smio_mod_dispatch [];
/*
* WARNING! Using SMIO_MOD_DECLARE requires .smio_mod_dispatch section in linker script
* .smio_mod_dispatch : ALIGN(4)
* {
* _smio_mod_dispatch = .;
* KEEP(*(.smio_mod_dispatch))
* _esmio_mod_dispatch = .;
* }
*/
extern const smio_mod_dispatch_t _smio_mod_dispatch;
extern const smio_mod_dispatch_t _esmio_mod_dispatch;
#define SMIO_MOD_DECLARE(mod_id, mod_name, mod_bootstrap_ops) \
const smio_mod_dispatch_t __attribute__ ((section (".smio_mod_dispatch"))) \
smio_mod_ ## mod_id ## _ ## mod_name = { \
.id = mod_id, \
.name = mod_name, \
.bootstrap_ops = &mod_bootstrap_ops \
};
#ifdef __cplusplus
}
......
SECTIONS
{
.smio_mod_dispatch : ALIGN(8)
{
_smio_mod_dispatch = .;
KEEP(*(.smio_mod_dispatch))
_esmio_mod_dispatch = .;
}
}
INSERT AFTER .rodata;
......@@ -389,6 +389,9 @@ devio_err_e devio_register_sm (devio_t *self, uint32_t smio_id, uint64_t base,
uint32_t pipe_mgmt_idx = 0;
uint32_t pipe_msg_idx = 0;
uint32_t pipe_config_idx = 0;
volatile const smio_mod_dispatch_t *smio_mod_dispatch_start = &_smio_mod_dispatch;
volatile const smio_mod_dispatch_t *smio_mod_dispatch_end = &_esmio_mod_dispatch;
smio_mod_dispatch_t *smio_mod_handler = (smio_mod_dispatch_t *) smio_mod_dispatch_start;
DBE_DEBUG (DBG_DEV_IO | DBG_LVL_TRACE,
"[dev_io_core:register_sm] searching for SMIO ID match\n");
......@@ -396,8 +399,8 @@ devio_err_e devio_register_sm (devio_t *self, uint32_t smio_id, uint64_t base,
/* For now, just do a simple linear search. We can afford this, as
* we don't expect to insert new sm_io modules often */
unsigned int i;
for (i = 0; smio_mod_dispatch[i].id != SMIO_DISPATCH_END_ID; ++i) {
if (smio_mod_dispatch[i].id != smio_id) {
for (i = 0; smio_mod_handler < smio_mod_dispatch_end; ++i, ++smio_mod_handler) {
if (smio_mod_handler->id != smio_id) {
continue;
}
......@@ -410,7 +413,7 @@ devio_err_e devio_register_sm (devio_t *self, uint32_t smio_id, uint64_t base,
"[dev_io_core:register_sm] Stringify hash ID\n");
char *inst_id_str = hutils_stringify_dec_key (inst_id);
ASSERT_ALLOC(inst_id_str, err_inst_id_str_alloc);
char *key = hutils_concat_strings_no_sep (smio_mod_dispatch[i].name,
char *key = hutils_concat_strings_no_sep (smio_mod_handler->name,
inst_id_str);
/* We don't need this anymore */
free (inst_id_str);
......
......@@ -892,3 +892,5 @@ const smio_bootstrap_ops_t acq_bootstrap_ops = {
.init = acq_init,
.shutdown = acq_shutdown
};
SMIO_MOD_DECLARE(ACQ_SDB_DEVID, ACQ_SDB_NAME, acq_bootstrap_ops)
......@@ -283,3 +283,5 @@ const smio_bootstrap_ops_t afc_diag_bootstrap_ops = {
.shutdown = afc_diag_shutdown,
.config_defaults = afc_diag_config_defaults
};
SMIO_MOD_DECLARE(AFC_DIAG_DEVID, AFC_DIAG_NAME, afc_diag_bootstrap_ops)
......@@ -337,3 +337,5 @@ const smio_bootstrap_ops_t dsp_bootstrap_ops = {
.shutdown = dsp_shutdown,
.config_defaults = dsp_config_defaults
};
SMIO_MOD_DECLARE(DSP_SDB_DEVID, DSP_SDB_NAME, dsp_bootstrap_ops)
......@@ -855,3 +855,5 @@ const smio_bootstrap_ops_t fmc130m_4ch_bootstrap_ops = {
.shutdown = fmc130m_4ch_shutdown,
.config_defaults = fmc130m_4ch_config_defaults
};
SMIO_MOD_DECLARE(FMC130M_4CH_SDB_DEVID, FMC130M_4CH_SDB_NAME, fmc130m_4ch_bootstrap_ops)
......@@ -7,8 +7,7 @@ include $(SRC_DIR)/sm_io/modules/fmc130m_4ch/fmc130m_4ch.mk \
sm_io_modules_DIR = $(SRC_DIR)/sm_io/modules
sm_io_modules_OBJS = $(sm_io_modules_DIR)/sm_io_mod_dispatch.o \
$(sm_io_modules_DIR)/sm_io_codes.o \
sm_io_modules_OBJS = $(sm_io_modules_DIR)/sm_io_codes.o \
$(sm_io_fmc130m_4ch_OBJS) \
$(sm_io_acq_OBJS) \
$(sm_io_dsp_OBJS) \
......
......@@ -389,3 +389,5 @@ const smio_bootstrap_ops_t rffe_bootstrap_ops = {
.shutdown = rffe_shutdown,
.config_defaults = rffe_config_defaults
};
SMIO_MOD_DECLARE(RFFE_DEVID, RFFE_NAME, rffe_bootstrap_ops)
/*
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU GPL, version 3 or any later version.
*/
#include "bpm_server.h"
/* Private headers. Include all available module we can handle */
#include "fmc130m_4ch/sm_io_fmc130m_4ch_exp.h"
#include "acq/sm_io_acq_exp.h"
#include "dsp/sm_io_dsp_exp.h"
#include "swap/sm_io_swap_exp.h"
#include "rffe/sm_io_rffe_exp.h"
#if defined (__BOARD_AFCV3__)
#include "afc_diag/sm_io_afc_diag_exp.h"
#endif
/* Table of all known modules we can handle */
const smio_mod_dispatch_t smio_mod_dispatch [] = {
{
.id = FMC130M_4CH_SDB_DEVID,
.name = FMC130M_4CH_SDB_NAME,
.bootstrap_ops = &fmc130m_4ch_bootstrap_ops
},
{
.id = ACQ_SDB_DEVID,
.name = ACQ_SDB_NAME,
.bootstrap_ops = &acq_bootstrap_ops
},
{
.id = DSP_SDB_DEVID,
.name = DSP_SDB_NAME,
.bootstrap_ops = &dsp_bootstrap_ops
},
{
.id = SWAP_SDB_DEVID,
.name = SWAP_SDB_NAME,
.bootstrap_ops = &swap_bootstrap_ops
},
{
.id = RFFE_DEVID, /* No SDB as this is not an FPGA module */
.name = RFFE_NAME,
.bootstrap_ops = &rffe_bootstrap_ops
},
#if defined (__BOARD_AFCV3__)
{
.id = AFC_DIAG_DEVID,
.name = AFC_DIAG_NAME,
.bootstrap_ops = &afc_diag_bootstrap_ops
},
#endif
{
.id = SMIO_DISPATCH_END_ID,
.name = "SMIO_DISPATCH_END",
.bootstrap_ops = NULL
}
};
......@@ -325,3 +325,5 @@ const smio_bootstrap_ops_t swap_bootstrap_ops = {
.shutdown = swap_shutdown,
.config_defaults = swap_config_defaults
};
SMIO_MOD_DECLARE(SWAP_SDB_DEVID, SWAP_SDB_NAME, swap_bootstrap_ops)
......@@ -42,6 +42,7 @@ void smio_startup (zsock_t *pipe, void *args)
th_boot_args_t *th_args = (th_boot_args_t *) args;
zsock_t *pipe_mgmt = pipe;
zsock_t *pipe_msg = th_args->pipe_msg;
volatile const smio_mod_dispatch_t *smio_mod_dispatch = &_smio_mod_dispatch;
/* Signal parent we are initializing */
zsock_signal (pipe_mgmt, 0);
......@@ -116,6 +117,7 @@ err_inst_id_str_alloc:
void smio_config_defaults (zsock_t *pipe, void *args)
{
th_config_args_t *th_args = (th_config_args_t *) args;
volatile const smio_mod_dispatch_t *smio_mod_dispatch = &_smio_mod_dispatch;
/* Signal parent we are initializing */
zsock_signal (pipe, 0);
......
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