269 throw Rexception(
"Rw11Cpu::AddCntl",
"Bad args: spcntl == 0");
271 string name(spcntl->Name());
274 "Bad state: duplicate controller name");;
276 fCntlMap.emplace(make_pair(name, spcntl));
277 spcntl->SetCpu(
this);
296 list.push_back(o.second->Name());
309 "Bad args: controller name '" + name +
"' unknown");
310 return *(it->second);
333 for (
char let=
'a'; let<=
'z'; let++) {
334 string name = base + let;
338 "Bad args: all controller letters used for '" + base +
"'");
356 if ((ibaddr & 0160001) != 0160000)
357 throw Rexception(
"Rw11Cpu::AddRibr",
"ibaddr out of IO page or odd");
367 if ((ibaddr & 0160001) != 0160000)
368 throw Rexception(
"Rw11Cpu::AddWibr",
"ibaddr out of IO page or odd");
377 if ((ibaddr & 0160001) != 0160000)
378 throw Rexception(
"Rw11Cpu::AddRbibr",
"ibaddr out of IO page or odd");
386 const std::vector<uint16_t>& block)
388 if ((ibaddr & 0160001) != 0160000)
389 throw Rexception(
"Rw11Cpu::AddWbibr",
"ibaddr out of IO page or odd");
397 std::vector<uint16_t>&& block)
399 if ((ibaddr & 0160001) != 0160000)
400 throw Rexception(
"Rw11Cpu::AddWbibr",
"ibaddr out of IO page or odd");
410 uint16_t al = uint16_t(addr);
422 uint32_t addr, uint16_t mode)
424 if (ind + 1 > clist.
Size())
425 throw Rexception(
"Rw11Cpu::ModLalh",
"Bad args: ind out of range");
427 uint16_t al = uint16_t(addr);
438 throw Rexception(
"Rw11Cpu::ModLalh",
"Bad state: not writing cpal/cpah");
449 size_t size, uint16_t mode,
bool singleblk)
452 if (singleblk && size > blkmax)
454 "Bad args: singleblk==true && size > BlockSizeMax()");
456 int ind =
AddLalh(clist, addr, mode);
458 size_t bsize = (size>blkmax) ? blkmax : size;
470 const uint16_t* buf,
size_t size,
471 uint16_t mode,
bool singleblk)
474 if (singleblk && size > blkmax)
476 "Bad args: singleblk==true && size > BlockSizeMax()");
478 int ind =
AddLalh(clist, addr, mode);
480 size_t bsize = (size>blkmax) ? blkmax : size;
492 uint16_t ibaddr1, uint16_t data1,
493 uint16_t ibaddr2, uint16_t data2)
496 AddWibr(clist, ibaddr0, data0);
497 if (ibaddr1 > 0)
AddWibr(clist, ibaddr1, data1);
498 if (ibaddr2 > 0)
AddWibr(clist, ibaddr2, data2);
509 int ic =
AddRibr(clist, ibaddr);
511 return clist[ic].Data();
523 while (nword>ndone) {
524 size_t nblk = min(blkmax, nword-ndone);
528 if (!
Server().Exec(clist, emsg))
return false;
541 size_t nword = data.size();
543 while (nword>ndone) {
544 size_t nblk = min(blkmax, nword-ndone);
548 if (!
Server().Exec(clist, emsg))
return false;
560 emsg.
Init(
"Rw11Cpu::MemWriteByte",
"addr out of range");
566 uint16_t wdata = (uint16_t(data)<<8) | data;
570 if (!
Server().Exec(clist, emsg))
return false;
581 "Bad args: fAddr == 0 or fProbeInt|fProbeRem == false");
630 uint16_t& start,
bool trace)
633 int fd = open(fname.c_str(), O_RDONLY);
636 emsg.
InitErrno(
"Rw11Cpu::LoadAbs()",
string(
"open() for '") + fname +
637 "' failed: ", errno);
652 vector<uint16_t> data;
663 bool firstodd =
false;
667 enum states state = s_chr0;
671 int irc = ::read(fd, &
byte, 1);
673 if (state == s_chr0) {
676 emsg.
Init(
"Rw11Cpu::LoadAbs()",
"unexpected EOF");
679 }
else if (irc < 0) {
680 emsg.
InitErrno(
"Rw11Cpu::LoadAbs()",
"read() failed: ", errno);
695 }
else if (
byte == 1) {
699 "unexpected start-of-block %3.3o",
byte);
709 "unexpected 2nd char %3.3o",
byte);
720 bytcnt |= uint16_t(
byte) << 8;
730 ldaddr |= uint16_t(
byte) << 8;
733 firstodd = (addr & 0x01) == 1;
737 lmsg <<
"LoadAbs-I: block " <<
RosPrintf(blknum,
"d",3)
738 <<
", length " <<
RosPrintf(bytcnt-6,
"d",5)
741 lmsg <<
":" <<
RosPrintBvi(uint16_t(ldaddr+(bytcnt-6)-1),8);
743 state = (bytcnt == 6) ? s_chksum : s_data;
747 if ((addr & 0x01) == 0) {
755 word |= uint16_t(
byte) << 8;
756 data.push_back(word);
760 if (chrnum == bytcnt-1) state = s_chksum;
765 emsg.
InitPrintf(
"Rw11Cpu::LoadAbs()",
"check sum error %3.3o", chksum);
767 }
else if (bytcnt == 6) {
771 lmsg <<
"LoadAbs-I: start address " <<
RosPrintBvi(ldaddr,8);
776 if (!
MemWrite(ldaddr, data, emsg)) go =
false;
777 if ((addr & 0x01) == 1) {
778 if (!
MemWriteByte(addr-1, uint8_t(word), emsg)) go =
false;
802 for (
size_t i=0; i<uname.length(); i++) {
804 if (c >=
'0' && c <=
'9') {
805 string unum = uname.substr(i);
806 uind = ::atoi(unum.c_str());
814 emsg.
Init(
"Rw11Cpu::Boot",
string(
"controller '") + cname +
"' not known");
819 if (uind >= cntl.
NUnit()) {
820 emsg.
Init(
"Rw11Cpu::Boot",
string(
"unit number '") + uname +
"' invalid");
824 vector<uint16_t> code;
828 if (!cntl.
BootCode(uind, code, aload, astart) || code.size()==0) {
829 emsg.
Init(
"Rw11Cpu::Boot",
string(
"boot not supported for controller '")
838 if (!
Server().Exec(clist, emsg))
return false;
841 if (!
MemWrite(aload, code, emsg))
return false;
848 if (!
Server().Exec(clist, emsg))
return false;
884 Rtime tstart(CLOCK_MONOTONIC);
887 chrono::duration<double> timeout(chrono::duration<double>::max());
889 timeout = chrono::duration<double>(tout.
ToDouble());
893 if (
fCpuActCond.wait_for(lock, timeout) == cv_status::timeout)
return -1;
895 twait =
Rtime(CLOCK_MONOTONIC) - tstart;
910 cname +=
'0'+
Index();
927 cname +=
'0'+
Index();
954 os << bl << (text?text:
"--") <<
"Rw11Cpu @ " <<
this << endl;
956 os << bl <<
" fpW11: " <<
fpW11 << endl;
957 os << bl <<
" fType: " <<
fType << endl;
958 os << bl <<
" fIndex: " <<
fIndex << endl;
964 os << bl <<
" fHasHbpt: " <<
fHasHbpt << endl;
973 os << bl <<
" fCntlMap: " << endl;
975 os << bl <<
" " <<
RosPrintf(o.first.c_str(),
"-s",8)
976 <<
" : " << o.second << endl;
1034 for (
char i=0; i<8; i++) {
1073 for (
int i=0; i<
kHBNMAX; i++) {
1102 fMemSize = uint32_t(clist[ims].Data()+1)<<6;
1108 fHasScnt = (clist[isc].Status() & statmsk) == 0;
1116 fHasCmon = (clist[icm].Status() & statmsk) == 0;
1130 for (
int i=0; i<
kHBNMAX; i++) {
1131 if ((clist[ihb[i]].Status() & statmsk) != 0)
break;
1134 std::string pref =
"hb";
1142 fHasPcnt = (clist[ipc].Status() & statmsk) == 0;
1150 fHasIbmon = (clist[iim].Status() & statmsk) == 0;
1160 fHasIbtst = (clist[iit].Status() & statmsk) == 0;
1168 fHasKw11l = (clist[ikwl].Status() & statmsk) == 0;
1173 fHasM9312 = (clist[im9].Status() & statmsk) == 0;
1178 fHasKw11p = (clist[ikwp].Status() & statmsk) == 0;
1185 fHasIist = (clist[iii].Status() & statmsk) == 0;
void Init(const std::string &meth, const std::string &text)
FIXME_docs.
void InitPrintf(const std::string &meth, const char *format,...)
FIXME_docs.
void InitErrno(const std::string &meth, const std::string &text, int errnum)
FIXME_docs.
void Dump(std::ostream &os, int ind=0, const char *text=0, int detail=0) const
FIXME_docs.
size_t AddWreg(uint16_t addr, uint16_t data)
FIXME_docs.
size_t Size() const
FIXME_docs.
size_t AddRblk(uint16_t addr, size_t size)
FIXME_docs.
void SetLastExpectStatus(uint8_t stat, uint8_t statmsk=0xff)
FIXME_docs.
size_t AddWblk(uint16_t addr, const std::vector< uint16_t > &block)
FIXME_docs.
size_t AddRreg(uint16_t addr)
FIXME_docs.
uint16_t Address() const
FIXME_docs.
static const uint8_t kStat_M_RbErr
stat: rberr flag set
static const uint8_t kStat_M_RbNak
stat: rbnak flag set
static const uint8_t kStat_M_RbTout
stat: rbtout flag set
void SetData(uint16_t data)
FIXME_docs.
uint8_t Command() const
FIXME_docs.
static const uint8_t kCmdWreg
command code write register
bool AddrMapInsert(const std::string &name, uint16_t addr)
FIXME_docs.
bool Exec(RlinkCommandList &clist, RerrMsg &emsg)
FIXME_docs.
size_t BlockSizeMax() const
FIXME_docs.
size_t BlockSizePrudent() const
FIXME_docs.
bool Exec(RlinkCommandList &clist, RerrMsg &emsg)
FIXME_docs.
I/O appicator to generate fill characters.
void Dump(std::ostream &os, int ind=0, const char *text=0, int detail=0) const
FIXME_docs.
bool IsPositive() const
FIXME_docs.
double ToDouble() const
FIXME_docs.
const Rw11Probe & ProbeStatus() const
FIXME_docs.
bool Enable() const
FIXME_docs.
virtual bool BootCode(size_t unit, std::vector< uint16_t > &code, uint16_t &aload, uint16_t &astart)
FIXME_docs.
virtual void Start()
FIXME_docs.
virtual bool Probe()
FIXME_docs.
virtual size_t NUnit() const =0
static const uint16_t kITSTAT
IT.STAT reg offset.
static const uint16_t kMEMLOSIZE
MEM LOSIZE address.
static const uint8_t kStat_M_CmdMErr
stat: cmdmerr flag
static const uint16_t kCPURUST_STEP
cpu was stepped
static const uint16_t kPCDATA
PC.DATA reg offset.
static const uint16_t kCPURUST_VECFET
vector fetch halt
static const uint16_t kHBSTAT
HB.STAT reg offset.
static const uint16_t kCPUUBMAP
UBMAP base address.
static const uint16_t kIISTADR
II.ADR reg offset.
void SetCpuActDown(uint16_t stat)
FIXME_docs.
static const uint16_t kMEMCNTRL
MEM CNTRL address.
static const uint16_t kCPURUST_RUNS
cpu running
uint16_t Base() const
FIXME_docs.
bool fHasIbtst
has ibtst (ibus tester)
static const uint16_t kHBHILIM
HB.HILIM reg offset.
static const uint16_t kIMSTAT
IM.STAT reg offset.
void Setup(Rw11 *pw11)
FIXME_docs.
static const uint16_t kKWPCTR
KWP.CTR reg offset.
static const uint16_t kCPMEM
CPMEM reg offset.
void SetupOpt()
FIXME_docs.
static const uint16_t kMMUPDRU
MMU PDRU address.
static const uint16_t kITBASE
Ibtst ibus address.
std::condition_variable fCpuActCond
static const uint16_t kCPUPIRQ
CPU PIRQ address.
static const uint16_t kCMIREG
CM.IREG reg offset.
static const uint16_t kCPFUNC_STOP
STOP func code.
bool fHasIist
has iist (smp comm)
static const uint16_t kCPR0
CPR0 reg offset.
static const uint16_t kKWPCSB
KWP.CSB reg offset.
bool Boot(const std::string &uname, RerrMsg &emsg)
FIXME_docs.
static const uint16_t kCPFUNC_NOOP
NOOP func code.
static const uint16_t kIMLOLIM
IM.LOLIM reg offset.
static const uint16_t kIMADDR
IM.ADDR reg offset.
RlinkConnect & Connect() const
FIXME_docs.
static const uint16_t kCPMEMBE_M_BE
membe: be field
static const uint16_t kSCBASE
DMSCNT reg base offset.
static const uint16_t kHBNMAX
DMHBPT max number units.
void AllIAddrMapInsert(const std::string &name, uint16_t ibaddr)
FIXME_docs.
uint16_t ExecRibr(uint16_t ibaddr)
FIXME_docs.
static const uint16_t kIMHILIM
IM.HILIM reg offset.
static const uint16_t kCPMEMBE_M_BE0
membe: be0 flag
static const uint16_t kCPSTAT_M_CpuGo
cpugo mask
void ListCntl(std::vector< std::string > &list) const
FIXME_docs.
static const uint16_t kCPSTAT_M_SuspInt
suspint mask
static const uint16_t kMMUPDRS
MMU PDRS address.
static const uint16_t kCPURUST_SFAIL
sequencer failure
static const uint16_t kCMIPC
CM.IPC reg offset.
static const uint16_t kCPAH
CPAH reg offset.
bool fHasM9312
has m9312 (boot rom)
void SetCpuActUp()
FIXME_docs.
static const uint16_t kIMDATA
IM.DATA reg offset.
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 kHBLOLIM
HB.LOLIM reg offset.
static const uint16_t kCPCONF
CPCONF reg offset.
static const uint16_t kCPSTAT_B_CpuRust
cpurust bit mask
uint16_t fHasHbpt
has dmhbpt (hardware breakpoint)
static const uint16_t kPCBASE
DMPCNT reg base offset.
RlinkAddrMap fRAddrMap
rbus name<->address mapping
RlogFile & LogFile() const
FIXME_docs.
static const uint16_t kCPAL
CPAL reg offset.
std::string NextCntlName(const std::string &base) const
FIXME_docs.
RlinkServer & Server() const
FIXME_docs.
static const uint16_t kCMIADDR
CM.IADDR reg offset.
static const uint16_t kMEMHIADDR
MEM HIADDR address.
static const uint16_t kMMUMMR0
MMU MMR0 address.
static const uint16_t kCMDATA
CM.DATA reg offset.
bool IAddrMapInsert(const std::string &name, uint16_t ibaddr)
FIXME_docs.
static const uint16_t kCPURUST_VFAIL
vmbox failure
static const uint16_t kCPPSW
CPPSW reg offset.
void ModLalh(RlinkCommandList &clist, size_t ind, uint32_t addr, uint16_t mode=kCPAH_M_22BIT)
FIXME_docs.
static const uint16_t kSCCNTL
SC.CNTL reg offset.
static const uint16_t kCMADDR
CM.ADDR reg offset.
static const uint16_t kCPFUNC_RESUME
RESUME func code.
static const uint16_t kCPUSTKLIM
CPU STKLIM address.
static const uint16_t kHBBASE
DMHBPT reg base offset.
virtual void Dump(std::ostream &os, int ind=0, const char *text=0, int detail=0) const
FIXME_docs.
static const uint16_t kCPFUNC_CRESET
CRESET func code.
int AddLalh(RlinkCommandList &clist, uint32_t addr, uint16_t mode=kCPAH_M_22BIT)
FIXME_docs.
static const uint16_t kCPURUST_SUSP
cpu was suspended
static const uint16_t kITDATA
IT.DATA reg offset.
size_t Index() const
FIXME_docs.
void SetupStd()
FIXME_docs.
static const uint16_t kCPMEMBE_M_STICK
membe: sticky flag
static const uint16_t kCPSTAT_M_CmdMErr
cmdmerr mask
static const uint16_t kCPURUST_RECRSV
rec red-stack halt
static const uint16_t kCPURUST_STOP
cpu was stopped
bool fHasIbmon
has ibmon (ibus monitor)
static const uint16_t kIISTBASE
IIST ibus address.
static const uint16_t kCPSTAT_M_CmdErr
cmderr mask
static const uint16_t kMEMLOADDR
MEM LOADDR address.
uint32_t fMemSize
memory size in byte
static const uint16_t kPCSTAT
PC.STAT reg offset.
static const uint16_t kKWPCSR
KWP.CSR reg offset.
static const uint16_t kCPFUNC_BRESET
BRESET func code.
bool fHasScnt
has dmscnt (state counter)
static const uint16_t kMMUPDRK
MMU PDRK address.
int AddWMem(RlinkCommandList &clist, uint32_t addr, const uint16_t *buf, size_t size, uint16_t mode=kCPAH_M_22BIT, bool singleblk=false)
FIXME_docs.
static const uint16_t kCPURUST_HALT
cpu executed HALT
static const uint16_t kCPURUST_RESET
cpu was reset
static const uint8_t kStat_M_CpuGo
stat: cpugo flag
static const uint16_t kCPUERR
CPU CPUERR address.
static const uint16_t kCPAH_M_22BIT
ena 22bit addressing
static const uint16_t kPCCNTL
PC.CNTL reg offset.
bool LoadAbs(const std::string &fname, RerrMsg &emsg, uint16_t &start, bool trace=false)
FIXME_docs.
static const uint16_t kITFIFO
IT.FIFO reg offset.
static const uint16_t kCPUSDREG
CPU SDREG address.
uint32_t MemSize() const
FIXME_docs.
int AddRMem(RlinkCommandList &clist, uint32_t addr, uint16_t *buf, size_t size, uint16_t mode=kCPAH_M_22BIT, bool singleblk=false)
FIXME_docs.
static const uint16_t kMEMHISIZE
MEM HISIZE address.
void ExecWibr(uint16_t ibaddr0, uint16_t data0, uint16_t ibaddr1=0, uint16_t data1=0, uint16_t ibaddr2=0, uint16_t data2=0)
FIXME_docs.
static const uint8_t kStat_M_CmdErr
stat: cmderr flag
static const uint16_t kMEMMAINT
MEM MAINT address.
bool ProbeCntl(Rw11Probe &dsc)
FIXME_docs.
bool MemWriteByte(uint32_t addr, uint8_t data, RerrMsg &emsg)
FIXME_docs.
int AddMembe(RlinkCommandList &clist, uint16_t be, bool stick=false)
FIXME_docs.
bool fHasPcnt
has dmpcnt (perf counters)
Rw11Cntl & Cntl(const std::string &name) const
FIXME_docs.
static const uint16_t kCPAH_M_ADDR
mask for 6bit msb
static const uint16_t kMMUPARK
MMU PARK address.
static const uint16_t kCPUMBRK
CPU MBRK address.
uint16_t IbusRemoteAddr(uint16_t ibaddr) const
FIXME_docs.
static const uint16_t kCPSTAT_V_CpuRust
cpurust shift
bool MemRead(uint16_t addr, std::vector< uint16_t > &data, size_t nword, RerrMsg &emsg)
FIXME_docs.
static const uint16_t kHBCNTL
HB.CNTL reg offset.
static const uint16_t kHBSIZE
DMHBPT unit size.
static const uint16_t kIMBASE
Ibmon ibus address.
static const uint16_t kCPSTAT_M_CpuRust
cpurust mask
static const uint16_t kCPMEMBE_M_BE1
membe: be1 flag
cmap_t fCntlMap
name->cntl map
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.
static const uint16_t kCPMEMBE
CPMEMBE reg offset.
virtual ~Rw11Cpu()
Destructor.
void AddCntl(const std::shared_ptr< Rw11Cntl > &spcntl)
FIXME_docs.
bool fHasKw11l
has kw11-l (line clock)
int AddWibr(RlinkCommandList &clist, uint16_t ibaddr, uint16_t data)
FIXME_docs.
static const uint16_t kSCADDR
SC.ADDR reg offset.
static const uint16_t kM9BASE
M9312 ibus address.
int WaitCpuActDown(const Rtime &tout, Rtime &twait)
FIXME_docs.
Rw11Cpu()
default ctor blocker
static const uint8_t kStat_M_CpuSusp
stat: cpususp flag
void W11AttnHandler()
FIXME_docs.
static const uint16_t kMMUMMR3
MMU MMR3 address.
static const uint16_t kCPUPSW
CPU PSW address.
RlinkAddrMap fIAddrMap
ibus name<->address mapping
static const uint16_t kMMUPARU
MMU PARU address.
bool MemWrite(uint16_t addr, const std::vector< uint16_t > &data, RerrMsg &emsg)
FIXME_docs.
static const uint16_t kCPUSYSID
CPU SYSID address.
static const uint16_t kKWLBASE
KW11-L ibus address.
static const uint16_t kCPURUST_INIT
cpu in init state
static const uint16_t kMMUMMR2
MMU MMR2 address.
int AddRibr(RlinkCommandList &clist, uint16_t ibaddr)
FIXME_docs.
static const uint16_t kCMBASE
DMCMON reg base offset.
static const uint16_t kCPAH_M_UBM22
ubmap+22bit
void AllRAddrMapInsert(const std::string &name, uint16_t rbaddr)
FIXME_docs.
static const uint16_t kMMUMMR1
MMU MMR1 address.
static const uint16_t kCMIMAL
CM.IMAL reg offset.
bool RAddrMapInsert(const std::string &name, uint16_t rbaddr)
FIXME_docs.
static const uint16_t kKWPBASE
KW11-P ibus address.
int AddWbibr(RlinkCommandList &clist, uint16_t ibaddr, const std::vector< uint16_t > &block)
FIXME_docs.
static const uint16_t kITCNTL
IT.CNTL reg offset.
static const uint16_t kCPSTAT
CPSTAT reg offset.
static const uint16_t kSCDATA
SC.DATA reg offset.
static const uint16_t kIISTACR
II.ACR reg offset.
static const uint16_t kCPSTAT_M_SuspExt
suspext mask
static const uint16_t kMMUPARS
MMU PARS address.
static const uint16_t kCPCNTL
CPADDR reg offset.
bool fHasCmon
has dmcmon (cpu monitor)
static const uint16_t kCMCNTL
CM.CNTL reg offset.
bool fHasKw11p
has kw11-p (prog clock)
static const uint16_t kCPSTAT_M_CpuSusp
cpususp mask
static const uint16_t kCMSTAT
CM.STAT reg offset.
static const uint16_t kCPAH_M_UBMAP
ena ubmap
static const uint16_t kMEMHM
MEM HM address.
static const uint16_t kCPURUST_HBPT
cpu hardware bpt
static const uint16_t kCPFUNC_SUSPEND
SUSPEND func code.
static const uint16_t kMEMSYSERR
MEM SYSERR address.
static const uint16_t kIMCNTL
IM.CNTL reg offset.
bool TestCntl(const std::string &name) const
FIXME_docs.
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.
Declaration of class ReventLoop.
bool Found() const
FIXME_docs.