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

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.61/] [tools/] [src/] [librwxxtpp/] [RtclRw11.cpp] - Blame information for rev 26

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 21 wfjm
// $Id: RtclRw11.cpp 513 2013-05-01 14:02:06Z mueller $
2 19 wfjm
//
3
// Copyright 2013- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4
//
5
// This program is free software; you may redistribute and/or modify it under
6
// the terms of the GNU General Public License as published by the Free
7
// Software Foundation, either version 2, or at your option any later version.
8
//
9
// This program is distributed in the hope that it will be useful, but
10
// WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
11
// or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12
// for complete details.
13
// 
14
// Revision History: 
15
// Date         Rev Version  Comment
16
// 2013-03-06   495   1.0    Initial version
17
// 2013-01-27   478   0.1    First Draft
18
// ---------------------------------------------------------------------------
19
 
20
/*!
21
  \file
22 21 wfjm
  \version $Id: RtclRw11.cpp 513 2013-05-01 14:02:06Z mueller $
23 19 wfjm
  \brief   Implemenation of class RtclRw11.
24
 */
25
 
26
#include <ctype.h>
27
 
28
#include <iostream>
29
#include <string>
30
 
31
#include "boost/bind.hpp"
32
 
33
#include "librtools/RosPrintf.hpp"
34
#include "librtcltools/RtclContext.hpp"
35
#include "librlinktpp/RtclRlinkServer.hpp"
36
#include "RtclRw11CpuW11a.hpp"
37
#include "librw11/Rw11Cpu.hpp"
38
#include "librw11/Rw11Cntl.hpp"
39
 
40
#include "RtclRw11.hpp"
41
 
42
using namespace std;
43
 
44
/*!
45
  \class Retro::RtclRw11
46
  \brief FIXME_docs
47
*/
48
 
49
// all method definitions in namespace Retro
50
namespace Retro {
51
 
52
//------------------------------------------+-----------------------------------
53
//! Constructor
54
 
55
RtclRw11::RtclRw11(Tcl_Interp* interp, const char* name)
56
  : RtclProxyOwned<Rw11>("Rw11", interp, name, new Rw11()),
57
    fspServ()
58
{
59
  AddMeth("start",    boost::bind(&RtclRw11::M_start,   this, _1));
60
  AddMeth("dump",     boost::bind(&RtclRw11::M_dump,    this, _1));
61
  AddMeth("$default", boost::bind(&RtclRw11::M_default, this, _1));
62
}
63
 
64
//------------------------------------------+-----------------------------------
65
//! Destructor
66
 
67
RtclRw11::~RtclRw11()
68
{}
69
 
70
//------------------------------------------+-----------------------------------
71
//! FIXME_docs
72
 
73
int RtclRw11::ClassCmdConfig(RtclArgs& args)
74
{
75
  string parent;
76
  if (!args.GetArg("parent", parent)) return kERR;
77
 
78
  // locate RlinkServer proxy and object -> setup W11->Server linkage
79
  RtclProxyBase* pprox = RtclContext::Find(args.Interp()).FindProxy(
80
                           "RlinkServer", parent);
81
 
82
  if (pprox == 0)
83
    return args.Quit(string("-E: object '") + parent +
84
                     "' not found or not type RlinkServer");
85
 
86
  // make RtclRlinkRw11 object be co-owner of RlinkServer object
87
  fspServ = dynamic_cast<RtclRlinkServer*>(pprox)->ObjSPtr();
88
 
89
  // set RlinkServer in Rw11 (make Rw11 also co-owner)
90
  Obj().SetServer(fspServ);
91
 
92
  // now configure cpu's
93
  string type;
94
  int    count = 1;
95
  if (!args.GetArg("type", type)) return kERR;
96
  if (!args.GetArg("?count", count, 1, 1)) return kERR;
97
  if (!args.AllDone()) return kERR;
98
 
99
  // 'factory section', create concrete w11Cpu objects
100
  if (type == "w11a") {                  // w11a --------------------------
101
    RtclRw11CpuW11a* pobj = new RtclRw11CpuW11a(args.Interp(), "cpu0");
102
    // configure cpu
103
    pobj->Obj().Setup(0,0);                 // ind=0,base=0
104
    // install in w11
105
    Obj().AddCpu(dynamic_pointer_cast<Rw11Cpu>(pobj->ObjSPtr()));
106
 
107
  } else {                               // unknown cpu type --------------
108
    return args.Quit(string("-E: unknown cpu type '") + type + "'");
109
  }
110
 
111
  return kOK;
112
}
113
 
114
//------------------------------------------+-----------------------------------
115
//! FIXME_docs
116
 
117
int RtclRw11::M_start(RtclArgs& args)
118
{
119
  if (!args.AllDone()) return kERR;
120
  if (Obj().IsStarted()) return args.Quit("already started");
121
  Obj().Start();
122
  return kOK;
123
}
124
 
125
//------------------------------------------+-----------------------------------
126
//! FIXME_docs
127
 
128
int RtclRw11::M_dump(RtclArgs& args)
129
{
130
  if (!args.AllDone()) return kERR;
131
 
132
  ostringstream sos;
133
  Obj().Dump(sos, 0);
134
  args.SetResult(sos);
135
  return kOK;
136
}
137
 
138
//------------------------------------------+-----------------------------------
139
//! FIXME_docs
140
 
141
int RtclRw11::M_default(RtclArgs& args)
142
{
143
  if (!args.AllDone()) return kERR;
144
  ostringstream sos;
145
 
146 21 wfjm
  sos << "cpu type base : cntl  type ibbase  probe  lam boot" << endl;
147 19 wfjm
 
148
  for (size_t i=0; i<Obj().NCpu(); i++) {
149
    Rw11Cpu& cpu(Obj().Cpu(i));
150
    sos << " " << i << " "
151
        << " " << RosPrintf(cpu.Type().c_str(),"-s",4)
152
        << " " << RosPrintf(cpu.Base(),"x",4)
153
        << endl;
154
    vector<string> list;
155
    cpu.ListCntl(list);
156
    for (size_t j=0; j<list.size(); j++) {
157
      Rw11Cntl& cntl(cpu.Cntl(list[j]));
158
      const Rw11Probe& pstat(cntl.ProbeStatus());
159
      sos << "                 " << RosPrintf(cntl.Name().c_str(),"-s",4)
160
          << " " << RosPrintf(cntl.Type().c_str(),"-s",4)
161
          << " " << RosPrintf(cntl.Base(),"o0",6)
162 21 wfjm
          << "  ir=" << pstat.IndicatorInt() << "," << pstat.IndicatorRem();
163 19 wfjm
      if (cntl.Lam() > 0) sos << " " << RosPrintf(cntl.Lam(),"d",3);
164
      else sos << "   -";
165
      uint16_t aload;
166
      uint16_t astart;
167
      vector<uint16_t> code;
168
      bool bootok = cntl.BootCode(0, code, aload, astart);
169
      sos << "   " << (bootok ? "y" : "n");
170
      sos << endl;
171
    }
172
  }
173
 
174
  args.AppendResultLines(sos);
175
  return kOK;
176
}
177
 
178
} // end namespace Retro

powered by: WebSVN 2.1.0

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