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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
|
//General routines to communicate via ICD with a target
//The following commands are implemented in the debugger monitor
//routine which is written in the last memory page on the target chip.
#define VER 1 //;version
#define STEP 2 //;step
#define GO 3 //;go
#define RREG 4 //;read register
#define WREG 5 //;write register
#define EEADR 0x10D
#define EEADRH 0x10F
#define EEDATA 0x10C
#define EEDATH 0x10E
#define EECON1 0x18C
#define EECON2 0x18D
#define w_temp 0x6B
#define status_temp 0x6C
#define pclath_temp 0x6D
#define fsr_temp 0x6E
extern struct var{ char* name; int display;} variables[0x200];
extern GtkWidget * statusTxt;
extern GtkWidget * sourceTxt;
extern GtkTextBuffer * sourceBuf;
extern GtkWidget * icdVbox1;
extern GtkWidget * icdMenuPC;
extern GtkWidget * icdMenuSTAT;
extern GtkWidget * icdMenuBank0;
extern GtkWidget * icdMenuBank1;
extern GtkWidget * icdMenuBank2;
extern GtkWidget * icdMenuBank3;
extern GtkWidget * icdMenuEE;
extern GtkWidget * icdCommand;
extern GtkTextBuffer * statusBuf;
extern int icdTimer;
//Prepare ICD interface by resetting the target with a power-up sequence.
//MCLR is low so the target is reset even if power is not supplied by the programmer.
//Set communication speed at 1/(2*Tck us)
void startICD(int Tck);
//Check whether the target is running or is executing the debug routine.
//This is signaled by RB7 (Data): D=1 -> debugger monitor running
int isRunning();
//Set the next breakpoint address, the freeze bit,
//and continue execution.
//This is necessary because at every break
//the ICD register is loaded with the last address.
void cont(int break_addr, int freeze);
//Execute a single step
void step();
//Remove reset so that the target can start executing its code.
void run();
//Get the debugger monitor version
int version();
//Halt execution by setting RB6 (Clock) low
void Halt();
//Read register at address addr
int ReadRegister(int addr);
//Read n registers starting at address addr
int ReadRegisterN(int addr,int n,int* buf);
//Write data at address addr
void WriteRegister(int addr,int data);
//Read program memory at address addr
int ReadProgMem(int addr);
//Read program memory at address addr
int ReadProgMemN(int addr,int n,int* buf);
//Read data memory at address addr
int ReadDataMem(int addr);
//Read data memory at address addr
int ReadDataMemN(int addr,int n,unsigned char* buf);
//Disassemble a command and return string
char* decodeCmd(int cmd,char *str, int addrH);
// get register name from list
char* getVar(int addr,char *var);
///
///Scroll source file
void scrollToLine(int line);
///
///Hilight line in source code
void SourceHilightLine(int line);
///
///Remove hilight line in source code
void SourceRemoveHilightLine(int line);
///
///load source file into source pane
int loadSource(FILE *f);
///
///load and analyze coff file
void loadCoff(GtkWidget *widget,GtkWidget *window);
///
/// List of variables used when decoding an assembly word
void initVar();
///
///Show ICD help window
void ICDHelp(GtkWidget *widget,GtkWidget *window);
///
///ICD: check if program is running
void icdCheck(GtkWidget *widget,GtkWidget *window);
///
///ICD: run program
void icdRun(GtkWidget *widget,GtkWidget *window);
///
///ICD: halt program
void icdHalt(GtkWidget *widget,GtkWidget *window);
///
///ICD: step program
void icdStep(GtkWidget *widget,GtkWidget *window);
///
///ICD: step program jumping over calls
void icdStepOver(GtkWidget *widget,GtkWidget *window);
///
///ICD: stop program
void icdStop(GtkWidget *widget,GtkWidget *window);
///
///ICD: refresh status
void icdRefresh(GtkWidget *widget,GtkWidget *window);
///
/// Read and display an entire bank of memory
void ShowBank(int bank,char* status);
///
/// Main ICD show function:
/// prints status info according to selected options
/// and the value of variables in the watch list
void ShowContext();
///
///Add symbol to the list of watched variables
int addWatch(struct symbol s);
///
/// ICD Command parser
int executeCommand(char *command);
///
///Remove variable from watch list
int removeWatch(char* name);
///
///Handle mouse events in source code window
gint source_mouse_event(GtkWidget *widget, GdkEventButton *event, gpointer func_data);
///
///Handle mouse events in ICD status window
gint icdStatus_mouse_event(GtkWidget *widget, GdkEventButton *event, gpointer func_data);
///
///Handle keyboard events in ICD command edit box
gint icdCommand_key_event(GtkWidget *widget, GdkEventButton *event, gpointer func_data);
///
///Handle keyboard events in ICD tab
gint icd_key_event(GtkWidget *widget, GdkEventButton *event, gpointer func_data);
|