Commit 9b31ef9c authored by Benoit Rat's avatar Benoit Rat

all: big restructuration (part II) with EPICS build system

* EPICS Makefile system has been added
* asynWBPortDrvr is now EWBAsynPortDrvr
* EWBMem*Con classes are rename as EWBBgd* classes
* Improve Type and how to cast it in EWBParam
* Add children and peripheral to EWBBus (try to use sdb structure)
parent cf571844
......@@ -53,10 +53,17 @@ Thumbs.db
.cproject
.settings/*
# Project specific #
####################
# EPICS #
###################
O.*/
configure/
lib/
include/
*.depends
# Project specific #
####################
doc/html
doc/latex
doc/man
......@@ -70,4 +77,3 @@ doc/man
#Makefile at top of application tree
TOP = .
include $(TOP)/configure/CONFIG
DIRS += configure
DIRS += src
src_DEPEND_DIRS = configure
include $(TOP)/configure/RULES_TOP
# CONFIG
include $(TOP)/configure/RELEASE
-include $(TOP)/configure/RELEASE.$(EPICS_HOST_ARCH)
-include $(TOP)/configure/RELEASE.$(EPICS_HOST_ARCH).Common
ifdef T_A
-include $(TOP)/configure/RELEASE.Common.$(T_A)
-include $(TOP)/configure/RELEASE.$(EPICS_HOST_ARCH).$(T_A)
endif
CONFIG=$(EPICS_BASE)/configure
include $(CONFIG)/CONFIG
# Override for definition in base
INSTALL_LOCATION = $(TOP)
include $(TOP)/configure/CONFIG_SITE
-include $(TOP)/configure/CONFIG_SITE.$(EPICS_HOST_ARCH)
-include $(TOP)/configure/CONFIG_SITE.$(EPICS_HOST_ARCH).Common
ifdef T_A
-include $(TOP)/configure/CONFIG_SITE.Common.$(T_A)
-include $(TOP)/configure/CONFIG_SITE.$(EPICS_HOST_ARCH).$(T_A)
-include $(TOP)/configure/O.$(T_A)/CONFIG_APP_INCLUDE
endif
# CONFIG_SITE - site-specific build configuration settings
# To restrict the architectures to cross-compile for, set this:
#CROSS_COMPILER_TARGET_ARCHS = arm-linux-gnueabi
# To install somewhere other than $(TOP) set this:
#INSTALL_LOCATION_APP = <install path>
#Makefile
TOP=..
include $(TOP)/configure/CONFIG
# Set the following to NO to disable consistency checking of
# the support applications defined in $(TOP)/configure/RELEASE
CHECK_RELEASE = YES
TARGETS = $(CONFIG_TARGETS)
CONFIGS += $(subst ../,,$(wildcard $(CONFIG_INSTALLS)))
include $(TOP)/configure/RULES
# EPICS root directory
EPICS_ROOT=/home/epicsmgr/EPICS
# EPICS BASE
EPICS_BASE=$(EPICS_ROOT)/base
# asynchronous driver
ASYN=$(EPICS_ROOT)/support/asyn
##### Bridges
# Set the route of X1052/Jungo
X1052 = /usr/local/include/x1052
JUNGOWDVER=1010
JUNGOWD = /opt/windriver/${JUNGOWDVER}
JUNGOWD_OFF=0
# Set the route of etherbone
ETHB = /usr/local/include/
#CONFIG
include $(EPICS_BASE)/configure/RULES
# Library should be rebuilt because LIBOBJS may have changed.
$(LIBNAME): ../Makefile
#RULES_DIRS
include $(EPICS_BASE)/configure/RULES_DIRS
#RULES_TOP
include $(EPICS_BASE)/configure/RULES_TOP
......@@ -14,57 +14,21 @@
## ensure the GNU Lesser General Public License version 2.1 requirements
## will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
########################################################################
TOP = ..
include $(TOP)/configure/CONFIG
## Cross Compile
CC = $(CROSS_COMPILE)g++
LD = $(CROSS_COMPILE)ld
AR = $(CROSS_COMPILE)ar
OBJDUMP = $(CROSS_COMPILE)objdump
OBJCOPY = $(CROSS_COMPILE)objcopy
SIZE = $(CROSS_COMPILE)size
##Test with the flags (DOESN'T WORK)
USR_FLAGS=-DDEBUG_NO_WAY
CXXFLAGS=-Wall -g -DTRACE_STDERR -Wno-format
USR_CXXFLAGS +=$(CXXFLAGS)
USR_CXXFLAGS +=-Wno-maybe-uninitialized
## Config
-include $(CURDIR)/.config
DIRS += ewbcore
## Obtain the version ($ is replaced by $$)
VERSION = $(shell git describe --always --dirty=+ | sed 's;^.*-\([v0-9\.]*\)\([a-z0-9\-+]*\)$$;\1\2;' )
DATE = $(shell date +"%d %b. %Y")
DIRS += ewbbridge
ewbbridge_DEPEND_DIRS = ewbcore
## Flags
INCLUDE_DIR=-Iewbcore/ -Iewbdrige/ -Iasynwb
CXXFLAGS=-Wall -g -O3 -DTRACE_STDERR -std=c++11
## File processing
ODIR=output/
SRC_MAIN=$(wildcard ewbcore/*.cpp)
OBJ_MAIN=$(addprefix $(ODIR), $(SRC_MAIN:.cpp=.o))
all: main
ODIR_%: $(ODIR)$(subst ODIR_,,$@)
mkdir -p $(ODIR)$(subst ODIR_,,$@)
@echo ""
@echo ":==================================================================================================================>"
@echo ""
main: ODIR_ewbcore $(ODIR)libewbmain.a
@echo "----> libewbmain.a OK"
output/libewbmain.a: $(OBJ_MAIN)
$(AR) rc $@ $^ $(LDFLAGS)
bridge:
asynwb:
output/%.o: %.cpp
${CC} $(CXXFLAGS) $(INCLUDE_DIR) $(LIB_DIR) -c $*.cpp -o $@
clean_%:
rm -Rvf $(ODIR)$(subst clean_,,$@)
clean: clean_ewbcore
DIRS += ewbasyn
ewbbridge_DEPEND_DIRS = ewbcore ewbbridge
include $(TOP)/configure/RULES_DIRS
......@@ -9,13 +9,15 @@
*/
#ifndef ASYNWBORTDRVR_H_
#define ASYNWBORTDRVR_H_
#ifndef EWBASYNPORTDRVR_H_
#define EWBASYNPORTDRVR_H_
#include <string>
#include <map>
#include "WBNode.h"
#include "EWBBus.h"
#include "EWBParam.h"
#include "EWBField.h"
#include <asynPortDriver.h>
//! Type of synchronization between the memory, Wishbone tree and Process variable
......@@ -26,8 +28,8 @@ enum AsynWBSync {
AWB_SYNC_DERIVED, //!< Sync must be performed on the children class.
};
struct AsynWBField {
WBField* pFld;
struct EWBAsynPrm {
EWBParam* pPrm;
int syncmode;
};
......@@ -63,10 +65,10 @@ struct AsynStatusObj {
*
* \ref AsynWBSync
*/
class asynWBPortDrvr : public asynPortDriver {
class EWBAsynPortDrvr : public asynPortDriver {
public:
asynWBPortDrvr(const char *portName, int max_nprm);
virtual ~asynWBPortDrvr();
EWBAsynPortDrvr(const char *portName, int max_nprm);
virtual ~EWBAsynPortDrvr();
virtual asynStatus setup()=0; //!< Need to be overriden
virtual asynStatus readInt32(asynUser *pasynUser, epicsInt32 *value);
......@@ -81,17 +83,16 @@ public:
bool isValid() { return pRoot!=NULL; } //!< return true if the child class has been properly setup()
protected:
asynStatus syncPending(WBAccMode amode=WB_AM_RW);
asynStatus createParam(WBField *fld, int *index=NULL,int syncmode=AWB_SYNC_DEVICE);
asynStatus createParam(const char *name, WBField *fld, int *index=NULL, int syncmode=AWB_SYNC_DEVICE);
asynStatus syncPending(EWBSync::AMode amode=EWBSync::EWB_AM_RW);
asynStatus createParam(EWBField *fld, int *index=NULL,int syncmode=AWB_SYNC_DEVICE);
asynStatus createParam(const char *name, EWBParam *pPrm, int *index=NULL, int syncmode=AWB_SYNC_DEVICE);
asynStatus createParam(const char *name, asynParamType type,int *index=NULL,int syncmode=AWB_SYNC_PRMLIST);
bool cvtWBNodetoPrmList(WBNode *node);
//bool cvtWBNodetoPrmList(WBNode *node);
int getParamIndex(const char *name);
WBNode *pRoot; //!< pointer on the WB tree structure.
WBMemCon* pMemCon; //!< generic pointer on the memory connector.
EWBBus *pRoot; //!< pointer on the WB root tree structure.
std::vector<AsynWBField> fldPrms;
std::vector<EWBAsynPrm> fldPrms;
private:
std::string driverName;
int P_BlkSyncIdx, syncNow;
......
########################################################################
## Makefile to compile C++ object from a folder
##
## References:
##
## Authors:
## - Benoit Rat (Seven Solutions, www.sevensols.com)
##
## GNU Lesser General Public License Usage
## This file may be used under the terms of the GNU Lesser
## General Public License version 2.1 as published by the Free Software
## Foundation and appearing in the file LICENSE.LGPL included in the
## packaging of this file. Please review the following information to
## ensure the GNU Lesser General Public License version 2.1 requirements
## will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
########################################################################
TOP = ../..
include $(TOP)/configure/CONFIG
#----------------------------------------
# ADD MACRO DEFINITIONS AFTER THIS LINE
GIT_VER = $(shell git describe --always --dirty=+)
USR_CXXFLAGS +=$(USR_FLAGS)
USR_CXXFLAGS +=-D__GIT_VER__="\"$(GIT_VER)\""
LIBRARY_Linux = ewbasyn
ewbasyn_LIBS += ewbcore
ewbasyn_LIBS += ewbbridge
ewbasyn_LIBS += asyn
ewbasyn_SRCS +=EWBAsynPortDrvr.cpp
INC += $(ewbasyn_SRCS:.cpp=.h)
include $(TOP)/configure/RULES
#----------------------------------------
# ADD RULES AFTER THIS LINE
#ODIR=output/
#
#
#core: $(ODIR)ewbcore $(ODIR)libewbcore.a
# @echo "----> libewbcore.a OK"
#
#output/libewbcore.a: $(CORE_OBJS)
# $(AR) rc $@ $^ $(LDFLAGS)
#
#output/%.o: %.cpp
# ${CC} $(CXXFLAGS) $(INCLUDE_DIR) $(LIB_DIR) -c $*.cpp -o $@
#
### Directories
#$(ODIR)ewbcore:
# mkdir -p $(ODIR)ewbcore
#
#$(ODIR)ewbbridge:
# mkdir -p $(ODIR)ewbbridge
#
#clean_%:
# rm -Rvf $(ODIR)$(subst clean_,,$@)
#
#mrproper: clean_ewbcore
......@@ -5,10 +5,13 @@
* Author: Benoit Rat (benoit<AT>sevensols.com)
*/
#include "EWBMemTestFileCon.h"
#include "EWBBgdTestFile.h"
#include <cstring>
#include "awbpd_trace.h"
#include <EWBTrace.h>
#include <EWBPeriph.h>
#include <EWBReg.h>
#include <EWBBus.h>
#define TRACE_P_VDEBUG(...) TRACE_P_DEBUG( __VA_ARGS__)
......@@ -24,8 +27,8 @@
* BUFF_MAX_SIZEB for both read and write.
* It will also try to open the file.
*/
WBMemTestFileCon::WBMemTestFileCon(const std::string& fname)
: EWBMemCon(EWBMemCon::TFILE), fname(fname), lastpos(0)
EWBMemTestFileCon::EWBMemTestFileCon(const std::string& fname)
: EWBBridge(EWBBridge::TFILE), fname(fname), lastpos(0)
{
o_file.open(fname.c_str(),std::fstream::out|std::fstream::in);
TRACE_P_INFO("tfile=%d (%s)",o_file.is_open(),fname.c_str());
......@@ -39,7 +42,7 @@ WBMemTestFileCon::WBMemTestFileCon(const std::string& fname)
* - Close the file
* - Free the internal buffer
*/
WBMemTestFileCon::~WBMemTestFileCon()
EWBMemTestFileCon::~EWBMemTestFileCon()
{
o_file.close();
......@@ -50,11 +53,11 @@ WBMemTestFileCon::~WBMemTestFileCon()
/**
* Function that fill the file with the all the registers in the wishbone structure.
*/
void EWBMemTestFileCon::generate(WBNode* node)
void EWBMemTestFileCon::generate(EWBBus* pBus)
{
WBReg *reg=NULL;
EWBReg *reg=NULL;
uint32_t data;
if(node==NULL) return;
if(pBus==NULL) return;
//If the file does not exist it can't be open as in|out (only out)...
if(o_file.is_open()==false)
......@@ -65,16 +68,22 @@ void EWBMemTestFileCon::generate(WBNode* node)
o_file.open(fname.c_str(),std::fstream::out|std::fstream::in); //and reopen as in|out.
}
TRACE_P_DEBUG("%s (%d)",node->getCName(), node->getChildren().size());
while( (reg=node->getNextReg(reg)) != NULL)
std::vector<EWBPeriph *> periphs = pBus->getPeripherals();
for(size_t i=0;i<periphs.size();i++)
{
TRACE_P_VDEBUG("%s (@0x%08X) 0x%08x",reg->getCName(),reg->getOffset(true),reg->getData());
data=reg->getData();
mem_access(reg->getOffset(true),&data,true);
EWBPeriph *pPrh=periphs[i];
if(pPrh==NULL) continue;
TRACE_P_DEBUG("%d %s (0x%08x)",i,pPrh->getCName(), pPrh->getOffset(true));
while( (reg=pPrh->getNextReg(reg)) != NULL)
{
TRACE_P_VDEBUG("%s (@0x%08X) 0x%08x",reg->getCName(),reg->getOffset(true),reg->getData());
data=reg->getData();
mem_access(reg->getOffset(true),&data,true);
}
}
std::vector<WBNode *> children = node->getChildren();
std::vector<EWBBus *> children = pBus->getChildren();
for(size_t i=0;i<children.size();i++)
generate(children[i]);
}
......@@ -105,7 +114,7 @@ bool EWBMemTestFileCon::mem_access(uint32_t wb_addr, uint32_t* data, bool to_dev
else o_file.seekp(0,std::ios::end);
snprintf(buff,50,"0x%08X: %08x",wb_addr,*data);
TRACE_P_VDEBUG("%d <=> '%s' (g=%ld, p=%ld)",pos, buff, o_file.tellg(), o_file.tellp());
TRACE_P_VDEBUG("%d <=> '%s' (g=%ld, p=%ld)",pos, buff,(long int)o_file.tellg(), (long int)o_file.tellp());
o_file << buff << std::endl;
}
else //Reading from file
......
......@@ -10,12 +10,14 @@
#ifndef EWBMEMTFILECON_H_
#define EWBMEMTFILECON_H_
#include EWBNode.h"
#include "EWBBridge.h"
#include <iostream>
#include <fstream>
#include <string>
class EWBBus; //!< Forward declaration
/**
* Fake EWB memory connector by testing on a file
*
......@@ -33,12 +35,12 @@
* \endcode
*
*/
class EWBMemTestFileCon: public EWBMemCon {
class EWBMemTestFileCon: public EWBBridge {
public:
WBMemTestFileCon(const std::string& fname);
virtual EWBMemTestFileCon();
EWBMemTestFileCon(const std::string& fname);
virtual ~EWBMemTestFileCon();
void generate(WBNode* node);
void generate(EWBBus* root);
virtual bool isValid() { return o_file.is_open(); } //!< Return true if the file has been opened
bool mem_access(uint32_t addr, uint32_t *data, bool from_dev);
......
......@@ -4,21 +4,19 @@
* Created on: Oct 31, 2013
* Author: Benoit Rat (benoit<AT>sevensols.com)
*/
#include "awbpd_trace.h"
#ifndef EWBPD_NO_X1052
#define TRACE_H
#include <x1052_api.h>
#define TRACE_H 1 //TODO: Should be removed from <x1052_api.h>
#include <wdc_lib.h>
#include <x1052_api.h>
//TODO: Quick fix
#ifndef BOOL
#define BOOL int
#endif
#include EWBMemX1052Con.h"
#include "EWBBgdX1052.h"
#include "EWBTrace.h"
#define TRACE_P_VDEBUG(...) //TRACE_P_DEBUG( __VA_ARGS__)
#define TRACE_P_VVDEBUG(...) //TRACE_P_DEBUG( __VA_ARGS__)
......@@ -34,8 +32,8 @@ int EWBMemX1052Con::nHandles = -1; //!< Initiate static nHandles to count number
*
* \param[in] idxPCIe The index of PCIe slot for X1052 Devices
*/
WBMemX1052Con::WBMemX1052Con(int idxPCIe,uint32_t magic_addr, uint32_t magic_val)
: EWBMemCon(WBMemCon::X1052,"X1052"), hBiDma(NULL), hDev(NULL)
EWBMemX1052Con::EWBMemX1052Con(int idxPCIe,uint32_t magic_addr, uint32_t magic_val)
:EWBBridge(EWBBridge::X1052,"X1052"), hDev(NULL), hBiDma(NULL)
{
uint32_t dwStatus, tmp;
if(nHandles<0)
......@@ -70,7 +68,7 @@ WBMemX1052Con::WBMemX1052Con(int idxPCIe,uint32_t magic_addr, uint32_t magic_val
/* Find and open a X1052 device (by default ID) */
hDev = X1052_DeviceOpen(idxPCIe);
if(hDev) nHandles++;
TRACE_P_INFO("Slot Index #%d : hDev=0x%x (nHandles=%d)",idxPCIe,hDev,nHandles);
TRACE_P_INFO("Slot Index #%d : hDev=0x%x (nHandles=%d)",idxPCIe,(uint32_t)hDev,nHandles);
hBiDma= X1052_BiDMAGetHandle(hDev);
......@@ -102,7 +100,7 @@ WBMemX1052Con::WBMemX1052Con(int idxPCIe,uint32_t magic_addr, uint32_t magic_val
*
* It will close the handler on the PCIe device.
*/
WBMemX1052Con::~WBMemX1052Con()
EWBMemX1052Con::~EWBMemX1052Con()
{
uint32_t dwStatus;
if(hDev)
......@@ -134,19 +132,19 @@ bool EWBMemX1052Con::isValid()
/**
* Single 32bit access to the wishbone device (seen as a memory map)
*
* \param[in] wb_addr The address of the data we want to access.
* \param[in] addr The address of the data we want to access.
* \param[inout] data the read "read from/write to" the device.
* \param[in] to_dev if true we write to the device.
* \see X1052_Wishbone_CSR() function
*/
bool EWBMemX1052Con::mem_access(uint32_t wb_addr, uint32_t* data, bool to_dev)
bool EWBMemX1052Con::mem_access(uint32_t addr, uint32_t* data, bool to_dev)
{
int status;
TRACE_CHECK_PTR(hDev,false);
status=X1052_Wishbone_CSR(hDev,wb_addr,data,(int)to_dev);
TRACE_CHECK_VA(status==S_OK,false,"%s@%08X %s %08x (%d)",(to_dev)?"W":"R", wb_addr,(to_dev)?"=>":"<=",*data,status);
TRACE_P_VDEBUG("%s@%08X %s %08x (%d)",(to_dev)?"W":"R", wb_addr,(to_dev)?"=>":"<=",*data,status);
status=X1052_Wishbone_CSR(hDev,addr,data,(int)to_dev);
TRACE_CHECK_VA(status==S_OK,false,"%s@%08X %s %08x (%d)",(to_dev)?"W":"R", addr,(to_dev)?"=>":"<=",*data,status);
TRACE_P_VDEBUG("%s@%08X %s %08x (%d)",(to_dev)?"W":"R", addr,(to_dev)?"=>":"<=",*data,status);
return (status==S_OK);
}
......
......@@ -38,7 +38,7 @@ typedef void * X1052_BIDMA_HANDLE; //!< Hack to not include all the X1052 api in
class EWBMemX1052Con: public EWBBridge {
public:
EWBMemX1052Con(int idPCIe,uint32_t magic_addr=0xFFFFFFFF, uint32_t magic_val=-1);
virtual EWBMemX1052Con();
virtual ~EWBMemX1052Con();
bool isValid();
......
/*
* EWBCmdConsole.cpp
*
* Created on: Aug 10, 2015
* Author: Benoit Rat (benoit<AT>sevensols.com)
*/
#include "EWBCmdConsole.h"
EWBCmdConsole::EWBCmdConsole() {
// TODO Auto-generated constructor stub
}
EWBCmdConsole::~EWBCmdConsole() {
// TODO Auto-generated destructor stub
}
......@@ -9,12 +9,13 @@
#define EWBCMDCONSOLE_H_
#include <EWBSync.h>
#include <string>
class EWBCmdConsole {
public:
enum Type { UNKNOWN=-1, SERIAL, MEMVUART, ETHVUART };
enum CmdType { UNKNOWN=-1, SERIAL, MEMVUART, ETHVUART };
EWBCmdConsole(Type t): _type(t) {};
EWBCmdConsole(EWBCmdConsole::CmdType t): _type((int)t) {};
virtual ~EWBCmdConsole() {};
virtual void writeCmd(std::string cmd, std::string value)=0;
......@@ -22,10 +23,10 @@ public:
virtual const std::string& getInfo() const =0;
virtual bool isValid() const =0;
Type getType() const { return _type; }
int getType() const { return _type; }
protected:
Type _type;
int _type;
};
......@@ -38,20 +39,6 @@ class EWBSerialConsole: public EWBCmdConsole {
};
/**
* Class that wrap the EWBCmdConsole class to improve parsing of WR consoles
*/
class EWBWRConsole: public EWBCmdConsole {
EWBWRConsole(EWBCmdConsole *term, int rgui_ms);
virtual ~EWBWRConsole();
void writeCmd(std::string cmd, std::string value) { term->writeCmd(cmd,value); }
std::string getCmd(std::string cmd);
const std::string& getInfo() const { return term->getInfo(); }
Type getType() const { return term->getType(); }
private:
EWBCmdConsole *term; //!< This is the real terminal
};
#endif /* EWBCMDCONSOLE_H_ */
/*
* EWBConsoleWR.cpp
*
* Created on: Aug 20, 2015
* Author: Benoit Rat (benoit<AT>sevensols.com)
*/
#include "EWBConsoleWR.h"
EWBConsoleWR::EWBConsoleWR(EWBCmdConsole *term, float rgui_s)
:EWBCmdConsole(UNKNOWN),term(term),rgui_nclick((clock_t)rgui_s*CLOCKS_PER_SEC), t_last(0)
{
if(term) _type=(EWBCmdConsole::CmdType)term->getType();
// TODO Auto-generated constructor stub
}
EWBConsoleWR::~EWBConsoleWR() {
// TODO Auto-generated destructor stub
}
/**
* This specific function improve the access to the GUI
* interface by making only one access to `gui` command
* each rgui_ms.
*/
std::string EWBConsoleWR::getCmd(std::string cmd)
{
if(cmd=="gui")
{
if(clock() - t_last > rgui_nclick)
{
lastgui=term->getCmd(cmd);
t_last=clock();
}
return lastgui;
}
return term->getCmd(cmd);
}
/*
* EWBConsoleWR.h
*
* Created on: Aug 20, 2015
* Author: Benoit Rat (benoit<AT>sevensols.com)
*/
#ifndef EWBCONSOLEWR_H_
#define EWBCONSOLEWR_H_
#include "EWBCmdConsole.h"
#include <ctime>
/**
* Class that wrap the EWBCmdConsole class to improve parsing of WR consoles
*/
class EWBConsoleWR: public EWBCmdConsole {
public:
EWBConsoleWR(EWBCmdConsole *term, float rgui_s=0.1);
virtual ~EWBConsoleWR();
void writeCmd(std::string cmd, std::string value) { term->writeCmd(cmd,value); }
std::string getCmd(std::string cmd);
const std::string& getInfo() const { return term->getInfo(); }
int getType() const { return term->getType(); }
private:
EWBCmdConsole *term; //!< This is the real terminal
clock_t rgui_nclick;
clock_t t_last;
std::string lastgui;
};
#endif /* EWBCONSOLEWR_H_ */
########################################################################
## Makefile to compile C++ object from a folder
##
## References:
##
## Authors:
## - Benoit Rat (Seven Solutions, www.sevensols.com)
##
## GNU Lesser General Public License Usage
## This file may be used under the terms of the GNU Lesser
## General Public License version 2.1 as published by the Free Software
## Foundation and appearing in the file LICENSE.LGPL included in the
## packaging of this file. Please review the following information to
## ensure the GNU Lesser General Public License version 2.1 requirements
## will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
########################################################################
TOP = ../..
include $(TOP)/configure/CONFIG
#----------------------------------------
# ADD MACRO DEFINITIONS AFTER THIS LINE
GIT_VER = $(shell git describe --always --dirty=+)
USR_CXXFLAGS +=$(USR_FLAGS)
USR_CXXFLAGS +=-D__GIT_VER__="\"$(GIT_VER)\""
LIBRARY_Linux = ewbbridge
ewbbridge_LIBS += ewbcore
ewbbridge_SRCS +=EWBBridge.cpp
ewbbridge_SRCS +=EWBConsoleWR.cpp
ewbbridge_SRCS +=EWBBgdTestFile.cpp
### Add external library for bridge
ifeq ($(JUNGOWD_OFF),1)
USR_CXXFLAGS +=-DAWBPD_NO_X1052
else
ewbbridge_SRCS +=EWBBgdX1052.cpp
USR_INCLUDES +=-I$(JUNGOWD) -I$(JUNGOWD)/include
USR_INCLUDES +=-I$(X1052) -I$(X1052)/include
USR_SYS_LIBS += x1052_api
USR_SYS_LIBS += wdapi$(JUNGOWDVER)
endif
INC += $(ewbbridge_SRCS:.cpp=.h)
include $(TOP)/configure/RULES
#----------------------------------------
# ADD RULES AFTER THIS LINE
#ODIR=output/
#
#
#core: $(ODIR)ewbcore $(ODIR)libewbcore.a
# @echo "----> libewbcore.a OK"
#
#output/libewbcore.a: $(CORE_OBJS)
# $(AR) rc $@ $^ $(LDFLAGS)
#
#output/%.o: %.cpp
# ${CC} $(CXXFLAGS) $(INCLUDE_DIR) $(LIB_DIR) -c $*.cpp -o $@
#
### Directories
#$(ODIR)ewbcore:
# mkdir -p $(ODIR)ewbcore
#
#$(ODIR)ewbbridge:
# mkdir -p $(ODIR)ewbbridge
#
#clean_%:
# rm -Rvf $(ODIR)$(subst clean_,,$@)
#
#mrproper: clean_ewbcore
/*
* EWBBus.cpp
*
* Created on: Aug 19, 2015
* Author: Benoit Rat (benoit<AT>sevensols.com)
*/
#include "EWBBus.h"
#include "EWBPeriph.h"
#include "EWBTrace.h"
#include "ewbbridge/EWBBridge.h"
EWBBus::EWBBus(EWBBridge *b, uint32_t base_offset, EWBBus *parent)
: b(b), base_offset(base_offset), parent(parent)
{
if(parent)
{
bool added = parent->appendChild(this);
if(added==false)
{
parent=NULL;
TRACE_P_WARNING("Could not append to parent");
}
}
};
EWBBus::~EWBBus()
{
for(size_t j=0;j<periphs.size();j++)
{
if(periphs[j]) delete periphs[j];
}
for(size_t j=0;j<children.size();j++)
{
if(children[j]) delete children[j];
}
}
bool EWBBus::isValid(int level) const
{
return ((level!=0)? (b && b->isValid()) : (b!=NULL) );
}
bool EWBBus::appendPeriph(EWBPeriph *pPrh)
{
if(pPrh)
{
//Adding to vector
periphs.push_back(pPrh);
return true;
}
return false;
}
bool EWBBus::appendChild(EWBBus *pBus)
{
if(pBus)
{
//Might check if already exist
//Adding to vector
children.push_back(pBus);
return true;
}
return false;
}
......@@ -8,29 +8,38 @@
#ifndef EWBBUS_H_
#define EWBBUS_H_
#include "../ewbbridge/EWBBridge.h"
#include <cstdint>
#include <stdint.h>
#include <cstddef>
#include <vector>
class EWBBridge;
class EWBPeriph;
/**
* Simple class that help us connecting different peripheral to a bus or a sub bus.
*/
class EWBBus {
public:
EWBBus(EWBBridge *b, uint32_t base_offset): b(b), base_offset(base_offset) {};
EWBBus(EWBBridge *b, uint32_t base_offset, EWBBus *parent=NULL);
virtual ~EWBBus();
const EWBBridge* getBridge() const { return b; }
EWBBridge* getBridge() { return b; }
uint32_t getOffset() const { return base_offset; }
bool isValid(bool connected=true) const { return (connected? (b && b->isValid()) : (b!=NULL) ); }
bool isValid(int level=-1) const;
const std::vector<EWBBus*>& getChildren() const { return children; }
const std::vector<EWBPeriph*>& getPeripherals() const { return periphs; }
bool appendPeriph(EWBPeriph *pPrh);
bool appendChild(EWBBus *bus);
protected:
EWBBridge *b;
uint32_t base_offset;
EWBBus *parent;
std::vector<EWBBus *> children;
std::vector<EWBPeriph *> periphs;
};
#endif /* EWBBUS_H_ */
......@@ -11,6 +11,8 @@
#include "EWBPeriph.h"
#include "EWBTrace.h"
#include "ewbbridge/EWBBridge.h"
#include <iostream>
#include <cmath>
#include <string>
......@@ -19,6 +21,15 @@
#include <ctype.h>
#include <limits>
#ifdef vxWorks
template<typename T>
inline bool isinf(T value)
{
return std::numeric_limits<T>::has_infinity &&
value == std::numeric_limits<T>::infinity();
}
#endif
#define TRACE_P_VDEBUG(...) //TRACE_P_DEBUG( __VA_ARGS__)
#define TRACE_P_VVDEBUG(...) //TRACE_P_DEBUG( __VA_ARGS__)
......@@ -44,7 +55,7 @@ EWBField::EWBField(EWBReg *pReg,
const std::string &name, uint8_t width,
uint8_t shift, uint8_t mode, const std::string &desc,
uint8_t signess, uint8_t nfb, int index, double iniVal):
EWBParam(name,0,mode,desc)
EWBParam(name,EWBF_TM_TYPE_FIELD,mode,desc)
{
if((width+shift)>32) TRACE_P_WARNING("width (%d) + shift (%d) <= 32 bits",width,shift);
......@@ -61,7 +72,7 @@ EWBField::EWBField(EWBReg *pReg,
this->pReg=pReg;
this->width=width;
this->shift=shift;
this->type=(signess & EWBF_TM_SIGNESS);
this->type |=(signess & EWBF_TM_SIGNESS);
if(nfb>0) this->type|=EWBF_TM_FIXED_POINT;
this->nfb=nfb;
this->forceSync=false;
......@@ -119,11 +130,11 @@ void EWBField::getLimit(float &fmin, float &fmax)
fmin=-((float)(1ULL<<(width-1))-1);
fmax=(float)(1ULL<<(width-1))-1;
break;
case EWBF_TM_SIGN_2COMP: //2C Signed Integer
case EWBF_32I2C: //2C Signed Integer
fmin=-(float)(1ULL<<(width-1));
fmax=(float)(1ULL<<(width-1))-1;
break;
case EWBF_TM_FIXED_POINT: //Unsigned Fixed Point (0x4)
case EWBF_32FPU: //Unsigned Fixed Point
fmin=0;
fmax=(float)(1ULL<<(width-nfb));
fmax-=1.f/(1ULL<<nfb);
......@@ -240,7 +251,7 @@ bool EWBField::regCvt(float *value, uint32_t *reg_data, bool to_value) const
ret=this->regCvt(&fixed,reg_data,to_value);
}
break;
case EWBF_TM_SIGN_2COMP:
case EWBF_32I2C:
if(to_value)
{
ret=this->regCvt(&fixed,reg_data,to_value);
......@@ -259,7 +270,7 @@ bool EWBField::regCvt(float *value, uint32_t *reg_data, bool to_value) const
ret=this->regCvt(&fixed,reg_data,to_value);
}
break;
case EWBF_TM_FIXED_POINT: //Unsigned Fixed point conversion
case EWBF_32FPU: //Unsigned Fixed point conversion
if(to_value)
{
ret=this->regCvt(&fixed,reg_data,to_value);
......@@ -357,6 +368,7 @@ bool EWBField::convert(float *pVal, bool to_value)
bool EWBField::setToSync()
{
TRACE_CHECK_PTR(pReg,false);
this->toSync=true;
pReg->toSync=true;
return true;
}
......
......@@ -12,6 +12,9 @@
#include <string>
class EWBField; //!< Forward declaration
class EWBParamStr; //!< Forward declaration
/**
* Generic class that represent a parameter that need to
......@@ -26,10 +29,14 @@ public:
//! Type Mask (Used by EWBField)
enum TMask {
EWBF_TM_SIGNESS = 0x3,
EWBF_TM_SIGN_UNSIGNED = 0x0,
EWBF_TM_SIGN_MSB = 0x1,
EWBF_TM_SIGN_2COMP = 0x2,
EWBF_TM_SIGNESS = 0x3,
EWBF_TM_FIXED_POINT = 0x4,
EWBF_TM_TYPENESS = 0x3 << 6, //(0b11000000)
EWBF_TM_TYPE_FIELD = 0x1 << 6,
EWBF_TM_TYPE_STRING = 0x2 << 6,
};
//! Type of EWBField available
......@@ -37,27 +44,34 @@ public:
//! Automatic Type
EWBF_AUTO=0xFF,
//! Unsigned integer field
EWBF_32U=0,
//! Signed integer field
EWBF_32I=1,
EWBF_32U=(EWBF_TM_TYPE_FIELD | EWBF_TM_SIGN_UNSIGNED),
//! MSB Signed integer field
EWBF_32I=(EWBF_TM_TYPE_FIELD | EWBF_TM_SIGN_MSB),
//! 2'complements Signed integer
EWBF_32I2C=(EWBF_TM_TYPE_FIELD | EWBF_TM_SIGN_2COMP),
//! Fixed point field with highest bit signed
EWBF_32FP = (EWBF_TM_FIXED_POINT | EWBF_TM_SIGN_MSB),
EWBF_32FPU = (EWBF_TM_TYPE_FIELD | EWBF_TM_FIXED_POINT | EWBF_TM_SIGN_UNSIGNED),
//! Fixed point field with highest bit signed
EWBF_32FP = (EWBF_TM_TYPE_FIELD | EWBF_TM_FIXED_POINT | EWBF_TM_SIGN_MSB),
//! Fixed point field with 2'complements signed
EWBF_32F2C =(EWBF_TM_FIXED_POINT | EWBF_TM_SIGN_2COMP),
EWBF_32F2C =(EWBF_TM_TYPE_FIELD | EWBF_TM_FIXED_POINT | EWBF_TM_SIGN_2COMP),
//! String parameters
EWBF_STRING,
EWBF_STRING = EWBF_TM_TYPE_STRING,
};
const std::string& getName() const { return name; } //!< Get the name
const char *getCName() const { return name.c_str(); } //!< Get the name in "C" format for printf function
const std::string& getDesc() const { return desc; } //!< Get the description
uint8_t getType() const { return type; } //!< Get the type of field
EWBField* castField() { return ((type&EWBF_TM_TYPENESS)==EWBF_TM_TYPE_FIELD)?(EWBField*)this:NULL; } //!< Cast to EWBField* if possible otherwise return NULL
EWBParamStr* castParamStr() { return ((type&EWBF_TM_TYPENESS)==EWBF_TM_TYPE_STRING)?(EWBParamStr*)this:NULL; } //!< Cast to EWBParamStr* if possible otherwise return NULL
protected:
std::string name; //!< Name of the EWBField
uint8_t type; //!< Type of data
std::string desc; //!< Description
};
......
......@@ -7,7 +7,8 @@
#include "EWBParamStrCmd.h"
#include "../ewbbridge/EWBCmdConsole.h"
#include "ewbbridge/EWBCmdConsole.h"
#include <iostream>
#include <string>
......
......@@ -12,6 +12,7 @@
#include "EWBBus.h"
#include <map>
#include <string>
//Forward declaration to improve compilation
class EWBBridge;
......
......@@ -11,6 +11,7 @@
#include "EWBPeriph.h"
#include "EWBTrace.h"
#include "ewbbridge/EWBBridge.h"
#include <iostream>
......
......@@ -8,7 +8,7 @@
#ifndef EWBSYNC_H_
#define EWBSYNC_H_
#include <cstdint>
#include <stdint.h>
/**
......@@ -25,12 +25,13 @@ public:
virtual bool sync(EWBSync::AMode mode) = 0;
virtual bool isValid(int level=-1) const = 0;
bool setToSync() { toSync=true; return toSync; }
void setForceSync(bool val=true) { this->forceSync=val; };
uint8_t getAccessMode() const { return mode; } //!< Get the mode of access
bool isModeRead() const { return mode==EWB_AM_R; }; //!< Return @true if this parameter can be read from the device.
bool isModeWrite() const { return mode==EWB_AM_W; }; //!< Return @true if this parameter can be written to the device.
bool isToSync() const { return toSync; }
protected:
uint8_t mode;
......
......@@ -5,7 +5,7 @@
* Author: Benoit Rat (benoit<AT>sevensols.com)
*/
#include "EWBTrace.h"
#include <EWBTrace.h>
#include <string>
#include <vector>
......
########################################################################
## Makefile to compile C++ object from a folder
##
## References:
##
## Authors:
## - Benoit Rat (Seven Solutions, www.sevensols.com)
##
## GNU Lesser General Public License Usage
## This file may be used under the terms of the GNU Lesser
## General Public License version 2.1 as published by the Free Software
## Foundation and appearing in the file LICENSE.LGPL included in the
## packaging of this file. Please review the following information to
## ensure the GNU Lesser General Public License version 2.1 requirements
## will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
########################################################################
TOP = ../..
include $(TOP)/configure/CONFIG
#----------------------------------------
# ADD MACRO DEFINITIONS AFTER THIS LINE
GIT_VER = $(shell git describe --always --dirty=+)
LIBRARY_Linux = ewbcore
#ewbcore_LIBS =
ewbcore_SRCS +=EWBBus.cpp
ewbcore_SRCS +=EWBField.cpp
ewbcore_SRCS +=EWBParam.cpp
ewbcore_SRCS +=EWBParamStrCmd.cpp
ewbcore_SRCS +=EWBPeriph.cpp
ewbcore_SRCS +=EWBReg.cpp
ewbcore_SRCS +=EWBTrace.cpp
INC +=EWBSync.h
INC += $(ewbcore_SRCS:.cpp=.h)
USR_CXXFLAGS +=$(USR_FLAGS)
#USR_CXXFLAGS +=$(CXX_FLAGS)
USR_CXXFLAGS +=-std=c++0x
USR_CXXFLAGS +=-D__GIT_VER__="\"$(GIT_VER)\""
USR_CXXFLAGS +=-I../../
include $(TOP)/configure/RULES
#----------------------------------------
# ADD RULES AFTER THIS LINE
#ODIR=output/
#
show:
@echo "INC=$(INC)"
@echo "ewbcore_SRC=$(ewb_SRCS)"
#
#core: $(ODIR)ewbcore $(ODIR)libewbcore.a
# @echo "----> libewbcore.a OK"
#
#output/libewbcore.a: $(CORE_OBJS)
# $(AR) rc $@ $^ $(LDFLAGS)
#
#output/%.o: %.cpp
# ${CC} $(CXXFLAGS) $(INCLUDE_DIR) $(LIB_DIR) -c $*.cpp -o $@
#
### Directories
#$(ODIR)ewbcore:
# mkdir -p $(ODIR)ewbcore
#
#$(ODIR)ewbbridge:
# mkdir -p $(ODIR)ewbbridge
#
#clean_%:
# rm -Rvf $(ODIR)$(subst clean_,,$@)
#
#mrproper: clean_ewbcore
......@@ -56,11 +56,11 @@ GTEST_SRCS_ = $(GTEST_DIR)/src/*.cc $(GTEST_DIR)/src/*.h $(GTEST_HEADERS)
all: ewb_test
main: ../src/output/libewbmain.a $(TESTS_MAIN)
main: $(TESTS_MAIN)
../src/output/libewbmain.a:
make -C $(ODIR)
../lib/linux-x86/%.a:
make -C .. /
# For simplicity and to avoid depending on Google Test's
......@@ -87,7 +87,7 @@ gtest_main.a : gtest-all.o gtest_main.o
${CC} $(CPPFLAGS) $(CXXFLAGS) $(INCLUDE_DIR) -c $*.cpp -o $@
#Final app
ewb_test: ewb_test.o EWBFakeWRConsole.o $(OBJ_MAIN) ../src/output/libewbmain.a gtest_main.a
ewb_test: ewb_test.o EWBFakeWRConsole.o $(OBJ_MAIN) ../lib/linux-x86/libewbcore.a ../lib/linux-x86/libewbbridge.a gtest_main.a
${CC} $(CPPFLAGS) $(CXXFLAGS) $(LFLAGS) $^ -o $@
clean:
......
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