17 extern char *mem2hex (void *mem
, char *buf
, int count
, int may_fault
);
18 extern char *hex2mem (char *buf
, void *mem
, int count
, int may_fault
);
19 extern int computeSignal (int exceptionVector
);
21 /* Get the registers out of the frame information. */
24 frame_to_registers (frame
, regs
)
25 struct StackFrame
*frame
;
28 mem2hex (&frame
->ExceptionPC
, ®s
[PC_REGNUM
* 8 * 2], 8 * 1, 0);
30 mem2hex (&frame
->ExceptionRegs
[SF_IREG_OFFSET
], ®s
[V0_REGNUM
* 8 * 2], 8 * 64, 0);
33 /* Put the registers back into the frame information. */
36 registers_to_frame (regs
, frame
)
38 struct StackFrame
*frame
;
40 hex2mem (®s
[PC_REGNUM
* 8 * 2], &frame
->ExceptionPC
, 8 * 1, 0);
42 hex2mem (®s
[V0_REGNUM
* 8 * 2], &frame
->ExceptionRegs
[SF_IREG_OFFSET
], 8 * 64, 0);
70 static LONG saved_inst
;
71 static LONG
*saved_inst_pc
= 0;
72 static LONG saved_target_inst
;
73 static LONG
*saved_target_inst_pc
= 0;
76 set_step_traps (frame
)
77 struct StackFrame
*frame
;
83 LONG
*pc
= (LONG
*)frame
->ExceptionPC
;
87 opcode
= inst
.inst
.variant
.branch
.opcode
;
89 if ((opcode
& 0x30) == 0x30) /* A branch of some sort */
90 target
= inst
.inst
.variant
.branch
.disp
+ pc
;
91 else if (opcode
== 0x1a) /* jmp, ret, etc... */
92 target
= (LONG
*)(frame
->ExceptionRegs
[SF_IREG_OFFSET
93 + inst
.inst
.variant
.jump
.rb
].lo
99 *pc
= 0x80; /* call_pal bpt */
104 saved_target_inst
= *target
;
105 *target
= 0x80; /* call_pal bpt */
106 saved_target_inst_pc
= target
;
110 /* Remove step breakpoints. Returns non-zero if pc was at a step breakpoint,
111 zero otherwise. This routine works even if there were no step breakpoints
115 clear_step_traps (frame
)
116 struct StackFrame
*frame
;
119 LONG
*pc
= (LONG
*)frame
->ExceptionPC
;
121 if (saved_inst_pc
== pc
|| saved_target_inst_pc
== pc
)
128 *saved_inst_pc
= saved_inst
;
132 if (saved_target_inst_pc
)
134 *saved_target_inst_pc
= saved_target_inst
;
135 saved_target_inst_pc
= 0;
142 do_status (ptr
, frame
)
144 struct StackFrame
*frame
;
148 sigval
= computeSignal (frame
->ExceptionNumber
);
150 sprintf (ptr
, "T%02x", sigval
);
153 sprintf (ptr
, "%02x:", PC_REGNUM
);
154 ptr
= mem2hex (&frame
->ExceptionPC
, ptr
+ 3, 8, 0);
157 sprintf (ptr
, "%02x:", SP_REGNUM
);
158 ptr
= mem2hex (&frame
->ExceptionRegs
[SF_IREG_OFFSET
+ SP_REGNUM
], ptr
+ 3, 8, 0);
161 sprintf (ptr
, "%02x:", RA_REGNUM
);
162 ptr
= mem2hex (&frame
->ExceptionRegs
[SF_IREG_OFFSET
+ RA_REGNUM
], ptr
+ 3, 8, 0);
165 sprintf (ptr
, "%02x:", FP_REGNUM
);
166 ptr
= mem2hex (&frame
->ExceptionRegs
[SF_IREG_OFFSET
+ FP_REGNUM
], ptr
+ 3, 8, 0);
172 /* This section provides stubs and equivalent interfaces for all functions that
173 the debugger stub needs, but aren't yet implemented (such as the AIO nlm). */
182 #define com1Rbr 0x3f8 /* Receiver Buffer - Read */
183 #define com1Thr 0x3f8 /* Transmitter Holding - Write */
184 #define com1Ier 0x3f9 /* Interrupt Enable */
185 #define com1Iir 0x3fa /* Interrupt Identification */
186 #define com1Lcr 0x3fb /* Line Control */
187 #define com1Mcr 0x3fc /* Modem Control */
188 #define com1Lsr 0x3fd /* Line Status */
189 #define com1Msr 0x3fe /* Modem Status */
190 #define com1Scr 0x3ff /* Scratch */
191 #define com1Dll 0x3f8 /* Divisor Latch - lsb */
192 #define com1Dlm 0x3f9 /* Divisor Latch - msb */
194 #define com2Rbr 0x2f8 /* Receiver Buffer - Read */
195 #define com2Thr 0x2f8 /* Transmitter Holding - Write */
196 #define com2Ier 0x2f9 /* Interrupt Enable */
197 #define com2Iir 0x2fa /* Interrupt Identification */
198 #define com2Lcr 0x2fb /* Line Control */
199 #define com2Mcr 0x2fc /* Modem Control */
200 #define com2Lsr 0x2fd /* Line Status */
201 #define com2Msr 0x2fe /* Modem Status */
202 #define com2Scr 0x2ff /* Scratch */
203 #define com2Dll 0x2f8 /* Divisor Latch - lsb */
204 #define com2Dlm 0x2f9 /* Divisor Latch - msb */
212 while ((inVti(com1Lsr
) & 1) == 0);
214 return inVti (com1Rbr
);
218 uart_putchar (char c
)
220 while ((inVti(com1Lsr
) & 0x20) == 0);
231 baudconst
= 115200 / baud
;
233 outVti (com1Lcr
, 0x87);
235 outVti (com1Dll
, baudconst
);
236 outVti (com1Lcr
, 0x07);
237 outVti (com1Mcr
, 0x0F);
238 outVti (com1Ier
, 0x0);
242 AIOReadData (int portHandle
, char *buffer
, LONG length
, LONG
*numberBytesRead
)
249 if ((c
& ~0377) == COM1
)
254 *numberBytesRead
= 1;
260 AIOWriteData (int portHandle
, char *buffer
, LONG length
,
261 LONG
*numberBytesWritten
)
264 *numberBytesWritten
= length
;
267 uart_putchar (*buffer
++);
273 AIOAcquirePort (int *hardwareType
, int *boardNumber
, int *portNumber
,
280 AIOConfigurePort (int portHandle
, BYTE bitRate
, BYTE dataBits
, BYTE stopBits
,
281 BYTE parityMode
, BYTE flowCtrlMode
)
289 AIOGetPortConfiguration (int portHandle
, AIOPORTCONFIG
*pPortConfig
,
290 AIODVRCONFIG
*pDvrConfig
)
292 fprintf (stderr
, "AIOGetPortConfiguration stubbed out\n");
297 AIOReleasePort (int portHandle
)
303 AIOSetExternalControl (int portHandle
, int requestType
, int requestValue
)
309 AIOGetExternalStatus (int portHandle
, LONG
*extStatus
, LONG
*chgdExtStatus
)
311 fprintf (stderr
, "AIOGetExternalStatus stubbed out\n");
321 Breakpoint (int __arg
)
323 fprintf (stderr
, "Breakpoint() stubbed out\n");