OpenCores
URL https://opencores.org/ocsvn/w11/w11/trunk

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.74/] [tools/] [src/] [librw11/] [Rw11Cpu.cpp] - Diff between revs 29 and 30

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 29 Rev 30
Line 1... Line 1...
// $Id: Rw11Cpu.cpp 632 2015-01-11 12:30:03Z mueller $
// $Id: Rw11Cpu.cpp 675 2015-05-08 21:05:08Z mueller $
//
//
// Copyright 2013-2014 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2013-2015 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
//
// This program is free software; you may redistribute and/or modify it under
// This program is free software; you may redistribute and/or modify it under
// the terms of the GNU General Public License as published by the Free
// the terms of the GNU General Public License as published by the Free
// Software Foundation, either version 2, or at your option any later version.
// Software Foundation, either version 2, or at your option any later version.
//
//
Line 11... Line 11...
// or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
// or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
// for complete details.
// for complete details.
// 
// 
// Revision History: 
// Revision History: 
// Date         Rev Version  Comment
// Date         Rev Version  Comment
 
// 2015-05-08   675   1.2.3  w11a start/stop/suspend overhaul
 
// 2015-04-25   668   1.2.2  add AddRbibr(), AddWbibr()
 
// 2015-04-03   661   1.2.1  add kStat_M_* defs
 
// 2015-03-21   659   1.2    add RAddrMap
// 2015-01-01   626   1.1    Adopt for rlink v4 and 4k ibus window
// 2015-01-01   626   1.1    Adopt for rlink v4 and 4k ibus window
// 2014-12-21   617   1.0.3  use kStat_M_RbTout for rbus timeout
// 2014-12-21   617   1.0.3  use kStat_M_RbTout for rbus timeout
// 2014-08-02   576   1.0.2  adopt rename of LastExpect->SetLastExpect
// 2014-08-02   576   1.0.2  adopt rename of LastExpect->SetLastExpect
// 2013-04-14   506   1.0.1  add AddLalh(),AddRMem(),AddWMem()
// 2013-04-14   506   1.0.1  add AddLalh(),AddRMem(),AddWMem()
// 2013-04-12   504   1.0    Initial version
// 2013-04-12   504   1.0    Initial version
// 2013-01-27   478   0.1    First draft
// 2013-01-27   478   0.1    First draft
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
 
 
/*!
/*!
  \file
  \file
  \version $Id: Rw11Cpu.cpp 632 2015-01-11 12:30:03Z mueller $
  \version $Id: Rw11Cpu.cpp 675 2015-05-08 21:05:08Z mueller $
  \brief   Implemenation of Rw11Cpu.
  \brief   Implemenation of Rw11Cpu.
*/
*/
#include <stdlib.h>
#include <stdlib.h>
#include <fcntl.h>
#include <fcntl.h>
#include <errno.h>
#include <errno.h>
Line 56... Line 60...
namespace Retro {
namespace Retro {
 
 
//------------------------------------------+-----------------------------------
//------------------------------------------+-----------------------------------
// constants definitions
// constants definitions
 
 
const uint16_t  Rw11Cpu::kCp_addr_conf;
const uint16_t  Rw11Cpu::kCPCONF;
const uint16_t  Rw11Cpu::kCp_addr_cntl;
const uint16_t  Rw11Cpu::kCPCNTL;
const uint16_t  Rw11Cpu::kCp_addr_stat;
const uint16_t  Rw11Cpu::kCPSTAT;
const uint16_t  Rw11Cpu::kCp_addr_psw;
const uint16_t  Rw11Cpu::kCPPSW;
const uint16_t  Rw11Cpu::kCp_addr_al;
const uint16_t  Rw11Cpu::kCPAL;
const uint16_t  Rw11Cpu::kCp_addr_ah;
const uint16_t  Rw11Cpu::kCPAH;
const uint16_t  Rw11Cpu::kCp_addr_mem;
const uint16_t  Rw11Cpu::kCPMEM;
const uint16_t  Rw11Cpu::kCp_addr_memi;
const uint16_t  Rw11Cpu::kCPMEMI;
const uint16_t  Rw11Cpu::kCp_addr_r0;
const uint16_t  Rw11Cpu::kCPR0;
const uint16_t  Rw11Cpu::kCp_addr_pc;
const uint16_t  Rw11Cpu::kCPPC;
const uint16_t  Rw11Cpu::kCp_addr_membe;
const uint16_t  Rw11Cpu::kCPMEMBE;
 
 
const uint16_t  Rw11Cpu::kCp_func_noop;
const uint16_t  Rw11Cpu::kCPFUNC_NOOP;
const uint16_t  Rw11Cpu::kCp_func_start;
const uint16_t  Rw11Cpu::kCPFUNC_START;
const uint16_t  Rw11Cpu::kCp_func_stop;
const uint16_t  Rw11Cpu::kCPFUNC_STOP;
const uint16_t  Rw11Cpu::kCp_func_cont;
const uint16_t  Rw11Cpu::kCPFUNC_STEP;
const uint16_t  Rw11Cpu::kCp_func_step;
const uint16_t  Rw11Cpu::kCPFUNC_CRESET;
const uint16_t  Rw11Cpu::kCp_func_reset;
const uint16_t  Rw11Cpu::kCPFUNC_BRESET;
 
const uint16_t  Rw11Cpu::kCPFUNC_SUSPEND;
const uint16_t  Rw11Cpu::kCp_stat_m_cpurust;
const uint16_t  Rw11Cpu::kCPFUNC_RESUME;
const uint16_t  Rw11Cpu::kCp_stat_v_cpurust;
 
const uint16_t  Rw11Cpu::kCp_stat_b_cpurust;
const uint16_t  Rw11Cpu::kCPSTAT_M_SuspExt;
const uint16_t  Rw11Cpu::kCp_stat_m_cpuhalt;
const uint16_t  Rw11Cpu::kCPSTAT_M_SuspInt;
const uint16_t  Rw11Cpu::kCp_stat_m_cpugo;
const uint16_t  Rw11Cpu::kCPSTAT_M_CpuRust;
const uint16_t  Rw11Cpu::kCp_stat_m_cmdmerr;
const uint16_t  Rw11Cpu::kCPSTAT_V_CpuRust;
const uint16_t  Rw11Cpu::kCp_stat_m_cmderr;
const uint16_t  Rw11Cpu::kCPSTAT_B_CpuRust;
 
const uint16_t  Rw11Cpu::kCPSTAT_M_CpuSusp;
const uint16_t  Rw11Cpu::kCp_cpurust_init;
const uint16_t  Rw11Cpu::kCPSTAT_M_CpuGo;
const uint16_t  Rw11Cpu::kCp_cpurust_halt;
const uint16_t  Rw11Cpu::kCPSTAT_M_CmdMErr;
const uint16_t  Rw11Cpu::kCp_cpurust_reset;
const uint16_t  Rw11Cpu::kCPSTAT_M_CmdErr;
const uint16_t  Rw11Cpu::kCp_cpurust_stop;
 
const uint16_t  Rw11Cpu::kCp_cpurust_step;
const uint16_t  Rw11Cpu::kCPURUST_INIT;
const uint16_t  Rw11Cpu::kCp_cpurust_susp;
const uint16_t  Rw11Cpu::kCPURUST_HALT;
const uint16_t  Rw11Cpu::kCp_cpurust_runs;
const uint16_t  Rw11Cpu::kCPURUST_RESET;
const uint16_t  Rw11Cpu::kCp_cpurust_vecfet;
const uint16_t  Rw11Cpu::kCPURUST_STOP;
const uint16_t  Rw11Cpu::kCp_cpurust_recrsv;
const uint16_t  Rw11Cpu::kCPURUST_STEP;
const uint16_t  Rw11Cpu::kCp_cpurust_sfail;
const uint16_t  Rw11Cpu::kCPURUST_SUSP;
const uint16_t  Rw11Cpu::kCp_cpurust_vfail;
const uint16_t  Rw11Cpu::kCPURUST_RUNS;
 
const uint16_t  Rw11Cpu::kCPURUST_VECFET;
const uint16_t  Rw11Cpu::kCp_ah_m_addr;
const uint16_t  Rw11Cpu::kCPURUST_RECRSV;
const uint16_t  Rw11Cpu::kCp_ah_m_22bit;
const uint16_t  Rw11Cpu::kCPURUST_SFAIL;
const uint16_t  Rw11Cpu::kCp_ah_m_ubmap;
const uint16_t  Rw11Cpu::kCPURUST_VFAIL;
 
 
const uint16_t  Rw11Cpu::kCp_membe_m_stick;
const uint16_t  Rw11Cpu::kCPAH_M_ADDR;
const uint16_t  Rw11Cpu::kCp_membe_m_be;
const uint16_t  Rw11Cpu::kCPAH_M_22BIT;
 
const uint16_t  Rw11Cpu::kCPAH_M_UBMAP;
 
 
 
const uint16_t  Rw11Cpu::kCPMEMBE_M_STICK;
 
const uint16_t  Rw11Cpu::kCPMEMBE_M_BE;
 
 
 
const uint8_t   Rw11Cpu::kStat_M_CmdErr;
 
const uint8_t   Rw11Cpu::kStat_M_CmdMErr;
 
const uint8_t   Rw11Cpu::kStat_M_CpuHalt;
 
const uint8_t   Rw11Cpu::kStat_M_CpuGo;
 
 
//------------------------------------------+-----------------------------------
//------------------------------------------+-----------------------------------
//! Constructor
//! Constructor
 
 
Rw11Cpu::Rw11Cpu(const std::string& type)
Rw11Cpu::Rw11Cpu(const std::string& type)
Line 118... Line 130...
    fCpuStat(0),
    fCpuStat(0),
    fCpuGoMutex(),
    fCpuGoMutex(),
    fCpuGoCond(),
    fCpuGoCond(),
    fCntlMap(),
    fCntlMap(),
    fIAddrMap(),
    fIAddrMap(),
 
    fRAddrMap(),
    fStats()
    fStats()
{}
{}
 
 
//------------------------------------------+-----------------------------------
//------------------------------------------+-----------------------------------
//! Destructor
//! Destructor
Line 134... Line 147...
 
 
void Rw11Cpu::Setup(Rw11* pw11)
void Rw11Cpu::Setup(Rw11* pw11)
{
{
  fpW11 = pw11;
  fpW11 = pw11;
  // add control port address rbus mappings
  // add control port address rbus mappings
  //   name base: 'cn.', where n is cpu index
  AllRAddrMapInsert("conf" , Base()+kCPCONF);
  string cbase = "c";
  AllRAddrMapInsert("cntl" , Base()+kCPCNTL);
  cbase += '0'+Index();
  AllRAddrMapInsert("stat" , Base()+kCPSTAT);
  cbase += '.';
  AllRAddrMapInsert("psw"  , Base()+kCPPSW);
  Connect().AddrMapInsert(cbase+"conf", Base()+kCp_addr_conf);
  AllRAddrMapInsert("al"   , Base()+kCPAL);
  Connect().AddrMapInsert(cbase+"cntl", Base()+kCp_addr_cntl);
  AllRAddrMapInsert("ah"   , Base()+kCPAH);
  Connect().AddrMapInsert(cbase+"stat", Base()+kCp_addr_stat);
  AllRAddrMapInsert("mem"  , Base()+kCPMEM);
  Connect().AddrMapInsert(cbase+"psw" , Base()+kCp_addr_psw);
  AllRAddrMapInsert("memi" , Base()+kCPMEMI);
  Connect().AddrMapInsert(cbase+"al"  , Base()+kCp_addr_al);
  AllRAddrMapInsert("r0"   , Base()+kCPR0);
  Connect().AddrMapInsert(cbase+"ah"  , Base()+kCp_addr_ah);
  AllRAddrMapInsert("r1"   , Base()+kCPR0+1);
  Connect().AddrMapInsert(cbase+"mem" , Base()+kCp_addr_mem);
  AllRAddrMapInsert("r2"   , Base()+kCPR0+2);
  Connect().AddrMapInsert(cbase+"memi", Base()+kCp_addr_memi);
  AllRAddrMapInsert("r3"   , Base()+kCPR0+3);
  Connect().AddrMapInsert(cbase+"r0"  , Base()+kCp_addr_r0);
  AllRAddrMapInsert("r4"   , Base()+kCPR0+4);
  Connect().AddrMapInsert(cbase+"r1"  , Base()+kCp_addr_r0+1);
  AllRAddrMapInsert("r5"   , Base()+kCPR0+5);
  Connect().AddrMapInsert(cbase+"r2"  , Base()+kCp_addr_r0+2);
  AllRAddrMapInsert("sp"   , Base()+kCPR0+6);
  Connect().AddrMapInsert(cbase+"r3"  , Base()+kCp_addr_r0+3);
  AllRAddrMapInsert("pc"   , Base()+kCPR0+7);
  Connect().AddrMapInsert(cbase+"r4"  , Base()+kCp_addr_r0+4);
  AllRAddrMapInsert("membe",Base()+kCPMEMBE);
  Connect().AddrMapInsert(cbase+"r5"  , Base()+kCp_addr_r0+5);
 
  Connect().AddrMapInsert(cbase+"sp"  , Base()+kCp_addr_r0+6);
 
  Connect().AddrMapInsert(cbase+"pc"  , Base()+kCp_addr_r0+7);
 
  Connect().AddrMapInsert(cbase+"membe",Base()+kCp_addr_membe);
 
 
 
  // add cpu register address ibus and rbus mappings
  // add cpu register address ibus and rbus mappings
  AllAddrMapInsert("psw"    , 0177776);
  AllIAddrMapInsert("psw"    , 0177776);
  AllAddrMapInsert("stklim" , 0177774);
  AllIAddrMapInsert("stklim" , 0177774);
  AllAddrMapInsert("pirq"   , 0177772);
  AllIAddrMapInsert("pirq"   , 0177772);
  AllAddrMapInsert("mbrk"   , 0177770);
  AllIAddrMapInsert("mbrk"   , 0177770);
  AllAddrMapInsert("cpuerr" , 0177766);
  AllIAddrMapInsert("cpuerr" , 0177766);
  AllAddrMapInsert("sysid"  , 0177764);
  AllIAddrMapInsert("sysid"  , 0177764);
  AllAddrMapInsert("hisize" , 0177762);
  AllIAddrMapInsert("hisize" , 0177762);
  AllAddrMapInsert("losize" , 0177760);
  AllIAddrMapInsert("losize" , 0177760);
 
 
  AllAddrMapInsert("hm"     , 0177752);
  AllIAddrMapInsert("hm"     , 0177752);
  AllAddrMapInsert("maint"  , 0177750);
  AllIAddrMapInsert("maint"  , 0177750);
  AllAddrMapInsert("cntrl"  , 0177746);
  AllIAddrMapInsert("cntrl"  , 0177746);
  AllAddrMapInsert("syserr" , 0177744);
  AllIAddrMapInsert("syserr" , 0177744);
  AllAddrMapInsert("hiaddr" , 0177742);
  AllIAddrMapInsert("hiaddr" , 0177742);
  AllAddrMapInsert("loaddr" , 0177740);
  AllIAddrMapInsert("loaddr" , 0177740);
 
 
  AllAddrMapInsert("ssr2"   , 0177576);
  AllIAddrMapInsert("ssr2"   , 0177576);
  AllAddrMapInsert("ssr1"   , 0177574);
  AllIAddrMapInsert("ssr1"   , 0177574);
  AllAddrMapInsert("ssr0"   , 0177572);
  AllIAddrMapInsert("ssr0"   , 0177572);
 
 
  AllAddrMapInsert("sdreg"  , 0177570);
  AllIAddrMapInsert("sdreg"  , 0177570);
 
 
  AllAddrMapInsert("ssr3"   , 0172516);
  AllIAddrMapInsert("ssr3"   , 0172516);
 
 
  // add mmu segment register files
  // add mmu segment register files
  string sdr = "sdr";
  string sdr = "sdr";
  string sar = "sar";
  string sar = "sar";
  for (char i=0; i<8; i++) {
  for (char i=0; i<8; i++) {
    char ichar = '0'+i;
    char ichar = '0'+i;
    AllAddrMapInsert(sdr+"ki."+ichar, 0172300+2*i);
    AllIAddrMapInsert(sdr+"ki."+ichar, 0172300+2*i);
    AllAddrMapInsert(sdr+"kd."+ichar, 0172320+2*i);
    AllIAddrMapInsert(sdr+"kd."+ichar, 0172320+2*i);
    AllAddrMapInsert(sar+"ki."+ichar, 0172340+2*i);
    AllIAddrMapInsert(sar+"ki."+ichar, 0172340+2*i);
    AllAddrMapInsert(sar+"kd."+ichar, 0172360+2*i);
    AllIAddrMapInsert(sar+"kd."+ichar, 0172360+2*i);
    AllAddrMapInsert(sdr+"si."+ichar, 0172200+2*i);
    AllIAddrMapInsert(sdr+"si."+ichar, 0172200+2*i);
    AllAddrMapInsert(sdr+"sd."+ichar, 0172220+2*i);
    AllIAddrMapInsert(sdr+"sd."+ichar, 0172220+2*i);
    AllAddrMapInsert(sar+"si."+ichar, 0172240+2*i);
    AllIAddrMapInsert(sar+"si."+ichar, 0172240+2*i);
    AllAddrMapInsert(sar+"sd."+ichar, 0172260+2*i);
    AllIAddrMapInsert(sar+"sd."+ichar, 0172260+2*i);
    AllAddrMapInsert(sdr+"ui."+ichar, 0177600+2*i);
    AllIAddrMapInsert(sdr+"ui."+ichar, 0177600+2*i);
    AllAddrMapInsert(sdr+"ud."+ichar, 0177620+2*i);
    AllIAddrMapInsert(sdr+"ud."+ichar, 0177620+2*i);
    AllAddrMapInsert(sar+"ui."+ichar, 0177640+2*i);
    AllIAddrMapInsert(sar+"ui."+ichar, 0177640+2*i);
    AllAddrMapInsert(sar+"ud."+ichar, 0177660+2*i);
    AllIAddrMapInsert(sar+"ud."+ichar, 0177660+2*i);
  }
  }
 
 
  return;
  return;
}
}
 
 
Line 287... Line 296...
//------------------------------------------+-----------------------------------
//------------------------------------------+-----------------------------------
//! FIXME_docs
//! FIXME_docs
 
 
int Rw11Cpu::AddMembe(RlinkCommandList& clist, uint16_t be, bool stick)
int Rw11Cpu::AddMembe(RlinkCommandList& clist, uint16_t be, bool stick)
{
{
  uint16_t data = be & kCp_membe_m_be;
  uint16_t data = be & kCPMEMBE_M_BE;
  if (stick) data |= kCp_membe_m_stick;
  if (stick) data |= kCPMEMBE_M_STICK;
  return clist.AddWreg(fBase+kCp_addr_membe, data);
  return clist.AddWreg(fBase+kCPMEMBE, data);
}
}
 
 
//------------------------------------------+-----------------------------------
//------------------------------------------+-----------------------------------
//! FIXME_docs
//! FIXME_docs
 
 
Line 316... Line 325...
  return clist.AddWreg(IbusRemoteAddr(ibaddr), data);
  return clist.AddWreg(IbusRemoteAddr(ibaddr), data);
}
}
 
 
//------------------------------------------+-----------------------------------
//------------------------------------------+-----------------------------------
//! FIXME_docs
//! FIXME_docs
 
int Rw11Cpu::AddRbibr(RlinkCommandList& clist, uint16_t ibaddr, size_t size)
 
{
 
  if ((ibaddr & 0160001) != 0160000)
 
    throw Rexception("Rw11Cpu::AddRbibr", "ibaddr out of IO page or odd");
 
 
 
  return clist.AddRblk(IbusRemoteAddr(ibaddr), size);
 
}
 
 
 
//------------------------------------------+-----------------------------------
 
//! FIXME_docs
 
int Rw11Cpu::AddWbibr(RlinkCommandList& clist, uint16_t ibaddr,
 
                      std::vector<uint16_t> block)
 
{
 
  if ((ibaddr & 0160001) != 0160000)
 
    throw Rexception("Rw11Cpu::AddWbibr", "ibaddr out of IO page or odd");
 
 
 
  return clist.AddWblk(IbusRemoteAddr(ibaddr), block);
 
}
 
 
 
//------------------------------------------+-----------------------------------
 
//! FIXME_docs
 
 
int Rw11Cpu::AddLalh(RlinkCommandList& clist, uint32_t addr, uint16_t mode)
int Rw11Cpu::AddLalh(RlinkCommandList& clist, uint32_t addr, uint16_t mode)
{
{
  uint16_t al = uint16_t(addr);
  uint16_t al = uint16_t(addr);
  uint16_t ah = uint16_t(addr>>16) & kCp_ah_m_addr;
  uint16_t ah = uint16_t(addr>>16) & kCPAH_M_ADDR;
  ah |= mode & (kCp_ah_m_22bit|kCp_ah_m_ubmap);
  ah |= mode & (kCPAH_M_22BIT|kCPAH_M_UBMAP);
  int ind = clist.AddWreg(fBase+kCp_addr_al, al);
  int ind = clist.AddWreg(fBase+kCPAL, al);
  clist.AddWreg(fBase+kCp_addr_ah, ah);
  clist.AddWreg(fBase+kCPAH, ah);
  return ind;
  return ind;
}
}
 
 
//------------------------------------------+-----------------------------------
//------------------------------------------+-----------------------------------
//! FIXME_docs
//! FIXME_docs
Line 341... Line 371...
                     "Bad args: singleblk==true && size > BlockSizeMax()");
                     "Bad args: singleblk==true && size > BlockSizeMax()");
 
 
  int ind = AddLalh(clist, addr, mode);
  int ind = AddLalh(clist, addr, mode);
  while (size > 0) {
  while (size > 0) {
    size_t bsize = (size>blkmax) ? blkmax : size;
    size_t bsize = (size>blkmax) ? blkmax : size;
    clist.AddRblk(fBase+kCp_addr_memi, buf, bsize);
    clist.AddRblk(fBase+kCPMEMI, buf, bsize);
    buf  += bsize;
    buf  += bsize;
    size -= bsize;
    size -= bsize;
  }
  }
  return ind;
  return ind;
}
}
Line 363... Line 393...
                     "Bad args: singleblk==true && size > BlockSizeMax()");
                     "Bad args: singleblk==true && size > BlockSizeMax()");
 
 
  int ind = AddLalh(clist, addr, mode);
  int ind = AddLalh(clist, addr, mode);
  while (size > 0) {
  while (size > 0) {
    size_t bsize = (size>blkmax) ? blkmax : size;
    size_t bsize = (size>blkmax) ? blkmax : size;
    clist.AddWblk(fBase+kCp_addr_memi, buf, bsize);
    clist.AddWblk(fBase+kCPMEMI, buf, bsize);
    buf  += bsize;
    buf  += bsize;
    size -= bsize;
    size -= bsize;
  }
  }
  return ind;
  return ind;
}
}
Line 382... Line 412...
  data.resize(nword);
  data.resize(nword);
  size_t ndone = 0;
  size_t ndone = 0;
  while (nword>ndone) {
  while (nword>ndone) {
    size_t nblk = min(blkmax, nword-ndone);
    size_t nblk = min(blkmax, nword-ndone);
    RlinkCommandList clist;
    RlinkCommandList clist;
    clist.AddWreg(fBase+kCp_addr_al, addr+2*ndone);
    clist.AddWreg(fBase+kCPAL, addr+2*ndone);
    clist.AddRblk(fBase+kCp_addr_memi, data.data()+ndone, nblk);
    clist.AddRblk(fBase+kCPMEMI, data.data()+ndone, nblk);
    if (!Server().Exec(clist, emsg)) return false;
    if (!Server().Exec(clist, emsg)) return false;
    ndone += nblk;
    ndone += nblk;
  }
  }
  return true;
  return true;
}
}
Line 402... Line 432...
  size_t nword = data.size();
  size_t nword = data.size();
  size_t ndone = 0;
  size_t ndone = 0;
  while (nword>ndone) {
  while (nword>ndone) {
    size_t nblk = min(blkmax, nword-ndone);
    size_t nblk = min(blkmax, nword-ndone);
    RlinkCommandList clist;
    RlinkCommandList clist;
    clist.AddWreg(fBase+kCp_addr_al, addr+2*ndone);
    clist.AddWreg(fBase+kCPAL, addr+2*ndone);
    clist.AddWblk(fBase+kCp_addr_memi, data.data()+ndone, nblk);
    clist.AddWblk(fBase+kCPMEMI, data.data()+ndone, nblk);
    if (!Server().Exec(clist, emsg)) return false;
    if (!Server().Exec(clist, emsg)) return false;
    ndone += nblk;
    ndone += nblk;
  }
  }
  return true;
  return true;
}
}
Line 424... Line 454...
  if (!dsc.fProbeDone) {
  if (!dsc.fProbeDone) {
    RlinkCommandList clist;
    RlinkCommandList clist;
    int iib = -1;
    int iib = -1;
    int irb = -1;
    int irb = -1;
    if (dsc.fProbeInt) {
    if (dsc.fProbeInt) {
      clist.AddWreg(fBase+kCp_addr_al,  dsc.fAddr);
      clist.AddWreg(fBase+kCPAL,  dsc.fAddr);
      iib = clist.AddRreg(fBase+kCp_addr_mem);
      iib = clist.AddRreg(fBase+kCPMEM);
      clist.SetLastExpect(new RlinkCommandExpect(0,0xff)); // disable stat check
      clist.SetLastExpectStatus(0,0);       // disable stat check
    }
    }
    if (dsc.fProbeRem) {
    if (dsc.fProbeRem) {
      irb = AddRibr(clist, dsc.fAddr);
      irb = AddRibr(clist, dsc.fAddr);
      clist.SetLastExpect(new RlinkCommandExpect(0,0xff)); // disable stat check
      clist.SetLastExpectStatus(0,0);       // disable stat check
    }
    }
 
 
    Server().Exec(clist);
    Server().Exec(clist);
 
 
    if (dsc.fProbeInt) {
    if (dsc.fProbeInt) {
Line 676... Line 706...
  }
  }
 
 
  if (!MemWrite(aload, code, emsg)) return false;
  if (!MemWrite(aload, code, emsg)) return false;
 
 
  RlinkCommandList clist;
  RlinkCommandList clist;
  clist.AddWreg(fBase+kCp_addr_pc, astart);
  clist.AddWreg(fBase+kCPCNTL, kCPFUNC_STOP);   // stop, just in case 
  clist.AddWreg(fBase+kCp_addr_cntl, kCp_func_start);
  clist.AddWreg(fBase+kCPCNTL, kCPFUNC_CRESET); // init cpu and bus
 
  clist.AddWreg(fBase+kCPPC, astart);           // load PC
 
  clist.AddWreg(fBase+kCPCNTL, kCPFUNC_START);  // and start
  SetCpuGoUp();
  SetCpuGoUp();
  if (!Server().Exec(clist, emsg)) return false;
  if (!Server().Exec(clist, emsg)) return false;
 
 
  return true;
  return true;
}
}
Line 701... Line 733...
//------------------------------------------+-----------------------------------
//------------------------------------------+-----------------------------------
//! FIXME_docs
//! FIXME_docs
 
 
void Rw11Cpu::SetCpuGoDown(uint16_t stat)
void Rw11Cpu::SetCpuGoDown(uint16_t stat)
{
{
  if ((stat & kCp_stat_m_cpugo) == 0) {
  if ((stat & kCPSTAT_M_CpuGo) == 0) {
    boost::lock_guard<boost::mutex> lock(fCpuGoMutex);
    boost::lock_guard<boost::mutex> lock(fCpuGoMutex);
    fCpuGo   = false;
    fCpuGo   = false;
    fCpuStat = stat;
    fCpuStat = stat;
    fCpuGoCond.notify_all();
    fCpuGoCond.notify_all();
  }
  }
Line 730... Line 762...
}
}
 
 
//------------------------------------------+-----------------------------------
//------------------------------------------+-----------------------------------
//! FIXME_docs
//! FIXME_docs
 
 
void Rw11Cpu::AllAddrMapInsert(const std::string& name, uint16_t ibaddr)
void Rw11Cpu::AllIAddrMapInsert(const std::string& name, uint16_t ibaddr)
{
{
  string rbname = "i";
 
  rbname += '0'+Index();
 
  rbname += '.';
 
  rbname += name;
 
  Connect().AddrMapInsert(rbname, IbusRemoteAddr(ibaddr));
 
  IAddrMapInsert(name, ibaddr);
  IAddrMapInsert(name, ibaddr);
 
  uint16_t rbaddr = IbusRemoteAddr(ibaddr);
 
  RAddrMapInsert(name, rbaddr);
 
 
 
  // add ix. to name in common Connect AddrMap to keep name unique
 
  string cname = "i";
 
  cname += '0'+Index();
 
  cname += '.';
 
  cname += name;
 
  Connect().AddrMapInsert(cname, rbaddr);
 
 
 
  return;
 
}
 
 
 
//------------------------------------------+-----------------------------------
 
//! FIXME_docs
 
 
 
void Rw11Cpu::AllRAddrMapInsert(const std::string& name, uint16_t rbaddr)
 
{
 
  RAddrMapInsert(name, rbaddr);
 
 
 
  // add cx. to name in common Connect AddrMap to keep name unique
 
  string cname = "c";
 
  cname += '0'+Index();
 
  cname += '.';
 
  cname += name;
 
  Connect().AddrMapInsert(cname, rbaddr);
 
 
  return;
  return;
}
}
 
 
//------------------------------------------+-----------------------------------
//------------------------------------------+-----------------------------------
//! FIXME_docs
//! FIXME_docs
 
 
void Rw11Cpu::W11AttnHandler()
void Rw11Cpu::W11AttnHandler()
{
{
  RlinkCommandList clist;
  RlinkCommandList clist;
  clist.AddRreg(fBase+kCp_addr_stat);
  clist.AddRreg(fBase+kCPSTAT);
  Server().Exec(clist);
  Server().Exec(clist);
  SetCpuGoDown(clist[0].Data());
  SetCpuGoDown(clist[0].Data());
  return;
  return;
}
}
 
 
Line 774... Line 828...
  for (cmap_cit_t it=fCntlMap.begin(); it!=fCntlMap.end(); it++) {
  for (cmap_cit_t it=fCntlMap.begin(); it!=fCntlMap.end(); it++) {
    os << bl << "    " << RosPrintf((it->first).c_str(), "-s",8)
    os << bl << "    " << RosPrintf((it->first).c_str(), "-s",8)
       << " : " << it->second << endl;
       << " : " << it->second << endl;
  }
  }
  fIAddrMap.Dump(os, ind+2, "fIAddrMap: ");
  fIAddrMap.Dump(os, ind+2, "fIAddrMap: ");
 
  fRAddrMap.Dump(os, ind+2, "fRAddrMap: ");
  fStats.Dump(os, ind+2, "fStats: ");
  fStats.Dump(os, ind+2, "fStats: ");
  return;
  return;
}
}
 
 
} // end namespace Retro
} // end namespace Retro

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.