summaryrefslogtreecommitdiffstats
path: root/src/progs/icd2/base/icd2_debug_specific.h
blob: 830ab0fb54560db392bb7cd389c6e59ee82c7808 (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
97
98
/***************************************************************************
 *   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_SPECIFIC_H
#define ICD2_DEBUG_SPECIFIC_H

#include "icd2_debug.h"

namespace Icd2
{
//-----------------------------------------------------------------------------
class DebuggerSpecific : public ::Debugger::Specific
{
public:
  DebuggerSpecific(::Debugger::Base &base) : ::Debugger::Specific(base) {}
  Debugger &base() { return static_cast<Debugger &>(_base); }
  const Debugger &base() const { return static_cast<const Debugger &>(_base); }
  const Pic::Data *device() const { return base().device(); }
  Hardware *hardware() { return base().programmer().hardware(); }
  DebugProgrammer &programmer() { return base().programmer(); }
  ::Debugger::PicSpecific *deviceSpecific() { return base().deviceSpecific(); }
  virtual Address addressWREG() const = 0;
  virtual BitValue tqmaskPC() const = 0;
  virtual Address addressRegister(Address address) const = 0;
  virtual bool setBreakpoint(Address address) = 0;
  virtual bool readBreakpoint(BitValue &value) = 0;
  virtual bool init(bool last) = 0;
  virtual bool reset() = 0;
};

//-----------------------------------------------------------------------------
class P16FDebuggerSpecific : public DebuggerSpecific
{
public:
  P16FDebuggerSpecific(::Debugger::Base &base) : DebuggerSpecific(base) {}
  virtual Address addressBreakpointRegister() const { return 0x18E; }
  virtual BitValue writeMaskBreakpointRegister() const { return 0x8000; }
  virtual BitValue readMaskBreakpointRegister() const { return 0x1FFF; }
  virtual Address addressWREG() const;
  virtual BitValue tqmaskPC() const { return 0x1FFF; }
  virtual Address addressRegister(Address address) const;
  virtual bool setBreakpoint(Address address);
  virtual bool readBreakpoint(BitValue &value);
  virtual bool reset();

protected:
  bool beginInit(Device::Array *saved);
  bool endInit(BitValue expectedPC);
};

class P16F872DebuggerSpecific : public P16FDebuggerSpecific
{
public:
  P16F872DebuggerSpecific(::Debugger::Base &base) : P16FDebuggerSpecific(base) {}
  virtual bool init(bool last);
};

class P16F87XDebuggerSpecific : public P16FDebuggerSpecific
{
public:
  P16F87XDebuggerSpecific(::Debugger::Base &base) : P16FDebuggerSpecific(base) {}
  virtual bool init(bool last);
};

class P16F7X7DebuggerSpecific : public P16FDebuggerSpecific
{
public:
  P16F7X7DebuggerSpecific(::Debugger::Base &base) : P16FDebuggerSpecific(base) {}
  virtual bool init(bool last);
};

//-----------------------------------------------------------------------------
class P18FDebuggerSpecific : public DebuggerSpecific
{
public:
  P18FDebuggerSpecific(::Debugger::Base &base);
  virtual Address addressWREG() const;
  virtual BitValue tqmaskPC() const { return 0xFFFF; }
  virtual Address addressRegister(Address address) const;
  virtual bool setBreakpoint(Address address);
  virtual bool readBreakpoint(BitValue &value);
  virtual bool init(bool last);
  virtual bool reset();
  uint reservedBank() const { return _reservedBank; }

private:
  uint _reservedBank; // bank where are the debugging sfrs
  uint reservedRegisterOffset() const { return reservedBank() << 8; }
};

} // namespace

#endif