forked from sysprogs/msp430-gdbproxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMSP430EEMTarget.h
110 lines (85 loc) · 3.01 KB
/
MSP430EEMTarget.h
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
#pragma once
#include "MSP430Target.h"
#include <bzscore/sync.h>
#include <set>
#include "settings.h"
namespace MSP430Proxy
{
class SoftwareBreakpointManager;
//! Implements EEM-related debugging functionality (data breakpoints and software breakpoints).
class MSP430EEMTarget : public MSP430GDBTarget
{
private:
bool m_bEEMInitialized;
BazisLib::Event m_TargetStopped;
BazisLib::Semaphore m_BreakInSemaphore;
DWORD m_LastStopEvent;
WORD m_SoftwareBreakpointWrapperHandle;
SoftwareBreakpointManager *m_pBreakpointManager;
RUN_MODES_t m_LastResumeMode;
unsigned m_HardwareBreakpointsUsed;
//! If the last resume operation was resuming from a breakpoint, this field contains its address. If not, it contains -1
LONG m_BreakpointAddrOfLastResumeOp;
private:
class RAMBreakpointDatabase
{
private:
unsigned char Flags[65536 / 8];
public:
RAMBreakpointDatabase()
{
memset(Flags, 0, sizeof(Flags));
}
void InsertBreakpoint(USHORT addr)
{
Flags[addr >> 3] |= (1 << (addr & 7));
}
void RemoveBreakpoint(USHORT addr)
{
Flags[addr >> 3] &= ~(1 << (addr & 7));
}
bool IsBreakpointPresent(USHORT addr)
{
return (Flags[addr >> 3] & (1 << (addr & 7))) != 0;
}
};
RAMBreakpointDatabase m_RAMBreakpoints;
unsigned short m_BreakpointInstruction;
BreakpointPolicy m_BreakpointPolicy;
protected:
virtual bool DoResumeTarget(RUN_MODES_t mode) override;
bool IsFLASHAddress(ULONGLONG addr)
{
return addr >= m_DeviceInfo.mainStart && addr <= m_DeviceInfo.mainEnd;
}
public:
MSP430EEMTarget()
: m_bEEMInitialized(false)
, m_SoftwareBreakpointWrapperHandle(0)
, m_pBreakpointManager(NULL)
, m_LastResumeMode(RUN_TO_BREAKPOINT)
, m_BreakpointAddrOfLastResumeOp(-1)
, m_BreakpointInstruction(0) //Will be updated in Initialize()
, m_HardwareBreakpointsUsed(0)
, m_BreakpointPolicy(HardwareThenSoftware)
{
}
public:
virtual bool Initialize(const GlobalSettings &settings) override;
~MSP430EEMTarget();
virtual bool WaitForJTAGEvent() override;
private:
static void sEEMHandler(UINT MsgId, UINT wParam, LONG lParam, LONG clientHandle);
void EEMNotificationHandler(MSP430_MSG wMsg, WPARAM wParam, LPARAM lParam);
GDBStatus DoCreateCodeBreakpoint(bool hardware, ULONGLONG Address, INT_PTR *pCookie);
GDBStatus DoRemoveCodeBreakpoint(bool hardware, ULONGLONG Address, INT_PTR Cookie);
void DoSendBreakInRequest();
public:
virtual GDBStatus CreateBreakpoint(BreakpointType type, ULONGLONG Address, unsigned kind, OUT INT_PTR *pCookie) override;
virtual GDBStatus RemoveBreakpoint(BreakpointType type, ULONGLONG Address, INT_PTR Cookie) override;
virtual GDBStatus SendBreakInRequestAsync();
public:
virtual GDBStatus ReadTargetMemory(ULONGLONG Address, void *pBuffer, size_t *pSizeInBytes) override;
virtual GDBStatus WriteTargetMemory(ULONGLONG Address, const void *pBuffer, size_t sizeInBytes) override;
};
}