Commit 44d873e2 authored by Benoit Rat's avatar Benoit Rat

WBNode: bug corrections (periph sync size)

The memory to retrieve should be the offset of the last register + the
register size (4)

Comments & Trace were also improved to ease debugging
parent 5ad30783
......@@ -21,22 +21,22 @@
#include <vector>
#include <cstdarg>
std::string string_format(const std::string &fmt, ...) {
int size = 512;
char* buffer = 0;
buffer = new char[size];
va_list vl;
va_start(vl, fmt);
int nsize = vsnprintf(buffer, size, fmt.c_str(), vl);
if(size<=nsize){ //fail delete buffer and try again
delete[] buffer;
buffer = 0;
buffer = new char[nsize+1]; //+1 for /0
nsize = vsnprintf(buffer, size, fmt.c_str(), vl);
}
std::string ret(buffer);
va_end(vl);
delete[] buffer;
return ret;
int size = 512;
char* buffer = 0;
buffer = new char[size];
va_list vl;
va_start(vl, fmt);
int nsize = vsnprintf(buffer, size, fmt.c_str(), vl);
if(size<=nsize){ //fail delete buffer and try again
delete[] buffer;
buffer = 0;
buffer = new char[nsize+1]; //+1 for /0
nsize = vsnprintf(buffer, size, fmt.c_str(), vl);
}
std::string ret(buffer);
va_end(vl);
delete[] buffer;
return ret;
}
//========================================================================
......@@ -621,9 +621,9 @@ bool WBNode::sync(WBMemCon* con, WBAccMode amode, uint32_t dma_dev_offset)
if(dma_dev_offset==WB_NODE_MEMBCK_OWNADDR) dma_dev_offset=address;
//Check if the latest register has the latest size.
prh_bsize=getLastReg()->getOffset()/sizeof(uint32_t);
prh_bsize=getLastReg()->getOffset()+4;
TRACE_P_DEBUG("%s 0x%08X + [0x0,0x%X]",getCName(),dma_dev_offset,getLastReg()->getOffset());
TRACE_P_DEBUG("%s 0x%08X + [0x0,0x%X] (DMA sync)",getCName(),dma_dev_offset,getLastReg()->getOffset());
//first write to dev
if(amode & WB_AM_W)
......
......@@ -156,7 +156,8 @@ public:
uint8_t getNOfFractionBit() const { return nfb; } //!< Get the number of fractional bit (0 for WBF_32U)
uint8_t getAccessMode() const { return mode; } //!< Get the mode of access
uint8_t getType() const { return type; } //!< Get the type of field
const WBReg* getReg() const { return pReg; } //!< Get the linked register
const WBReg* getReg() const { return pReg; } //!< Get the linked register (RO)
WBReg* getReg() { return pReg; } //!< Get the linked register
bool isOverflowPrevented() const { return checkOverflow; } //!< When true prevent overflow during FP conversion \ref regCvt(), \ ref convert()
protected:
......@@ -196,6 +197,7 @@ public:
const WBField* getField(const std::string& name) const;
const WBField* operator[](const std::string& name) const { return this->getField(name); }
std::vector<WBField*> getFields() { return fields; }
const std::vector<WBField*> getFields() const { return fields; } //!< Get a vector on the belonging WBField
const WBNode* getPrtNode() const { return pPrtNode; } //!< Get the parent WBNode
......@@ -268,11 +270,11 @@ private:
/**
* Virtual class to connect to a device memory in order to sync the WBnode structure.
* Polymorphic & abstract class to connect to a device memory in order to sync the WBnode structure.
*
* The child class:
* - must redefine single access to the memory
* - might redefine DMA access to the memory
* The inherited class:
* - must overload single access to the memory
* - might overload DMA access to the memory
*
* The child class will be defined for each type of physical driver used to access to our WB board.
*/
......
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