Commit 44a68c0f authored by Leon Hiemstra's avatar Leon Hiemstra

MMAP format update, prepared pipe io

parent 9ef6c528
......@@ -124,6 +124,47 @@ bool Common::monitor(TermOutput& termout)
}
bool Common::pread(TermOutput& termout, const string addr, const uint offs, const int len)
{
bool ret, retval = false;
uint retcnt=0;
std::vector<int> nodes = path_to_node(addr);
std::string relative_addr = addr_to_relative_addr(addr);
std::string type = addr_to_type(addr);
std::string peripheral = addr_to_peripheral(addr);
ostringstream strs;
termout.strout << "[";
for(uint idx=0;idx<nodes.size();idx++) {
auto node = select_node(nodes[idx]);
uint node_nr = node_number(node);
if(idx > 0) termout.strout << ",";
strs.str(""); strs.clear();
ret = false;
try {
RegisterMap *regmap = node->get_RegisterMap();
uint32_t nvalues = (len<0 ? regmap->getSpan(relative_addr) : len);
std::vector<int> datavec;
if((ret=node->pread(strs, relative_addr, type, peripheral, offs, datavec, nvalues))) {
retcnt++;
}
} catch(std::exception& e) {
termout.strerr << e.what() << endl;
}
termout.strout << "(" << node_nr << (ret ? ",0,[" : ",1,[") << strs.str() << "])";
}
termout.strout << "]";
retval = (retcnt==nodes.size());
if(nodes.size() == 0) {
termout.strerr << "no nodes";
retval = false;
}
return retval;
}
bool Common::read(TermOutput& termout, const string addr, const uint offs, const int len)
{
bool ret, retval = false;
......
......@@ -55,6 +55,7 @@ public:
const uint offs, const std::vector<int>& data);
bool read(TermOutput& termout, const string addr, const uint offs, const int len);
bool pread(TermOutput& termout, const string addr, const uint offs, const int len);
std::vector<int> unb_pn__to__nodes(std::vector<int> unbs, std::vector<int> pns);
......
......@@ -270,7 +270,6 @@ bool UNBos::writeRegister(uint32_t addr, uint32_t nvalues, const uint32_t *data_
if(data_ptr==NULL) throw runtime_error("UNBos::writeRegister data_ptr=NULL");
if(isfifo) {
opcode = UNBOS_OPCODE_FIFO_WRITE;
cout << "UNBOS fifo write" << endl;
} else {
opcode = UNBOS_OPCODE_MEMORY_WRITE;
......
......@@ -109,7 +109,6 @@ class UNBos
protected:
uint32_t seq_nr;
udpsocket *commdev;
int leon;
public:
int count;
......
......@@ -42,7 +42,7 @@ using namespace std;
extern int debug;
Node::Node(const string ipaddr, const uint unb, const uint localnr, const std::string type,
const string firmware, const uint firmware_version) : unbos(ipaddr)
const string firmware, const uint firmware_version, const int nof_pipes) : unbos(ipaddr)
{
myIPaddr = ipaddr;
......@@ -56,11 +56,36 @@ Node::Node(const string ipaddr, const uint unb, const uint localnr, const std::s
Type=type;
syslog(LOG_INFO,"Uniboard=%d New node IP=%s type=%s localnr=%d globalnr=%d\n",
UniboardNr, myIPaddr.c_str(), Type.c_str(), LocalNr, GlobalNr);
read_pipe = new int*[nof_pipes];
write_pipe = new int*[nof_pipes];
Nof_pipes = nof_pipes;
for(int i=0;i<Nof_pipes;i++) {
read_pipe[i] = new int[2];
write_pipe[i] = new int[2];
}
for(int i=0;i<Nof_pipes;i++) {
pipe(read_pipe[i]);
pipe(write_pipe[i]);
}
}
Node::~Node()
{
for(int i=0;i<Nof_pipes;i++) {
close(read_pipe[i][0]);
close(read_pipe[i][1]);
close(write_pipe[i][0]);
close(write_pipe[i][1]);
}
delete periph_system;
for(int i=0;i<Nof_pipes;i++) {
delete []read_pipe[i];
delete []write_pipe[i];
}
delete []*read_pipe;
delete []*write_pipe;
}
bool Node::cread(ostringstream& strs,const string peripheral) {
......@@ -102,3 +127,16 @@ bool Node::mwrite(const std::string addr, const uint offs,
return periph_system->mwrite(addr, offs, data);
}
bool Node::pread(std::ostringstream& strs, const std::string relative_addr,
const std::string type, const std::string peripheral,
const uint offs, std::vector<int>& data, const uint len) {
// - make struct
// - put all in
// - write struct into my writepipe
// ---> my thread handles this transaction
// - wait for answer by reading my readpipe
// - return response
return true;
}
......@@ -61,6 +61,10 @@ class Node {
std::string Type;
UNBos unbos;
int Nof_pipes;
int **write_pipe;
int **read_pipe;
Periph_system *periph_system;
void print_node_nr(void) {
......@@ -71,7 +75,7 @@ class Node {
public:
Node(const std::string ipaddr,
const uint unb, const uint localnr, const std::string type,
const std::string firmware, const uint firmware_version);
const std::string firmware, const uint firmware_version, const int nof_pipes);
~Node();
uint ipaddr_to_id(const std::string ipaddr);
......@@ -89,6 +93,9 @@ class Node {
bool mwrite(const std::string addr, const uint offs,
const std::vector<int>& data);
bool pread(std::ostringstream& strs, const std::string relative_addr, const std::string type,
const std::string peripheral, const uint offs, std::vector<int>& data, const uint len);
RegisterMap * get_RegisterMap(void);
};
......
......@@ -191,7 +191,8 @@ void server_init(bool warm_start)
uint n = GLOBALNODE_to_NODE(gn);
string type = GLOBALNODE_to_TYPE(gn);
Node *node = new Node(nc.ipaddr, uniboardnr, n, type, nc.firmware, nc.version);
Node *node = new Node(nc.ipaddr, uniboardnr, n, type, nc.firmware, nc.version,
c_MAX_CONTROL_SERVERS);
nodelist.push_back(node);
}
SD.unb = new UniboardMap(nodelist);
......
......@@ -34,14 +34,16 @@ using namespace boost::numeric::ublas;
void mmap_add_register(RegisterMap& regmap,
std::string qsysname, std::string fullname,
uint base, uint span, uint32_t mask, uint32_t shift,
std::string perm, std::string type)
std::string perm, std::string type, std::string nof_slaves)
{
// TODO: use nof_slaves in case it will get >1...
// add full name register
regmap.add_register(fullname, base, span, mask, shift, perm, type);
// add qsys name register
if(!regmap.find_register(qsysname)) {
regmap.add_register(qsysname, base, span, mask, shift, perm, type);
} else {
} else if(nof_slaves == "-") {
uint update_base, update_span;
update_base = regmap.getBaseAddr(qsysname);
update_span = regmap.getSpan(qsysname);
......@@ -62,12 +64,12 @@ RegisterMap mmap_to_regmap(std::istringstream& iss)
RegisterMap regmap;
ostringstream err_str;
// unb2b rom_system info REG 0x00000000000 8192 RO b[31:0] PIO_SYSTEM_INFO
#define RE_MMAP_LINE_REG "^\\s*\\w+\\s+\\w+\\s+\\w+\\s+REG\\s+0x\\S+\\s+\\d+\\s+[R,W][O,W]\\s+b\\[\\d+:\\d+\\]\\s+\\w+\\s+.*$"
// eth1g eth data RAM 0x00000000800 1024 RW - AVS_ETH_0_RAM
#define RE_MMAP_LINE_RAM "^\\s*\\w+\\s+\\w+\\s+\\w+\\s+RAM\\s+0x\\S+\\s+\\d+\\s+[R,W][O,W]\\s+-\\s+\\w+\\s+.*$"
// epcs dpmm_data data FIFO 0x000000000e8 1 RO - REG_DPMM_DATA
#define RE_MMAP_LINE_FIFO "^\\s*\\w+\\s+\\w+\\s+\\w+\\s+FIFO\\s+0x\\S+\\s+\\d+\\s+[R,W][O,W]\\s+-\\s+\\w+\\s+.*$"
// unb2b rom_system info REG 0x00000000000 8192 RO b[31:0] 1 PIO_SYSTEM_INFO
#define RE_MMAP_LINE_REG "^\\s*\\w+\\s+\\w+\\s+\\w+\\s+REG\\s+0x\\S+\\s+\\d+\\s+[R,W][O,W]\\s+b\\[\\d+:\\d+\\]\\s+\\S+\\s+\\w+\\s*.*$"
// eth1g eth data RAM 0x00000000800 1024 RW - 1 AVS_ETH_0_RAM
#define RE_MMAP_LINE_RAM "^\\s*\\w+\\s+\\w+\\s+\\w+\\s+RAM\\s+0x\\S+\\s+\\d+\\s+[R,W][O,W]\\s+-\\s+\\S+\\s+\\w+\\s*.*$"
// epcs dpmm_data data FIFO 0x000000000e8 1 RO - 1 REG_DPMM_DATA
#define RE_MMAP_LINE_FIFO "^\\s*\\w+\\s+\\w+\\s+\\w+\\s+FIFO\\s+0x\\S+\\s+\\d+\\s+[R,W][O,W]\\s+-\\s+\\S+\\s+\\w+\\s*.*$"
boost::regex comment_re, spaces_re, REG_re, RAM_re, FIFO_re;
......@@ -89,7 +91,7 @@ RegisterMap mmap_to_regmap(std::istringstream& iss)
} else if (regex_match(line, REG_re)) {
cout << "import_mmap_file match: REG ok" << endl;
stringstream ss(line);
string type, perm, peripheral, regname, regfield, qsysname;
string type, perm, peripheral, regname, regfield, qsysname, nof_slaves;
unsigned long long base44;
uint base, span;
uint32_t mask,shift;
......@@ -110,6 +112,7 @@ RegisterMap mmap_to_regmap(std::istringstream& iss)
ss >> c; // ':'
ss >> dec >> mask_from;
ss >> c; // ']'
ss >> nof_slaves;
mask = 0;
for(uint i=mask_from;i<=mask_to;i++) {
......@@ -122,12 +125,12 @@ RegisterMap mmap_to_regmap(std::istringstream& iss)
cerr << "import_mmap_file: invalid REG" << endl;
} else {
mmap_add_register(regmap,"mm/"+qsysname,"mm/"+peripheral+"/"+regname+"/"+regfield,
base,span,mask,shift,perm,type);
base,span,mask,shift,perm,type,nof_slaves);
}
} else if (regex_match(line, RAM_re)) {
cout << "import_mmap_file match: RAM ok" << endl;
stringstream ss(line);
string type, perm, peripheral, regname, regfield, qsysname;
string type, perm, peripheral, regname, regfield, qsysname, nof_slaves;
unsigned long long base44;
uint base, span;
uint32_t mask,shift;
......@@ -142,6 +145,7 @@ RegisterMap mmap_to_regmap(std::istringstream& iss)
ss >> dec >> span; // in dwords
ss >> perm;
ss >> c; // '-'
ss >> nof_slaves;
mask = 0xffffffff;
shift = 0;
......@@ -151,12 +155,12 @@ RegisterMap mmap_to_regmap(std::istringstream& iss)
cerr << "import_mmap_file: invalid RAM" << endl;
} else {
mmap_add_register(regmap,"mm/"+qsysname,"mm/"+peripheral+"/"+regname+"/"+regfield,
base,span,mask,shift,perm,type);
base,span,mask,shift,perm,type,nof_slaves);
}
} else if (regex_match(line, FIFO_re)) {
cout << "import_mmap_file match: FIFO ok" << endl;
stringstream ss(line);
string type, perm, peripheral, regname, regfield, qsysname;
string type, perm, peripheral, regname, regfield, qsysname, nof_slaves;
unsigned long long base44;
uint base, span;
uint32_t mask,shift;
......@@ -171,6 +175,7 @@ RegisterMap mmap_to_regmap(std::istringstream& iss)
ss >> dec >> span; // in dwords
ss >> perm;
ss >> c; // '-'
ss >> nof_slaves;
mask = 0xffffffff;
shift = 0;
......@@ -180,7 +185,7 @@ RegisterMap mmap_to_regmap(std::istringstream& iss)
cerr << "import_mmap_file: invalid FIFO" << endl;
} else {
mmap_add_register(regmap,"mm/"+qsysname,"mm/"+peripheral+"/"+regname+"/"+regfield,
base,span,mask,shift,perm,type);
base,span,mask,shift,perm,type,nof_slaves);
}
} else {
cerr << "import_mmap_file: error! illegal line: [" << line << "]" << endl;
......
......@@ -6,6 +6,6 @@
#node 0 10.99.1.1 unb2b_minimal 2
#node 1 10.99.1.2 unb2b_minimal 2
node 2 10.99.1.3 unb2b_minimal 2
#node 3 10.99.1.4 unb2b_minimal 2
node 3 10.99.1.4 unb2b_minimal 2
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