summaryrefslogtreecommitdiffstats
path: root/src/progs/icd2/base/icd2_debug.h
blob: 7042a22c451a66ff1797f77209fa7e9854ac8760 (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
/***************************************************************************
 *   Copyright (C) 2005-2007 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 ICD2_DEBUG_H
#define ICD2_DEBUG_H

#include "icd2_prog.h"
#include "devices/pic/prog/pic_debug.h"

namespace Icd2
{
class DebuggerSpecific;

//-----------------------------------------------------------------------------
class DebugProgrammer : public ProgrammerBase
{
Q_OBJECT
  TQ_OBJECT
public:
  DebugProgrammer(const ::Programmer::Group &group, const Pic::Data *data);
  bool readDebugExecutiveVersion();
  const VersionData &debugExecutiveVersion() const { return _debugExecutiveVersion; }

private:
  VersionData   _debugExecutiveVersion;
  Device::Array _deArray;
  uint          _deStart, _deEnd;

  virtual void clear();
  virtual bool internalSetupHardware();
  virtual bool doProgram(const Device::Memory &memory, const Device::MemoryRange &range);
  virtual bool programAll(const Pic::Memory &memory);
  virtual bool internalRead(Device::Memory *memory, const Device::MemoryRange &range, const ::Programmer::VerifyData *vdata);

  bool getDebugExecutive();
  bool writeDebugExecutive();
  Pic::Memory toDebugMemory(const Pic::Memory &memory, bool withDebugExecutive);
};

//-----------------------------------------------------------------------------
class Debugger : public ::Debugger::PicBase
{
public:
  Debugger(DebugProgrammer &programmer) : ::Debugger::PicBase(programmer) {}
  virtual bool setBreakpoints(const TQValueList<Address> &addresses);
  Hardware *hardware() { return static_cast<Hardware *>(_programmer.hardware()); }
  DebugProgrammer &programmer() { return static_cast<DebugProgrammer &>(_programmer); }
  DebuggerSpecific *specific();
  bool waitForTargetMode(Pic::TargetMode mode);
  virtual bool readRegister(const Register::TypeData &data, BitValue &value);
  virtual bool writeRegister(const Register::TypeData &data, BitValue value);
  bool init(bool last);

protected:
  virtual bool internalInit();
  virtual bool internalRun();
  virtual bool internalStep();
  virtual bool softHalt(bool &success);
  virtual bool hardHalt();
  virtual bool internalReset();
  virtual bool updateState();

private:
  bool _initLast;
};

//-----------------------------------------------------------------------------
class DebuggerGroup : public Group
{
public:
  virtual TQString name() const { return "icd2_debugger"; }
  virtual TQString label() const { return i18n("ICD2 Debugger"); }
  virtual ::Programmer::Properties properties() const { return Group::properties() | ::Programmer::Debugger; }
  virtual uint maxNbBreakpoints(const Device::Data *) const { return 1; }

protected:
  virtual void addDevice(const TQString &name, const Device::Data *data, ::Group::Support support);
  virtual ::Programmer::Base *createBase(const Device::Data *data) const { return new DebugProgrammer(*this, static_cast<const Pic::Data *>(data)); }
  virtual ::Debugger::Base *createDebuggerBase(::Programmer::Base &base) const { return new Debugger(static_cast<DebugProgrammer &>(base)); }
  virtual ::Debugger::Specific *createDebuggerSpecific(::Debugger::Base &base) const;
};

} // namespace

#endif