blob: ebdcd75fb12c78bfcd2b27e96a60c4ab35154c75 (
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
/***************************************************************************
* 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. *
***************************************************************************/
#include "pic_debug.h"
#include "common/common/misc.h"
#include "devices/pic/base/pic_register.h"
#include "progs/manager/debug_manager.h"
//----------------------------------------------------------------------------
Register::TypeData Debugger::PicBase::registerTypeData(const TQString &name) const
{
const Pic::RegistersData &rdata = device()->registersData();
Q_ASSERT(rdata.sfrs.tqcontains(name));
return Register::TypeData(rdata.sfrs[name].address, rdata.nbChars());
}
bool Debugger::PicBase::updatePorttqStatus(uint index, TQMap<uint, Device::PortBitData> &bits)
{
const Pic::RegistersData &rdata = device()->registersData();
BitValue tris;
if ( rdata.hasTris(index) ) {
tris = Register::list().value(registerTypeData(rdata.trisName(index)));
Q_ASSERT( tris.isInitialized() );
}
BitValue port = Register::list().value(registerTypeData(rdata.portName(index)));
Q_ASSERT( port.isInitialized() );
BitValue latch;
if ( rdata.hasLatch(index) ) {
latch = Register::list().value(registerTypeData(rdata.latchName(index)));
Q_ASSERT( latch.isInitialized() );
}
for (uint i=0; i<Device::MAX_NB_PORT_BITS; i++) {
if ( !rdata.hasPortBit(index, i) ) continue;
bits[i].state = Device::Unknown;
bits[i].drivenState = Device::IoUnknown;
bits[i].drivingState = Device::IoUnknown;
if ( tris.isInitialized() ) {
bits[i].driving = !tris.bit(i);
if (bits[i].driving) {
bits[i].drivenState = Device::IoUnknown;
bits[i].drivingState = (port.bit(i) ? Device::IoHigh : Device::IoLow);
} else {
bits[i].drivenState = (port.bit(i) ? Device::IoHigh : Device::IoLow);
if ( latch.isInitialized() ) bits[i].drivingState = (latch.bit(i) ? Device::IoHigh : Device::IoLow);
else bits[i].drivingState = Device::IoUnknown;
}
}
}
return true;
}
//----------------------------------------------------------------------------
Debugger::PicBase &Debugger::PicSpecific::base()
{
return static_cast<PicBase &>(_base);
}
const Debugger::PicBase &Debugger::PicSpecific::base() const
{
return static_cast<PicBase &>(_base);
}
bool Debugger::PicSpecific::updatetqStatus()
{
if ( !Debugger::manager->readRegister(base().pcTypeData()) ) return false;
if ( !Debugger::manager->readRegister(base().registerTypeData("STATUS")) ) return false;
if ( !Debugger::manager->readRegister(wregTypeData()) ) return false;
return true;
}
//----------------------------------------------------------------------------
Register::TypeData Debugger::P16FSpecific::wregTypeData() const
{
return Register::TypeData("WREG", device().registersData().nbChars());
}
TQString Debugger::P16FSpecific::statusString() const
{
const Pic::RegistersData &rdata = device().registersData();
BitValue status = Register::list().value(base().registerTypeData("STATUS"));
uint bank = (status.bit(5) ? 1 : 0) + (status.bit(6) ? 2 : 0);
BitValue wreg = Register::list().value(wregTypeData());
return TQString("W:%1 %2 %3 %4 PC:%5 Bank:%6")
.tqarg(toHexLabel(wreg, rdata.nbChars())).tqarg(status.bit(2) ? "Z" : "z")
.tqarg(status.bit(1) ? "DC" : "dc").tqarg(status.bit(0) ? "C" : "c")
.tqarg(toHexLabel(_base.pc(), device().nbCharsAddress())).tqarg(bank);
}
//----------------------------------------------------------------------------
bool Debugger::P18FSpecific::updatetqStatus()
{
if ( !PicSpecific::updatetqStatus() ) return false;
if ( !Debugger::manager->readRegister(base().registerTypeData("BSR")) ) return false;
return true;
}
Register::TypeData Debugger::P18FSpecific::wregTypeData() const
{
return base().registerTypeData("WREG");
}
TQString Debugger::P18FSpecific::statusString() const
{
const Pic::RegistersData &rdata = device().registersData();
BitValue status = Register::list().value(base().registerTypeData("STATUS"));
BitValue bsr = Register::list().value(base().registerTypeData("BSR"));
BitValue wreg = Register::list().value(wregTypeData());
return TQString("W:%1 %2 %3 %4 %5 %6 PC:%7 Bank:%8")
.tqarg(toHexLabel(wreg, rdata.nbChars())).tqarg(status.bit(4) ? "N" : "n")
.tqarg(status.bit(3) ? "OV" : "ov").tqarg(status.bit(2) ? "Z" : "z")
.tqarg(status.bit(1) ? "DC" : "dc").tqarg(status.bit(0) ? "C" : "c")
.tqarg(toHexLabel(base().pc(), device().nbCharsAddress())).tqarg(toLabel(bsr));
}
|