w11 - cpp 0.794
Backend server for Rlink and w11
Loading...
Searching...
No Matches
RtclRw11Cpu.cpp
Go to the documentation of this file.
1// $Id: RtclRw11Cpu.cpp 1347 2023-01-07 12:48:58Z mueller $
2// SPDX-License-Identifier: GPL-3.0-or-later
3// Copyright 2013-2023 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4//
5// Revision History:
6// Date Rev Version Comment
7// 2023-01-06 1347 1.2.37 use kCPUUBMAP, fix rust code name
8// 2022-09-03 1292 1.2.36 M_show: fix mmr1 display, better mmr0 display
9// 2022-08-11 1276 1.2.35 ssr->mmr rename
10// 2022-07-07 1249 1.2.34 BUGFIX: quit before mem write if asm-11 error seen
11// 2019-06-29 1175 1.2.33 M_ldabs(): add missing OptValid() call
12// 2019-06-07 1160 1.2.32 use RtclStats::Exec()
13// 2019-04-30 1143 1.2.31 add HasM9312() getter
14// 2019-04-12 1131 1.2.30 BUGFIX: M_wtcpu(): check cpu attn in no-server case
15// add MemSize() getter; loadabs: add -trace and start
16// 2019-03-10 1121 1.2.28 M_cp(): tranfer BlockDone values after rblk
17// 2019-03-09 1120 1.2.27 add -brf,-bwf; add range checks for -wa
18// 2019-02-23 1114 1.2.26 use std::bind instead of lambda
19// 2019-02-15 1112 1.2.25 add HasIbtst() getter
20// 2018-12-23 1091 1.2.24 use AddWbibr(move),AddWblk(move)
21// 2018-12-18 1089 1.2.23 use c++ style casts
22// 2018-12-17 1085 1.2.22 use std::lock_guard instead of boost
23// 2018-12-15 1082 1.2.21 use lambda instead of boost::bind
24// 2018-12-07 1077 1.2.20 use SetLastExpectBlock move semantics
25// 2018-11-16 1070 1.2.19 use auto; use emplace_back; use range loop
26// 2018-09-23 1050 1.2.18 add HasPcnt()
27// 2018-09-21 1048 1.2.18 coverity fixup (uninitialized scalar)
28// 2017-04-22 883 1.2.17 M_(imap|rmap): -testname optional addr check
29// 2017-04-15 876 1.2.16 add ControllerCommands()
30// 2017-04-15 875 1.2.15 M_default: add attached units summary
31// 2017-04-07 868 1.2.14 M_dump: use GetArgsDump and Dump detail
32// 2017-02-26 857 1.2.13 use kCPAH_M_UBM22 for cp -wa -ubm
33// 2017-02-19 853 1.2.12 use Rtime
34// 2017-02-17 851 1.2.11 probe/setup auxilliary devices: kw11l,kw11p,iist
35// 2017-02-04 848 1.2.10 M_default: add 'probe ena on' output
36// 2016-12-30 834 1.2.9 use 'ssr' instead of 'mmr' for MMU registers
37// 2015-12-26 718 1.2.8 use BlockSizeMax() for 'cp -b[rw]m' and 'ldasm'
38// 2015-07-12 700 1.2.4 use ..CpuAct instead ..CpuGo (new active based lam);
39// add probe and map setup for optional cpu components
40// 2015-06-27 695 1.2.3 M_get: add ibase getter
41// 2015-05-04 674 1.2.2 w11a start/stop/suspend overhaul
42// 2015-04-25 668 1.2.1 M_cp: add -rbibr, wbibr; GetRAddr: drop odd check
43// 2015-04-03 661 1.2 expect logic: drop estatdef, use LastExpect..
44// 2015-03-28 660 1.1.4 M_cp: add -estat(err|nak|tout)
45// 2015-03-21 659 1.1.3 rename M_amap->M_imap; add M_rmap; add GetRAddr()
46// add -rreg,...,-init and -[rw]ma
47// 2014-12-29 623 1.1.2 add M_amap; M_cp: add -print and -dump
48// 2014-12-20 616 1.1.1 M_cp: add -edone for BlockDone checking
49// 2014-11-30 607 1.1 new rlink v4 iface
50// 2014-08-22 584 1.0.5 use nullptr
51// 2014-08-02 576 1.0.4 BUGFIX: redo estatdef logic; avoid LastExpect()
52// 2014-03-02 552 1.0.3 M_cp: add -ral and -rah options (addr reg readback)
53// 2013-05-19 521 1.0.2 M_cp: merge -wibrb|-wibrbbe again; add -wa
54// 2013-04-26 511 1.0.1 add M_show
55// 2013-04-02 502 1.0 Initial version
56// 2013-02-02 480 0.1 First draft
57// ---------------------------------------------------------------------------
58
63#include <unistd.h>
64#include <errno.h>
65#include <stdio.h>
66#include <stdlib.h>
67#include <sys/wait.h>
68
69#include <vector>
70#include <memory>
71#include <sstream>
72#include <functional>
73
74#include "librtools/RerrMsg.hpp"
75#include "librtools/RlogMsg.hpp"
78#include "librtcltools/Rtcl.hpp"
83
84#include "librw11/Rw11Unit.hpp"
85
86#include "RtclRw11.hpp"
87
89#include "librw11/Rw11Cntl.hpp"
90
91#include "RtclRw11Cpu.hpp"
92
93using namespace std;
94using namespace std::placeholders;
95
101// all method definitions in namespace Retro
102namespace Retro {
103
104//------------------------------------------+-----------------------------------
106
107RtclRw11Cpu::RtclRw11Cpu(const std::string& type)
108 : RtclProxyBase(type),
109 fGets(),
110 fSets()
111{
112 AddMeth("add", bind(&RtclRw11Cpu::M_add, this, _1));
113 AddMeth("imap", bind(&RtclRw11Cpu::M_imap, this, _1));
114 AddMeth("rmap", bind(&RtclRw11Cpu::M_rmap, this, _1));
115 AddMeth("cp", bind(&RtclRw11Cpu::M_cp, this, _1));
116 AddMeth("wtcpu", bind(&RtclRw11Cpu::M_wtcpu, this, _1));
117 AddMeth("deposit", bind(&RtclRw11Cpu::M_deposit, this, _1));
118 AddMeth("examine", bind(&RtclRw11Cpu::M_examine, this, _1));
119 AddMeth("lsmem", bind(&RtclRw11Cpu::M_lsmem, this, _1));
120 AddMeth("ldabs", bind(&RtclRw11Cpu::M_ldabs, this, _1));
121 AddMeth("ldasm", bind(&RtclRw11Cpu::M_ldasm, this, _1));
122 AddMeth("boot", bind(&RtclRw11Cpu::M_boot, this, _1));
123 AddMeth("get", bind(&RtclRw11Cpu::M_get, this, _1));
124 AddMeth("set", bind(&RtclRw11Cpu::M_set, this, _1));
125 AddMeth("stats", bind(&RtclRw11Cpu::M_stats, this, _1));
126 AddMeth("show", bind(&RtclRw11Cpu::M_show, this, _1));
127 AddMeth("dump", bind(&RtclRw11Cpu::M_dump, this, _1));
128 AddMeth("$default", bind(&RtclRw11Cpu::M_default, this, _1));
129
130 fGets.Add<Tcl_Obj*> ("cntls", bind(&RtclRw11Cpu::ControllerCommands, this));
131}
132
133//------------------------------------------+-----------------------------------
135
137{}
138
139//------------------------------------------+-----------------------------------
141
143{
144 return RtclRw11CntlFactory(args, *this);
145}
146
147//------------------------------------------+-----------------------------------
149
151{
152 static RtclNameSet optset("-name|-testname|-testaddr|-insert|-erase|-print");
153
154 const RlinkAddrMap& addrmap = Obj().IAddrMap();
155
156 string opt;
157 string name;
158 uint16_t addr=0;
159
160 if (args.NextOpt(opt, optset)) {
161 if (opt == "-name") { // imap -name addr
162 if (!args.GetArg("addr", addr)) return kERR;
163 if (!args.AllDone()) return kERR;
164 string tstname;
165 if(addrmap.Find(addr, tstname)) {
166 args.SetResult(tstname);
167 } else {
168 return args.Quit(string("-E: address '") + args.PeekArgString(-1) +
169 "' not mapped");
170 }
171
172 } else if (opt == "-testname") { // imap -testname name ?addr
173 if (!args.GetArg("name", name)) return kERR;
174 if (!args.GetArg("?addr", addr)) return kERR;
175 if (!args.AllDone()) return kERR;
176 uint16_t tstaddr=0;
177 bool found = addrmap.Find(name, tstaddr);
178 if (found && args.NOptMiss()==0) { // if specified addr
179 if (tstaddr != addr) found = false; // verify addr
180 }
181 args.SetResult(int(found));
182
183 } else if (opt == "-testaddr") { // imap -testaddr addr
184 if (!args.GetArg("addr", addr)) return kERR;
185 if (!args.AllDone()) return kERR;
186 string tstname;
187 args.SetResult(int(addrmap.Find(addr, tstname)));
188
189 } else if (opt == "-insert") { // imap -insert name addr
190 uint16_t tstaddr=0;
191 string tstname;
192 int tstint=0;
193 if (!args.GetArg("name", name)) return kERR;
194 // enforce that the name is not a valid representation of an int
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 '")+
197 name + "' does");
198 if (!args.GetArg("addr", addr)) return kERR;
199 if (!args.AllDone()) return kERR;
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 '") +
204 args.PeekArgString(-1) + "'");
205 Obj().IAddrMapInsert(name, addr);
206
207 } else if (opt == "-erase") { // imap -erase name
208 if (!args.GetArg("name", name)) return kERR;
209 if (!args.AllDone()) return kERR;
210 if (!Obj().IAddrMapErase(name))
211 return args.Quit(string("-E: no mapping defined for '") + name + "'");
212
213 } else if (opt == "-print") { // imap -print
214 if (!args.AllDone()) return kERR;
215 ostringstream sos;
216 addrmap.Print(sos);
217 args.AppendResultLines(sos);
218 }
219
220 } else {
221 if (!args.OptValid()) return kERR;
222 if (!args.GetArg("?name", name)) return kERR;
223 if (args.NOptMiss()==0) { // imap name
224 uint16_t tstaddr=0;
225 if(addrmap.Find(name, tstaddr)) {
226 args.SetResult(int(tstaddr));
227 } else {
228 return args.Quit(string("-E: no mapping defined for '") + name + "'");
229 }
230
231 } else { // imap
232 RtclOPtr plist(Tcl_NewListObj(0, nullptr));
233 const auto amap = addrmap.Amap();
234 for (auto& o: amap) {
235 Tcl_Obj* tpair[2];
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));
239 }
240 args.SetResult(plist);
241 }
242 }
243
244 return kOK;
245}
246
247//------------------------------------------+-----------------------------------
249
251{
252 static RtclNameSet optset("-name|-testname|-testaddr|-insert|-erase|-print");
253
254 const RlinkAddrMap& lmap = Obj().RAddrMap(); // local map
255 const RlinkAddrMap& cmap = Connect().AddrMap(); // common map
256
257 string opt;
258 string name;
259 uint16_t addr=0;
260
261 if (args.NextOpt(opt, optset)) {
262 if (opt == "-name") { // rmap -name addr
263 if (!args.GetArg("addr", addr)) return kERR;
264 if (!args.AllDone()) return kERR;
265 string tstname;
266 if(lmap.Find(addr, tstname)) {
267 args.SetResult(tstname);
268 } else if(cmap.Find(addr, tstname)) {
269 args.SetResult(tstname);
270 } else {
271 return args.Quit(string("-E: address '") + args.PeekArgString(-1) +
272 "' not mapped");
273 }
274
275 } else if (opt == "-testname") { // rmap -testname name ?addr
276 if (!args.GetArg("name", name)) return kERR;
277 if (!args.GetArg("?addr", addr)) return kERR;
278 if (!args.AllDone()) return kERR;
279 uint16_t tstaddr=0;
280 bool found = lmap.Find(name, tstaddr);
281 if (found && args.NOptMiss()==0) { // if specified addr
282 if (tstaddr != addr) found = false; // verify addr
283 }
284 args.SetResult(int(found));
285
286 } else if (opt == "-testaddr") { // rmap -testaddr addr
287 if (!args.GetArg("addr", addr)) return kERR;
288 if (!args.AllDone()) return kERR;
289 string tstname;
290 args.SetResult(int(lmap.Find(addr, tstname)));
291
292 } else if (opt == "-insert") { // rmap -insert name addr
293 uint16_t tstaddr=0;
294 string tstname;
295 int tstint=0;
296 if (!args.GetArg("name", name)) return kERR;
297 // enforce that the name is not a valid representation of an int
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 '")+
300 name + "' does");
301 if (!args.GetArg("addr", addr)) return kERR;
302 if (!args.AllDone()) return kERR;
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 '") +
307 args.PeekArgString(-1) + "'");
308 Obj().RAddrMapInsert(name, addr);
309
310 } else if (opt == "-erase") { // rmap -erase name
311 if (!args.GetArg("name", name)) return kERR;
312 if (!args.AllDone()) return kERR;
313 if (!Obj().RAddrMapErase(name))
314 return args.Quit(string("-E: no mapping defined for '") + name + "'");
315
316 } else if (opt == "-print") { // rmap -print
317 if (!args.AllDone()) return kERR;
318 ostringstream sos;
319 lmap.Print(sos);
320 args.AppendResultLines(sos);
321 }
322
323 } else {
324 if (!args.OptValid()) return kERR;
325 if (!args.GetArg("?name", name)) return kERR;
326 if (args.NOptMiss()==0) { // rmap name
327 uint16_t tstaddr=0;
328 if(lmap.Find(name, tstaddr)) {
329 args.SetResult(int(tstaddr));
330 } else if(cmap.Find(name, tstaddr)) {
331 args.SetResult(int(tstaddr));
332 } else {
333 return args.Quit(string("-E: no mapping defined for '") + name + "'");
334 }
335
336 } else { // rmap
337 RtclOPtr plist(Tcl_NewListObj(0, nullptr));
338 const auto amap = lmap.Amap();
339 for (auto& o: amap) {
340 Tcl_Obj* tpair[2];
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));
344 }
345 args.SetResult(plist);
346 }
347 }
348
349 return kOK;
350}
351
352//------------------------------------------+-----------------------------------
354
356{
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|"
361 "-rps|-wps|"
362 "-ral|-rah|-wal|-wah|-wa|"
363 "-rm|-rmi|-rma|-wm|-wmi|-wma|-brm|-bwm|-brf|-bwf|"
364 "-start|-stop|-step|-creset|-breset|"
365 "-suspend|-resume|"
366 "-stapc|"
367 "-rmembe|-wmembe|-ribr|-rbibr|-wibr|-wbibr|"
368 "-rconf|-rstat|"
369 "-edata|-edone|-estat|"
370 "-estaterr|-estatnak|-estattout|"
371 "-print|-dump");
372
373 Tcl_Interp* interp = args.Interp();
374
375 RlinkCommandList clist;
376 string opt;
377 uint16_t base = Obj().Base();
378
379 vector<string> vardata;
380 vector<string> varstat;
381 string varprint;
382 string vardump;
383
384 bool setcpuact = false;
385
386 while (args.NextOpt(opt, optset)) {
387 size_t lsize = clist.Size();
388
389 // map register read/write
390 if (opt == "-rsp") opt = "-rr6";
391 if (opt == "-rpc") opt = "-rr7";
392 if (opt == "-wsp") opt = "-wr6";
393 if (opt == "-wpc") opt = "-wr7";
394
395 int regnum = 0;
396 if (opt.substr(0,3) == "-rr" || opt.substr(0,3) == "-wr" ) {
397 if (opt.length() == 3) { // -rr n or -wr n option
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);
402 }
403 }
404
405 if (opt == "-rreg") { // -rreg addr ?varData ?varStat ---
406 uint16_t addr=0;
407 if (!GetRAddr(args, addr)) return kERR;
408 if (!GetVarName(args, "??varData", lsize, vardata)) return kERR;
409 if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR;
410 clist.AddRreg(addr);
411
412 } else if (opt == "-rblk") { // -rblk addr size ?varData ?varStat
413 uint16_t addr=0;
414 int32_t bsize=0;
415 if (!GetRAddr(args, addr)) return kERR;
416 if (!args.GetArg("bsize", bsize, 1, Connect().BlockSizeMax())) return kERR;
417 if (!GetVarName(args, "??varData", lsize, vardata)) return kERR;
418 if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR;
419 clist.AddRblk(addr, size_t(bsize));
420
421 } else if (opt == "-wreg") { // -wreg addr data ?varStat -------
422 uint16_t addr=0;
423 uint16_t data=0;
424 if (!GetRAddr(args, addr)) return kERR;
425 if (!args.GetArg("data", data)) return kERR;
426 if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR;
427 clist.AddWreg(addr, data);
428
429 } else if (opt == "-wblk") { // -wblk addr block ?varStat ------
430 uint16_t addr=0;
431 vector<uint16_t> block;
432 if (!GetRAddr(args, addr)) return kERR;
433 if (!args.GetArg("data", block, 1, Connect().BlockSizeMax())) return kERR;
434 if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR;
435 clist.AddWblk(addr, move(block));
436
437 } else if (opt == "-labo") { // -labo varData ?varStat ---------
438 if (!GetVarName(args, "??varData", lsize, vardata)) return kERR;
439 if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR;
440 clist.AddLabo();
441
442 } else if (opt == "-attn") { // -attn varData ?varStat ---------
443 if (!GetVarName(args, "??varData", lsize, vardata)) return kERR;
444 if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR;
445 clist.AddAttn();
446
447 } else if (opt == "-init") { // -init addr data ?varStat -------
448 uint16_t addr=0;
449 uint16_t data=0;
450 if (!GetRAddr(args, addr)) return kERR;
451 if (!args.GetArg("data", data)) return kERR;
452 if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR;
453 clist.AddInit(addr, data);
454
455 } else if (opt == "-rr") { // -rr* ?varData ?varStat --------
456 if (!GetVarName(args, "??varData", lsize, vardata)) return kERR;
457 if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR;
458 clist.AddRreg(base + Rw11Cpu::kCPR0 + regnum);
459
460 } else if (opt == "-wr") { // -wr* data ?varStat ------------
461 uint16_t data=0;
462 if (!args.GetArg("data", data)) return kERR;
463 if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR;
464 clist.AddWreg(base + Rw11Cpu::kCPR0 + regnum, data);
465
466 } else if (opt == "-rps") { // -rps ?varData ?varStat --------
467 if (!GetVarName(args, "??varData", lsize, vardata)) return kERR;
468 if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR;
469 clist.AddRreg(base + Rw11Cpu::kCPPSW);
470
471 } else if (opt == "-wps") { // -wps data ?varStat ------------
472 uint16_t data=0;
473 if (!args.GetArg("data", data)) return kERR;
474 if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR;
475 clist.AddWreg(base + Rw11Cpu::kCPPSW, data);
476
477 } else if (opt == "-ral") { // -ral ?varData ?varStat --------
478 if (!GetVarName(args, "??varData", lsize, vardata)) return kERR;
479 if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR;
480 clist.AddRreg(base + Rw11Cpu::kCPAL);
481
482 } else if (opt == "-rah") { // -rah ?varData ?varStat --------
483 if (!GetVarName(args, "??varData", lsize, vardata)) return kERR;
484 if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR;
485 clist.AddRreg(base + Rw11Cpu::kCPAH);
486
487 } else if (opt == "-wal") { // -wal data ?varStat ------------
488 uint16_t ibaddr=0;
489 if (!GetIAddr(args, ibaddr)) return kERR;
490 if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR;
491 clist.AddWreg(base + Rw11Cpu::kCPAL, ibaddr);
492
493 } else if (opt == "-wah") { // -wah data ?varStat ------------
494 uint16_t data=0;
495 if (!args.GetArg("ah", data)) return kERR;
496 if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR;
497 clist.AddWreg(base + Rw11Cpu::kCPAH, data);
498
499 // Note: -wa without -p22 or -ubm options is equivalent to -wal
500 } else if (opt == "-wa") { // -wa addr ?varStat [-p22 -ubm]--
501 uint32_t addr=0;
502 if (!args.GetArg("addr", addr, 017777776)) return kERR;
503 if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR;
504 uint16_t al = addr;
505 uint16_t ah = (addr>>16);
506 static RtclNameSet suboptset("-p22|-ubm");
507 string subopt;
508 while (args.NextSubOpt(subopt, suboptset)>=0) { // loop for sub-options
509 if (!args.OptValid()) return kERR;
510 if (subopt == "-p22") { // -p22
512 } else if (subopt == "-ubm") { // -ubm
514 if (addr > 0777776) {
515 ostringstream sos;
516 sos << "-E: value '" << addr
517 << "' for 'addr' out of range 0...0777776";
518 args.AppendResult(sos);
519 return kERR;
520 }
521 }
522 }
524 addr > 0177776) {
525 ostringstream sos;
526 sos << "-E: value '" << addr
527 << "' for 'addr' out of range 0...0177776";
528 args.AppendResult(sos);
529 return kERR;
530 }
531
532 clist.AddWreg(base + Rw11Cpu::kCPAL, al);
533 if (ah!=0) clist.AddWreg(base + Rw11Cpu::kCPAH, ah);
534
535 } else if (opt == "-rm" || // -rm(i) ?varData ?varStat ------
536 opt == "-rmi") {
537 uint16_t addr = opt=="-rm" ? Rw11Cpu::kCPMEM :
539 if (!GetVarName(args, "??varData", lsize, vardata)) return kERR;
540 if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR;
541 clist.AddRreg(base + addr);
542
543 } else if (opt == "-rma") { // -rma addr ?varData ?varStat ---
544 uint16_t ibaddr=0;
545 if (!GetIAddr(args, ibaddr)) return kERR;
546 // bind expects to memi access, which is second command
547 if (!GetVarName(args, "??varData", lsize+1, vardata)) return kERR;
548 if (!GetVarName(args, "??varStat", lsize+1, varstat)) return kERR;
549 clist.AddWreg(base + Rw11Cpu::kCPAL, ibaddr);
550 clist.AddRreg(base + Rw11Cpu::kCPMEMI);
551
552 } else if (opt == "-wm" || // -wm(i) data ?varStat -
553 opt == "-wmi") {
554 uint16_t addr = opt=="-wm" ? Rw11Cpu::kCPMEM :
556 uint16_t data=0;
557 if (!args.GetArg("data", data)) return kERR;
558 if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR;
559 clist.AddWreg(base + addr, data);
560
561 } else if (opt == "-wma") { // -wma addr data ?varStat -------
562 uint16_t ibaddr=0;
563 uint16_t data=0;
564 if (!GetIAddr(args, ibaddr)) return kERR;
565 if (!args.GetArg("data", data)) return kERR;
566 // bind expects to memi access, which is second command
567 if (!GetVarName(args, "??varStat", lsize+1, varstat)) return kERR;
568 clist.AddWreg(base + Rw11Cpu::kCPAL, ibaddr);
569 clist.AddWreg(base + Rw11Cpu::kCPMEMI, data);
570
571 } else if (opt == "-brm") { // -brm size ?varData ?varStat ---
572 int32_t bsize=0;
573 if (!args.GetArg("bsize", bsize, 1, Connect().BlockSizeMax())) return kERR;
574 if (!GetVarName(args, "??varData", lsize, vardata)) return kERR;
575 if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR;
576 clist.AddRblk(base + Rw11Cpu::kCPMEMI, size_t(bsize));
577
578 } else if (opt == "-bwm") { // -bwm block ?varStat -----------
579 vector<uint16_t> block;
580 if (!args.GetArg("data", block, 1, Connect().BlockSizeMax())) return kERR;
581 if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR;
582 clist.AddWblk(base + Rw11Cpu::kCPMEMI, move(block));
583
584 } else if (opt == "-brf") { // -brf size ?varData ?varStat ---
585 int32_t bsize=0;
586 if (!args.GetArg("bsize", bsize, 1, Connect().BlockSizeMax())) return kERR;
587 if (!GetVarName(args, "??varData", lsize, vardata)) return kERR;
588 if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR;
589 clist.AddRblk(base + Rw11Cpu::kCPMEM, size_t(bsize));
590
591 } else if (opt == "-bwf") { // -bwf block ?varStat -----------
592 vector<uint16_t> block;
593 if (!args.GetArg("data", block, 1, Connect().BlockSizeMax())) return kERR;
594 if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR;
595 clist.AddWblk(base + Rw11Cpu::kCPMEM, move(block));
596
597 } else if (opt == "-start") { // -start ?varStat ---------------
598 if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR;
600 setcpuact = true;
601
602 } else if (opt == "-stop") { // -stop ?varStat ----------------
603 if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR;
605
606 } else if (opt == "-step") { // -step ?varStat ----------------
607 if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR;
609
610 } else if (opt == "-creset") { // -creset ?varStat --------------
611 if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR;
613
614 } else if (opt == "-breset") { // -breset ?varStat --------------
615 if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR;
617
618 } else if (opt == "-suspend") { // -suspend ?varStat -------------
619 if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR;
621
622 } else if (opt == "-resume") { // -resume ?varStat --------------
623 if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR;
625 setcpuact = true;
626
627 } else if (opt == "-stapc") { // -stapc addr ?varStat ----------
628 uint16_t data=0;
629 if (!args.GetArg("data", data)) return kERR;
630 if (!GetVarName(args, "??varStat", lsize+1, varstat)) return kERR;
633 clist.AddWreg(base + Rw11Cpu::kCPPC, data);
635 setcpuact = true;
636
637 } else if (opt == "-rmembe") { // -rmembe ?varData ?varStat ------
638 if (!GetVarName(args, "??varData", lsize, vardata)) return kERR;
639 if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR;
640 clist.AddRreg(base + Rw11Cpu::kCPMEMBE);
641
642 } else if (opt == "-wmembe") { // -wmembe be ?varStat [-stick] -
643 uint16_t be=0;
644 bool stick = false;
645 if (!args.GetArg("be", be, 3)) return kERR;
646 if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR;
647
648 static RtclNameSet suboptset("-stick");
649 string subopt;
650 while (args.NextSubOpt(subopt, suboptset)>=0) { // loop for sub-options
651 if (!args.OptValid()) return kERR;
652 if (subopt == "-stick") { // -stick
653 stick = true;
654 }
655 }
656 Obj().AddMembe(clist, be, stick);
657
658 } else if (opt == "-ribr") { // -ribr iba ?varData ?varStat ----
659 uint16_t ibaddr=0;
660 if (!GetIAddr(args, ibaddr)) return kERR;
661 if (!GetVarName(args, "??varData", lsize, vardata)) return kERR;
662 if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR;
663 Obj().AddRibr(clist, ibaddr);
664
665 } else if (opt == "-rbibr") { // -rbibr iba size ?varData ?varStat
666 uint16_t ibaddr=0;
667 int32_t bsize=0;
668 if (!GetIAddr(args, ibaddr)) return kERR;
669 if (!args.GetArg("bsize", bsize, 1, Connect().BlockSizeMax())) return kERR;
670 if (!GetVarName(args, "??varData", lsize, vardata)) return kERR;
671 if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR;
672 Obj().AddRbibr(clist, ibaddr, size_t(bsize));
673
674 } else if (opt == "-wibr") { // -wibr iba data ?varStat --------
675 uint16_t ibaddr=0;
676 uint16_t data=0;
677 if (!GetIAddr(args, ibaddr)) return kERR;
678 if (!args.GetArg("data", data)) return kERR;
679 if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR;
680 Obj().AddWibr(clist, ibaddr, data);
681
682 } else if (opt == "-wbibr") { // -wbibr iba block data ?varStat -
683 uint16_t ibaddr=0;
684 vector<uint16_t> block;
685 if (!GetIAddr(args, ibaddr)) return kERR;
686 if (!args.GetArg("data", block, 1, Connect().BlockSizeMax())) return kERR;
687 if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR;
688 Obj().AddWbibr(clist, ibaddr, move(block));
689
690 } else if (opt == "-rconf") { // -rconf ?varData ?varStat ------
691 if (!GetVarName(args, "??varData", lsize, vardata)) return kERR;
692 if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR;
693 clist.AddRreg(base + Rw11Cpu::kCPCONF);
694
695 } else if (opt == "-rstat") { // -rstat ?varData ?varStat ------
696 if (!GetVarName(args, "??varData", lsize, vardata)) return kERR;
697 if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR;
698 clist.AddRreg(base + Rw11Cpu::kCPSTAT);
699
700 } else if (opt == "-edata") { // -edata data ?mask --------------
701 if (!ClistNonEmpty(args, clist)) return kERR;
702 if (clist[lsize-1].Command() == RlinkCommand::kCmdRblk) {
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;
708 clist.SetLastExpectBlock(move(data), move(mask));
709 } else {
710 uint16_t data=0;
711 uint16_t mask=0xffff;
712 if (!args.GetArg("data", data)) return kERR;
713 if (!args.GetArg("??mask", mask)) return kERR;
714 clist.SetLastExpectData(data, mask);
715 }
716
717 } else if (opt == "-edone") { // -edone done --------------------
718 if (!ClistNonEmpty(args, clist)) return kERR;
719 uint16_t done=0;
720 if (!args.GetArg("done", done)) return kERR;
721 uint8_t cmd = clist[lsize-1].Command();
722 if (cmd == RlinkCommand::kCmdRblk ||
723 cmd == RlinkCommand::kCmdWblk) {
724 clist.SetLastExpectDone(done);
725 } else {
726 return args.Quit("-E: -edone allowed only after -rblk,-wblk");
727 }
728
729 } else if (opt == "-estat") { // -estat stat ?mask --------------
730 if (!ClistNonEmpty(args, clist)) return kERR;
731 uint8_t stat=0;
732 uint8_t mask=0xff;
733 if (!args.GetArg("stat", stat)) return kERR;
734 if (!args.GetArg("??mask", mask)) return kERR;
735 clist.SetLastExpectStatus(stat, mask);
736
737 } else if (opt == "-estaterr" || // -estaterr ----------------------
738 opt == "-estatnak" || // -estatnak ----------------------
739 opt == "-estattout" || // -estattout ---------------------
740 opt == "-estatmerr") { // -estatmerr ---------------------
741 if (!ClistNonEmpty(args, clist)) return kERR;
742 uint8_t val = 0;
743 uint8_t msk = RlinkCommand::kStat_M_RbTout |
746 if (opt == "-estaterr") val = RlinkCommand::kStat_M_RbErr;
747 if (opt == "-estatnak") val = RlinkCommand::kStat_M_RbNak;
748 if (opt == "-estattout") val = RlinkCommand::kStat_M_RbTout;
749 if (opt == "-estatmerr") {
753 }
754 clist.SetLastExpectStatus(val, msk);
755
756 } else if (opt == "-print") { // -print ?varRes -----------------
757 varprint = "-";
758 if (!args.GetArg("??varRes", varprint)) return kERR;
759 } else if (opt == "-dump") { // -dump ?varRes ------------------
760 vardump = "-";
761 if (!args.GetArg("??varRes", vardump)) return kERR;
762 }
763
764 } // while (args.NextOpt(opt, optset))
765
766 int nact = 0;
767 if (varprint == "-") nact += 1;
768 if (vardump == "-") nact += 1;
769 if (nact > 1)
770 return args.Quit(
771 "-E: more that one of -print,-dump without target variable found");
772
773 if (!args.AllDone()) return kERR;
774 if (clist.Size() == 0) return kOK;
775
776 // signal cpugo up before clist executed to prevent races
777 if (setcpuact) Obj().SetCpuActUp();
778
779 RerrMsg emsg;
780 // this one intentionally on Connect() to allow mixing of rlc + w11 commands
781 // FIXME_code: is this a good idea ??
782 if (!Connect().Exec(clist, emsg)) return args.Quit(emsg);
783
784 // FIXME: this code is a 1-to-1 copy from RtclRlinkConnect ! put into a method
785 for (size_t icmd=0; icmd<clist.Size(); icmd++) {
786 RlinkCommand& cmd = clist[icmd];
787
788 if (icmd<vardata.size() && !vardata[icmd].empty()) {
789 RtclOPtr pres;
790 vector<uint16_t> retstat;
791 RtclOPtr pele;
792 switch (cmd.Command()) {
796 pres = Tcl_NewIntObj(int(cmd.Data()));
797 break;
798
800 pres = Rtcl::NewListIntObj(cmd.Block().data(), cmd.BlockDone());
801 break;
802 }
803 if(!Rtcl::SetVar(interp, vardata[icmd], pres)) return kERR;
804 }
805
806 if (icmd<varstat.size() && !varstat[icmd].empty()) {
807 RtclOPtr pres(Tcl_NewIntObj(int(cmd.Status())));
808 if (!Rtcl::SetVar(interp, varstat[icmd], pres)) return kERR;
809 }
810 }
811
812 if (!varprint.empty()) {
813 ostringstream sos;
814 clist.Print(sos, &Connect().AddrMap(),
815 Connect().LogBaseAddr(), Connect().LogBaseData(),
816 Connect().LogBaseStat());
817 RtclOPtr pobj(Rtcl::NewLinesObj(sos));
818 if (!Rtcl::SetVarOrResult(args.Interp(), varprint, pobj)) return kERR;
819 }
820
821 if (!vardump.empty()) {
822 ostringstream sos;
823 clist.Dump(sos, 0);
824 RtclOPtr pobj(Rtcl::NewLinesObj(sos));
825 if (!Rtcl::SetVarOrResult(args.Interp(), vardump, pobj)) return kERR;
826 }
827
828 return kOK;
829}
830
831//------------------------------------------+-----------------------------------
833
835{
836 static RtclNameSet optset("-reset");
837
838 string opt;
839 bool reset = false;
840 double dtout = 0.;
841
842 while (args.NextOpt(opt, optset)) {
843 if (opt == "-reset") reset = true;
844 }
845 if (!args.OptValid()) return kERR;
846 if (!args.GetArg("tout", dtout, 0.001)) return kERR;
847 if (!args.AllDone()) return kERR;
848
849 Rtime tout(dtout);
850 Rtime twait;
851 int irc = -1;
852
853 if (!Server().IsActive()) { // server is not active
854 Rtime twait1;
855 RerrMsg emsg;
856 uint16_t apat;
857 uint16_t apatcpu = uint16_t(1)<<Rw11::kLam;
858 // FIXME_code: make apat accessible in tcl
859 while (true) {
860 irc = Connect().WaitAttn(tout, twait1, apat, emsg);
861 twait += twait1;
862 tout -= twait1;
863 if (irc == -2) return args.Quit(emsg); // if fail, quit
864 if (irc < 0) break; // if timeout, quit loop
865
866 RlinkCommandList clist; // get and discard attn pattern
867 clist.AddAttn();
868 if (!Connect().Exec(clist, emsg)) return args.Quit(emsg);
869 apat = clist[0].Data(); // get attn pattern
870 if (apat & apatcpu) break; // cpu seen, quit loop
871 }
872
873 } else { // server is active
874 irc = Obj().WaitCpuActDown(tout, twait);
875 }
876
877 if (irc < 0) { // timeout
878 if (Connect().PrintLevel() >= 1) {
879 RlogMsg lmsg(Connect().LogFile());
880 lmsg << "-- wtcpu to=" << RosPrintf(dtout, "f", 0,3) << " FAIL timeout";
881 }
883 if (reset) { // reset requested
884 uint16_t base = Obj().Base();
885 RlinkCommandList clist;
887 RerrMsg emsg;
888 if (!Connect().Exec(clist, emsg)) return args.Quit(emsg);
889 }
890 } else { // no timeout
891 if (Connect().PrintLevel() >= 3) {
892 RlogMsg lmsg(Connect().LogFile());
893 lmsg << "-- wtcpu to=" << RosPrintf(dtout, "f", 0,3)
894 << " T=" << RosPrintf(double(twait), "f", 0,3)
895 << " OK";
896 }
897 }
898
899 args.SetResult(irc >= 0 ? double(twait) : double(irc));
900 return kOK;
901}
902
903//------------------------------------------+-----------------------------------
905
907{
908 uint16_t addr=0;
909 vector<uint16_t> data;
910 if (!args.GetArg("addr", addr)) return kERR;
911 if (!args.GetArg("data", data, 1)) return kERR;
912 if (!args.AllDone()) return kERR;
913
914 RerrMsg emsg;
915 // FIXME_code: handle memory read/write error
916 if (!Obj().MemWrite(addr, data, emsg)) return args.Quit(emsg);
917
918 return kOK;
919}
920
921//------------------------------------------+-----------------------------------
923
925{
926 uint16_t addr=0;
927 if (!args.GetArg("addr", addr)) return kERR;
928 if (!args.AllDone()) return kERR;
929
930 RerrMsg emsg;
931 vector<uint16_t> data;
932 // FIXME_code: handle memory read/write error
933 if (!Obj().MemRead(addr, data, 1, emsg)) return args.Quit(emsg);
934
935 args.SetResult(Rtcl::NewListIntObj(data));
936
937 return kOK;
938}
939
940//------------------------------------------+-----------------------------------
942
944{
945 uint16_t abeg=0;
946 if (!args.GetArg("abeg", abeg)) return kERR;
947 uint16_t aend = abeg;
948 if (!args.GetArg("?aend", aend, 0xffff, abeg)) return kERR;
949 if (!args.AllDone()) return kERR;
950
951 RerrMsg emsg;
952 vector<uint16_t> data;
953 size_t nword = 1+(aend-abeg)/2;
954 // FIXME_code: handle memory read/write error
955 if (!Obj().MemRead(abeg, data, nword, emsg)) return args.Quit(emsg);
956
957 ostringstream sos;
958 for (size_t i=0; i<nword; i++) {
959 sos << RosPrintBvi(uint16_t(abeg+i*2), 8)
960 << " : " << RosPrintBvi(data[i], 8) << endl;
961 }
962
963 args.SetResult(sos);
964
965 return kOK;
966}
967
968//------------------------------------------+-----------------------------------
970
972{
973 static RtclNameSet optset("-trace");
974
975 string opt;
976 bool trace = false;
977 while (args.NextOpt(opt, optset)) {
978 if (opt == "-trace") trace = true;
979 }
980 if (!args.OptValid()) return kERR;
981
982 string file;
983 string varstart;
984 if (!args.GetArg("file", file)) return kERR;
985 if (!args.GetArg("??start", varstart)) return kERR;
986 if (!args.AllDone()) return kERR;
987 RerrMsg emsg;
988 uint16_t start;
989 // FIXME_code: handle memory read/write error
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)));
994 if (!Rtcl::SetVar(interp, varstart, pres)) return kERR;
995 }
996 return kOK;
997}
998
999//------------------------------------------+-----------------------------------
1001
1003{
1004 static RtclNameSet optset("-lst|-sym|-opt|-file");
1005 Tcl_Interp* interp = args.Interp();
1006
1007 string varlst;
1008 string varsym;
1009 string asmopt;
1010 string file;
1011 string code;
1012
1013 string opt;
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") {
1020 // don't use ?? because the argument will look like an option...
1021 if (!args.GetArg("opts", asmopt)) return kERR;
1022 } else if (opt == "-file") {
1023 if (!args.GetArg("??file", file)) return kERR;
1024 }
1025 }
1026 if (!args.OptValid()) return kERR;
1027
1028 if (file.length() == 0) {
1029 if (!args.GetArg("code", code)) return kERR;
1030 }
1031 if (!args.AllDone()) return kERR;
1032
1033 // delete sym array, otherwise old entries are preserved
1034 if (varsym.length())
1035 Tcl_UnsetVar(interp, varsym.c_str(), 0);
1036
1037 int pipe_tcl2asm[2]; // [0] read, [1] write end
1038 int pipe_asm2tcl[2];
1039
1040 if (::pipe(pipe_tcl2asm) < 0)
1041 return args.Quit(RerrMsg("RtclRw11Cpu::M_ldasm" ,
1042 "1st pipe() failed: ", errno));
1043 if (::pipe(pipe_asm2tcl) < 0)
1044 return args.Quit(RerrMsg("RtclRw11Cpu::M_ldasm" ,
1045 "2nd pipe() failed: ", errno));
1046
1047 pid_t pid = ::fork();
1048 if (pid == pid_t(0)) { // in child here
1049 vector<const char*> argv;
1050 vector<string> opts;
1051
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);
1057 string tok;
1058 while (optstream >> tok) {
1059 opts.push_back(tok);
1060 argv.push_back(opts[opts.size()-1].c_str());
1061 }
1062 }
1063 if (file.length()) {
1064 argv.push_back(file.c_str());
1065 } else {
1066 argv.push_back("-");
1067 }
1068 argv.push_back(nullptr);
1069
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);
1078
1079 } else { // in parent here
1080 ::close(pipe_tcl2asm[0]);
1081 ::close(pipe_asm2tcl[1]);
1082 if (pid < pid_t(0))
1083 return args.Quit(RerrMsg("RtclRw11Cpu::M_ldasm" ,
1084 "fork() failed: ", errno));
1085 }
1086
1087 // if first line empty, drop it (created often by using {)
1088 if (code.length() && code[0] == '\n') code = code.substr(1);
1089
1090 istringstream ostream(code);
1091 string oline;
1092 while (std::getline(ostream, oline)) {
1093 oline += '\n';
1094 //cout << "+++1:" << oline;
1095 if (::write(pipe_tcl2asm[1], oline.data(), oline.length()) < 0) break;
1096 }
1097 ::close(pipe_tcl2asm[1]);
1098
1099 FILE* fp = ::fdopen(pipe_asm2tcl[0], "r");
1100 if (fp == nullptr) {
1101 ::close(pipe_asm2tcl[0]);
1102 return args.Quit(RerrMsg("RtclRw11Cpu::M_ldasm" ,
1103 "fdopen() failed: ", errno));
1104 }
1105
1106 vector<string> ilines;
1107 while(true) {
1108 char* pline = nullptr;
1109 size_t nchar;
1110 if (::getline(&pline, &nchar, fp) < 0) break;
1111 //cout << "+++2:" << pline;
1112 string line(pline);
1113 if (line.length() && line[line.length()-1] =='\n')
1114 line.resize(line.length()-1);
1115 ilines.push_back(line);
1116 ::free(pline);
1117 }
1118 ::fclose(fp);
1119 ::close(pipe_asm2tcl[0]);
1120
1121 int wstat;
1122 int wexit = -1;
1123 waitpid(pid, &wstat, 0);
1124 if (WIFEXITED(wstat)) wexit = WEXITSTATUS(wstat);
1125
1126 bool insym = false;
1127 bool indat = false;
1128 char dtyp = ' ';
1129
1130 ostringstream los; // list stream
1131 ostringstream eos; // error stream
1132 bool lstbodyseen = false;
1133
1134 typedef map<uint16_t, uint16_t> cmap_t;
1135
1136 cmap_t cmap;
1137 uint16_t dot = 0;
1138
1139 for (size_t i=0; i<ilines.size(); i++) {
1140 string& line = ilines[i];
1141 if (line == "sym {") {
1142 insym = true;
1143 continue;
1144 } else if (line == "dat {") {
1145 indat = true;
1146 continue;
1147 } else if (dtyp == ' ' && line == "}") {
1148 insym = false;
1149 indat = false;
1150 continue;
1151 }
1152
1153 // handle symbol table
1154 if (insym) {
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;
1163 } else {
1164 return args.Quit(string("bad sym spec: ") + line);
1165 }
1166
1167 // handle data part
1168 } else if (indat) {
1169 if (dtyp == ' ') {
1170 if (line.length() != 10)
1171 return args.Quit(string("bad dat spec: ") + line);
1172 dtyp = line[0];
1173 dot = uint16_t(::strtol(line.c_str()+2,nullptr,8));
1174 } else if (line[0] == '}') {
1175 dtyp = ' ';
1176 } else {
1177 istringstream datstream(line);
1178 string dat;
1179 while (datstream >> dat) {
1180 //cout << "+++1 " << dtyp << ":" << dat << endl;
1181 uint16_t val = uint16_t(::strtol(dat.c_str(),nullptr,8));
1182 if (dtyp == 'w') {
1183 cmap[dot] = val;
1184 dot += 2;
1185 } else {
1186 uint16_t tmp = cmap[dot&0xfffe];
1187 if (dot & 01) {
1188 tmp = (val&0xff)<<8 | (tmp&0xff); // odd (high) byte
1189 } else {
1190 tmp = (tmp&0xff00) | (val&0xff); // even (low) byte
1191 }
1192 cmap[dot&0xfffe] = tmp;
1193 dot += 1;
1194 }
1195 }
1196 }
1197
1198 // handle listing part (everything not sym{} or dat{}
1199 } else {
1200 los << line << endl;
1201 // put lines into error stream if
1202 // 1. before 'Input file list:' and not starting with '--'
1203 // 2. after 'Input file list:' and starting with uppercase letter
1204 if (line == "; Input file list:") lstbodyseen = true;
1205 bool etake = false;
1206 if (lstbodyseen) {
1207 if (line.length() && (line[0]>'A' && line[0]<'Z')) etake = true;
1208 } else {
1209 if (line.substr(0,2) != "--") etake = true;
1210 }
1211 if (line.substr(0,6) == "asm-11") etake = true;
1212 if (etake) eos << line << endl;
1213 }
1214 }
1215
1216 if (varlst.length()) {
1217 if (!Rtcl::SetVar(interp, varlst, Rtcl::NewLinesObj(los))) return kERR;
1218 }
1219
1220 // in case of asm-11 error quit (after lst and sym processing)
1221 if (wexit != 0) {
1222 args.AppendResultLines("asm-11 compilation failed with:");
1223 args.AppendResultLines(eos);
1224 return kERR;
1225 }
1226
1227 // now, finally, iterate over cmap and write code to memory
1228 vector<uint16_t> block;
1229 uint16_t base = 0;
1230 dot = 0;
1231 RerrMsg emsg;
1232
1233 for (auto& o: cmap) {
1234 if (dot != o.first || block.size() >= Connect().BlockSizeMax()) {
1235 if (block.size()) {
1236 if (!Obj().MemWrite(base, block, emsg)) return args.Quit(emsg);
1237 block.clear();
1238 }
1239 base = dot = o.first;
1240 }
1241 block.push_back(o.second);
1242 dot += 2;
1243 }
1244
1245 if (block.size()) {
1246 if (!Obj().MemWrite(base, block, emsg)) return args.Quit(emsg);
1247 block.clear();
1248 }
1249
1250 return kOK;
1251}
1252
1253//------------------------------------------+-----------------------------------
1255
1257{
1258 string uname;
1259 if (!args.GetArg("uname", uname)) return kERR;
1260 if (!args.AllDone()) return kERR;
1261 RerrMsg emsg;
1262 if (!Obj().Boot(uname, emsg)) return args.Quit(emsg);
1263 return kOK;
1264}
1265
1266//------------------------------------------+-----------------------------------
1268
1270{
1271 // synchronize with server thread
1272 lock_guard<RlinkConnect> lock(Obj().Connect());
1273 return fGets.M_get(args);
1274}
1275
1276//------------------------------------------+-----------------------------------
1278
1280{
1281 // synchronize with server thread
1282 lock_guard<RlinkConnect> lock(Obj().Connect());
1283 return fSets.M_set(args);
1284}
1285
1286//------------------------------------------+-----------------------------------
1288
1290{
1291 static RtclNameSet optset("-pcps|-r0ps|-mmu|-ubmap"
1292 );
1293
1294 string opt;
1295 uint16_t base = Obj().Base();
1296 ostringstream sos;
1297 RerrMsg emsg;
1298
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"};
1304
1305 while (args.NextOpt(opt, optset)) {
1306 if (opt == "-pcps" || opt == "-r0ps") {
1307 RlinkCommandList clist;
1308 size_t i_pc = clist.AddRreg(base + Rw11Cpu::kCPPC);
1309 size_t i_psw = clist.AddRreg(base + Rw11Cpu::kCPPSW);
1310 size_t i_stat = clist.AddRreg(base + Rw11Cpu::kCPSTAT);
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;
1321 uint16_t regs[8];
1322 regs[7] = clist[i_pc].Data();
1323 bool r0ps = opt == "-r0ps";
1324
1325 if (r0ps) {
1326 clist.Clear();
1327 for (size_t i=0; i<7; i++) clist.AddRreg(base + Rw11Cpu::kCPR0+i);
1328 if (!Server().Exec(clist, emsg)) return args.Quit(emsg);
1329 for (size_t i=0; i<7; i++) regs[i] = clist[i].Data();
1330 }
1331
1332 if (r0ps) sos << "Processor registers and status:" << endl;
1333 if (!r0ps) sos << " PC: " << RosPrintBvi(regs[7],8);
1334 sos << " PS: " << RosPrintBvi(psw,8)
1335 << " cm,pm=" << mode[psw_cm] << "," << mode[psw_pm]
1336 << " s,p,t=" << psw_set << "," << psw_pri << "," << psw_tbit
1337 << " NZVC=" << RosPrintBvi(psw_nzvc,2,4)
1338 << " rust: " << RosPrintBvi(stat_rust,8,4) << " " << rust[stat_rust]
1339 << endl;
1340
1341 if (r0ps) {
1342 sos << " R0: " << RosPrintBvi(regs[0],8)
1343 << " R1: " << RosPrintBvi(regs[1],8)
1344 << " R2: " << RosPrintBvi(regs[2],8)
1345 << " R3: " << RosPrintBvi(regs[3],8) << endl;
1346 sos << " R4: " << RosPrintBvi(regs[4],8)
1347 << " R5: " << RosPrintBvi(regs[5],8)
1348 << " SP: " << RosPrintBvi(regs[6],8)
1349 << " PC: " << RosPrintBvi(regs[7],8) << endl;
1350 }
1351
1352 } else if (opt == "-r0r5") {
1353 RlinkCommandList clist;
1354 for (size_t i=0; i<6; i++) clist.AddRreg(base + Rw11Cpu::kCPR0+i);
1355 if (!Server().Exec(clist, emsg)) return args.Quit(emsg);
1356 sos << "R0-R5:";
1357 for (size_t i=0; i<6; i++) sos << " " << RosPrintBvi(clist[i].Data(),8);
1358 sos << endl;
1359
1360 } else if (opt == "-mmu") {
1361 uint16_t mmr[4];
1362 uint16_t asr[3][32];
1363 const char* pmode[3] = {"km","sm","um"};
1364 const char* acf[8] = {"nres ",
1365 "r -r ",
1366 "r ",
1367 "011 ",
1368 "rw-rw",
1369 "rw- w",
1370 "rw ",
1371 "111 "};
1372 {
1373 lock_guard<RlinkConnect> lock(Connect());
1374 RlinkCommandList clist;
1376 clist.AddRblk(base + Rw11Cpu::kCPMEMI, mmr, 3);
1378 clist.AddRblk(base + Rw11Cpu::kCPMEMI, mmr+3, 1);
1379 if (!Server().Exec(clist, emsg)) return args.Quit(emsg);
1380 clist.Clear();
1382 clist.AddRblk(base + Rw11Cpu::kCPMEMI, asr[0], 32);
1384 clist.AddRblk(base + Rw11Cpu::kCPMEMI, asr[1], 32);
1386 clist.AddRblk(base + Rw11Cpu::kCPMEMI, asr[2], 32);
1387 if (!Server().Exec(clist, emsg)) return args.Quit(emsg);
1388 }
1389 // use local explicit constants here, avoid to define them system wide
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;
1409
1410 sos << "mmu:" << endl;
1411 sos << "mmr0=" << RosPrintBvi(mmr[0],8);
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";
1418 sos << " page: " << RosPrintBvi(mmr0_mode,2,2)
1419 << "," << RosPrintf(mmr0_ds,"d",1)
1420 << "," << RosPrintf(mmr0_page,"d",1);
1421 if (mmr0_ena) sos << " ena";
1422 sos << endl;
1423
1424 if (mmr1_0_val & 020) mmr1_0_val |= 0177740;
1425 if (mmr1_1_val & 020) mmr1_1_val |= 0177740;
1426 sos << "mmr1=" << RosPrintBvi(mmr[1],8);
1427 if (mmr1_0_val) sos << " r" << mmr1_0_reg
1428 << ":" << RosPrintf(mmr1_0_val,"d",3);
1429 if (mmr1_1_val) sos << " r" << mmr1_1_reg
1430 << ":" << RosPrintf(mmr1_1_val,"d",3);
1431 sos << endl;
1432
1433 sos << "mmr2=" << RosPrintBvi(mmr[2],8) << endl;
1434 sos << "mmr3=" << RosPrintBvi(mmr[3],8)
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;
1439
1440 for (size_t m=0; m<3; m++) {
1441 sos << pmode[m] << " "
1442 << " I pdr plf aw d acf I par"
1443 << " "
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;
1456 sos<< RosPrintBvi(pdr,8)
1457 << " " << RosPrintf(pdr_plf,"d",3)
1458 << " " << pdr_a << pdr_w
1459 << " " << (pdr_e ? "d" : "u")
1460 << " " << acf[pdr_acf]
1461 << " " << RosPrintBvi(par,8);
1462 }
1463 sos << endl;
1464 }
1465 }
1466
1467 } else if (opt == "-ubmap") {
1468 uint16_t ubmap[64];
1469 RlinkCommandList clist;
1471 clist.AddRblk(base + Rw11Cpu::kCPMEMI, ubmap, 64);
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) {
1476 size_t k = 2*(i+j);
1477 uint32_t data = uint32_t(ubmap[k]) | (uint32_t(ubmap[k+1]))<<16;
1478 if (j!=0) sos << " ";
1479 sos << RosPrintBvi(uint32_t(j+i),8,5) << " "
1480 << RosPrintBvi(data,8,22);
1481 }
1482 sos << endl;
1483 }
1484 }
1485 }
1486
1487 if (!args.AllDone()) return kERR;
1488 args.SetResult(sos);
1489
1490 return kOK;
1491}
1492
1493//------------------------------------------+-----------------------------------
1495
1497{
1498 RtclStats::Context cntx;
1499 if (!RtclStats::GetArgs(args, cntx)) return kERR;
1500 if (!RtclStats::Exec(args, cntx, Obj().Stats())) return kERR;
1501 return kOK;
1502}
1503
1504//------------------------------------------+-----------------------------------
1506
1508{
1509 int detail=0;
1510 if (!GetArgsDump(args, detail)) return kERR;
1511 if (!args.AllDone()) return kERR;
1512
1513 ostringstream sos;
1514 Obj().Dump(sos, 0, "", detail);
1515 args.SetResult(sos);
1516 return kOK;
1517}
1518
1519//------------------------------------------+-----------------------------------
1521
1523{
1524 if (!args.AllDone()) return kERR;
1525 ostringstream sos;
1526
1527 vector<string> cntlnames;
1528 Obj().ListCntl(cntlnames);
1529
1530 sos << "name type ibbase lam probe ena on" << endl;
1531
1532 for (auto& cname : cntlnames) {
1533 Rw11Cntl& cntl(Obj().Cntl(cname));
1534 sos << RosPrintf(cntl.Name().c_str(),"-s",4)
1535 << " " << RosPrintf(cntl.Type().c_str(),"-s",5)
1536 << " " << RosPrintf(cntl.Base(),"o",6)
1537 << " " << RosPrintf(cntl.Lam(),"d",3)
1538 << " " << cntl.ProbeStatus().Found()
1539 << " " << cntl.ProbeStatus().IndicatorInt()
1540 << " " << cntl.ProbeStatus().IndicatorRem()
1541 << " " << cntl.Enable()
1542 << " " << cntl.IsStarted()
1543 << endl;
1544 }
1545
1546 sos << endl;
1547 sos << "name attachurl" << endl;
1548
1549 for (auto& cname : cntlnames) {
1550 Rw11Cntl& cntl(Obj().Cntl(cname));
1551 for (size_t j=0; j<cntl.NUnit(); j++) {
1552 Rw11Unit& unit(cntl.UnitBase(j));
1553 if (unit.IsAttached()) {
1554 sos << RosPrintf(unit.Name().c_str(),"-s",5)
1555 << " " << unit.AttachUrl() << endl;
1556 }
1557 }
1558 }
1559
1560 args.AppendResultLines(sos);
1561 return kOK;
1562}
1563
1564//------------------------------------------+-----------------------------------
1566
1568{
1569 Rw11Cpu* pobj = &Obj();
1570 fGets.Add<const string&>("type", bind(&Rw11Cpu::Type, pobj));
1571 fGets.Add<size_t> ("index", bind(&Rw11Cpu::Index, pobj));
1572 fGets.Add<uint16_t> ("base", bind(&Rw11Cpu::Base, pobj));
1573 fGets.Add<uint16_t> ("ibase", bind(&Rw11Cpu::IBase, pobj));
1574 fGets.Add<uint32_t> ("memsize", bind(&Rw11Cpu::MemSize, pobj));
1575 fGets.Add<bool> ("hasscnt", bind(&Rw11Cpu::HasScnt, pobj));
1576 fGets.Add<bool> ("haspcnt", bind(&Rw11Cpu::HasPcnt, pobj));
1577 fGets.Add<bool> ("hascmon", bind(&Rw11Cpu::HasCmon, pobj));
1578 fGets.Add<uint16_t> ("hashbpt", bind(&Rw11Cpu::HasHbpt, pobj));
1579 fGets.Add<bool> ("hasibmon", bind(&Rw11Cpu::HasIbmon, pobj));
1580 fGets.Add<bool> ("hasibtst", bind(&Rw11Cpu::HasIbtst, pobj));
1581 fGets.Add<bool> ("hasm9312", bind(&Rw11Cpu::HasM9312, pobj));
1582 fGets.Add<bool> ("haskw11l", bind(&Rw11Cpu::HasKw11l, pobj));
1583 fGets.Add<bool> ("haskw11p", bind(&Rw11Cpu::HasKw11p, pobj));
1584 fGets.Add<bool> ("hasiist", bind(&Rw11Cpu::HasIist, pobj));
1585 return;
1586}
1587
1588//------------------------------------------+-----------------------------------
1590
1591bool RtclRw11Cpu::GetIAddr(RtclArgs& args, uint16_t& ibaddr)
1592{
1593 Tcl_Obj* pobj=0;
1594 if (!args.GetArg("ibaddr", pobj)) return kERR;
1595
1596 int tstint;
1597 // if a number is given..
1598 if (Tcl_GetIntFromObj(nullptr, pobj, &tstint) == kOK) {
1599 if (tstint >= 0 && tstint <= 0xffff && (tstint & 0x1) == 0) {
1600 ibaddr = uint16_t(tstint);
1601 } else {
1602 args.AppendResult("-E: value '", Tcl_GetString(pobj),
1603 "' for 'addr' odd number or out of range 0...0xffff",
1604 nullptr);
1605 return false;
1606 }
1607 // if a name is given
1608 } else {
1609 string name(Tcl_GetString(pobj));
1610 uint16_t tstaddr;
1611 if (Obj().IAddrMap().Find(name, tstaddr)) {
1612 ibaddr = tstaddr;
1613 } else {
1614 args.AppendResult("-E: no address mapping known for '",
1615 Tcl_GetString(pobj), "'", nullptr);
1616 return false;
1617 }
1618 }
1619
1620 return true;
1621}
1622
1623//------------------------------------------+-----------------------------------
1625
1626bool RtclRw11Cpu::GetRAddr(RtclArgs& args, uint16_t& rbaddr)
1627{
1628 Tcl_Obj* pobj=0;
1629 if (!args.GetArg("rbaddr", pobj)) return kERR;
1630
1631 int tstint;
1632 // if a number is given..
1633 if (Tcl_GetIntFromObj(nullptr, pobj, &tstint) == kOK) {
1634 if (tstint >= 0 && tstint <= 0xffff) {
1635 rbaddr = uint16_t(tstint);
1636 } else {
1637 args.AppendResult("-E: value '", Tcl_GetString(pobj),
1638 "' for 'addr' out of range 0...0xffff",
1639 nullptr);
1640 return false;
1641 }
1642 // if a name is given
1643 } else {
1644 string name(Tcl_GetString(pobj));
1645 uint16_t tstaddr;
1646 if (Obj().RAddrMap().Find(name, tstaddr)) {
1647 rbaddr = tstaddr;
1648 } else if (Connect().AddrMap().Find(name, tstaddr)) {
1649 rbaddr = tstaddr;
1650 } else {
1651 args.AppendResult("-E: no address mapping known for '",
1652 Tcl_GetString(pobj), "'", nullptr);
1653 return false;
1654 }
1655 }
1656
1657 return true;
1658}
1659
1660//------------------------------------------+-----------------------------------
1662
1663bool RtclRw11Cpu::GetVarName(RtclArgs& args, const char* argname,
1664 size_t nind,
1665 std::vector<std::string>& varname)
1666{
1667 while (varname.size() < nind+1) varname.emplace_back(string());
1668 string name;
1669 if (!args.GetArg(argname, name)) return false;
1670 if (name.length()) { // if variable defined
1671 char c = name[0];
1672 if (isdigit(c) || c=='+' || c=='-' ) { // check for mistaken number
1673 args.AppendResult("-E: invalid variable name '", name.c_str(),
1674 "': looks like a number", nullptr);
1675 return false;
1676 }
1677 }
1678
1679 varname[nind] = name;
1680 return true;
1681}
1682
1683//------------------------------------------+-----------------------------------
1685
1687{
1688 if (clist.Size() == 0) {
1689 args.AppendResult("-E: -edata, -edone, or -estat "
1690 "not allowed on empty command list", nullptr);
1691 return false;
1692 }
1693 return true;
1694}
1695
1696//------------------------------------------+-----------------------------------
1698
1700{
1701 vector<string> cntlnames;
1702 Obj().ListCntl(cntlnames);
1703
1704 Tcl_Obj* rlist = Tcl_NewListObj(0,nullptr);
1705 for (auto& cname : cntlnames) {
1706 string ccmd = CommandName() + cname;
1707 RtclOPtr pele(Tcl_NewStringObj(ccmd.data(), ccmd.length()));
1708 Tcl_ListObjAppendElement(nullptr, rlist, pele);
1709 }
1710 return rlist;
1711}
1712
1713} // end namespace Retro
FIXME_docs.
Definition: RerrMsg.hpp:25
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.
Definition: RlinkServer.ipp:60
FIXME_docs.
Definition: RlogMsg.hpp:24
FIXME_docs.
Definition: RtclArgs.hpp:41
bool NextOpt(std::string &val)
FIXME_docs.
Definition: RtclArgs.cpp:368
const char * PeekArgString(int rind) const
FIXME_docs.
Definition: RtclArgs.cpp:461
void AppendResultLines(const std::string &str)
FIXME_docs.
Definition: RtclArgs.cpp:484
int NextSubOpt(std::string &val, const RtclNameSet &optset)
FIXME_docs.
Definition: RtclArgs.cpp:409
bool GetArg(const char *name, Tcl_Obj *&pval)
FIXME_docs.
Definition: RtclArgs.cpp:114
void AppendResult(const char *str,...)
FIXME_docs.
Definition: RtclArgs.cpp:471
bool OptValid() const
FIXME_docs.
Definition: RtclArgs.ipp:52
int Quit(const std::string &str)
FIXME_docs.
Definition: RtclArgs.ipp:157
void SetResult(const std::string &str)
FIXME_docs.
Definition: RtclArgs.ipp:76
size_t NOptMiss() const
FIXME_docs.
Definition: RtclArgs.ipp:68
size_t NDone() const
FIXME_docs.
Definition: RtclArgs.ipp:60
Tcl_Interp * Interp() const
FIXME_docs.
Definition: RtclArgs.ipp:28
bool AllDone()
FIXME_docs.
Definition: RtclArgs.cpp:447
void AddMeth(const std::string &name, methfo_t &&methfo)
FIXME_docs.
static const int kOK
Definition: RtclCmdBase.hpp:54
bool GetArgsDump(RtclArgs &args, int &detail)
FIXME_docs.
static const int kERR
Definition: RtclCmdBase.hpp:55
int M_get(RtclArgs &args)
FIXME_docs.
Definition: RtclGetList.cpp:73
void Add(const std::string &name, get_uptr_t &&upget)
FIXME_docs.
Definition: RtclGetList.cpp:52
Implemenation (inline) of RtclOPtr.
Definition: RtclOPtr.hpp:23
std::string CommandName() const
FIXME_docs.
RtclSetList fSets
Definition: RtclRw11Cpu.hpp:80
int M_add(RtclArgs &args)
FIXME_docs.
RtclGetList fGets
Definition: RtclRw11Cpu.hpp:79
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.
Definition: RtclRw11Cpu.ipp:29
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.
Definition: RtclRw11Cpu.ipp:21
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.
Definition: RtclSetList.cpp:73
static bool Exec(RtclArgs &args, const Context &cntx, Rstats &stats)
FIXME_docs.
Definition: RtclStats.cpp:75
static bool GetArgs(RtclArgs &args, Context &cntx)
FIXME_docs.
Definition: RtclStats.cpp:37
FIXME_docs.
Definition: Rtime.hpp:25
FIXME_docs.
Definition: Rw11Cntl.hpp:42
const Rw11Probe & ProbeStatus() const
FIXME_docs.
Definition: Rw11Cntl.ipp:136
const std::string & Type() const
FIXME_docs.
Definition: Rw11Cntl.ipp:72
uint16_t Base() const
FIXME_docs.
Definition: Rw11Cntl.ipp:88
int Lam() const
FIXME_docs.
Definition: Rw11Cntl.ipp:96
bool Enable() const
FIXME_docs.
Definition: Rw11Cntl.ipp:104
bool IsStarted() const
FIXME_docs.
Definition: Rw11Cntl.ipp:144
const std::string & Name() const
FIXME_docs.
Definition: Rw11Cntl.ipp:80
virtual Rw11Unit & UnitBase(size_t index) const =0
virtual size_t NUnit() const =0
FIXME_docs.
Definition: Rw11Cpu.hpp:66
static const uint8_t kStat_M_CmdMErr
stat: cmdmerr flag
Definition: Rw11Cpu.hpp:237
bool HasPcnt() const
FIXME_docs.
Definition: Rw11Cpu.ipp:110
const RlinkAddrMap & IAddrMap() const
FIXME_docs.
Definition: Rw11Cpu.ipp:238
bool HasIbmon() const
FIXME_docs.
Definition: Rw11Cpu.ipp:134
static const uint16_t kCPUUBMAP
UBMAP base address.
Definition: Rw11Cpu.hpp:249
uint16_t Base() const
FIXME_docs.
Definition: Rw11Cpu.ipp:78
static const uint16_t kCPMEM
CPMEM reg offset.
Definition: Rw11Cpu.hpp:187
static const uint16_t kMMUPDRU
MMU PDRU address.
Definition: Rw11Cpu.hpp:269
static const uint16_t kCPFUNC_STOP
STOP func code.
Definition: Rw11Cpu.hpp:195
static const uint16_t kCPR0
CPR0 reg offset.
Definition: Rw11Cpu.hpp:189
void ListCntl(std::vector< std::string > &list) const
FIXME_docs.
Definition: Rw11Cpu.cpp:292
static const uint16_t kMMUPDRS
MMU PDRS address.
Definition: Rw11Cpu.hpp:267
uint16_t IBase() const
FIXME_docs.
Definition: Rw11Cpu.ipp:86
static const uint16_t kCPAH
CPAH reg offset.
Definition: Rw11Cpu.hpp:186
void SetCpuActUp()
FIXME_docs.
Definition: Rw11Cpu.cpp:856
static const uint16_t kCPFUNC_STEP
STEP func code.
Definition: Rw11Cpu.hpp:196
int AddRbibr(RlinkCommandList &clist, uint16_t ibaddr, size_t size)
FIXME_docs.
Definition: Rw11Cpu.cpp:375
static const uint16_t kCPCONF
CPCONF reg offset.
Definition: Rw11Cpu.hpp:181
static const uint16_t kCPAL
CPAL reg offset.
Definition: Rw11Cpu.hpp:185
bool HasM9312() const
FIXME_docs.
Definition: Rw11Cpu.ipp:150
static const uint16_t kMMUMMR0
MMU MMR0 address.
Definition: Rw11Cpu.hpp:263
bool IAddrMapInsert(const std::string &name, uint16_t ibaddr)
FIXME_docs.
Definition: Rw11Cpu.ipp:206
bool HasIbtst() const
FIXME_docs.
Definition: Rw11Cpu.ipp:142
static const uint16_t kCPPSW
CPPSW reg offset.
Definition: Rw11Cpu.hpp:184
static const uint16_t kCPFUNC_RESUME
RESUME func code.
Definition: Rw11Cpu.hpp:200
virtual void Dump(std::ostream &os, int ind=0, const char *text=0, int detail=0) const
FIXME_docs.
Definition: Rw11Cpu.cpp:950
bool HasKw11p() const
FIXME_docs.
Definition: Rw11Cpu.ipp:166
static const uint16_t kCPFUNC_CRESET
CRESET func code.
Definition: Rw11Cpu.hpp:197
uint16_t HasHbpt() const
FIXME_docs.
Definition: Rw11Cpu.ipp:126
size_t Index() const
FIXME_docs.
Definition: Rw11Cpu.ipp:70
static const uint16_t kCPFUNC_BRESET
BRESET func code.
Definition: Rw11Cpu.hpp:198
static const uint16_t kMMUPDRK
MMU PDRK address.
Definition: Rw11Cpu.hpp:265
bool HasKw11l() const
FIXME_docs.
Definition: Rw11Cpu.ipp:158
static const uint16_t kCPAH_M_22BIT
ena 22bit addressing
Definition: Rw11Cpu.hpp:226
uint32_t MemSize() const
FIXME_docs.
Definition: Rw11Cpu.ipp:94
static const uint8_t kStat_M_CmdErr
stat: cmderr flag
Definition: Rw11Cpu.hpp:236
int AddMembe(RlinkCommandList &clist, uint16_t be, bool stick=false)
FIXME_docs.
Definition: Rw11Cpu.cpp:344
bool HasIist() const
FIXME_docs.
Definition: Rw11Cpu.ipp:174
const RlinkAddrMap & RAddrMap() const
FIXME_docs.
Definition: Rw11Cpu.ipp:278
bool MemRead(uint16_t addr, std::vector< uint16_t > &data, size_t nword, RerrMsg &emsg)
FIXME_docs.
Definition: Rw11Cpu.cpp:517
static const uint16_t kCPPC
CPPC reg offset.
Definition: Rw11Cpu.hpp:190
static const uint16_t kCPFUNC_START
START func code.
Definition: Rw11Cpu.hpp:194
static const uint16_t kCPMEMI
CPMEMI reg offset.
Definition: Rw11Cpu.hpp:188
bool HasScnt() const
FIXME_docs.
Definition: Rw11Cpu.ipp:102
static const uint16_t kCPMEMBE
CPMEMBE reg offset.
Definition: Rw11Cpu.hpp:191
bool HasCmon() const
FIXME_docs.
Definition: Rw11Cpu.ipp:118
int AddWibr(RlinkCommandList &clist, uint16_t ibaddr, uint16_t data)
FIXME_docs.
Definition: Rw11Cpu.cpp:365
int WaitCpuActDown(const Rtime &tout, Rtime &twait)
FIXME_docs.
Definition: Rw11Cpu.cpp:882
static const uint16_t kMMUMMR3
MMU MMR3 address.
Definition: Rw11Cpu.hpp:260
bool MemWrite(uint16_t addr, const std::vector< uint16_t > &data, RerrMsg &emsg)
FIXME_docs.
Definition: Rw11Cpu.cpp:537
int AddRibr(RlinkCommandList &clist, uint16_t ibaddr)
FIXME_docs.
Definition: Rw11Cpu.cpp:354
static const uint16_t kCPAH_M_UBM22
ubmap+22bit
Definition: Rw11Cpu.hpp:228
bool RAddrMapInsert(const std::string &name, uint16_t rbaddr)
FIXME_docs.
Definition: Rw11Cpu.ipp:246
int AddWbibr(RlinkCommandList &clist, uint16_t ibaddr, const std::vector< uint16_t > &block)
FIXME_docs.
Definition: Rw11Cpu.cpp:385
static const uint16_t kCPSTAT
CPSTAT reg offset.
Definition: Rw11Cpu.hpp:183
static const uint16_t kCPCNTL
CPADDR reg offset.
Definition: Rw11Cpu.hpp:182
static const uint16_t kCPFUNC_SUSPEND
SUSPEND func code.
Definition: Rw11Cpu.hpp:199
const std::string & Type() const
FIXME_docs.
Definition: Rw11Cpu.ipp:62
FIXME_docs.
Definition: Rw11Unit.hpp:39
bool IsAttached() const
FIXME_docs.
Definition: Rw11Unit.cpp:61
std::string Name() const
FIXME_docs.
Definition: Rw11Unit.ipp:31
const std::string & AttachUrl() const
FIXME_docs.
Definition: Rw11Unit.cpp:69
static const int kLam
W11 CPU cluster lam.
Definition: Rw11.hpp:57
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.
Definition: RosPrintf.ipp:38
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.
Definition: ReventLoop.cpp:47
int RtclRw11CntlFactory(RtclArgs &args, RtclRw11Cpu &cpu)
FIXME_docs.
char IndicatorInt() const
FIXME_docs.
Definition: Rw11Probe.cpp:63
bool Found() const
FIXME_docs.
Definition: Rw11Probe.cpp:52
char IndicatorRem() const
FIXME_docs.
Definition: Rw11Probe.cpp:73