Commit 40c5626c authored by Leon Hiemstra's avatar Leon Hiemstra

integrated dev and mm in register 'file' tree

parent 1689a39b
......@@ -72,6 +72,8 @@ CMDstatus CMD::command(string line, TermOutput& termout, string& cmdname, Server
*/
if(cmd == INFO) {
req_ret = Info(argc,argv,termout,sd);
} else if(cmd == CAT) {
req_ret = Cat(argc,argv,termout,sd);
} else if(cmd == VERBOSE) {
req_ret = Verbose(argc,argv,termout,sd);
} else if(cmd == MREAD) {
......@@ -200,13 +202,7 @@ CMDstatus CMD::Info(int argc, char* argv[], TermOutput& termout, Serverdat *sd)
"Node local number: [0:3] for PN 0, 1, 2 and 3")
("unb", po::value<std::string>(),
"UniBoard number: [0,2:4] for UniBoard 0, 2, 3 and 4")
("whois", "shows who is who")
("name", "display design name")
("system,c", "display system config data")
("regmap,l", "display memory map")
("note,o", "display design note")
("stamps,t", "display stamps: date,time,svn")
("sensors,s","display sensor data")
("list,l", "display uniboard map")
;
try {
......@@ -242,42 +238,19 @@ CMDstatus CMD::Info(int argc, char* argv[], TermOutput& termout, Serverdat *sd)
nodes=sd->unb->get_nodes();
}
if (vm.count("whois")) {
termout.strout << "Selected global nodes: [";
for(uint i=0;i<nodes.size();i++) {
if(i>0) termout.strout << ",";
termout.strout << nodes[i];
}
termout.strout << "]" << endl;
for(uint i=0;i<nodes.size();i++) {
termout.strout << "gn=" << nodes[i]
<< " uniboardnr:" << GLOBALNODE_to_UNB(nodes[i])
<< " type:" << GLOBALNODE_to_TYPE(nodes[i])
<< " node:" << GLOBALNODE_to_NODE(nodes[i]) << endl;
}
}
if(nodes.size()==0) throw runtime_error("missing argument(s), add options: --gn or --unb,--pn");
if (vm.count("system")) {
if(!sd->unb->get_system_info(termout,nodes,"system")) return ret;
}
if(vm.count("regmap")) {
if(!sd->unb->get_system_info(termout,nodes,"regmap")) return ret;
}
if(vm.count("name")) {
if(!sd->unb->get_system_info(termout,nodes,"name")) return ret;
}
if(vm.count("note")) {
if(!sd->unb->get_system_info(termout,nodes,"note")) return ret;
}
if(vm.count("stamps")) {
if(!sd->unb->get_system_info(termout,nodes,"stamps")) return ret;
}
if(vm.count("sensors")) {
if(!sd->unb->get_system_info(termout,nodes,"sensors")) return ret;
if(vm.count("list")) {
for(auto node : nodes) {
RegisterMap *regmap = sd->unb->get_RegisterMap(termout, node);
std::string prefix = sd->unb->string_node_id(node);
std::vector<std::string> regnames = regmap->getRegnames_full(prefix);
for(auto m : regnames) {
termout.strout << m << endl;
}
}
}
string what_str="";
ret.status=CMD_STATUS_OK;
} catch(po::error& e) {
termout.strerr << e.what() << endl;
......@@ -453,6 +426,36 @@ CMDstatus CMD::Mwrite(int argc, char* argv[], TermOutput& termout, Serverdat *sd
return ret;
}
CMDstatus CMD::Cat(int argc, char* argv[], TermOutput& termout, Serverdat *sd)
{
CMDstatus ret={CMD_STATUS_ERROR,0,0};
po::options_description desc("concatenate files and print on the standard output");
desc.add_options()
("help,h", "shows this help text")
("file,f", po::value<std::string>(), "filename")
;
try {
po::variables_map vm;
po::store(po::parse_command_line(argc,argv,desc), vm);
po::notify(vm);
if (vm.count("help")) {
termout.strhuman << "usage: " << CAT << " [options]" << endl << "Options: " << desc;
return {CMD_STATUS_OK,0,0};
} else if (vm.count("file")) {
string filename=vm["file"].as<string>();
if(sd->unb->read(termout,filename)) ret.status=CMD_STATUS_OK;
} else throw runtime_error("missing argument(s)");
} catch(po::error& e) {
termout.strerr << e.what() << endl;
} catch(std::exception& e) {
termout.strerr << e.what() << endl;
}
return ret;
}
/***********************
* End user commands *
***********************/
......
......@@ -34,7 +34,7 @@ private:
const std::string VERBOSE="verbose";
const std::string QUIT="quit";
const std::string INFO="ls";
const std::string SETUP="set";
const std::string CAT="cat";
const std::string MREAD="mread";
const std::string MWRITE="mwrite";
......@@ -45,7 +45,7 @@ private:
// (3)
CMDstatus Info(int argc, char* argv[], TermOutput& termout, Serverdat *sd);
CMDstatus Setup(int argc, char* argv[], TermOutput& termout, Serverdat *sd);
CMDstatus Cat(int argc, char* argv[], TermOutput& termout, Serverdat *sd);
CMDstatus Verbose(int argc, char* argv[], TermOutput& termout, Serverdat *sd);
CMDstatus Mread(int argc, char* argv[], TermOutput& termout, Serverdat *sd);
CMDstatus Mwrite(int argc, char* argv[], TermOutput& termout, Serverdat *sd);
......@@ -57,7 +57,7 @@ private:
supported_cmds.push_back(HELP);
supported_cmds.push_back(QUIT);
supported_cmds.push_back(INFO);
supported_cmds.push_back(SETUP);
supported_cmds.push_back(CAT);
supported_cmds.push_back(MREAD);
supported_cmds.push_back(MWRITE);
}
......
......@@ -47,8 +47,6 @@ Node * Common::select_node(const int nr)
void Common::print_node_id(ostringstream& strs, Node *node)
{
//strs << "node[" << node->GetUniboardNr() << "." << node->GetType()
// << node->GetLocalNr() << "]:" << endl;
strs << "/unb" << node->GetUniboardNr() << "/" << node->GetType()
<< node->GetLocalNr() << "/" << endl;
}
......@@ -59,16 +57,6 @@ std::string Common::string_node_id(int node)
return "/unb" + to_string(n->GetUniboardNr()) + "/" + n->GetType() + to_string(n->GetLocalNr()) + "/";
}
std::string Common::string_mm(void)
{
return "mm/";
}
std::string Common::string_peripheral(void)
{
return "dev/";
}
std::vector<int> Common::get_nodes(void)
{
std::vector<int> nodes;
......@@ -94,20 +82,8 @@ bool Common::get_system_info(TermOutput& termout, std::vector<int> nodes, const
RegisterMap * Common::get_RegisterMap(TermOutput& termout, int node)
{
//bool retval=false;
//uint retcnt=0;
auto n = select_node(node);
return n->get_RegisterMap(termout.strout);
/*
for(auto n : nodes) {
auto node = select_node(n);
print_node_id(termout.strout,node);
return node->get_RegisterMap(termout.strout);
}
retval = (retcnt==nodes.size());
return NULL;
*/
}
bool Common::mread(TermOutput& termout, std::vector<int> nodes, const string addr,
......@@ -138,22 +114,28 @@ bool Common::mread(TermOutput& termout, std::vector<int> nodes, const string add
return retval;
}
bool Common::reg_read(TermOutput& termout, const string addr, const uint offs, const uint len)
bool Common::read(TermOutput& termout, const string addr)
{
bool retval=false;
uint retcnt=0;
auto node = select_node(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);
termout.strout << "node " << node->GetGlobalNr() << "(" << relative_addr << ")=[";
std::vector<int> datavec;
if(node->mread(termout.strhuman,relative_addr,offs,datavec,len)) {
retcnt++;
for(uint i=0;i<datavec.size();i++) {
if(i>0) termout.strout << ",";
termout.strout << datavec[i];
termout.strout << addr << "=[";
if(type == "mm") {
std::vector<int> datavec;
if(node->mread(termout.strhuman,relative_addr,0,datavec,1)) {
retcnt++;
for(uint i=0;i<datavec.size();i++) {
if(i>0) termout.strout << ",";
termout.strout << datavec[i];
}
}
} else if(type == "dev") {
if(node->get_system_info(termout.strout,peripheral)) retcnt++;
}
termout.strout << "]";
......@@ -161,23 +143,6 @@ bool Common::reg_read(TermOutput& termout, const string addr, const uint offs, c
return retval;
}
bool Common::peripheral_read(TermOutput& termout, const string addr)
{
bool retval=false;
uint retcnt=0;
auto node = select_node(path_to_node(addr));
std::string relative_addr = addr_to_relative_addr(addr);
std::string peripheral = addr_to_peripheral(addr);
termout.strout << "node " << node->GetGlobalNr() << "(" << relative_addr << ")=[";
if(node->get_system_info(termout.strout,peripheral)) retcnt++;
termout.strout << "]";
retval = retcnt;
return retval;
}
bool Common::mwrite(TermOutput& termout, std::vector<int> nodes, const string addr,
const uint offs, const std::vector<int>& data)
{
......@@ -286,11 +251,6 @@ int Common::path_to_node(std::string path_str)
while (std::getline(ss, token, '/')) {
tokens.push_back(token);
}
/*
for(auto t : tokens) {
cout << "Common::path_to_node:" << t << endl;
}
*/
if(tokens[0] == "") {
// ok, is absolute path starting with '/'
int unb = unb_name_to_number(tokens[1]);
......@@ -311,16 +271,36 @@ std::string Common::addr_to_relative_addr(std::string addr)
tokens.push_back(token);
}
// "/unb0/PN3/mm/rel_addr"
// 0 1 2 3 4
// "/unb0/P3/mm/addr"
// 0 1 2 3 4
for(uint i=4;i<tokens.size();i++) {
if(i>4) rel_addr += "/";
for(uint i=3;i<tokens.size();i++) {
if(i>3) rel_addr += "/";
rel_addr += tokens[i];
}
return rel_addr;
}
std::string Common::addr_to_type(std::string addr)
{
std::string type;
std::stringstream ss(addr);
std::string token;
std::vector<std::string> tokens;
while (std::getline(ss, token, '/')) {
tokens.push_back(token);
}
// "/unb0/P3/dev/peripheral"
// 0 1 2 3 4
if(tokens.size() >= 4) {
type = tokens[3];
}
return type;
}
std::string Common::addr_to_peripheral(std::string addr)
{
std::string peripheral;
......@@ -332,8 +312,8 @@ std::string Common::addr_to_peripheral(std::string addr)
tokens.push_back(token);
}
// "/unb0/PN3/dev/peripheral"
// 0 1 2 3
// "/unb0/P3/dev/peripheral"
// 0 1 2 3 4
if(tokens.size() >= 5) {
peripheral = tokens[4];
......
......@@ -39,8 +39,7 @@ public:
bool mwrite(TermOutput& termout, std::vector<int> nodes, const std::string addr,
const uint offs, const std::vector<int>& data);
bool reg_read(TermOutput& termout, const std::string addr, const uint offs, const uint len);
bool peripheral_read(TermOutput& termout, const string addr);
bool read(TermOutput& termout, const string addr);
std::vector<int> unb_pn__to__nodes(std::vector<int> unbs, std::vector<int> pns);
......@@ -48,14 +47,14 @@ public:
RegisterMap * get_RegisterMap(TermOutput& termout, int node);
std::string string_node_id(int node);
std::string string_mm(void);
std::string string_peripheral(void);
int path_to_node(std::string path_str);
int unb_name_to_number(const std::string unb_name);
int pn_name_to_number(const std::string pn_name);
std::string addr_to_relative_addr(std::string addr);
std::string addr_to_peripheral(std::string addr);
std::string addr_to_type(std::string addr);
};
......
......@@ -59,9 +59,9 @@ Node::~Node()
bool Node::get_system_info(ostringstream& strs,const string what) {
if(what=="system") {
return periph_system->read_system_info(strs);
} else if(what=="regmap") {
periph_system->print_regmap(strs,"gn="+to_string(GetGlobalNr()));
return true;
// } else if(what=="regmap") {
// periph_system->print_regmap(strs,"gn="+to_string(GetGlobalNr()));
// return true;
} else if(what=="name") {
strs << "read_design_name:" << periph_system->read_design_name() << endl;
return true;
......
......@@ -15,18 +15,6 @@ string p_termout(TermOutput& termout)
{
string s = "";
s += termout.strout.str();
/*
if(termout.Verbose) {
s += "human={\n";
s += termout.strhuman.str();
s += "}\n";
}
s += "errors={\n";
s += termout.strerr.str();
s += "}\n";
*/
//cout << "p_termout: " << s << endl;
return s;
}
......@@ -64,16 +52,15 @@ static void addVariable(UA_Server *server)
updateVariable(server);
}
static UA_StatusCode
UNB_registers_MM_MethodCallback(UA_Server *server,
const UA_NodeId *sessionId, void *sessionHandle,
const UA_NodeId *methodId, void *methodContext,
const UA_NodeId *objectId, void *objectContext,
size_t inputSize, const UA_Variant *input,
size_t outputSize, UA_Variant *output) {
static UA_StatusCode UNB_MethodCallback(UA_Server *server,
const UA_NodeId *sessionId, void *sessionHandle,
const UA_NodeId *methodId, void *methodContext,
const UA_NodeId *objectId, void *objectContext,
size_t inputSize, const UA_Variant *input,
size_t outputSize, UA_Variant *output) {
UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_SERVER, (char *)"UNB_registers_MM_MethodCallback");
UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_SERVER, (char *)"UNB_MethodCallback");
TermOutput termout(1);
UA_String *inputStr = (UA_String*)input->data;
......@@ -81,9 +68,9 @@ UNB_registers_MM_MethodCallback(UA_Server *server,
cout <<"inputStr->data=" << inputStr->data <<endl;
try {
SD->unb->reg_read(termout,std::string((char *)inputStr->data),0,1); // TODO: make read/write
SD->unb->read(termout,std::string((char *)inputStr->data)); // TODO: make read/write
} catch(runtime_error& e) {
cerr << "UNB_registers_MM_MethodCallback: " << e.what() << endl;
cerr << "UNB_MethodCallback: " << e.what() << endl;
termout.strout << e.what();
}
......@@ -98,10 +85,9 @@ UNB_registers_MM_MethodCallback(UA_Server *server,
return UA_STATUSCODE_GOOD;
}
static void add_UNB_registers_MM_Method(UA_Server *server, std::string regname)
static void add_UNB_Method(UA_Server *server, std::string regname)
{
UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND,"add_UNB_registers_MM_Method: %s",
(char *)regname.c_str());
UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND,"add_UNB_Method: %s",(char *)regname.c_str());
UA_Argument inputArgument;
UA_Argument_init(&inputArgument);
......@@ -118,81 +104,15 @@ static void add_UNB_registers_MM_Method(UA_Server *server, std::string regname)
outputArgument.valueRank = UA_VALUERANK_SCALAR;
UA_MethodAttributes helloAttr = UA_MethodAttributes_default;
helloAttr.description = UA_LOCALIZEDTEXT((char *)"en-US",(char *)"UNB MM register");
helloAttr.displayName = UA_LOCALIZEDTEXT((char *)"en-US",(char *)"UNB MM register");
helloAttr.description = UA_LOCALIZEDTEXT((char *)"en-US",(char *)"UNB file");
helloAttr.displayName = UA_LOCALIZEDTEXT((char *)"en-US",(char *)"UNB file");
helloAttr.executable = true;
helloAttr.userExecutable = true;
UA_Server_addMethodNode(server, UA_NODEID_STRING(1, (char *)regname.c_str()),
UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER),
UA_NODEID_NUMERIC(0, UA_NS0ID_HASORDEREDCOMPONENT),
UA_QUALIFIEDNAME(1, (char *)regname.c_str()),
helloAttr, &UNB_registers_MM_MethodCallback,
1, &inputArgument, 1, &outputArgument, NULL, NULL);
}
static UA_StatusCode
UNB_peripheral_MethodCallback(UA_Server *server,
const UA_NodeId *sessionId, void *sessionHandle,
const UA_NodeId *methodId, void *methodContext,
const UA_NodeId *objectId, void *objectContext,
size_t inputSize, const UA_Variant *input,
size_t outputSize, UA_Variant *output) {
UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_SERVER, (char *)"UNB_peripheral_MethodCallback");
TermOutput termout(1);
UA_String *inputStr = (UA_String*)input->data;
if(inputStr->length > 0) {
cout <<"inputStr->data=" << inputStr->data <<endl;
try {
SD->unb->peripheral_read(termout,std::string((char *)inputStr->data)); // TODO: make read/write
} catch(runtime_error& e) {
cerr << "UNB_peripheral_MethodCallback: " << e.what() << endl;
termout.strout << e.what();
}
UA_String tmp = UA_STRING_ALLOC((char *)p_termout(termout).c_str());
UA_Variant_setScalarCopy(output, &tmp, &UA_TYPES[UA_TYPES_STRING]);
UA_String_clear(&tmp);
}
UA_String *outputStr = (UA_String*)output->data;
cout <<"outputStr->data=" << outputStr->data <<endl;
return UA_STATUSCODE_GOOD;
}
static void add_UNB_peripheral_Method(UA_Server *server, std::string regname)
{
UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND,"add_UNB_peripheral_Method: %s",
(char *)regname.c_str());
UA_Argument inputArgument;
UA_Argument_init(&inputArgument);
inputArgument.description = UA_LOCALIZEDTEXT((char *)"en-US",(char *) "A String");
inputArgument.name = UA_STRING((char *)"MyInput");
inputArgument.dataType = UA_TYPES[UA_TYPES_STRING].typeId;
inputArgument.valueRank = UA_VALUERANK_SCALAR;
UA_Argument outputArgument;
UA_Argument_init(&outputArgument);
outputArgument.description = UA_LOCALIZEDTEXT((char *)"en-US",(char *) "A String");
outputArgument.name = UA_STRING((char *)"MyOutput");
outputArgument.dataType = UA_TYPES[UA_TYPES_STRING].typeId;
outputArgument.valueRank = UA_VALUERANK_SCALAR;
UA_MethodAttributes helloAttr = UA_MethodAttributes_default;
helloAttr.description = UA_LOCALIZEDTEXT((char *)"en-US",(char *)"UNB peripheral");
helloAttr.displayName = UA_LOCALIZEDTEXT((char *)"en-US",(char *)"UNB peripheral");
helloAttr.executable = true;
helloAttr.userExecutable = true;
UA_Server_addMethodNode(server, UA_NODEID_STRING(1, (char *)regname.c_str()),
UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER),
UA_NODEID_NUMERIC(0, UA_NS0ID_HASORDEREDCOMPONENT),
UA_QUALIFIEDNAME(1, (char *)regname.c_str()),
helloAttr, &UNB_peripheral_MethodCallback,
helloAttr, &UNB_MethodCallback,
1, &inputArgument, 1, &outputArgument, NULL, NULL);
}
......@@ -211,17 +131,11 @@ int ua_server(Serverdat *sd) {
for(auto node : nodes) {
RegisterMap *regmap = SD->unb->get_RegisterMap(termout, node);
std::string mm_prefix = SD->unb->string_node_id(node) + SD->unb->string_mm();
std::vector<std::string> regnames = regmap->getRegnames(mm_prefix);
std::string prefix = SD->unb->string_node_id(node);
std::vector<std::string> regnames = regmap->getRegnames(prefix);
for(auto m : regnames) {
add_UNB_registers_MM_Method(mUaServer, m);
add_UNB_Method(mUaServer, m);
}
std::string peripheral_prefix = SD->unb->string_node_id(node) + SD->unb->string_peripheral();
add_UNB_peripheral_Method(mUaServer, peripheral_prefix + "name");
add_UNB_peripheral_Method(mUaServer, peripheral_prefix + "stamps");
add_UNB_peripheral_Method(mUaServer, peripheral_prefix + "note");
add_UNB_peripheral_Method(mUaServer, peripheral_prefix + "sensors");
}
......
......@@ -35,6 +35,10 @@ Periph_system::Periph_system(UNBos &commdev, const string design_name) : unbos(c
registerMap = new RegisterMap(read_reg_map()); // used old version style
} else {
registerMap = new RegisterMap(import_ccfg_file(ifs));
registerMap->add_register("dev/name", 0,0,0xffffffff,0,"RO");
registerMap->add_register("dev/stamps", 0,0,0xffffffff,0,"RO");
registerMap->add_register("dev/note", 0,0,0xffffffff,0,"RO");
registerMap->add_register("dev/sensors",0,0,0xffffffff,0,"RO");
}
}
......@@ -93,7 +97,7 @@ bool Periph_system::Write(const string addr_str, const uint32_t offset, const ui
bool Periph_system::read_system_info(ostringstream& strs)
{
uint32_t data;
bool retval = Read("system/info/info",0,1,&data);
bool retval = Read("mm/system/info/info",0,1,&data);
if(data&(1<<11)) {
strs << " read_design_name:" << read_design_name() << endl;
read_use_phy(strs);
......@@ -146,7 +150,7 @@ string Periph_system::read_design_name(void)
uint32_t nof_design_name_regs = 8;
uint32_t nvalues = nof_design_name_regs;
uint32_t *data = new uint32_t[nvalues*sizeof(uint32_t)+1];
bool retval = Read("system/info/info",2,nvalues,data);
bool retval = Read("mm/system/info/info",2,nvalues,data);
char *str_ptr=(char *)data;
string name=string(str_ptr);
delete[] data;
......@@ -158,7 +162,7 @@ string Periph_system::read_design_note(void)
uint32_t nof_design_name_regs = 8;
uint32_t nvalues = nof_design_name_regs;
uint32_t *data = new uint32_t[nvalues*sizeof(uint32_t)+1];
bool retval = Read("system/info/info",13,nvalues,data);
bool retval = Read("mm/system/info/info",13,nvalues,data);
data[nvalues]=0; // add end of string char
char *str_ptr=(char *)data;
string note=string(str_ptr);
......@@ -171,7 +175,7 @@ bool Periph_system::read_stamps(ostringstream& strs)
uint32_t nof_regs = 3;
uint32_t nvalues = nof_regs;
uint32_t *data = new uint32_t[nvalues*sizeof(uint32_t)+1];
bool retval = Read("system/info/info",10,nvalues,data);
bool retval = Read("mm/system/info/info",10,nvalues,data);
strs << " Stamp: date=" << data[0] << endl;
strs << " Stamp: time=" << data[1] << endl;
......@@ -183,7 +187,7 @@ bool Periph_system::read_stamps(ostringstream& strs)
bool Periph_system::read_use_phy(ostringstream& strs)
{
uint32_t data;
bool retval = Read("system/info/info",1,1,&data);
bool retval = Read("mm/system/info/info",1,1,&data);
// This can be used to find the phy name based position in SLV
const char* c_unb_use_phy[] = {
......@@ -208,7 +212,7 @@ bool Periph_system::read_unb_sensors(ostringstream& strs, const uint nodeNr, con
uint32_t nvalues = 1;
uint32_t *data = new uint32_t[nvalues*sizeof(uint32_t)];
retval = Read("sens/sens/sens_data0",0,nvalues,data);
retval = Read("mm/sens/sens/sens_data0",0,nvalues,data);
char str[1000];
sprintf(str," FPGA temperature = %d [degC]\n",data[0]); strs << str;
......@@ -222,7 +226,7 @@ bool Periph_system::read_unb_sensor(uint32_t *sensor, const uint nodeNr, const c
uint32_t nvalues = 1;
uint32_t *data = new uint32_t[nvalues*sizeof(uint32_t)];
retval = Read("sens/sens/sens_data0",0,nvalues,data);
retval = Read("mm/sens/sens/sens_data0",0,nvalues,data);
*sensor = data[0];
delete[] data;
......@@ -233,7 +237,7 @@ bool Periph_system::read_temp_high(ostringstream& strs)
{
bool retval=false;
uint32_t data;
retval=Read("sens/sens/temp_high", 5,1,&data);
retval=Read("mm/sens/sens/temp_high", 5,1,&data);
strs << " High temp limit = " << data << " [degC]" << endl;
return retval;
}
......@@ -242,13 +246,13 @@ bool Periph_system::write_temp_high(ostringstream& strs, const int val)
{
if(val < 10) throw runtime_error("bad high temp value");
uint32_t data = val;
return Write("sens/sens/temp_high", 5,1,&data);
return Write("mm/sens/sens/temp_high", 5,1,&data);
}
bool Periph_system::write_wdi_override(ostringstream& strs)
{
uint32_t data = 0xB007FAC7;
return Write("wdi/wdi/reset_word", 0,1,&data);
return Write("mm/wdi/wdi/reset_word", 0,1,&data);
}
/*
......@@ -258,7 +262,7 @@ RegisterMap Periph_system::read_reg_map(void)
{
RegisterMap reg;
uint32_t nvalues = 1024;
uint32_t addr = reg.getValidAddr("rom_system/info/info", 0, nvalues);
uint32_t addr = reg.getValidAddr("mm/rom_system/info/info", 0, nvalues);
uint32_t *data = new uint32_t[nvalues*sizeof(uint32_t)];
if(!unbos.readRegister(addr,nvalues,data)) {
delete[] data;
......
......@@ -48,6 +48,15 @@ std::vector<std::string> RegisterMap::getRegnames(std::string prefix)
return regnames;
}
std::vector<std::string> RegisterMap::getRegnames_full(std::string prefix)
{
std::vector<std::string> regnames;
for(auto m : reg) {
regnames.push_back(m.second.access + " " + prefix + m.first);
}
return regnames;
}
uint32_t RegisterMap::getValidAddr(const std::string name, const uint32_t offset, const uint32_t size)
{
......
......@@ -40,6 +40,7 @@ class RegisterMap {
bool getWritePermission(const std::string name);
std::vector<std::string> getRegnames(std::string prefix);
std::vector<std::string> getRegnames_full(std::string prefix);
};
#endif // __REGISTERMAP_H__
......@@ -74,7 +74,7 @@ RegisterMap import_ccfg_file(std::ifstream& ifs)
if (ss.fail() || ss.bad()) {
cerr << "import_ccfg_file: invalid DistrRAM" << endl;
} else {
regmap.add_register(peripheral+"/"+regname+"/"+regfield,base,span,0xffffffff,0,perm);
regmap.add_register("mm/"+peripheral+"/"+regname+"/"+regfield,base,span,0xffffffff,0,perm);
}
} else if (regex_match(line, BitField_re)) {
......@@ -114,7 +114,7 @@ RegisterMap import_ccfg_file(std::ifstream& ifs)
if (ss.fail() || ss.bad()) {
cerr << "import_ccfg_file: invalid BitField" << endl;
} else {
regmap.add_register(peripheral+"/"+regname+"/"+regfield,base,span,mask,shift,perm);
regmap.add_register("mm/"+peripheral+"/"+regname+"/"+regfield,base,span,mask,shift,perm);
}
} else if (regex_match(line, BlockRAM_re)) {
......@@ -141,7 +141,7 @@ RegisterMap import_ccfg_file(std::ifstream& ifs)
if (ss.fail() || ss.bad()) {
cerr << "import_ccfg_file: invalid BlockRAM" << endl;
} else {
regmap.add_register(peripheral+"/"+regname+"/"+regfield,base,span,0xffffffff,0,perm);
regmap.add_register("mm/"+peripheral+"/"+regname+"/"+regfield,base,span,0xffffffff,0,perm);
}
} else {
......
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