summaryrefslogtreecommitdiffstats
path: root/src/progs/gpsim/base/gpsim_debug.h
blob: 920bc9a0662c96ace56a8c9c42d4049e49ce811a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/***************************************************************************
 *   Copyright (C) 2006 Nicolas Hadacek <hadacek@kde.org>                  *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 ***************************************************************************/
#ifndef GPSIM_DEBUG_H
#define GPSIM_DEBUG_H

#include "gpsim.h"
#include "devices/pic/prog/pic_prog.h"
#include "devices/pic/prog/pic_debug.h"

namespace GPSim
{
//-----------------------------------------------------------------------------
class Programmer : public ::Programmer::PicBase
{
Q_OBJECT
  TQ_OBJECT
public:
  Programmer(const ::Programmer::Group &group, const Pic::Data *data)
   : Programmer::PicBase(group, data, "gpsim_programmer") {}

private:
  virtual VersionData minVersion() const { return VersionData(0, 21, 0); }
  virtual bool verifyDeviceId() { return true; }
  virtual bool checkErase() { return false; }
  virtual bool internalErase(const Device::MemoryRange &) { return false; }
  virtual bool checkRead() { return false; }
  virtual bool internalRead(Device::Memory &, const Device::MemoryRange &) { return false; }
  virtual bool checkProgram(const Device::Memory &) { return false; }
  virtual bool internalProgram(const Device::Memory &, const Device::MemoryRange &) { return false; }
  virtual bool checkVerify() { return false; }
  virtual bool internalVerify(const Device::Memory &, const Device::MemoryRange &, ::Programmer::VerifyActions) { return false; }
};

//-----------------------------------------------------------------------------
class Debugger : public ::Debugger::PicBase
{
public:
  Debugger(Programmer &programmer);
  virtual bool setBreakpoints(const TQValueList<Address> &list);
  virtual bool readRegister(const Register::TypeData &data, BitValue &value);
  virtual bool writeRegister(const Register::TypeData &data, BitValue value);
  virtual bool updatePortStatus(uint index, TQMap<uint, Device::PortBitData> &bits);

private:
  uint _nbBreakpoints;

  bool findRegExp(const TQStringList &lines, const TQString &pattern,
                  const TQString &label, TQString &value) const;
  bool getRegister(const TQString &name, BitValue &value);
  bool setRegister(const TQString &name, BitValue value);
  bool getRegister(Address address, BitValue &value);
  bool setRegister(Address address, BitValue value);
  Hardware *hardware() { return static_cast<Hardware *>(_programmer.hardware()); }
  const Pic::Data *device() const { return static_cast<const Pic::Data *>(_programmer.device()); }
  virtual bool internalInit();
  virtual bool updateState();
  virtual bool internalRun();
  virtual bool internalStep();
  virtual bool softHalt(bool &success);
  virtual bool hardHalt();
  virtual bool internalReset();
  bool readWreg(BitValue &value);
  bool writeWreg(BitValue value);
};

//-----------------------------------------------------------------------------
class Group : public ::Programmer::PicGroup
{
public:
  virtual TQString name() const { return "gpsim"; }
  virtual TQString label() const { return i18n("GPSim"); }
  virtual TQString statusLabel() const;
  virtual ::Programmer::Properties properties() const { return ::Programmer::Debugger | ::Programmer::HasConnectedState; }
  virtual ::Programmer::TargetPowerMode targetPowerMode() const { return ::Programmer::TargetSelfPowered; }
  virtual bool isPortSupported(PortType) const { return false; }
  virtual uint maxNbBreakpoints(const Device::Data *) const { return 100; }
  virtual bool isInputFileTypeSupported(PURL::FileType type) const { return ( type==PURL::Cod || type==PURL::Hex ); }

protected:
  virtual void initSupported();
  virtual ::Programmer::Base *createBase(const Device::Data *data) const { return new Programmer(*this, static_cast<const Pic::Data *>(data)); }
  virtual ::Programmer::Hardware *createHardware(::Programmer::Base &base, const ::Programmer::HardwareDescription &hd) const;
  virtual ::Programmer::DeviceSpecific *createDeviceSpecific(::Programmer::Base &base) const;
  virtual ::Debugger::Base *createDebuggerBase(::Programmer::Base &base) const { return new Debugger(static_cast<Programmer &>(base)); }
  virtual ::Debugger::Specific *createDebuggerSpecific(::Debugger::Base &) const { return 0; }
};

} // namespace

#endif