94using namespace std::placeholders;
152 static RtclNameSet optset(
"-name|-testname|-testaddr|-insert|-erase|-print");
160 if (args.
NextOpt(opt, optset)) {
161 if (opt ==
"-name") {
165 if(addrmap.
Find(addr, tstname)) {
172 }
else if (opt ==
"-testname") {
177 bool found = addrmap.
Find(name, tstaddr);
179 if (tstaddr != addr) found =
false;
183 }
else if (opt ==
"-testaddr") {
189 }
else if (opt ==
"-insert") {
195 if (Tcl_GetIntFromObj(
nullptr, args[args.
NDone()-1], &tstint) ==
kOK)
196 return args.
Quit(
string(
"-E: name should not look like an int but '")+
200 if (addrmap.
Find(name, tstaddr))
201 return args.
Quit(
string(
"-E: mapping already defined for '")+name+
"'");
202 if (addrmap.
Find(addr, tstname))
203 return args.
Quit(
string(
"-E: mapping already defined for address '") +
207 }
else if (opt ==
"-erase") {
210 if (!
Obj().IAddrMapErase(name))
211 return args.
Quit(
string(
"-E: no mapping defined for '") + name +
"'");
213 }
else if (opt ==
"-print") {
225 if(addrmap.
Find(name, tstaddr)) {
228 return args.
Quit(
string(
"-E: no mapping defined for '") + name +
"'");
232 RtclOPtr plist(Tcl_NewListObj(0,
nullptr));
233 const auto amap = addrmap.
Amap();
234 for (
auto& o: amap) {
236 tpair[0] = Tcl_NewIntObj(o.first);
237 tpair[1] = Tcl_NewStringObj(o.second.c_str(),o.second.length());
238 Tcl_ListObjAppendElement(
nullptr, plist, Tcl_NewListObj(2, tpair));
252 static RtclNameSet optset(
"-name|-testname|-testaddr|-insert|-erase|-print");
261 if (args.
NextOpt(opt, optset)) {
262 if (opt ==
"-name") {
266 if(lmap.
Find(addr, tstname)) {
268 }
else if(cmap.
Find(addr, tstname)) {
275 }
else if (opt ==
"-testname") {
280 bool found = lmap.
Find(name, tstaddr);
282 if (tstaddr != addr) found =
false;
286 }
else if (opt ==
"-testaddr") {
292 }
else if (opt ==
"-insert") {
298 if (Tcl_GetIntFromObj(
nullptr, args[args.
NDone()-1], &tstint) ==
kOK)
299 return args.
Quit(
string(
"-E: name should not look like an int but '")+
303 if (lmap.
Find(name, tstaddr))
304 return args.
Quit(
string(
"-E: mapping already defined for '")+name+
"'");
305 if (lmap.
Find(addr, tstname))
306 return args.
Quit(
string(
"-E: mapping already defined for address '") +
310 }
else if (opt ==
"-erase") {
313 if (!
Obj().RAddrMapErase(name))
314 return args.
Quit(
string(
"-E: no mapping defined for '") + name +
"'");
316 }
else if (opt ==
"-print") {
328 if(lmap.
Find(name, tstaddr)) {
330 }
else if(cmap.
Find(name, tstaddr)) {
333 return args.
Quit(
string(
"-E: no mapping defined for '") + name +
"'");
337 RtclOPtr plist(Tcl_NewListObj(0,
nullptr));
338 const auto amap = lmap.
Amap();
339 for (
auto& o: amap) {
341 tpair[0] = Tcl_NewIntObj(o.first);
342 tpair[1] = Tcl_NewStringObj(o.second.c_str(),o.second.length());
343 Tcl_ListObjAppendElement(
nullptr, plist, Tcl_NewListObj(2, tpair));
357 static RtclNameSet optset(
"-rreg|-rblk|-wreg|-wblk|-labo|-attn|-init|"
358 "-rr|-rr0|-rr1|-rr2|-rr3|-rr4|-rr5|-rr6|-rr7|"
359 "-wr|-wr0|-wr1|-wr2|-wr3|-wr4|-wr5|-wr6|-wr7|"
360 "-rsp|-rpc|-wsp|-wpc|"
362 "-ral|-rah|-wal|-wah|-wa|"
363 "-rm|-rmi|-rma|-wm|-wmi|-wma|-brm|-bwm|-brf|-bwf|"
364 "-start|-stop|-step|-creset|-breset|"
367 "-rmembe|-wmembe|-ribr|-rbibr|-wibr|-wbibr|"
369 "-edata|-edone|-estat|"
370 "-estaterr|-estatnak|-estattout|"
373 Tcl_Interp* interp = args.
Interp();
379 vector<string> vardata;
380 vector<string> varstat;
384 bool setcpuact =
false;
386 while (args.
NextOpt(opt, optset)) {
387 size_t lsize = clist.
Size();
390 if (opt ==
"-rsp") opt =
"-rr6";
391 if (opt ==
"-rpc") opt =
"-rr7";
392 if (opt ==
"-wsp") opt =
"-wr6";
393 if (opt ==
"-wpc") opt =
"-wr7";
396 if (opt.substr(0,3) ==
"-rr" || opt.substr(0,3) ==
"-wr" ) {
397 if (opt.length() == 3) {
398 if (!args.
GetArg(
"regnum", regnum, 0, 7))
return kERR;
399 }
else if (opt.length() == 4 && opt[3] >=
'0' && opt[3] <=
'7') {
400 regnum = opt[3] -
'0';
401 opt = opt.substr(0,3);
405 if (opt ==
"-rreg") {
412 }
else if (opt ==
"-rblk") {
419 clist.
AddRblk(addr,
size_t(bsize));
421 }
else if (opt ==
"-wreg") {
429 }
else if (opt ==
"-wblk") {
431 vector<uint16_t> block;
435 clist.
AddWblk(addr, move(block));
437 }
else if (opt ==
"-labo") {
442 }
else if (opt ==
"-attn") {
447 }
else if (opt ==
"-init") {
455 }
else if (opt ==
"-rr") {
460 }
else if (opt ==
"-wr") {
466 }
else if (opt ==
"-rps") {
471 }
else if (opt ==
"-wps") {
477 }
else if (opt ==
"-ral") {
482 }
else if (opt ==
"-rah") {
487 }
else if (opt ==
"-wal") {
493 }
else if (opt ==
"-wah") {
500 }
else if (opt ==
"-wa") {
502 if (!args.
GetArg(
"addr", addr, 017777776))
return kERR;
505 uint16_t ah = (addr>>16);
508 while (args.
NextSubOpt(subopt, suboptset)>=0) {
510 if (subopt ==
"-p22") {
512 }
else if (subopt ==
"-ubm") {
514 if (addr > 0777776) {
516 sos <<
"-E: value '" << addr
517 <<
"' for 'addr' out of range 0...0777776";
526 sos <<
"-E: value '" << addr
527 <<
"' for 'addr' out of range 0...0177776";
535 }
else if (opt ==
"-rm" ||
543 }
else if (opt ==
"-rma") {
547 if (!
GetVarName(args,
"??varData", lsize+1, vardata))
return kERR;
548 if (!
GetVarName(args,
"??varStat", lsize+1, varstat))
return kERR;
552 }
else if (opt ==
"-wm" ||
559 clist.
AddWreg(base + addr, data);
561 }
else if (opt ==
"-wma") {
567 if (!
GetVarName(args,
"??varStat", lsize+1, varstat))
return kERR;
571 }
else if (opt ==
"-brm") {
578 }
else if (opt ==
"-bwm") {
579 vector<uint16_t> block;
584 }
else if (opt ==
"-brf") {
591 }
else if (opt ==
"-bwf") {
592 vector<uint16_t> block;
597 }
else if (opt ==
"-start") {
602 }
else if (opt ==
"-stop") {
606 }
else if (opt ==
"-step") {
610 }
else if (opt ==
"-creset") {
614 }
else if (opt ==
"-breset") {
618 }
else if (opt ==
"-suspend") {
622 }
else if (opt ==
"-resume") {
627 }
else if (opt ==
"-stapc") {
630 if (!
GetVarName(args,
"??varStat", lsize+1, varstat))
return kERR;
637 }
else if (opt ==
"-rmembe") {
642 }
else if (opt ==
"-wmembe") {
650 while (args.
NextSubOpt(subopt, suboptset)>=0) {
652 if (subopt ==
"-stick") {
658 }
else if (opt ==
"-ribr") {
665 }
else if (opt ==
"-rbibr") {
674 }
else if (opt ==
"-wibr") {
682 }
else if (opt ==
"-wbibr") {
684 vector<uint16_t> block;
690 }
else if (opt ==
"-rconf") {
695 }
else if (opt ==
"-rstat") {
700 }
else if (opt ==
"-edata") {
703 vector<uint16_t> data;
704 vector<uint16_t> mask;
705 size_t bsize = clist[lsize-1].BlockSize();
706 if (!args.
GetArg(
"data", data, 0, bsize))
return kERR;
707 if (!args.
GetArg(
"??mask", mask, 0, bsize))
return kERR;
711 uint16_t mask=0xffff;
713 if (!args.
GetArg(
"??mask", mask))
return kERR;
717 }
else if (opt ==
"-edone") {
721 uint8_t cmd = clist[lsize-1].Command();
726 return args.
Quit(
"-E: -edone allowed only after -rblk,-wblk");
729 }
else if (opt ==
"-estat") {
734 if (!args.
GetArg(
"??mask", mask))
return kERR;
737 }
else if (opt ==
"-estaterr" ||
738 opt ==
"-estatnak" ||
739 opt ==
"-estattout" ||
740 opt ==
"-estatmerr") {
749 if (opt ==
"-estatmerr") {
756 }
else if (opt ==
"-print") {
758 if (!args.
GetArg(
"??varRes", varprint))
return kERR;
759 }
else if (opt ==
"-dump") {
761 if (!args.
GetArg(
"??varRes", vardump))
return kERR;
767 if (varprint ==
"-") nact += 1;
768 if (vardump ==
"-") nact += 1;
771 "-E: more that one of -print,-dump without target variable found");
774 if (clist.
Size() == 0)
return kOK;
782 if (!
Connect().Exec(clist, emsg))
return args.
Quit(emsg);
785 for (
size_t icmd=0; icmd<clist.
Size(); icmd++) {
788 if (icmd<vardata.size() && !vardata[icmd].empty()) {
790 vector<uint16_t> retstat;
796 pres = Tcl_NewIntObj(
int(cmd.
Data()));
806 if (icmd<varstat.size() && !varstat[icmd].empty()) {
812 if (!varprint.empty()) {
821 if (!vardump.empty()) {
842 while (args.
NextOpt(opt, optset)) {
843 if (opt ==
"-reset") reset =
true;
846 if (!args.
GetArg(
"tout", dtout, 0.001))
return kERR;
853 if (!
Server().IsActive()) {
863 if (irc == -2)
return args.
Quit(emsg);
868 if (!
Connect().Exec(clist, emsg))
return args.
Quit(emsg);
869 apat = clist[0].Data();
870 if (apat & apatcpu)
break;
878 if (
Connect().PrintLevel() >= 1) {
880 lmsg <<
"-- wtcpu to=" <<
RosPrintf(dtout,
"f", 0,3) <<
" FAIL timeout";
888 if (!
Connect().Exec(clist, emsg))
return args.
Quit(emsg);
891 if (
Connect().PrintLevel() >= 3) {
893 lmsg <<
"-- wtcpu to=" <<
RosPrintf(dtout,
"f", 0,3)
894 <<
" T=" <<
RosPrintf(
double(twait),
"f", 0,3)
899 args.
SetResult(irc >= 0 ?
double(twait) :
double(irc));
909 vector<uint16_t> data;
911 if (!args.
GetArg(
"data", data, 1))
return kERR;
916 if (!
Obj().MemWrite(addr, data, emsg))
return args.
Quit(emsg);
931 vector<uint16_t> data;
933 if (!
Obj().MemRead(addr, data, 1, emsg))
return args.
Quit(emsg);
947 uint16_t aend = abeg;
948 if (!args.
GetArg(
"?aend", aend, 0xffff, abeg))
return kERR;
952 vector<uint16_t> data;
953 size_t nword = 1+(aend-abeg)/2;
955 if (!
Obj().
MemRead(abeg, data, nword, emsg))
return args.
Quit(emsg);
958 for (
size_t i=0; i<nword; i++) {
977 while (args.
NextOpt(opt, optset)) {
978 if (opt ==
"-trace") trace =
true;
985 if (!args.
GetArg(
"??start", varstart))
return kERR;
990 if (!
Obj().LoadAbs(file, emsg, start, trace))
return args.
Quit(emsg);
991 if (varstart.length()) {
992 Tcl_Interp* interp = args.
Interp();
993 RtclOPtr pres(Tcl_NewIntObj(
int(start)));
1004 static RtclNameSet optset(
"-lst|-sym|-opt|-file");
1005 Tcl_Interp* interp = args.
Interp();
1014 while (args.
NextOpt(opt, optset)) {
1015 if (opt ==
"-lst") {
1016 if (!args.
GetArg(
"??varLst", varlst))
return kERR;
1017 }
else if (opt ==
"-sym") {
1018 if (!args.
GetArg(
"??varSym", varsym))
return kERR;
1019 }
else if (opt ==
"-opt") {
1021 if (!args.
GetArg(
"opts", asmopt))
return kERR;
1022 }
else if (opt ==
"-file") {
1023 if (!args.
GetArg(
"??file", file))
return kERR;
1028 if (file.length() == 0) {
1034 if (varsym.length())
1035 Tcl_UnsetVar(interp, varsym.c_str(), 0);
1037 int pipe_tcl2asm[2];
1038 int pipe_asm2tcl[2];
1040 if (::pipe(pipe_tcl2asm) < 0)
1042 "1st pipe() failed: ", errno));
1043 if (::pipe(pipe_asm2tcl) < 0)
1045 "2nd pipe() failed: ", errno));
1047 pid_t pid = ::fork();
1048 if (pid == pid_t(0)) {
1049 vector<const char*> argv;
1050 vector<string> opts;
1052 argv.push_back(
"asm-11");
1053 if (varlst.length()>0) argv.push_back(
"--olst=-");
1054 argv.push_back(
"--ocof=-");
1055 if (asmopt.length()) {
1056 istringstream optstream(asmopt);
1058 while (optstream >> tok) {
1059 opts.push_back(tok);
1060 argv.push_back(opts[opts.size()-1].c_str());
1063 if (file.length()) {
1064 argv.push_back(file.c_str());
1066 argv.push_back(
"-");
1068 argv.push_back(
nullptr);
1070 ::dup2(pipe_tcl2asm[0], STDIN_FILENO);
1071 ::dup2(pipe_asm2tcl[1], STDOUT_FILENO);
1072 ::dup2(STDOUT_FILENO, STDERR_FILENO);
1073 ::close(pipe_tcl2asm[1]);
1074 ::close(pipe_asm2tcl[0]);
1075 ::execvp(
"asm-11",
const_cast<char* const*
>(argv.data()));
1076 ::perror(
"execvp() for asm-11 failed");
1077 ::exit(EXIT_FAILURE);
1080 ::close(pipe_tcl2asm[0]);
1081 ::close(pipe_asm2tcl[1]);
1084 "fork() failed: ", errno));
1088 if (code.length() && code[0] ==
'\n') code = code.substr(1);
1090 istringstream ostream(code);
1092 while (std::getline(ostream, oline)) {
1095 if (::write(pipe_tcl2asm[1], oline.data(), oline.length()) < 0)
break;
1097 ::close(pipe_tcl2asm[1]);
1099 FILE* fp = ::fdopen(pipe_asm2tcl[0],
"r");
1100 if (fp ==
nullptr) {
1101 ::close(pipe_asm2tcl[0]);
1103 "fdopen() failed: ", errno));
1106 vector<string> ilines;
1108 char* pline =
nullptr;
1110 if (::getline(&pline, &nchar, fp) < 0)
break;
1113 if (line.length() && line[line.length()-1] ==
'\n')
1114 line.resize(line.length()-1);
1115 ilines.push_back(line);
1119 ::close(pipe_asm2tcl[0]);
1123 waitpid(pid, &wstat, 0);
1124 if (WIFEXITED(wstat)) wexit = WEXITSTATUS(wstat);
1132 bool lstbodyseen =
false;
1134 typedef map<uint16_t, uint16_t> cmap_t;
1139 for (
size_t i=0; i<ilines.size(); i++) {
1140 string& line = ilines[i];
1141 if (line ==
"sym {") {
1144 }
else if (line ==
"dat {") {
1147 }
else if (dtyp ==
' ' && line ==
"}") {
1155 if (varsym.length() == 0)
continue;
1156 size_t dpos = line.find(
" => ");
1157 if (dpos != std::string::npos) {
1158 string key = line.substr(0,dpos);
1159 string val= line.substr(dpos+4);
1160 if (!Tcl_SetVar2Ex(interp, varsym.c_str(), key.c_str(),
1161 Tcl_NewIntObj(
int(::strtol(val.c_str(),
nullptr,8))),
1162 TCL_LEAVE_ERR_MSG))
return kERR;
1164 return args.
Quit(
string(
"bad sym spec: ") + line);
1170 if (line.length() != 10)
1171 return args.
Quit(
string(
"bad dat spec: ") + line);
1173 dot = uint16_t(::strtol(line.c_str()+2,
nullptr,8));
1174 }
else if (line[0] ==
'}') {
1177 istringstream datstream(line);
1179 while (datstream >> dat) {
1181 uint16_t val = uint16_t(::strtol(dat.c_str(),
nullptr,8));
1186 uint16_t tmp = cmap[dot&0xfffe];
1188 tmp = (val&0xff)<<8 | (tmp&0xff);
1190 tmp = (tmp&0xff00) | (val&0xff);
1192 cmap[dot&0xfffe] = tmp;
1200 los << line << endl;
1204 if (line ==
"; Input file list:") lstbodyseen =
true;
1207 if (line.length() && (line[0]>
'A' && line[0]<
'Z')) etake =
true;
1209 if (line.substr(0,2) !=
"--") etake =
true;
1211 if (line.substr(0,6) ==
"asm-11") etake =
true;
1212 if (etake) eos << line << endl;
1216 if (varlst.length()) {
1228 vector<uint16_t> block;
1233 for (
auto& o: cmap) {
1239 base = dot = o.first;
1241 block.push_back(o.second);
1259 if (!args.
GetArg(
"uname", uname))
return kERR;
1262 if (!
Obj().Boot(uname, emsg))
return args.
Quit(emsg);
1272 lock_guard<RlinkConnect> lock(
Obj().
Connect());
1282 lock_guard<RlinkConnect> lock(
Obj().
Connect());
1291 static RtclNameSet optset(
"-pcps|-r0ps|-mmu|-ubmap"
1299 const char* mode[4] = {
"k",
"s",
"?",
"u"};
1300 const char* rust[16] = {
"init",
"HALTed",
"reset",
"stopped",
1301 "stepped",
"suspend",
"hbpt",
"..run..",
1302 "F:vecfet",
"F:recser",
"1010",
"1011",
1303 "F:seq",
"F:vmbox" ,
"1101",
"1111"};
1305 while (args.
NextOpt(opt, optset)) {
1306 if (opt ==
"-pcps" || opt ==
"-r0ps") {
1311 if (!
Server().Exec(clist, emsg))
return args.
Quit(emsg);
1312 uint16_t psw = clist[i_psw].Data();
1313 uint16_t stat = clist[i_stat].Data();
1314 uint16_t psw_cm = (psw>>14) & 003;
1315 uint16_t psw_pm = (psw>>12) & 003;
1316 uint16_t psw_set = (psw>>11) & 001;
1317 uint16_t psw_pri = (psw>>5) & 007;
1318 uint16_t psw_tbit = (psw>>4) & 001;
1319 uint16_t psw_nzvc = (psw) & 017;
1320 uint16_t stat_rust = (stat>>4) & 017;
1322 regs[7] = clist[i_pc].Data();
1323 bool r0ps = opt ==
"-r0ps";
1329 for (
size_t i=0; i<7; i++) regs[i] = clist[i].Data();
1332 if (r0ps) sos <<
"Processor registers and status:" << endl;
1333 if (!r0ps) sos <<
" PC: " <<
RosPrintBvi(regs[7],8);
1335 <<
" cm,pm=" << mode[psw_cm] <<
"," << mode[psw_pm]
1336 <<
" s,p,t=" << psw_set <<
"," << psw_pri <<
"," << psw_tbit
1338 <<
" rust: " <<
RosPrintBvi(stat_rust,8,4) <<
" " << rust[stat_rust]
1352 }
else if (opt ==
"-r0r5") {
1355 if (!
Server().Exec(clist, emsg))
return args.
Quit(emsg);
1357 for (
size_t i=0; i<6; i++) sos <<
" " <<
RosPrintBvi(clist[i].Data(),8);
1360 }
else if (opt ==
"-mmu") {
1362 uint16_t asr[3][32];
1363 const char* pmode[3] = {
"km",
"sm",
"um"};
1364 const char* acf[8] = {
"nres ",
1373 lock_guard<RlinkConnect> lock(
Connect());
1379 if (!
Server().Exec(clist, emsg))
return args.
Quit(emsg);
1387 if (!
Server().Exec(clist, emsg))
return args.
Quit(emsg);
1390 uint16_t mmr0_anr = (mmr[0]>>15) & 001;
1391 uint16_t mmr0_ale = (mmr[0]>>14) & 001;
1392 uint16_t mmr0_ard = (mmr[0]>>13) & 001;
1393 uint16_t mmr0_trp = (mmr[0]>>12) & 001;
1394 uint16_t mmr0_ent = (mmr[0]>> 9) & 001;
1395 uint16_t mmr0_ico = (mmr[0]>> 7) & 001;
1396 uint16_t mmr0_mode = (mmr[0]>> 5) & 003;
1397 uint16_t mmr0_ds = (mmr[0]>> 4) & 001;
1398 uint16_t mmr0_page = (mmr[0]>> 1) & 007;
1399 uint16_t mmr0_ena = (mmr[0] ) & 001;
1400 uint16_t mmr1_0_reg = (mmr[1] ) & 007;
1401 int16_t mmr1_0_val = (mmr[1]>> 3) & 037;
1402 uint16_t mmr1_1_reg = (mmr[1]>> 8) & 007;
1403 int16_t mmr1_1_val = (mmr[1]>>11) & 037;
1404 uint16_t mmr3_ubmap = (mmr[3]>> 5) & 001;
1405 uint16_t mmr3_22bit = (mmr[3]>> 4) & 001;
1406 uint16_t mmr3_d_km = (mmr[3]>> 2) & 001;
1407 uint16_t mmr3_d_sm = (mmr[3]>> 1) & 001;
1408 uint16_t mmr3_d_um = (mmr[3] ) & 001;
1410 sos <<
"mmu:" << endl;
1412 if (mmr0_anr) sos <<
" anr";
1413 if (mmr0_ale) sos <<
" ale";
1414 if (mmr0_ard) sos <<
" ard";
1415 if (mmr0_trp) sos <<
" trp";
1416 if (mmr0_ent) sos <<
" ent";
1417 if (mmr0_ico) sos <<
" ico";
1421 if (mmr0_ena) sos <<
" ena";
1424 if (mmr1_0_val & 020) mmr1_0_val |= 0177740;
1425 if (mmr1_1_val & 020) mmr1_1_val |= 0177740;
1427 if (mmr1_0_val) sos <<
" r" << mmr1_0_reg
1429 if (mmr1_1_val) sos <<
" r" << mmr1_1_reg
1435 <<
" ubmap=" << mmr3_ubmap
1436 <<
" 22bit=" << mmr3_22bit
1437 <<
" d-space k,s,u=" << mmr3_d_km
1438 <<
"," << mmr3_d_sm <<
"," << mmr3_d_um << endl;
1440 for (
size_t m=0; m<3; m++) {
1441 sos << pmode[m] <<
" "
1442 <<
" I pdr plf aw d acf I par"
1444 <<
" D pdr plf aw d acf D par" << endl;
1445 for (
size_t i=0; i<=7; i++) {
1446 sos <<
" " << i <<
" ";
1447 for (
size_t s=0; s<=1; s++) {
1448 if (s!=0) sos <<
" ";
1449 uint16_t pdr = asr[m][i +8*s];
1450 uint16_t par = asr[m][i+16+8*s];
1451 uint16_t pdr_plf = (pdr>>8) & 0177;
1452 uint16_t pdr_a = (pdr>>7) & 01;
1453 uint16_t pdr_w = (pdr>>6) & 01;
1454 uint16_t pdr_e = (pdr>>3) & 01;
1455 uint16_t pdr_acf = (pdr) & 07;
1458 <<
" " << pdr_a << pdr_w
1459 <<
" " << (pdr_e ?
"d" :
"u")
1460 <<
" " << acf[pdr_acf]
1467 }
else if (opt ==
"-ubmap") {
1472 if (!
Server().Exec(clist, emsg))
return args.
Quit(emsg);
1473 sos <<
"unibus map:" << endl;
1474 for (
size_t i = 0; i<=7; i++) {
1475 for (
size_t j = 0; j <= 030; j+=010) {
1477 uint32_t data = uint32_t(ubmap[k]) | (uint32_t(ubmap[k+1]))<<16;
1478 if (j!=0) sos <<
" ";
1514 Obj().
Dump(sos, 0,
"", detail);
1527 vector<string> cntlnames;
1530 sos <<
"name type ibbase lam probe ena on" << endl;
1532 for (
auto& cname : cntlnames) {
1547 sos <<
"name attachurl" << endl;
1549 for (
auto& cname : cntlnames) {
1551 for (
size_t j=0; j<cntl.
NUnit(); j++) {
1594 if (!args.
GetArg(
"ibaddr", pobj))
return kERR;
1598 if (Tcl_GetIntFromObj(
nullptr, pobj, &tstint) ==
kOK) {
1599 if (tstint >= 0 && tstint <= 0xffff && (tstint & 0x1) == 0) {
1600 ibaddr = uint16_t(tstint);
1603 "' for 'addr' odd number or out of range 0...0xffff",
1609 string name(Tcl_GetString(pobj));
1611 if (
Obj().IAddrMap().Find(name, tstaddr)) {
1614 args.
AppendResult(
"-E: no address mapping known for '",
1615 Tcl_GetString(pobj),
"'",
nullptr);
1629 if (!args.
GetArg(
"rbaddr", pobj))
return kERR;
1633 if (Tcl_GetIntFromObj(
nullptr, pobj, &tstint) ==
kOK) {
1634 if (tstint >= 0 && tstint <= 0xffff) {
1635 rbaddr = uint16_t(tstint);
1638 "' for 'addr' out of range 0...0xffff",
1644 string name(Tcl_GetString(pobj));
1646 if (
Obj().RAddrMap().Find(name, tstaddr)) {
1648 }
else if (
Connect().AddrMap().Find(name, tstaddr)) {
1651 args.
AppendResult(
"-E: no address mapping known for '",
1652 Tcl_GetString(pobj),
"'",
nullptr);
1665 std::vector<std::string>& varname)
1667 while (varname.size() < nind+1) varname.emplace_back(
string());
1669 if (!args.
GetArg(argname, name))
return false;
1670 if (name.length()) {
1672 if (isdigit(c) || c==
'+' || c==
'-' ) {
1673 args.
AppendResult(
"-E: invalid variable name '", name.c_str(),
1674 "': looks like a number",
nullptr);
1679 varname[nind] = name;
1688 if (clist.
Size() == 0) {
1690 "not allowed on empty command list",
nullptr);
1701 vector<string> cntlnames;
1704 Tcl_Obj* rlist = Tcl_NewListObj(0,
nullptr);
1705 for (
auto& cname : cntlnames) {
1707 RtclOPtr pele(Tcl_NewStringObj(ccmd.data(), ccmd.length()));
1708 Tcl_ListObjAppendElement(
nullptr, rlist, pele);
const amap_t & Amap() const
FIXME_docs.
bool Find(const std::string &name, uint16_t &addr) const
FIXME_docs.
void Print(std::ostream &os, int ind=0) const
FIXME_docs.
size_t AddWreg(uint16_t addr, uint16_t data)
FIXME_docs.
size_t AddAttn()
FIXME_docs.
size_t Size() const
FIXME_docs.
size_t AddInit(uint16_t addr, uint16_t data)
FIXME_docs.
size_t AddRblk(uint16_t addr, size_t size)
FIXME_docs.
void SetLastExpectStatus(uint8_t stat, uint8_t statmsk=0xff)
FIXME_docs.
void SetLastExpectBlock(const std::vector< uint16_t > &block)
FIXME_docs.
void Dump(std::ostream &os, int ind=0, const char *text=0, int detail=0) const
FIXME_docs.
size_t AddWblk(uint16_t addr, const std::vector< uint16_t > &block)
FIXME_docs.
size_t AddRreg(uint16_t addr)
FIXME_docs.
void Print(std::ostream &os, const RlinkAddrMap *pamap=0, size_t abase=16, size_t dbase=16, size_t sbase=16) const
FIXME_docs.
void SetLastExpectDone(uint16_t done)
FIXME_docs.
void SetLastExpectData(uint16_t data, uint16_t datamsk=0xffff)
FIXME_docs.
size_t AddLabo()
FIXME_docs.
uint16_t Data() const
FIXME_docs.
static const uint8_t kCmdRblk
command code read block
static const uint8_t kStat_M_RbErr
stat: rberr flag set
uint8_t Status() const
FIXME_docs.
const std::vector< uint16_t > & Block() const
FIXME_docs.
static const uint8_t kStat_M_RbNak
stat: rbnak flag set
static const uint8_t kStat_M_RbTout
stat: rbtout flag set
uint8_t Command() const
FIXME_docs.
static const uint8_t kCmdRreg
command code read register
size_t BlockDone() const
FIXME_docs.
static const uint8_t kCmdAttn
command code get attention
static const uint8_t kCmdLabo
command code list abort
static const uint8_t kCmdWblk
command code write block
int WaitAttn(const Rtime &timeout, Rtime &twait, uint16_t &apat, RerrMsg &emsg)
Wait for an attention notify.
RlinkContext & Context()
FIXME_docs.
size_t BlockSizeMax() const
FIXME_docs.
const RlinkAddrMap & AddrMap() const
FIXME_docs.
void IncErrorCount(size_t inc=1)
FIXME_docs.
bool Exec(RlinkCommandList &clist, RerrMsg &emsg)
FIXME_docs.
bool NextOpt(std::string &val)
FIXME_docs.
const char * PeekArgString(int rind) const
FIXME_docs.
void AppendResultLines(const std::string &str)
FIXME_docs.
int NextSubOpt(std::string &val, const RtclNameSet &optset)
FIXME_docs.
bool GetArg(const char *name, Tcl_Obj *&pval)
FIXME_docs.
void AppendResult(const char *str,...)
FIXME_docs.
bool OptValid() const
FIXME_docs.
int Quit(const std::string &str)
FIXME_docs.
void SetResult(const std::string &str)
FIXME_docs.
size_t NOptMiss() const
FIXME_docs.
size_t NDone() const
FIXME_docs.
Tcl_Interp * Interp() const
FIXME_docs.
bool AllDone()
FIXME_docs.
void AddMeth(const std::string &name, methfo_t &&methfo)
FIXME_docs.
bool GetArgsDump(RtclArgs &args, int &detail)
FIXME_docs.
int M_get(RtclArgs &args)
FIXME_docs.
void Add(const std::string &name, get_uptr_t &&upget)
FIXME_docs.
Implemenation (inline) of RtclOPtr.
std::string CommandName() const
FIXME_docs.
int M_add(RtclArgs &args)
FIXME_docs.
int M_ldabs(RtclArgs &args)
FIXME_docs.
bool GetIAddr(RtclArgs &args, uint16_t &ibaddr)
FIXME_docs.
int M_rmap(RtclArgs &args)
FIXME_docs.
int M_examine(RtclArgs &args)
FIXME_docs.
int M_wtcpu(RtclArgs &args)
FIXME_docs.
int M_set(RtclArgs &args)
FIXME_docs.
RtclRw11Cpu(const std::string &type)
Default constructor.
int M_stats(RtclArgs &args)
FIXME_docs.
bool ClistNonEmpty(RtclArgs &args, const RlinkCommandList &clist)
FIXME_docs.
RlinkConnect & Connect()
FIXME_docs.
bool GetVarName(RtclArgs &args, const char *argname, size_t nind, std::vector< std::string > &varname)
FIXME_docs.
bool GetRAddr(RtclArgs &args, uint16_t &rbaddr)
FIXME_docs.
int M_get(RtclArgs &args)
FIXME_docs.
int M_ldasm(RtclArgs &args)
FIXME_docs.
int M_dump(RtclArgs &args)
FIXME_docs.
int M_cp(RtclArgs &args)
FIXME_docs.
RlinkServer & Server()
FIXME_docs.
int M_imap(RtclArgs &args)
FIXME_docs.
Tcl_Obj * ControllerCommands()
FIXME_docs.
int M_lsmem(RtclArgs &args)
FIXME_docs.
virtual ~RtclRw11Cpu()
Destructor.
int M_default(RtclArgs &args)
FIXME_docs.
void SetupGetSet()
FIXME_docs.
int M_show(RtclArgs &args)
FIXME_docs.
int M_deposit(RtclArgs &args)
FIXME_docs.
int M_boot(RtclArgs &args)
FIXME_docs.
virtual Rw11Cpu & Obj()=0
int M_set(RtclArgs &args)
FIXME_docs.
static bool Exec(RtclArgs &args, const Context &cntx, Rstats &stats)
FIXME_docs.
static bool GetArgs(RtclArgs &args, Context &cntx)
FIXME_docs.
const Rw11Probe & ProbeStatus() const
FIXME_docs.
const std::string & Type() const
FIXME_docs.
uint16_t Base() const
FIXME_docs.
int Lam() const
FIXME_docs.
bool Enable() const
FIXME_docs.
bool IsStarted() const
FIXME_docs.
const std::string & Name() const
FIXME_docs.
virtual Rw11Unit & UnitBase(size_t index) const =0
virtual size_t NUnit() const =0
static const uint8_t kStat_M_CmdMErr
stat: cmdmerr flag
bool HasPcnt() const
FIXME_docs.
const RlinkAddrMap & IAddrMap() const
FIXME_docs.
bool HasIbmon() const
FIXME_docs.
static const uint16_t kCPUUBMAP
UBMAP base address.
uint16_t Base() const
FIXME_docs.
static const uint16_t kCPMEM
CPMEM reg offset.
static const uint16_t kMMUPDRU
MMU PDRU address.
static const uint16_t kCPFUNC_STOP
STOP func code.
static const uint16_t kCPR0
CPR0 reg offset.
void ListCntl(std::vector< std::string > &list) const
FIXME_docs.
static const uint16_t kMMUPDRS
MMU PDRS address.
uint16_t IBase() const
FIXME_docs.
static const uint16_t kCPAH
CPAH reg offset.
void SetCpuActUp()
FIXME_docs.
static const uint16_t kCPFUNC_STEP
STEP func code.
int AddRbibr(RlinkCommandList &clist, uint16_t ibaddr, size_t size)
FIXME_docs.
static const uint16_t kCPCONF
CPCONF reg offset.
static const uint16_t kCPAL
CPAL reg offset.
bool HasM9312() const
FIXME_docs.
static const uint16_t kMMUMMR0
MMU MMR0 address.
bool IAddrMapInsert(const std::string &name, uint16_t ibaddr)
FIXME_docs.
bool HasIbtst() const
FIXME_docs.
static const uint16_t kCPPSW
CPPSW reg offset.
static const uint16_t kCPFUNC_RESUME
RESUME func code.
virtual void Dump(std::ostream &os, int ind=0, const char *text=0, int detail=0) const
FIXME_docs.
bool HasKw11p() const
FIXME_docs.
static const uint16_t kCPFUNC_CRESET
CRESET func code.
uint16_t HasHbpt() const
FIXME_docs.
size_t Index() const
FIXME_docs.
static const uint16_t kCPFUNC_BRESET
BRESET func code.
static const uint16_t kMMUPDRK
MMU PDRK address.
bool HasKw11l() const
FIXME_docs.
static const uint16_t kCPAH_M_22BIT
ena 22bit addressing
uint32_t MemSize() const
FIXME_docs.
static const uint8_t kStat_M_CmdErr
stat: cmderr flag
int AddMembe(RlinkCommandList &clist, uint16_t be, bool stick=false)
FIXME_docs.
bool HasIist() const
FIXME_docs.
const RlinkAddrMap & RAddrMap() const
FIXME_docs.
bool MemRead(uint16_t addr, std::vector< uint16_t > &data, size_t nword, RerrMsg &emsg)
FIXME_docs.
static const uint16_t kCPPC
CPPC reg offset.
static const uint16_t kCPFUNC_START
START func code.
static const uint16_t kCPMEMI
CPMEMI reg offset.
bool HasScnt() const
FIXME_docs.
static const uint16_t kCPMEMBE
CPMEMBE reg offset.
bool HasCmon() const
FIXME_docs.
int AddWibr(RlinkCommandList &clist, uint16_t ibaddr, uint16_t data)
FIXME_docs.
int WaitCpuActDown(const Rtime &tout, Rtime &twait)
FIXME_docs.
static const uint16_t kMMUMMR3
MMU MMR3 address.
bool MemWrite(uint16_t addr, const std::vector< uint16_t > &data, RerrMsg &emsg)
FIXME_docs.
int AddRibr(RlinkCommandList &clist, uint16_t ibaddr)
FIXME_docs.
static const uint16_t kCPAH_M_UBM22
ubmap+22bit
bool RAddrMapInsert(const std::string &name, uint16_t rbaddr)
FIXME_docs.
int AddWbibr(RlinkCommandList &clist, uint16_t ibaddr, const std::vector< uint16_t > &block)
FIXME_docs.
static const uint16_t kCPSTAT
CPSTAT reg offset.
static const uint16_t kCPCNTL
CPADDR reg offset.
static const uint16_t kCPFUNC_SUSPEND
SUSPEND func code.
const std::string & Type() const
FIXME_docs.
bool IsAttached() const
FIXME_docs.
std::string Name() const
FIXME_docs.
const std::string & AttachUrl() const
FIXME_docs.
static const int kLam
W11 CPU cluster lam.
RosPrintfS< bool > RosPrintf(bool value, const char *form=0, int width=0, int prec=0)
Creates a print object for the formatted output of a bool value.
bool SetVarOrResult(Tcl_Interp *interp, const std::string &varname, Tcl_Obj *pobj)
Tcl_Obj * NewLinesObj(const std::string &str)
bool SetVar(Tcl_Interp *interp, const std::string &varname, Tcl_Obj *pobj)
Tcl_Obj * NewListIntObj(const uint8_t *data, size_t size)
Declaration of class ReventLoop.
int RtclRw11CntlFactory(RtclArgs &args, RtclRw11Cpu &cpu)
FIXME_docs.
char IndicatorInt() const
FIXME_docs.
bool Found() const
FIXME_docs.
char IndicatorRem() const
FIXME_docs.