]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/sparclet-stub.c
2003-04-16 Andrew Cagney <cagney@redhat.com>
[thirdparty/binutils-gdb.git] / gdb / sparclet-stub.c
CommitLineData
f81824a9
AC
1// OBSOLETE /****************************************************************************
2// OBSOLETE
3// OBSOLETE THIS SOFTWARE IS NOT COPYRIGHTED
4// OBSOLETE
5// OBSOLETE HP offers the following for use in the public domain. HP makes no
6// OBSOLETE warranty with regard to the software or it's performance and the
7// OBSOLETE user accepts the software "AS IS" with all faults.
8// OBSOLETE
9// OBSOLETE HP DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED, WITH REGARD
10// OBSOLETE TO THIS SOFTWARE INCLUDING BUT NOT LIMITED TO THE WARRANTIES
11// OBSOLETE OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
12// OBSOLETE
13// OBSOLETE ****************************************************************************/
14// OBSOLETE
15// OBSOLETE /****************************************************************************
16// OBSOLETE * Header: remcom.c,v 1.34 91/03/09 12:29:49 glenne Exp $
17// OBSOLETE *
18// OBSOLETE * Module name: remcom.c $
19// OBSOLETE * Revision: 1.34 $
20// OBSOLETE * Date: 91/03/09 12:29:49 $
21// OBSOLETE * Contributor: Lake Stevens Instrument Division$
22// OBSOLETE *
23// OBSOLETE * Description: low level support for gdb debugger. $
24// OBSOLETE *
25// OBSOLETE * Considerations: only works on target hardware $
26// OBSOLETE *
27// OBSOLETE * Written by: Glenn Engel $
28// OBSOLETE * ModuleState: Experimental $
29// OBSOLETE *
30// OBSOLETE * NOTES: See Below $
31// OBSOLETE *
32// OBSOLETE * Modified for SPARC by Stu Grossman, Cygnus Support.
33// OBSOLETE * Based on sparc-stub.c, it's modified for SPARClite Debug Unit hardware
34// OBSOLETE * breakpoint support to create sparclite-stub.c, by Kung Hsu, Cygnus Support.
35// OBSOLETE *
36// OBSOLETE * This code has been extensively tested on the Fujitsu SPARClite demo board.
37// OBSOLETE *
38// OBSOLETE * To enable debugger support, two things need to happen. One, a
39// OBSOLETE * call to set_debug_traps() is necessary in order to allow any breakpoints
40// OBSOLETE * or error conditions to be properly intercepted and reported to gdb.
41// OBSOLETE * Two, a breakpoint needs to be generated to begin communication. This
42// OBSOLETE * is most easily accomplished by a call to breakpoint(). Breakpoint()
43// OBSOLETE * simulates a breakpoint by executing a trap #1.
44// OBSOLETE *
45// OBSOLETE *************
46// OBSOLETE *
47// OBSOLETE * The following gdb commands are supported:
48// OBSOLETE *
49// OBSOLETE * command function Return value
50// OBSOLETE *
51// OBSOLETE * g return the value of the CPU registers hex data or ENN
52// OBSOLETE * G set the value of the CPU registers OK or ENN
53// OBSOLETE * P set the value of a single CPU register OK or ENN
54// OBSOLETE *
55// OBSOLETE * mAA..AA,LLLL Read LLLL bytes at address AA..AA hex data or ENN
56// OBSOLETE * MAA..AA,LLLL: Write LLLL bytes at address AA.AA OK or ENN
57// OBSOLETE *
58// OBSOLETE * c Resume at current address SNN ( signal NN)
59// OBSOLETE * cAA..AA Continue at address AA..AA SNN
60// OBSOLETE *
61// OBSOLETE * s Step one instruction SNN
62// OBSOLETE * sAA..AA Step one instruction from AA..AA SNN
63// OBSOLETE *
64// OBSOLETE * k kill
65// OBSOLETE *
66// OBSOLETE * ? What was the last sigval ? SNN (signal NN)
67// OBSOLETE *
68// OBSOLETE * All commands and responses are sent with a packet which includes a
69// OBSOLETE * checksum. A packet consists of
70// OBSOLETE *
71// OBSOLETE * $<packet info>#<checksum>.
72// OBSOLETE *
73// OBSOLETE * where
74// OBSOLETE * <packet info> :: <characters representing the command or response>
75// OBSOLETE * <checksum> :: <two hex digits computed as modulo 256 sum of <packetinfo>>
76// OBSOLETE *
77// OBSOLETE * When a packet is received, it is first acknowledged with either '+' or '-'.
78// OBSOLETE * '+' indicates a successful transfer. '-' indicates a failed transfer.
79// OBSOLETE *
80// OBSOLETE * Example:
81// OBSOLETE *
82// OBSOLETE * Host: Reply:
83// OBSOLETE * $m0,10#2a +$00010203040506070809101112131415#42
84// OBSOLETE *
85// OBSOLETE ****************************************************************************/
86// OBSOLETE
87// OBSOLETE #include <string.h>
88// OBSOLETE #include <signal.h>
89// OBSOLETE
90// OBSOLETE /************************************************************************
91// OBSOLETE *
92// OBSOLETE * external low-level support routines
93// OBSOLETE */
94// OBSOLETE
95// OBSOLETE extern void putDebugChar(); /* write a single character */
96// OBSOLETE extern int getDebugChar(); /* read and return a single char */
97// OBSOLETE
98// OBSOLETE /************************************************************************/
99// OBSOLETE /* BUFMAX defines the maximum number of characters in inbound/outbound buffers*/
100// OBSOLETE /* at least NUMREGBYTES*2 are needed for register packets */
101// OBSOLETE #define BUFMAX 2048
102// OBSOLETE
103// OBSOLETE static int initialized = 0; /* !0 means we've been initialized */
104// OBSOLETE static int remote_debug = 0; /* turn on verbose debugging */
105// OBSOLETE
106// OBSOLETE extern void breakinst();
107// OBSOLETE void _cprint();
108// OBSOLETE static void hw_breakpoint();
109// OBSOLETE static void set_mem_fault_trap();
110// OBSOLETE static void get_in_break_mode();
111// OBSOLETE static unsigned char *mem2hex();
112// OBSOLETE
113// OBSOLETE static const char hexchars[]="0123456789abcdef";
114// OBSOLETE
115// OBSOLETE #define NUMREGS 121
116// OBSOLETE
117// OBSOLETE static unsigned long saved_stack_pointer;
118// OBSOLETE
119// OBSOLETE /* Number of bytes of registers. */
120// OBSOLETE #define NUMREGBYTES (NUMREGS * 4)
121// OBSOLETE enum regnames { G0, G1, G2, G3, G4, G5, G6, G7,
122// OBSOLETE O0, O1, O2, O3, O4, O5, SP, O7,
123// OBSOLETE L0, L1, L2, L3, L4, L5, L6, L7,
124// OBSOLETE I0, I1, I2, I3, I4, I5, FP, I7,
125// OBSOLETE
126// OBSOLETE F0, F1, F2, F3, F4, F5, F6, F7,
127// OBSOLETE F8, F9, F10, F11, F12, F13, F14, F15,
128// OBSOLETE F16, F17, F18, F19, F20, F21, F22, F23,
129// OBSOLETE F24, F25, F26, F27, F28, F29, F30, F31,
130// OBSOLETE
131// OBSOLETE Y, PSR, WIM, TBR, PC, NPC, FPSR, CPSR,
132// OBSOLETE CCSR, CCPR, CCCRCR, CCOR, CCOBR, CCIBR, CCIR, UNUSED1,
133// OBSOLETE
134// OBSOLETE ASR1, ASR15, ASR17, ASR18, ASR19, ASR20, ASR21, ASR22,
135// OBSOLETE /* the following not actually implemented */
136// OBSOLETE AWR0, AWR1, AWR2, AWR3, AWR4, AWR5, AWR6, AWR7,
137// OBSOLETE AWR8, AWR9, AWR10, AWR11, AWR12, AWR13, AWR14, AWR15,
138// OBSOLETE AWR16, AWR17, AWR18, AWR19, AWR20, AWR21, AWR22, AWR23,
139// OBSOLETE AWR24, AWR25, AWR26, AWR27, AWR28, AWR29, AWR30, AWR31,
140// OBSOLETE APSR
141// OBSOLETE };
142// OBSOLETE
143// OBSOLETE /*************************** ASSEMBLY CODE MACROS *************************/
144// OBSOLETE /* */
145// OBSOLETE
146// OBSOLETE extern void trap_low();
147// OBSOLETE
148// OBSOLETE asm("
149// OBSOLETE .reserve trapstack, 1000 * 4, \"bss\", 8
150// OBSOLETE
151// OBSOLETE .data
152// OBSOLETE .align 4
153// OBSOLETE
154// OBSOLETE in_trap_handler:
155// OBSOLETE .word 0
156// OBSOLETE
157// OBSOLETE .text
158// OBSOLETE .align 4
159// OBSOLETE
160// OBSOLETE ! This function is called when any SPARC trap (except window overflow or
161// OBSOLETE ! underflow) occurs. It makes sure that the invalid register window is still
162// OBSOLETE ! available before jumping into C code. It will also restore the world if you
163// OBSOLETE ! return from handle_exception.
164// OBSOLETE !
165// OBSOLETE ! On entry, trap_low expects l1 and l2 to contain pc and npc respectivly.
166// OBSOLETE
167// OBSOLETE .globl _trap_low
168// OBSOLETE _trap_low:
169// OBSOLETE mov %psr, %l0
170// OBSOLETE mov %wim, %l3
171// OBSOLETE
172// OBSOLETE srl %l3, %l0, %l4 ! wim >> cwp
173// OBSOLETE and %l4, 0xff, %l4 ! Mask off windows 28, 29
174// OBSOLETE cmp %l4, 1
175// OBSOLETE bne window_fine ! Branch if not in the invalid window
176// OBSOLETE nop
177// OBSOLETE
178// OBSOLETE ! Handle window overflow
179// OBSOLETE
180// OBSOLETE mov %g1, %l4 ! Save g1, we use it to hold the wim
181// OBSOLETE srl %l3, 1, %g1 ! Rotate wim right
182// OBSOLETE and %g1, 0xff, %g1 ! Mask off windows 28, 29
183// OBSOLETE tst %g1
184// OBSOLETE bg good_wim ! Branch if new wim is non-zero
185// OBSOLETE nop
186// OBSOLETE
187// OBSOLETE ! At this point, we need to bring a 1 into the high order bit of the wim.
188// OBSOLETE ! Since we don't want to make any assumptions about the number of register
189// OBSOLETE ! windows, we figure it out dynamically so as to setup the wim correctly.
190// OBSOLETE
191// OBSOLETE ! The normal way doesn't work on the sparclet as register windows
192// OBSOLETE ! 28 and 29 are special purpose windows.
193// OBSOLETE !not %g1 ! Fill g1 with ones
194// OBSOLETE !mov %g1, %wim ! Fill the wim with ones
195// OBSOLETE !nop
196// OBSOLETE !nop
197// OBSOLETE !nop
198// OBSOLETE !mov %wim, %g1 ! Read back the wim
199// OBSOLETE !inc %g1 ! Now g1 has 1 just to left of wim
200// OBSOLETE !srl %g1, 1, %g1 ! Now put 1 at top of wim
201// OBSOLETE
202// OBSOLETE mov 0x80, %g1 ! Hack for sparclet
203// OBSOLETE
204// OBSOLETE ! This doesn't work on the sparclet.
205// OBSOLETE !mov %g0, %wim ! Clear wim so that subsequent save
206// OBSOLETE ! won't trap
207// OBSOLETE andn %l3, 0xff, %l5 ! Clear wim but not windows 28, 29
208// OBSOLETE mov %l5, %wim
209// OBSOLETE nop
210// OBSOLETE nop
211// OBSOLETE nop
212// OBSOLETE
213// OBSOLETE good_wim:
214// OBSOLETE save %g0, %g0, %g0 ! Slip into next window
215// OBSOLETE mov %g1, %wim ! Install the new wim
216// OBSOLETE
217// OBSOLETE std %l0, [%sp + 0 * 4] ! save L & I registers
218// OBSOLETE std %l2, [%sp + 2 * 4]
219// OBSOLETE std %l4, [%sp + 4 * 4]
220// OBSOLETE std %l6, [%sp + 6 * 4]
221// OBSOLETE
222// OBSOLETE std %i0, [%sp + 8 * 4]
223// OBSOLETE std %i2, [%sp + 10 * 4]
224// OBSOLETE std %i4, [%sp + 12 * 4]
225// OBSOLETE std %i6, [%sp + 14 * 4]
226// OBSOLETE
227// OBSOLETE restore ! Go back to trap window.
228// OBSOLETE mov %l4, %g1 ! Restore %g1
229// OBSOLETE
230// OBSOLETE window_fine:
231// OBSOLETE sethi %hi(in_trap_handler), %l4
232// OBSOLETE ld [%lo(in_trap_handler) + %l4], %l5
233// OBSOLETE tst %l5
234// OBSOLETE bg recursive_trap
235// OBSOLETE inc %l5
236// OBSOLETE
237// OBSOLETE set trapstack+1000*4, %sp ! Switch to trap stack
238// OBSOLETE
239// OBSOLETE recursive_trap:
240// OBSOLETE st %l5, [%lo(in_trap_handler) + %l4]
241// OBSOLETE sub %sp,(16+1+6+1+88)*4,%sp ! Make room for input & locals
242// OBSOLETE ! + hidden arg + arg spill
243// OBSOLETE ! + doubleword alignment
244// OBSOLETE ! + registers[121]
245// OBSOLETE
246// OBSOLETE std %g0, [%sp + (24 + 0) * 4] ! registers[Gx]
247// OBSOLETE std %g2, [%sp + (24 + 2) * 4]
248// OBSOLETE std %g4, [%sp + (24 + 4) * 4]
249// OBSOLETE std %g6, [%sp + (24 + 6) * 4]
250// OBSOLETE
251// OBSOLETE std %i0, [%sp + (24 + 8) * 4] ! registers[Ox]
252// OBSOLETE std %i2, [%sp + (24 + 10) * 4]
253// OBSOLETE std %i4, [%sp + (24 + 12) * 4]
254// OBSOLETE std %i6, [%sp + (24 + 14) * 4]
255// OBSOLETE
256// OBSOLETE ! FP regs (sparclet doesn't have fpu)
257// OBSOLETE
258// OBSOLETE mov %y, %l4
259// OBSOLETE mov %tbr, %l5
260// OBSOLETE st %l4, [%sp + (24 + 64) * 4] ! Y
261// OBSOLETE st %l0, [%sp + (24 + 65) * 4] ! PSR
262// OBSOLETE st %l3, [%sp + (24 + 66) * 4] ! WIM
263// OBSOLETE st %l5, [%sp + (24 + 67) * 4] ! TBR
264// OBSOLETE st %l1, [%sp + (24 + 68) * 4] ! PC
265// OBSOLETE st %l2, [%sp + (24 + 69) * 4] ! NPC
266// OBSOLETE ! CPSR and FPSR not impl
267// OBSOLETE or %l0, 0xf20, %l4
268// OBSOLETE mov %l4, %psr ! Turn on traps, disable interrupts
269// OBSOLETE nop
270// OBSOLETE nop
271// OBSOLETE nop
272// OBSOLETE
273// OBSOLETE ! Save coprocessor state.
274// OBSOLETE ! See SK/demo/hdlc_demo/ldc_swap_context.S.
275// OBSOLETE
276// OBSOLETE mov %psr, %l0
277// OBSOLETE sethi %hi(0x2000), %l5 ! EC bit in PSR
278// OBSOLETE or %l5, %l0, %l5
279// OBSOLETE mov %l5, %psr ! enable coprocessor
280// OBSOLETE nop ! 3 nops after write to %psr (needed?)
281// OBSOLETE nop
282// OBSOLETE nop
283// OBSOLETE crdcxt %ccsr, %l1 ! capture CCSR
284// OBSOLETE mov 0x6, %l2
285// OBSOLETE cwrcxt %l2, %ccsr ! set CCP state machine for CCFR
286// OBSOLETE crdcxt %ccfr, %l2 ! capture CCOR
287// OBSOLETE cwrcxt %l2, %ccfr ! tickle CCFR
288// OBSOLETE crdcxt %ccfr, %l3 ! capture CCOBR
289// OBSOLETE cwrcxt %l3, %ccfr ! tickle CCFR
290// OBSOLETE crdcxt %ccfr, %l4 ! capture CCIBR
291// OBSOLETE cwrcxt %l4, %ccfr ! tickle CCFR
292// OBSOLETE crdcxt %ccfr, %l5 ! capture CCIR
293// OBSOLETE cwrcxt %l5, %ccfr ! tickle CCFR
294// OBSOLETE crdcxt %ccpr, %l6 ! capture CCPR
295// OBSOLETE crdcxt %cccrcr, %l7 ! capture CCCRCR
296// OBSOLETE st %l1, [%sp + (24 + 72) * 4] ! save CCSR
297// OBSOLETE st %l2, [%sp + (24 + 75) * 4] ! save CCOR
298// OBSOLETE st %l3, [%sp + (24 + 76) * 4] ! save CCOBR
299// OBSOLETE st %l4, [%sp + (24 + 77) * 4] ! save CCIBR
300// OBSOLETE st %l5, [%sp + (24 + 78) * 4] ! save CCIR
301// OBSOLETE st %l6, [%sp + (24 + 73) * 4] ! save CCPR
302// OBSOLETE st %l7, [%sp + (24 + 74) * 4] ! save CCCRCR
303// OBSOLETE mov %l0, %psr ! restore original PSR
304// OBSOLETE nop ! 3 nops after write to %psr (needed?)
305// OBSOLETE nop
306// OBSOLETE nop
307// OBSOLETE
308// OBSOLETE ! End of saving coprocessor state.
309// OBSOLETE ! Save asr regs
310// OBSOLETE
311// OBSOLETE ! Part of this is silly -- we should not display ASR15 or ASR19 at all.
312// OBSOLETE
313// OBSOLETE sethi %hi(0x01000000), %l6
314// OBSOLETE st %l6, [%sp + (24 + 81) * 4] ! ASR15 == NOP
315// OBSOLETE sethi %hi(0xdeadc0de), %l6
316// OBSOLETE or %l6, %lo(0xdeadc0de), %l6
317// OBSOLETE st %l6, [%sp + (24 + 84) * 4] ! ASR19 == DEADC0DE
318// OBSOLETE
319// OBSOLETE rd %asr1, %l4
320// OBSOLETE st %l4, [%sp + (24 + 80) * 4]
321// OBSOLETE ! rd %asr15, %l4 ! must not read ASR15
322// OBSOLETE ! st %l4, [%sp + (24 + 81) * 4] ! (illegal instr trap)
323// OBSOLETE rd %asr17, %l4
324// OBSOLETE st %l4, [%sp + (24 + 82) * 4]
325// OBSOLETE rd %asr18, %l4
326// OBSOLETE st %l4, [%sp + (24 + 83) * 4]
327// OBSOLETE ! rd %asr19, %l4 ! must not read asr19
328// OBSOLETE ! st %l4, [%sp + (24 + 84) * 4] ! (halts the CPU)
329// OBSOLETE rd %asr20, %l4
330// OBSOLETE st %l4, [%sp + (24 + 85) * 4]
331// OBSOLETE rd %asr21, %l4
332// OBSOLETE st %l4, [%sp + (24 + 86) * 4]
333// OBSOLETE rd %asr22, %l4
334// OBSOLETE st %l4, [%sp + (24 + 87) * 4]
335// OBSOLETE
336// OBSOLETE ! End of saving asr regs
337// OBSOLETE
338// OBSOLETE call _handle_exception
339// OBSOLETE add %sp, 24 * 4, %o0 ! Pass address of registers
340// OBSOLETE
341// OBSOLETE ! Reload all of the registers that aren't on the stack
342// OBSOLETE
343// OBSOLETE ld [%sp + (24 + 1) * 4], %g1 ! registers[Gx]
344// OBSOLETE ldd [%sp + (24 + 2) * 4], %g2
345// OBSOLETE ldd [%sp + (24 + 4) * 4], %g4
346// OBSOLETE ldd [%sp + (24 + 6) * 4], %g6
347// OBSOLETE
348// OBSOLETE ldd [%sp + (24 + 8) * 4], %i0 ! registers[Ox]
349// OBSOLETE ldd [%sp + (24 + 10) * 4], %i2
350// OBSOLETE ldd [%sp + (24 + 12) * 4], %i4
351// OBSOLETE ldd [%sp + (24 + 14) * 4], %i6
352// OBSOLETE
353// OBSOLETE ! FP regs (sparclet doesn't have fpu)
354// OBSOLETE
355// OBSOLETE ! Update the coprocessor registers.
356// OBSOLETE ! See SK/demo/hdlc_demo/ldc_swap_context.S.
357// OBSOLETE
358// OBSOLETE mov %psr, %l0
359// OBSOLETE sethi %hi(0x2000), %l5 ! EC bit in PSR
360// OBSOLETE or %l5, %l0, %l5
361// OBSOLETE mov %l5, %psr ! enable coprocessor
362// OBSOLETE nop ! 3 nops after write to %psr (needed?)
363// OBSOLETE nop
364// OBSOLETE nop
365// OBSOLETE
366// OBSOLETE mov 0x6, %l2
367// OBSOLETE cwrcxt %l2, %ccsr ! set CCP state machine for CCFR
368// OBSOLETE
369// OBSOLETE ld [%sp + (24 + 72) * 4], %l1 ! saved CCSR
370// OBSOLETE ld [%sp + (24 + 75) * 4], %l2 ! saved CCOR
371// OBSOLETE ld [%sp + (24 + 76) * 4], %l3 ! saved CCOBR
372// OBSOLETE ld [%sp + (24 + 77) * 4], %l4 ! saved CCIBR
373// OBSOLETE ld [%sp + (24 + 78) * 4], %l5 ! saved CCIR
374// OBSOLETE ld [%sp + (24 + 73) * 4], %l6 ! saved CCPR
375// OBSOLETE ld [%sp + (24 + 74) * 4], %l7 ! saved CCCRCR
376// OBSOLETE
377// OBSOLETE cwrcxt %l2, %ccfr ! restore CCOR
378// OBSOLETE cwrcxt %l3, %ccfr ! restore CCOBR
379// OBSOLETE cwrcxt %l4, %ccfr ! restore CCIBR
380// OBSOLETE cwrcxt %l5, %ccfr ! restore CCIR
381// OBSOLETE cwrcxt %l6, %ccpr ! restore CCPR
382// OBSOLETE cwrcxt %l7, %cccrcr ! restore CCCRCR
383// OBSOLETE cwrcxt %l1, %ccsr ! restore CCSR
384// OBSOLETE
385// OBSOLETE mov %l0, %psr ! restore PSR
386// OBSOLETE nop ! 3 nops after write to %psr (needed?)
387// OBSOLETE nop
388// OBSOLETE nop
389// OBSOLETE
390// OBSOLETE ! End of coprocessor handling stuff.
391// OBSOLETE ! Update asr regs
392// OBSOLETE
393// OBSOLETE ld [%sp + (24 + 80) * 4], %l4
394// OBSOLETE wr %l4, %asr1
395// OBSOLETE ! ld [%sp + (24 + 81) * 4], %l4 ! can't write asr15
396// OBSOLETE ! wr %l4, %asr15
397// OBSOLETE ld [%sp + (24 + 82) * 4], %l4
398// OBSOLETE wr %l4, %asr17
399// OBSOLETE ld [%sp + (24 + 83) * 4], %l4
400// OBSOLETE wr %l4, %asr18
401// OBSOLETE ! ld [%sp + (24 + 84) * 4], %l4 ! can't write asr19
402// OBSOLETE ! wr %l4, %asr19
403// OBSOLETE ! ld [%sp + (24 + 85) * 4], %l4 ! can't write asr20
404// OBSOLETE ! wr %l4, %asr20
405// OBSOLETE ! ld [%sp + (24 + 86) * 4], %l4 ! can't write asr21
406// OBSOLETE ! wr %l4, %asr21
407// OBSOLETE ld [%sp + (24 + 87) * 4], %l4
408// OBSOLETE wr %l4, %asr22
409// OBSOLETE
410// OBSOLETE ! End of restoring asr regs
411// OBSOLETE
412// OBSOLETE
413// OBSOLETE ldd [%sp + (24 + 64) * 4], %l0 ! Y & PSR
414// OBSOLETE ldd [%sp + (24 + 68) * 4], %l2 ! PC & NPC
415// OBSOLETE
416// OBSOLETE restore ! Ensure that previous window is valid
417// OBSOLETE save %g0, %g0, %g0 ! by causing a window_underflow trap
418// OBSOLETE
419// OBSOLETE mov %l0, %y
420// OBSOLETE mov %l1, %psr ! Make sure that traps are disabled
421// OBSOLETE ! for rett
422// OBSOLETE nop ! 3 nops after write to %psr (needed?)
423// OBSOLETE nop
424// OBSOLETE nop
425// OBSOLETE
426// OBSOLETE sethi %hi(in_trap_handler), %l4
427// OBSOLETE ld [%lo(in_trap_handler) + %l4], %l5
428// OBSOLETE dec %l5
429// OBSOLETE st %l5, [%lo(in_trap_handler) + %l4]
430// OBSOLETE
431// OBSOLETE jmpl %l2, %g0 ! Restore old PC
432// OBSOLETE rett %l3 ! Restore old nPC
433// OBSOLETE ");
434// OBSOLETE
435// OBSOLETE /* Convert ch from a hex digit to an int */
436// OBSOLETE
437// OBSOLETE static int
438// OBSOLETE hex (unsigned char ch)
439// OBSOLETE {
440// OBSOLETE if (ch >= 'a' && ch <= 'f')
441// OBSOLETE return ch-'a'+10;
442// OBSOLETE if (ch >= '0' && ch <= '9')
443// OBSOLETE return ch-'0';
444// OBSOLETE if (ch >= 'A' && ch <= 'F')
445// OBSOLETE return ch-'A'+10;
446// OBSOLETE return -1;
447// OBSOLETE }
448// OBSOLETE
449// OBSOLETE static char remcomInBuffer[BUFMAX];
450// OBSOLETE static char remcomOutBuffer[BUFMAX];
451// OBSOLETE
452// OBSOLETE /* scan for the sequence $<data>#<checksum> */
453// OBSOLETE
454// OBSOLETE unsigned char *
455// OBSOLETE getpacket (void)
456// OBSOLETE {
457// OBSOLETE unsigned char *buffer = &remcomInBuffer[0];
458// OBSOLETE unsigned char checksum;
459// OBSOLETE unsigned char xmitcsum;
460// OBSOLETE int count;
461// OBSOLETE char ch;
462// OBSOLETE
463// OBSOLETE while (1)
464// OBSOLETE {
465// OBSOLETE /* wait around for the start character, ignore all other characters */
466// OBSOLETE while ((ch = getDebugChar ()) != '$')
467// OBSOLETE ;
468// OBSOLETE
469// OBSOLETE retry:
470// OBSOLETE checksum = 0;
471// OBSOLETE xmitcsum = -1;
472// OBSOLETE count = 0;
473// OBSOLETE
474// OBSOLETE /* now, read until a # or end of buffer is found */
475// OBSOLETE while (count < BUFMAX)
476// OBSOLETE {
477// OBSOLETE ch = getDebugChar ();
478// OBSOLETE if (ch == '$')
479// OBSOLETE goto retry;
480// OBSOLETE if (ch == '#')
481// OBSOLETE break;
482// OBSOLETE checksum = checksum + ch;
483// OBSOLETE buffer[count] = ch;
484// OBSOLETE count = count + 1;
485// OBSOLETE }
486// OBSOLETE buffer[count] = 0;
487// OBSOLETE
488// OBSOLETE if (ch == '#')
489// OBSOLETE {
490// OBSOLETE ch = getDebugChar ();
491// OBSOLETE xmitcsum = hex (ch) << 4;
492// OBSOLETE ch = getDebugChar ();
493// OBSOLETE xmitcsum += hex (ch);
494// OBSOLETE
495// OBSOLETE if (checksum != xmitcsum)
496// OBSOLETE {
497// OBSOLETE putDebugChar ('-'); /* failed checksum */
498// OBSOLETE }
499// OBSOLETE else
500// OBSOLETE {
501// OBSOLETE putDebugChar ('+'); /* successful transfer */
502// OBSOLETE
503// OBSOLETE /* if a sequence char is present, reply the sequence ID */
504// OBSOLETE if (buffer[2] == ':')
505// OBSOLETE {
506// OBSOLETE putDebugChar (buffer[0]);
507// OBSOLETE putDebugChar (buffer[1]);
508// OBSOLETE
509// OBSOLETE return &buffer[3];
510// OBSOLETE }
511// OBSOLETE
512// OBSOLETE return &buffer[0];
513// OBSOLETE }
514// OBSOLETE }
515// OBSOLETE }
516// OBSOLETE }
517// OBSOLETE
518// OBSOLETE /* send the packet in buffer. */
519// OBSOLETE
520// OBSOLETE static void
521// OBSOLETE putpacket (unsigned char *buffer)
522// OBSOLETE {
523// OBSOLETE unsigned char checksum;
524// OBSOLETE int count;
525// OBSOLETE unsigned char ch;
526// OBSOLETE
527// OBSOLETE /* $<packet info>#<checksum>. */
528// OBSOLETE do
529// OBSOLETE {
530// OBSOLETE putDebugChar('$');
531// OBSOLETE checksum = 0;
532// OBSOLETE count = 0;
533// OBSOLETE
534// OBSOLETE while (ch = buffer[count])
535// OBSOLETE {
536// OBSOLETE putDebugChar(ch);
537// OBSOLETE checksum += ch;
538// OBSOLETE count += 1;
539// OBSOLETE }
540// OBSOLETE
541// OBSOLETE putDebugChar('#');
542// OBSOLETE putDebugChar(hexchars[checksum >> 4]);
543// OBSOLETE putDebugChar(hexchars[checksum & 0xf]);
544// OBSOLETE
545// OBSOLETE }
546// OBSOLETE while (getDebugChar() != '+');
547// OBSOLETE }
548// OBSOLETE
549// OBSOLETE /* Indicate to caller of mem2hex or hex2mem that there has been an
550// OBSOLETE error. */
551// OBSOLETE static volatile int mem_err = 0;
552// OBSOLETE
553// OBSOLETE /* Convert the memory pointed to by mem into hex, placing result in buf.
554// OBSOLETE * Return a pointer to the last char put in buf (null), in case of mem fault,
555// OBSOLETE * return 0.
556// OBSOLETE * If MAY_FAULT is non-zero, then we will handle memory faults by returning
557// OBSOLETE * a 0, else treat a fault like any other fault in the stub.
558// OBSOLETE */
559// OBSOLETE
560// OBSOLETE static unsigned char *
561// OBSOLETE mem2hex (unsigned char *mem, unsigned char *buf, int count, int may_fault)
562// OBSOLETE {
563// OBSOLETE unsigned char ch;
564// OBSOLETE
565// OBSOLETE set_mem_fault_trap(may_fault);
566// OBSOLETE
567// OBSOLETE while (count-- > 0)
568// OBSOLETE {
569// OBSOLETE ch = *mem++;
570// OBSOLETE if (mem_err)
571// OBSOLETE return 0;
572// OBSOLETE *buf++ = hexchars[ch >> 4];
573// OBSOLETE *buf++ = hexchars[ch & 0xf];
574// OBSOLETE }
575// OBSOLETE
576// OBSOLETE *buf = 0;
577// OBSOLETE
578// OBSOLETE set_mem_fault_trap(0);
579// OBSOLETE
580// OBSOLETE return buf;
581// OBSOLETE }
582// OBSOLETE
583// OBSOLETE /* convert the hex array pointed to by buf into binary to be placed in mem
584// OBSOLETE * return a pointer to the character AFTER the last byte written */
585// OBSOLETE
586// OBSOLETE static char *
587// OBSOLETE hex2mem (unsigned char *buf, unsigned char *mem, int count, int may_fault)
588// OBSOLETE {
589// OBSOLETE int i;
590// OBSOLETE unsigned char ch;
591// OBSOLETE
592// OBSOLETE set_mem_fault_trap(may_fault);
593// OBSOLETE
594// OBSOLETE for (i=0; i<count; i++)
595// OBSOLETE {
596// OBSOLETE ch = hex(*buf++) << 4;
597// OBSOLETE ch |= hex(*buf++);
598// OBSOLETE *mem++ = ch;
599// OBSOLETE if (mem_err)
600// OBSOLETE return 0;
601// OBSOLETE }
602// OBSOLETE
603// OBSOLETE set_mem_fault_trap(0);
604// OBSOLETE
605// OBSOLETE return mem;
606// OBSOLETE }
607// OBSOLETE
608// OBSOLETE /* This table contains the mapping between SPARC hardware trap types, and
609// OBSOLETE signals, which are primarily what GDB understands. It also indicates
610// OBSOLETE which hardware traps we need to commandeer when initializing the stub. */
611// OBSOLETE
612// OBSOLETE static struct hard_trap_info
613// OBSOLETE {
614// OBSOLETE unsigned char tt; /* Trap type code for SPARClite */
615// OBSOLETE unsigned char signo; /* Signal that we map this trap into */
616// OBSOLETE } hard_trap_info[] = {
617// OBSOLETE {1, SIGSEGV}, /* instruction access exception */
618// OBSOLETE {0x3b, SIGSEGV}, /* instruction access error */
619// OBSOLETE {2, SIGILL}, /* illegal instruction */
620// OBSOLETE {3, SIGILL}, /* privileged instruction */
621// OBSOLETE {4, SIGEMT}, /* fp disabled */
622// OBSOLETE {0x24, SIGEMT}, /* cp disabled */
623// OBSOLETE {7, SIGBUS}, /* mem address not aligned */
624// OBSOLETE {0x29, SIGSEGV}, /* data access exception */
625// OBSOLETE {10, SIGEMT}, /* tag overflow */
626// OBSOLETE {128+1, SIGTRAP}, /* ta 1 - normal breakpoint instruction */
627// OBSOLETE {0, 0} /* Must be last */
628// OBSOLETE };
629// OBSOLETE
630// OBSOLETE /* Set up exception handlers for tracing and breakpoints */
631// OBSOLETE
632// OBSOLETE void
633// OBSOLETE set_debug_traps (void)
634// OBSOLETE {
635// OBSOLETE struct hard_trap_info *ht;
636// OBSOLETE
637// OBSOLETE for (ht = hard_trap_info; ht->tt && ht->signo; ht++)
638// OBSOLETE exceptionHandler(ht->tt, trap_low);
639// OBSOLETE
640// OBSOLETE initialized = 1;
641// OBSOLETE }
642// OBSOLETE
643// OBSOLETE asm ("
644// OBSOLETE ! Trap handler for memory errors. This just sets mem_err to be non-zero. It
645// OBSOLETE ! assumes that %l1 is non-zero. This should be safe, as it is doubtful that
646// OBSOLETE ! 0 would ever contain code that could mem fault. This routine will skip
647// OBSOLETE ! past the faulting instruction after setting mem_err.
648// OBSOLETE
649// OBSOLETE .text
650// OBSOLETE .align 4
651// OBSOLETE
652// OBSOLETE _fltr_set_mem_err:
653// OBSOLETE sethi %hi(_mem_err), %l0
654// OBSOLETE st %l1, [%l0 + %lo(_mem_err)]
655// OBSOLETE jmpl %l2, %g0
656// OBSOLETE rett %l2+4
657// OBSOLETE ");
658// OBSOLETE
659// OBSOLETE static void
660// OBSOLETE set_mem_fault_trap (int enable)
661// OBSOLETE {
662// OBSOLETE extern void fltr_set_mem_err();
663// OBSOLETE mem_err = 0;
664// OBSOLETE
665// OBSOLETE if (enable)
666// OBSOLETE exceptionHandler(0x29, fltr_set_mem_err);
667// OBSOLETE else
668// OBSOLETE exceptionHandler(0x29, trap_low);
669// OBSOLETE }
670// OBSOLETE
671// OBSOLETE asm ("
672// OBSOLETE .text
673// OBSOLETE .align 4
674// OBSOLETE
675// OBSOLETE _dummy_hw_breakpoint:
676// OBSOLETE jmpl %l2, %g0
677// OBSOLETE rett %l2+4
678// OBSOLETE nop
679// OBSOLETE nop
680// OBSOLETE ");
681// OBSOLETE
682// OBSOLETE static void
683// OBSOLETE set_hw_breakpoint_trap (int enable)
684// OBSOLETE {
685// OBSOLETE extern void dummy_hw_breakpoint();
686// OBSOLETE
687// OBSOLETE if (enable)
688// OBSOLETE exceptionHandler(255, dummy_hw_breakpoint);
689// OBSOLETE else
690// OBSOLETE exceptionHandler(255, trap_low);
691// OBSOLETE }
692// OBSOLETE
693// OBSOLETE static void
694// OBSOLETE get_in_break_mode (void)
695// OBSOLETE {
696// OBSOLETE #if 0
697// OBSOLETE int x;
698// OBSOLETE mesg("get_in_break_mode, sp = ");
699// OBSOLETE phex(&x);
700// OBSOLETE #endif
701// OBSOLETE set_hw_breakpoint_trap(1);
702// OBSOLETE
703// OBSOLETE asm("
704// OBSOLETE sethi %hi(0xff10), %l4
705// OBSOLETE or %l4, %lo(0xff10), %l4
706// OBSOLETE sta %g0, [%l4]0x1
707// OBSOLETE nop
708// OBSOLETE nop
709// OBSOLETE nop
710// OBSOLETE ");
711// OBSOLETE
712// OBSOLETE set_hw_breakpoint_trap(0);
713// OBSOLETE }
714// OBSOLETE
715// OBSOLETE /* Convert the SPARC hardware trap type code to a unix signal number. */
716// OBSOLETE
717// OBSOLETE static int
718// OBSOLETE computeSignal (int tt)
719// OBSOLETE {
720// OBSOLETE struct hard_trap_info *ht;
721// OBSOLETE
722// OBSOLETE for (ht = hard_trap_info; ht->tt && ht->signo; ht++)
723// OBSOLETE if (ht->tt == tt)
724// OBSOLETE return ht->signo;
725// OBSOLETE
726// OBSOLETE return SIGHUP; /* default for things we don't know about */
727// OBSOLETE }
728// OBSOLETE
729// OBSOLETE /*
730// OBSOLETE * While we find nice hex chars, build an int.
731// OBSOLETE * Return number of chars processed.
732// OBSOLETE */
733// OBSOLETE
734// OBSOLETE static int
735// OBSOLETE hexToInt(char **ptr, int *intValue)
736// OBSOLETE {
737// OBSOLETE int numChars = 0;
738// OBSOLETE int hexValue;
739// OBSOLETE
740// OBSOLETE *intValue = 0;
741// OBSOLETE
742// OBSOLETE while (**ptr)
743// OBSOLETE {
744// OBSOLETE hexValue = hex(**ptr);
745// OBSOLETE if (hexValue < 0)
746// OBSOLETE break;
747// OBSOLETE
748// OBSOLETE *intValue = (*intValue << 4) | hexValue;
749// OBSOLETE numChars ++;
750// OBSOLETE
751// OBSOLETE (*ptr)++;
752// OBSOLETE }
753// OBSOLETE
754// OBSOLETE return (numChars);
755// OBSOLETE }
756// OBSOLETE
757// OBSOLETE /*
758// OBSOLETE * This function does all command procesing for interfacing to gdb. It
759// OBSOLETE * returns 1 if you should skip the instruction at the trap address, 0
760// OBSOLETE * otherwise.
761// OBSOLETE */
762// OBSOLETE
763// OBSOLETE static void
764// OBSOLETE handle_exception (unsigned long *registers)
765// OBSOLETE {
766// OBSOLETE int tt; /* Trap type */
767// OBSOLETE int sigval;
768// OBSOLETE int addr;
769// OBSOLETE int length;
770// OBSOLETE char *ptr;
771// OBSOLETE unsigned long *sp;
772// OBSOLETE unsigned long dsr;
773// OBSOLETE
774// OBSOLETE /* First, we must force all of the windows to be spilled out */
775// OBSOLETE
776// OBSOLETE asm("
777// OBSOLETE ! Ugh. sparclet has broken save
778// OBSOLETE !save %sp, -64, %sp
779// OBSOLETE save
780// OBSOLETE add %fp,-64,%sp
781// OBSOLETE !save %sp, -64, %sp
782// OBSOLETE save
783// OBSOLETE add %fp,-64,%sp
784// OBSOLETE !save %sp, -64, %sp
785// OBSOLETE save
786// OBSOLETE add %fp,-64,%sp
787// OBSOLETE !save %sp, -64, %sp
788// OBSOLETE save
789// OBSOLETE add %fp,-64,%sp
790// OBSOLETE !save %sp, -64, %sp
791// OBSOLETE save
792// OBSOLETE add %fp,-64,%sp
793// OBSOLETE !save %sp, -64, %sp
794// OBSOLETE save
795// OBSOLETE add %fp,-64,%sp
796// OBSOLETE !save %sp, -64, %sp
797// OBSOLETE save
798// OBSOLETE add %fp,-64,%sp
799// OBSOLETE !save %sp, -64, %sp
800// OBSOLETE save
801// OBSOLETE add %fp,-64,%sp
802// OBSOLETE restore
803// OBSOLETE restore
804// OBSOLETE restore
805// OBSOLETE restore
806// OBSOLETE restore
807// OBSOLETE restore
808// OBSOLETE restore
809// OBSOLETE restore
810// OBSOLETE ");
811// OBSOLETE
812// OBSOLETE if (registers[PC] == (unsigned long)breakinst)
813// OBSOLETE {
814// OBSOLETE registers[PC] = registers[NPC];
815// OBSOLETE registers[NPC] += 4;
816// OBSOLETE }
817// OBSOLETE sp = (unsigned long *)registers[SP];
818// OBSOLETE
819// OBSOLETE tt = (registers[TBR] >> 4) & 0xff;
820// OBSOLETE
821// OBSOLETE /* reply to host that an exception has occurred */
822// OBSOLETE sigval = computeSignal(tt);
823// OBSOLETE ptr = remcomOutBuffer;
824// OBSOLETE
825// OBSOLETE *ptr++ = 'T';
826// OBSOLETE *ptr++ = hexchars[sigval >> 4];
827// OBSOLETE *ptr++ = hexchars[sigval & 0xf];
828// OBSOLETE
829// OBSOLETE *ptr++ = hexchars[PC >> 4];
830// OBSOLETE *ptr++ = hexchars[PC & 0xf];
831// OBSOLETE *ptr++ = ':';
832// OBSOLETE ptr = mem2hex((char *)&registers[PC], ptr, 4, 0);
833// OBSOLETE *ptr++ = ';';
834// OBSOLETE
835// OBSOLETE *ptr++ = hexchars[FP >> 4];
836// OBSOLETE *ptr++ = hexchars[FP & 0xf];
837// OBSOLETE *ptr++ = ':';
838// OBSOLETE ptr = mem2hex(sp + 8 + 6, ptr, 4, 0); /* FP */
839// OBSOLETE *ptr++ = ';';
840// OBSOLETE
841// OBSOLETE *ptr++ = hexchars[SP >> 4];
842// OBSOLETE *ptr++ = hexchars[SP & 0xf];
843// OBSOLETE *ptr++ = ':';
844// OBSOLETE ptr = mem2hex((char *)&sp, ptr, 4, 0);
845// OBSOLETE *ptr++ = ';';
846// OBSOLETE
847// OBSOLETE *ptr++ = hexchars[NPC >> 4];
848// OBSOLETE *ptr++ = hexchars[NPC & 0xf];
849// OBSOLETE *ptr++ = ':';
850// OBSOLETE ptr = mem2hex((char *)&registers[NPC], ptr, 4, 0);
851// OBSOLETE *ptr++ = ';';
852// OBSOLETE
853// OBSOLETE *ptr++ = hexchars[O7 >> 4];
854// OBSOLETE *ptr++ = hexchars[O7 & 0xf];
855// OBSOLETE *ptr++ = ':';
856// OBSOLETE ptr = mem2hex((char *)&registers[O7], ptr, 4, 0);
857// OBSOLETE *ptr++ = ';';
858// OBSOLETE
859// OBSOLETE *ptr++ = 0;
860// OBSOLETE
861// OBSOLETE putpacket(remcomOutBuffer);
862// OBSOLETE
863// OBSOLETE while (1)
864// OBSOLETE {
865// OBSOLETE remcomOutBuffer[0] = 0;
866// OBSOLETE
867// OBSOLETE ptr = getpacket();
868// OBSOLETE switch (*ptr++)
869// OBSOLETE {
870// OBSOLETE case '?':
871// OBSOLETE remcomOutBuffer[0] = 'S';
872// OBSOLETE remcomOutBuffer[1] = hexchars[sigval >> 4];
873// OBSOLETE remcomOutBuffer[2] = hexchars[sigval & 0xf];
874// OBSOLETE remcomOutBuffer[3] = 0;
875// OBSOLETE break;
876// OBSOLETE
877// OBSOLETE case 'd':
878// OBSOLETE remote_debug = !(remote_debug); /* toggle debug flag */
879// OBSOLETE break;
880// OBSOLETE
881// OBSOLETE case 'g': /* return the value of the CPU registers */
882// OBSOLETE {
883// OBSOLETE ptr = remcomOutBuffer;
884// OBSOLETE ptr = mem2hex((char *)registers, ptr, 16 * 4, 0); /* G & O regs */
885// OBSOLETE ptr = mem2hex(sp + 0, ptr, 16 * 4, 0); /* L & I regs */
886// OBSOLETE memset(ptr, '0', 32 * 8); /* Floating point */
887// OBSOLETE ptr = mem2hex((char *)&registers[Y],
888// OBSOLETE ptr + 32 * 4 * 2,
889// OBSOLETE 8 * 4,
890// OBSOLETE 0); /* Y, PSR, WIM, TBR, PC, NPC, FPSR, CPSR */
891// OBSOLETE ptr = mem2hex((char *)&registers[CCSR],
892// OBSOLETE ptr,
893// OBSOLETE 8 * 4,
894// OBSOLETE 0); /* CCSR, CCPR, CCCRCR, CCOR, CCOBR, CCIBR, CCIR */
895// OBSOLETE ptr = mem2hex((char *)&registers[ASR1],
896// OBSOLETE ptr,
897// OBSOLETE 8 * 4,
898// OBSOLETE 0); /* ASR1,ASR15,ASR17,ASR18,ASR19,ASR20,ASR21,ASR22 */
899// OBSOLETE #if 0 /* not implemented */
900// OBSOLETE ptr = mem2hex((char *) &registers[AWR0],
901// OBSOLETE ptr,
902// OBSOLETE 32 * 4,
903// OBSOLETE 0); /* Alternate Window Registers */
904// OBSOLETE #endif
905// OBSOLETE }
906// OBSOLETE break;
907// OBSOLETE
908// OBSOLETE case 'G': /* set value of all the CPU registers - return OK */
909// OBSOLETE case 'P': /* set value of one CPU register - return OK */
910// OBSOLETE {
911// OBSOLETE unsigned long *newsp, psr;
912// OBSOLETE
913// OBSOLETE psr = registers[PSR];
914// OBSOLETE
915// OBSOLETE if (ptr[-1] == 'P') /* do a single register */
916// OBSOLETE {
917// OBSOLETE int regno;
918// OBSOLETE
919// OBSOLETE if (hexToInt (&ptr, &regno)
920// OBSOLETE && *ptr++ == '=')
921// OBSOLETE if (regno >= L0 && regno <= I7)
922// OBSOLETE hex2mem (ptr, sp + regno - L0, 4, 0);
923// OBSOLETE else
924// OBSOLETE hex2mem (ptr, (char *)&registers[regno], 4, 0);
925// OBSOLETE else
926// OBSOLETE {
927// OBSOLETE strcpy (remcomOutBuffer, "E01");
928// OBSOLETE break;
929// OBSOLETE }
930// OBSOLETE }
931// OBSOLETE else
932// OBSOLETE {
933// OBSOLETE hex2mem(ptr, (char *)registers, 16 * 4, 0); /* G & O regs */
934// OBSOLETE hex2mem(ptr + 16 * 4 * 2, sp + 0, 16 * 4, 0); /* L & I regs */
935// OBSOLETE hex2mem(ptr + 64 * 4 * 2, (char *)&registers[Y],
936// OBSOLETE 8 * 4, 0); /* Y,PSR,WIM,TBR,PC,NPC,FPSR,CPSR */
937// OBSOLETE hex2mem(ptr + 72 * 4 * 2, (char *)&registers[CCSR],
938// OBSOLETE 8 * 4, 0); /* CCSR,CCPR,CCCRCR,CCOR,CCOBR,CCIBR,CCIR */
939// OBSOLETE hex2mem(ptr + 80 * 4 * 2, (char *)&registers[ASR1],
940// OBSOLETE 8 * 4, 0); /* ASR1 ... ASR22 */
941// OBSOLETE #if 0 /* not implemented */
942// OBSOLETE hex2mem(ptr + 88 * 4 * 2, (char *)&registers[AWR0],
943// OBSOLETE 8 * 4, 0); /* Alternate Window Registers */
944// OBSOLETE #endif
945// OBSOLETE }
946// OBSOLETE /* See if the stack pointer has moved. If so, then copy the saved
947// OBSOLETE locals and ins to the new location. This keeps the window
948// OBSOLETE overflow and underflow routines happy. */
949// OBSOLETE
950// OBSOLETE newsp = (unsigned long *)registers[SP];
951// OBSOLETE if (sp != newsp)
952// OBSOLETE sp = memcpy(newsp, sp, 16 * 4);
953// OBSOLETE
954// OBSOLETE /* Don't allow CWP to be modified. */
955// OBSOLETE
956// OBSOLETE if (psr != registers[PSR])
957// OBSOLETE registers[PSR] = (psr & 0x1f) | (registers[PSR] & ~0x1f);
958// OBSOLETE
959// OBSOLETE strcpy(remcomOutBuffer,"OK");
960// OBSOLETE }
961// OBSOLETE break;
962// OBSOLETE
963// OBSOLETE case 'm': /* mAA..AA,LLLL Read LLLL bytes at address AA..AA */
964// OBSOLETE /* Try to read %x,%x. */
965// OBSOLETE
966// OBSOLETE if (hexToInt(&ptr, &addr)
967// OBSOLETE && *ptr++ == ','
968// OBSOLETE && hexToInt(&ptr, &length))
969// OBSOLETE {
970// OBSOLETE if (mem2hex((char *)addr, remcomOutBuffer, length, 1))
971// OBSOLETE break;
972// OBSOLETE
973// OBSOLETE strcpy (remcomOutBuffer, "E03");
974// OBSOLETE }
975// OBSOLETE else
976// OBSOLETE strcpy(remcomOutBuffer,"E01");
977// OBSOLETE break;
978// OBSOLETE
979// OBSOLETE case 'M': /* MAA..AA,LLLL: Write LLLL bytes at address AA.AA return OK */
980// OBSOLETE /* Try to read '%x,%x:'. */
981// OBSOLETE
982// OBSOLETE if (hexToInt(&ptr, &addr)
983// OBSOLETE && *ptr++ == ','
984// OBSOLETE && hexToInt(&ptr, &length)
985// OBSOLETE && *ptr++ == ':')
986// OBSOLETE {
987// OBSOLETE if (hex2mem(ptr, (char *)addr, length, 1))
988// OBSOLETE strcpy(remcomOutBuffer, "OK");
989// OBSOLETE else
990// OBSOLETE strcpy(remcomOutBuffer, "E03");
991// OBSOLETE }
992// OBSOLETE else
993// OBSOLETE strcpy(remcomOutBuffer, "E02");
994// OBSOLETE break;
995// OBSOLETE
996// OBSOLETE case 'c': /* cAA..AA Continue at address AA..AA(optional) */
997// OBSOLETE /* try to read optional parameter, pc unchanged if no parm */
998// OBSOLETE
999// OBSOLETE if (hexToInt(&ptr, &addr))
1000// OBSOLETE {
1001// OBSOLETE registers[PC] = addr;
1002// OBSOLETE registers[NPC] = addr + 4;
1003// OBSOLETE }
1004// OBSOLETE
1005// OBSOLETE /* Need to flush the instruction cache here, as we may have deposited a
1006// OBSOLETE breakpoint, and the icache probably has no way of knowing that a data ref to
1007// OBSOLETE some location may have changed something that is in the instruction cache.
1008// OBSOLETE */
1009// OBSOLETE
1010// OBSOLETE flush_i_cache();
1011// OBSOLETE return;
1012// OBSOLETE
1013// OBSOLETE /* kill the program */
1014// OBSOLETE case 'k' : /* do nothing */
1015// OBSOLETE break;
1016// OBSOLETE #if 0
1017// OBSOLETE case 't': /* Test feature */
1018// OBSOLETE asm (" std %f30,[%sp]");
1019// OBSOLETE break;
1020// OBSOLETE #endif
1021// OBSOLETE case 'r': /* Reset */
1022// OBSOLETE asm ("call 0
1023// OBSOLETE nop ");
1024// OBSOLETE break;
1025// OBSOLETE } /* switch */
1026// OBSOLETE
1027// OBSOLETE /* reply to the request */
1028// OBSOLETE putpacket(remcomOutBuffer);
1029// OBSOLETE }
1030// OBSOLETE }
1031// OBSOLETE
1032// OBSOLETE /* This function will generate a breakpoint exception. It is used at the
1033// OBSOLETE beginning of a program to sync up with a debugger and can be used
1034// OBSOLETE otherwise as a quick means to stop program execution and "break" into
1035// OBSOLETE the debugger. */
1036// OBSOLETE
1037// OBSOLETE void
1038// OBSOLETE breakpoint (void)
1039// OBSOLETE {
1040// OBSOLETE if (!initialized)
1041// OBSOLETE return;
1042// OBSOLETE
1043// OBSOLETE asm(" .globl _breakinst
1044// OBSOLETE
1045// OBSOLETE _breakinst: ta 1
1046// OBSOLETE ");
1047// OBSOLETE }
1048// OBSOLETE
1049// OBSOLETE static void
1050// OBSOLETE hw_breakpoint (void)
1051// OBSOLETE {
1052// OBSOLETE asm("
1053// OBSOLETE ta 127
1054// OBSOLETE ");
1055// OBSOLETE }
1056// OBSOLETE
1057// OBSOLETE #if 0 /* experimental and never finished, left here for reference */
1058// OBSOLETE static void
1059// OBSOLETE splet_temp(void)
1060// OBSOLETE {
1061// OBSOLETE asm(" sub %sp,(16+1+6+1+121)*4,%sp ! Make room for input & locals
1062// OBSOLETE ! + hidden arg + arg spill
1063// OBSOLETE ! + doubleword alignment
1064// OBSOLETE ! + registers[121]
1065// OBSOLETE
1066// OBSOLETE ! Leave a trail of breadcrumbs! (save register save area for debugging)
1067// OBSOLETE mov %sp, %l0
1068// OBSOLETE add %l0, 24*4, %l0
1069// OBSOLETE sethi %hi(_debug_registers), %l1
1070// OBSOLETE st %l0, [%lo(_debug_registers) + %l1]
1071// OBSOLETE
1072// OBSOLETE ! Save the Alternate Register Set: (not implemented yet)
1073// OBSOLETE ! To save the Alternate Register set, we must:
1074// OBSOLETE ! 1) Save the current SP in some global location.
1075// OBSOLETE ! 2) Swap the register sets.
1076// OBSOLETE ! 3) Save the Alternate SP in the Y register
1077// OBSOLETE ! 4) Fetch the SP that we saved in step 1.
1078// OBSOLETE ! 5) Use that to save the rest of the regs (not forgetting ASP in Y)
1079// OBSOLETE ! 6) Restore the Alternate SP from Y
1080// OBSOLETE ! 7) Swap the registers back.
1081// OBSOLETE
1082// OBSOLETE ! 1) Copy the current stack pointer to global _SAVED_STACK_POINTER:
1083// OBSOLETE sethi %hi(_saved_stack_pointer), %l0
1084// OBSOLETE st %sp, [%lo(_saved_stack_pointer) + %l0]
1085// OBSOLETE
1086// OBSOLETE ! 2) Swap the register sets:
1087// OBSOLETE mov %psr, %l1
1088// OBSOLETE sethi %hi(0x10000), %l2
1089// OBSOLETE xor %l1, %l2, %l1
1090// OBSOLETE mov %l1, %psr
1091// OBSOLETE nop ! 3 nops after write to %psr (needed?)
1092// OBSOLETE nop
1093// OBSOLETE nop
1094// OBSOLETE
1095// OBSOLETE ! 3) Save Alternate L0 in Y
1096// OBSOLETE wr %l0, 0, %y
1097// OBSOLETE
1098// OBSOLETE ! 4) Load former SP into alternate SP, using L0
1099// OBSOLETE sethi %hi(_saved_stack_pointer), %l0
1100// OBSOLETE or %lo(_saved_stack_pointer), %l0, %l0
1101// OBSOLETE swap [%l0], %sp
1102// OBSOLETE
1103// OBSOLETE ! 4.5) Restore alternate L0
1104// OBSOLETE rd %y, %l0
1105// OBSOLETE
1106// OBSOLETE ! 5) Save the Alternate Window Registers
1107// OBSOLETE st %r0, [%sp + (24 + 88) * 4] ! AWR0
1108// OBSOLETE st %r1, [%sp + (24 + 89) * 4] ! AWR1
1109// OBSOLETE st %r2, [%sp + (24 + 90) * 4] ! AWR2
1110// OBSOLETE st %r3, [%sp + (24 + 91) * 4] ! AWR3
1111// OBSOLETE st %r4, [%sp + (24 + 92) * 4] ! AWR4
1112// OBSOLETE st %r5, [%sp + (24 + 93) * 4] ! AWR5
1113// OBSOLETE st %r6, [%sp + (24 + 94) * 4] ! AWR6
1114// OBSOLETE st %r7, [%sp + (24 + 95) * 4] ! AWR7
1115// OBSOLETE st %r8, [%sp + (24 + 96) * 4] ! AWR8
1116// OBSOLETE st %r9, [%sp + (24 + 97) * 4] ! AWR9
1117// OBSOLETE st %r10, [%sp + (24 + 98) * 4] ! AWR10
1118// OBSOLETE st %r11, [%sp + (24 + 99) * 4] ! AWR11
1119// OBSOLETE st %r12, [%sp + (24 + 100) * 4] ! AWR12
1120// OBSOLETE st %r13, [%sp + (24 + 101) * 4] ! AWR13
1121// OBSOLETE ! st %r14, [%sp + (24 + 102) * 4] ! AWR14 (SP)
1122// OBSOLETE st %r15, [%sp + (24 + 103) * 4] ! AWR15
1123// OBSOLETE st %r16, [%sp + (24 + 104) * 4] ! AWR16
1124// OBSOLETE st %r17, [%sp + (24 + 105) * 4] ! AWR17
1125// OBSOLETE st %r18, [%sp + (24 + 106) * 4] ! AWR18
1126// OBSOLETE st %r19, [%sp + (24 + 107) * 4] ! AWR19
1127// OBSOLETE st %r20, [%sp + (24 + 108) * 4] ! AWR20
1128// OBSOLETE st %r21, [%sp + (24 + 109) * 4] ! AWR21
1129// OBSOLETE st %r22, [%sp + (24 + 110) * 4] ! AWR22
1130// OBSOLETE st %r23, [%sp + (24 + 111) * 4] ! AWR23
1131// OBSOLETE st %r24, [%sp + (24 + 112) * 4] ! AWR24
1132// OBSOLETE st %r25, [%sp + (24 + 113) * 4] ! AWR25
1133// OBSOLETE st %r26, [%sp + (24 + 114) * 4] ! AWR26
1134// OBSOLETE st %r27, [%sp + (24 + 115) * 4] ! AWR27
1135// OBSOLETE st %r28, [%sp + (24 + 116) * 4] ! AWR28
1136// OBSOLETE st %r29, [%sp + (24 + 117) * 4] ! AWR29
1137// OBSOLETE st %r30, [%sp + (24 + 118) * 4] ! AWR30
1138// OBSOLETE st %r31, [%sp + (24 + 119) * 4] ! AWR21
1139// OBSOLETE
1140// OBSOLETE ! Get the Alternate PSR (I hope...)
1141// OBSOLETE
1142// OBSOLETE rd %psr, %l2
1143// OBSOLETE st %l2, [%sp + (24 + 120) * 4] ! APSR
1144// OBSOLETE
1145// OBSOLETE ! Don't forget the alternate stack pointer
1146// OBSOLETE
1147// OBSOLETE rd %y, %l3
1148// OBSOLETE st %l3, [%sp + (24 + 102) * 4] ! AWR14 (SP)
1149// OBSOLETE
1150// OBSOLETE ! 6) Restore the Alternate SP (saved in Y)
1151// OBSOLETE
1152// OBSOLETE rd %y, %o6
1153// OBSOLETE
1154// OBSOLETE
1155// OBSOLETE ! 7) Swap the registers back:
1156// OBSOLETE
1157// OBSOLETE mov %psr, %l1
1158// OBSOLETE sethi %hi(0x10000), %l2
1159// OBSOLETE xor %l1, %l2, %l1
1160// OBSOLETE mov %l1, %psr
1161// OBSOLETE nop ! 3 nops after write to %psr (needed?)
1162// OBSOLETE nop
1163// OBSOLETE nop
1164// OBSOLETE ");
1165// OBSOLETE }
1166// OBSOLETE
1167// OBSOLETE #endif