sparc-stub.c
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:18k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /* $Id: sparc-stub.c,v 1.28 2001/10/30 04:54:21 davem Exp $
  2.  * sparc-stub.c:  KGDB support for the Linux kernel.
  3.  *
  4.  * Modifications to run under Linux
  5.  * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
  6.  *
  7.  * This file originally came from the gdb sources, and the
  8.  * copyright notices have been retained below.
  9.  */
  10. /****************************************************************************
  11. THIS SOFTWARE IS NOT COPYRIGHTED
  12.    HP offers the following for use in the public domain.  HP makes no
  13.    warranty with regard to the software or its performance and the
  14.    user accepts the software "AS IS" with all faults.
  15.    HP DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED, WITH REGARD
  16.    TO THIS SOFTWARE INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  17.    OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  18. ****************************************************************************/
  19. /****************************************************************************
  20.  *  Header: remcom.c,v 1.34 91/03/09 12:29:49 glenne Exp $
  21.  *
  22.  *  Module name: remcom.c $
  23.  *  Revision: 1.34 $
  24.  *  Date: 91/03/09 12:29:49 $
  25.  *  Contributor:     Lake Stevens Instrument Division$
  26.  *
  27.  *  Description:     low level support for gdb debugger. $
  28.  *
  29.  *  Considerations:  only works on target hardware $
  30.  *
  31.  *  Written by:      Glenn Engel $
  32.  *  ModuleState:     Experimental $
  33.  *
  34.  *  NOTES:           See Below $
  35.  *
  36.  *  Modified for SPARC by Stu Grossman, Cygnus Support.
  37.  *
  38.  *  This code has been extensively tested on the Fujitsu SPARClite demo board.
  39.  *
  40.  *  To enable debugger support, two things need to happen.  One, a
  41.  *  call to set_debug_traps() is necessary in order to allow any breakpoints
  42.  *  or error conditions to be properly intercepted and reported to gdb.
  43.  *  Two, a breakpoint needs to be generated to begin communication.  This
  44.  *  is most easily accomplished by a call to breakpoint().  Breakpoint()
  45.  *  simulates a breakpoint by executing a trap #1.
  46.  *
  47.  *************
  48.  *
  49.  *    The following gdb commands are supported:
  50.  *
  51.  * command          function                               Return value
  52.  *
  53.  *    g             return the value of the CPU registers  hex data or ENN
  54.  *    G             set the value of the CPU registers     OK or ENN
  55.  *
  56.  *    mAA..AA,LLLL  Read LLLL bytes at address AA..AA      hex data or ENN
  57.  *    MAA..AA,LLLL: Write LLLL bytes at address AA.AA      OK or ENN
  58.  *
  59.  *    c             Resume at current address              SNN   ( signal NN)
  60.  *    cAA..AA       Continue at address AA..AA             SNN
  61.  *
  62.  *    s             Step one instruction                   SNN
  63.  *    sAA..AA       Step one instruction from AA..AA       SNN
  64.  *
  65.  *    k             kill
  66.  *
  67.  *    ?             What was the last sigval ?             SNN   (signal NN)
  68.  *
  69.  *    bBB..BB     Set baud rate to BB..BB    OK or BNN, then sets
  70.  *    baud rate
  71.  *
  72.  * All commands and responses are sent with a packet which includes a
  73.  * checksum.  A packet consists of
  74.  *
  75.  * $<packet info>#<checksum>.
  76.  *
  77.  * where
  78.  * <packet info> :: <characters representing the command or response>
  79.  * <checksum>    :: < two hex digits computed as modulo 256 sum of <packetinfo>>
  80.  *
  81.  * When a packet is received, it is first acknowledged with either '+' or '-'.
  82.  * '+' indicates a successful transfer.  '-' indicates a failed transfer.
  83.  *
  84.  * Example:
  85.  *
  86.  * Host:                  Reply:
  87.  * $m0,10#2a               +$00010203040506070809101112131415#42
  88.  *
  89.  ****************************************************************************/
  90. #include <linux/kernel.h>
  91. #include <linux/string.h>
  92. #include <linux/mm.h>
  93. #include <linux/smp.h>
  94. #include <linux/smp_lock.h>
  95. #include <asm/system.h>
  96. #include <asm/signal.h>
  97. #include <asm/oplib.h>
  98. #include <asm/head.h>
  99. #include <asm/traps.h>
  100. #include <asm/vac-ops.h>
  101. #include <asm/kgdb.h>
  102. #include <asm/pgalloc.h>
  103. #include <asm/pgtable.h>
  104. /*
  105.  *
  106.  * external low-level support routines
  107.  */
  108. extern void putDebugChar(char);   /* write a single character      */
  109. extern char getDebugChar(void);   /* read and return a single char */
  110. /*
  111.  * BUFMAX defines the maximum number of characters in inbound/outbound buffers
  112.  * at least NUMREGBYTES*2 are needed for register packets
  113.  */
  114. #define BUFMAX 2048
  115. static int initialized; /* !0 means we've been initialized */
  116. static const char hexchars[]="0123456789abcdef";
  117. #define NUMREGS 72
  118. /* Number of bytes of registers.  */
  119. #define NUMREGBYTES (NUMREGS * 4)
  120. enum regnames {G0, G1, G2, G3, G4, G5, G6, G7,
  121.  O0, O1, O2, O3, O4, O5, SP, O7,
  122.  L0, L1, L2, L3, L4, L5, L6, L7,
  123.  I0, I1, I2, I3, I4, I5, FP, I7,
  124.  F0, F1, F2, F3, F4, F5, F6, F7,
  125.  F8, F9, F10, F11, F12, F13, F14, F15,
  126.  F16, F17, F18, F19, F20, F21, F22, F23,
  127.  F24, F25, F26, F27, F28, F29, F30, F31,
  128.  Y, PSR, WIM, TBR, PC, NPC, FPSR, CPSR };
  129. extern void trap_low(void);  /* In arch/sparc/kernel/entry.S */
  130. unsigned long get_sun4cpte(unsigned long addr)
  131. {
  132. unsigned long entry;
  133. __asm__ __volatile__("ntlda [%1] %2, %0nt" : 
  134.      "=r" (entry) :
  135.      "r" (addr), "i" (ASI_PTE));
  136. return entry;
  137. }
  138. unsigned long get_sun4csegmap(unsigned long addr)
  139. {
  140. unsigned long entry;
  141. __asm__ __volatile__("ntlduba [%1] %2, %0nt" : 
  142.      "=r" (entry) :
  143.      "r" (addr), "i" (ASI_SEGMAP));
  144. return entry;
  145. }
  146. #if 0
  147. /* Have to sort this out. This cannot be done after initialization. */
  148. static void flush_cache_all_nop(void) {}
  149. #endif
  150. /* Place where we save old trap entries for restoration */
  151. struct tt_entry kgdb_savettable[256];
  152. typedef void (*trapfunc_t)(void);
  153. /* Helper routine for manipulation of kgdb_savettable */
  154. static inline void copy_ttentry(struct tt_entry *src, struct tt_entry *dest)
  155. {
  156. dest->inst_one = src->inst_one;
  157. dest->inst_two = src->inst_two;
  158. dest->inst_three = src->inst_three;
  159. dest->inst_four = src->inst_four;
  160. }
  161. /* Initialize the kgdb_savettable so that debugging can commence */
  162. static void eh_init(void)
  163. {
  164. int i, flags;
  165. save_and_cli(flags);
  166. for(i=0; i < 256; i++)
  167. copy_ttentry(&sparc_ttable[i], &kgdb_savettable[i]);
  168. restore_flags(flags);
  169. }
  170. /* Install an exception handler for kgdb */
  171. static void exceptionHandler(int tnum, trapfunc_t trap_entry)
  172. {
  173. unsigned long te_addr = (unsigned long) trap_entry;
  174. int flags;
  175. /* We are dorking with a live trap table, all irqs off */
  176. save_and_cli(flags);
  177. /* Make new vector */
  178. sparc_ttable[tnum].inst_one =
  179. SPARC_BRANCH((unsigned long) te_addr,
  180.      (unsigned long) &sparc_ttable[tnum].inst_one);
  181. sparc_ttable[tnum].inst_two = SPARC_RD_PSR_L0;
  182. sparc_ttable[tnum].inst_three = SPARC_NOP;
  183. sparc_ttable[tnum].inst_four = SPARC_NOP;
  184. restore_flags(flags);
  185. }
  186. /* Convert ch from a hex digit to an int */
  187. static int
  188. hex(unsigned char ch)
  189. {
  190. if (ch >= 'a' && ch <= 'f')
  191. return ch-'a'+10;
  192. if (ch >= '0' && ch <= '9')
  193. return ch-'0';
  194. if (ch >= 'A' && ch <= 'F')
  195. return ch-'A'+10;
  196. return -1;
  197. }
  198. /* scan for the sequence $<data>#<checksum>     */
  199. static void
  200. getpacket(char *buffer)
  201. {
  202. unsigned char checksum;
  203. unsigned char xmitcsum;
  204. int i;
  205. int count;
  206. unsigned char ch;
  207. do {
  208. /* wait around for the start character, ignore all other characters */
  209. while ((ch = (getDebugChar() & 0x7f)) != '$') ;
  210. checksum = 0;
  211. xmitcsum = -1;
  212. count = 0;
  213. /* now, read until a # or end of buffer is found */
  214. while (count < BUFMAX) {
  215. ch = getDebugChar() & 0x7f;
  216. if (ch == '#')
  217. break;
  218. checksum = checksum + ch;
  219. buffer[count] = ch;
  220. count = count + 1;
  221. }
  222. if (count >= BUFMAX)
  223. continue;
  224. buffer[count] = 0;
  225. if (ch == '#') {
  226. xmitcsum = hex(getDebugChar() & 0x7f) << 4;
  227. xmitcsum |= hex(getDebugChar() & 0x7f);
  228. if (checksum != xmitcsum)
  229. putDebugChar('-'); /* failed checksum */
  230. else {
  231. putDebugChar('+'); /* successful transfer */
  232. /* if a sequence char is present, reply the ID */
  233. if (buffer[2] == ':') {
  234. putDebugChar(buffer[0]);
  235. putDebugChar(buffer[1]);
  236. /* remove sequence chars from buffer */
  237. count = strlen(buffer);
  238. for (i=3; i <= count; i++)
  239. buffer[i-3] = buffer[i];
  240. }
  241. }
  242. }
  243. } while (checksum != xmitcsum);
  244. }
  245. /* send the packet in buffer.  */
  246. static void
  247. putpacket(unsigned char *buffer)
  248. {
  249. unsigned char checksum;
  250. int count;
  251. unsigned char ch, recv;
  252. /*  $<packet info>#<checksum>. */
  253. do {
  254. putDebugChar('$');
  255. checksum = 0;
  256. count = 0;
  257. while ((ch = buffer[count])) {
  258. putDebugChar(ch);
  259. checksum += ch;
  260. count += 1;
  261. }
  262. putDebugChar('#');
  263. putDebugChar(hexchars[checksum >> 4]);
  264. putDebugChar(hexchars[checksum & 0xf]);
  265. recv = getDebugChar();
  266. } while ((recv & 0x7f) != '+');
  267. }
  268. static char remcomInBuffer[BUFMAX];
  269. static char remcomOutBuffer[BUFMAX];
  270. /* Convert the memory pointed to by mem into hex, placing result in buf.
  271.  * Return a pointer to the last char put in buf (null), in case of mem fault,
  272.  * return 0.
  273.  */
  274. static unsigned char *
  275. mem2hex(char *mem, char *buf, int count)
  276. {
  277. unsigned char ch;
  278. while (count-- > 0) {
  279. /* This assembler code is basically:  ch = *mem++;
  280.  * except that we use the SPARC/Linux exception table
  281.  * mechanism (see how "fixup" works in kernel_mna_trap_fault)
  282.  * to arrange for a "return 0" upon a memory fault
  283.  */
  284. __asm__(
  285. "n1:nt"
  286. "ldub [%0], %1nt"
  287. "inc %0nt"
  288. ".section .fixup,#alloc,#execinstrnt"
  289. ".align 4n"
  290. "2:nt"
  291. "retlnt"
  292. " mov 0, %%o0nt"
  293. ".section __ex_table, #allocnt"
  294. ".align 4nt"
  295. ".word 1b, 2bnt"
  296. ".textn"
  297. : "=r" (mem), "=r" (ch) : "0" (mem));
  298. *buf++ = hexchars[ch >> 4];
  299. *buf++ = hexchars[ch & 0xf];
  300. }
  301. *buf = 0;
  302. return buf;
  303. }
  304. /* convert the hex array pointed to by buf into binary to be placed in mem
  305.  * return a pointer to the character AFTER the last byte written.
  306. */
  307. static char *
  308. hex2mem(char *buf, char *mem, int count)
  309. {
  310. int i;
  311. unsigned char ch;
  312. for (i=0; i<count; i++) {
  313. ch = hex(*buf++) << 4;
  314. ch |= hex(*buf++);
  315. /* Assembler code is   *mem++ = ch;   with return 0 on fault */
  316. __asm__(
  317. "n1:nt"
  318. "stb %1, [%0]nt"
  319. "inc %0nt"
  320. ".section .fixup,#alloc,#execinstrnt"
  321. ".align 4n"
  322. "2:nt"
  323. "retlnt"
  324. " mov 0, %%o0nt"
  325. ".section __ex_table, #allocnt"
  326. ".align 4nt"
  327. ".word 1b, 2bnt"
  328. ".textn"
  329. : "=r" (mem) : "r" (ch) , "0" (mem));
  330. }
  331. return mem;
  332. }
  333. /* This table contains the mapping between SPARC hardware trap types, and
  334.    signals, which are primarily what GDB understands.  It also indicates
  335.    which hardware traps we need to commandeer when initializing the stub. */
  336. static struct hard_trap_info
  337. {
  338.   unsigned char tt; /* Trap type code for SPARC */
  339.   unsigned char signo; /* Signal that we map this trap into */
  340. } hard_trap_info[] = {
  341.   {SP_TRAP_SBPT, SIGTRAP},      /* ta 1 - Linux/KGDB software breakpoint */
  342.   {0, 0} /* Must be last */
  343. };
  344. /* Set up exception handlers for tracing and breakpoints */
  345. void
  346. set_debug_traps(void)
  347. {
  348. struct hard_trap_info *ht;
  349. unsigned long flags;
  350. save_and_cli(flags);
  351. #if 0
  352. /* Have to sort this out. This cannot be done after initialization. */
  353. BTFIXUPSET_CALL(flush_cache_all, flush_cache_all_nop, BTFIXUPCALL_NOP);
  354. #endif
  355. /* Initialize our copy of the Linux Sparc trap table */
  356. eh_init();
  357. for (ht = hard_trap_info; ht->tt && ht->signo; ht++) {
  358. /* Only if it doesn't destroy our fault handlers */
  359. if((ht->tt != SP_TRAP_TFLT) && 
  360.    (ht->tt != SP_TRAP_DFLT))
  361. exceptionHandler(ht->tt, trap_low);
  362. }
  363. /* In case GDB is started before us, ack any packets (presumably
  364.  * "$?#xx") sitting there.
  365.  *
  366.  * I've found this code causes more problems than it solves,
  367.  * so that's why it's commented out.  GDB seems to work fine
  368.  * now starting either before or after the kernel   -bwb
  369.  */
  370. #if 0
  371. while((c = getDebugChar()) != '$');
  372. while((c = getDebugChar()) != '#');
  373. c = getDebugChar(); /* eat first csum byte */
  374. c = getDebugChar(); /* eat second csum byte */
  375. putDebugChar('+'); /* ack it */
  376. #endif
  377. initialized = 1; /* connect! */
  378. restore_flags(flags);
  379. }
  380. /* Convert the SPARC hardware trap type code to a unix signal number. */
  381. static int
  382. computeSignal(int tt)
  383. {
  384. struct hard_trap_info *ht;
  385. for (ht = hard_trap_info; ht->tt && ht->signo; ht++)
  386. if (ht->tt == tt)
  387. return ht->signo;
  388. return SIGHUP;         /* default for things we don't know about */
  389. }
  390. /*
  391.  * While we find nice hex chars, build an int.
  392.  * Return number of chars processed.
  393.  */
  394. static int
  395. hexToInt(char **ptr, int *intValue)
  396. {
  397. int numChars = 0;
  398. int hexValue;
  399. *intValue = 0;
  400. while (**ptr) {
  401. hexValue = hex(**ptr);
  402. if (hexValue < 0)
  403. break;
  404. *intValue = (*intValue << 4) | hexValue;
  405. numChars ++;
  406. (*ptr)++;
  407. }
  408. return (numChars);
  409. }
  410. /*
  411.  * This function does all command processing for interfacing to gdb.  It
  412.  * returns 1 if you should skip the instruction at the trap address, 0
  413.  * otherwise.
  414.  */
  415. extern void breakinst(void);
  416. void
  417. handle_exception (unsigned long *registers)
  418. {
  419. int tt;       /* Trap type */
  420. int sigval;
  421. int addr;
  422. int length;
  423. char *ptr;
  424. unsigned long *sp;
  425. /* First, we must force all of the windows to be spilled out */
  426. asm("save %sp, -64, %spnt"
  427.     "save %sp, -64, %spnt"
  428.     "save %sp, -64, %spnt"
  429.     "save %sp, -64, %spnt"
  430.     "save %sp, -64, %spnt"
  431.     "save %sp, -64, %spnt"
  432.     "save %sp, -64, %spnt"
  433.     "save %sp, -64, %spnt"
  434.     "restorent"
  435.     "restorent"
  436.     "restorent"
  437.     "restorent"
  438.     "restorent"
  439.     "restorent"
  440.     "restorent"
  441.     "restorent");
  442. lock_kernel();
  443. if (registers[PC] == (unsigned long)breakinst) {
  444. /* Skip over breakpoint trap insn */
  445. registers[PC] = registers[NPC];
  446. registers[NPC] += 4;
  447. }
  448. sp = (unsigned long *)registers[SP];
  449. tt = (registers[TBR] >> 4) & 0xff;
  450. /* reply to host that an exception has occurred */
  451. sigval = computeSignal(tt);
  452. ptr = remcomOutBuffer;
  453. *ptr++ = 'T';
  454. *ptr++ = hexchars[sigval >> 4];
  455. *ptr++ = hexchars[sigval & 0xf];
  456. *ptr++ = hexchars[PC >> 4];
  457. *ptr++ = hexchars[PC & 0xf];
  458. *ptr++ = ':';
  459. ptr = mem2hex((char *)&registers[PC], ptr, 4);
  460. *ptr++ = ';';
  461. *ptr++ = hexchars[FP >> 4];
  462. *ptr++ = hexchars[FP & 0xf];
  463. *ptr++ = ':';
  464. ptr = mem2hex((char *) (sp + 8 + 6), ptr, 4); /* FP */
  465. *ptr++ = ';';
  466. *ptr++ = hexchars[SP >> 4];
  467. *ptr++ = hexchars[SP & 0xf];
  468. *ptr++ = ':';
  469. ptr = mem2hex((char *)&sp, ptr, 4);
  470. *ptr++ = ';';
  471. *ptr++ = hexchars[NPC >> 4];
  472. *ptr++ = hexchars[NPC & 0xf];
  473. *ptr++ = ':';
  474. ptr = mem2hex((char *)&registers[NPC], ptr, 4);
  475. *ptr++ = ';';
  476. *ptr++ = hexchars[O7 >> 4];
  477. *ptr++ = hexchars[O7 & 0xf];
  478. *ptr++ = ':';
  479. ptr = mem2hex((char *)&registers[O7], ptr, 4);
  480. *ptr++ = ';';
  481. *ptr++ = 0;
  482. putpacket(remcomOutBuffer);
  483. /* XXX We may want to add some features dealing with poking the
  484.  * XXX page tables, the real ones on the srmmu, and what is currently
  485.  * XXX loaded in the sun4/sun4c tlb at this point in time.  But this
  486.  * XXX also required hacking to the gdb sources directly...
  487.  */
  488. while (1) {
  489. remcomOutBuffer[0] = 0;
  490. getpacket(remcomInBuffer);
  491. switch (remcomInBuffer[0]) {
  492. case '?':
  493. remcomOutBuffer[0] = 'S';
  494. remcomOutBuffer[1] = hexchars[sigval >> 4];
  495. remcomOutBuffer[2] = hexchars[sigval & 0xf];
  496. remcomOutBuffer[3] = 0;
  497. break;
  498. case 'd':
  499. /* toggle debug flag */
  500. break;
  501. case 'g': /* return the value of the CPU registers */
  502. {
  503. ptr = remcomOutBuffer;
  504. /* G & O regs */
  505. ptr = mem2hex((char *)registers, ptr, 16 * 4);
  506. /* L & I regs */
  507. ptr = mem2hex((char *) (sp + 0), ptr, 16 * 4);
  508. /* Floating point */
  509. memset(ptr, '0', 32 * 8);
  510. /* Y, PSR, WIM, TBR, PC, NPC, FPSR, CPSR */
  511. mem2hex((char *)&registers[Y], (ptr + 32 * 4 * 2), (8 * 4));
  512. }
  513. break;
  514. case 'G':    /* set the value of the CPU registers - return OK */
  515. {
  516. unsigned long *newsp, psr;
  517. psr = registers[PSR];
  518. ptr = &remcomInBuffer[1];
  519. /* G & O regs */
  520. hex2mem(ptr, (char *)registers, 16 * 4);
  521. /* L & I regs */
  522. hex2mem(ptr + 16 * 4 * 2, (char *) (sp + 0), 16 * 4);
  523. /* Y, PSR, WIM, TBR, PC, NPC, FPSR, CPSR */
  524. hex2mem(ptr + 64 * 4 * 2, (char *)&registers[Y], 8 * 4);
  525. /* See if the stack pointer has moved.  If so,
  526.  * then copy the saved locals and ins to the
  527.  * new location.  This keeps the window
  528.  * overflow and underflow routines happy.
  529.  */
  530. newsp = (unsigned long *)registers[SP];
  531. if (sp != newsp)
  532. sp = memcpy(newsp, sp, 16 * 4);
  533. /* Don't allow CWP to be modified. */
  534. if (psr != registers[PSR])
  535. registers[PSR] = (psr & 0x1f) | (registers[PSR] & ~0x1f);
  536. strcpy(remcomOutBuffer,"OK");
  537. }
  538. break;
  539. case 'm':   /* mAA..AA,LLLL  Read LLLL bytes at address AA..AA */
  540. /* Try to read %x,%x.  */
  541. ptr = &remcomInBuffer[1];
  542. if (hexToInt(&ptr, &addr)
  543.     && *ptr++ == ','
  544.     && hexToInt(&ptr, &length)) {
  545. if (mem2hex((char *)addr, remcomOutBuffer, length))
  546. break;
  547. strcpy (remcomOutBuffer, "E03");
  548. } else {
  549. strcpy(remcomOutBuffer,"E01");
  550. }
  551. break;
  552. case 'M': /* MAA..AA,LLLL: Write LLLL bytes at address AA.AA return OK */
  553. /* Try to read '%x,%x:'.  */
  554. ptr = &remcomInBuffer[1];
  555. if (hexToInt(&ptr, &addr)
  556.     && *ptr++ == ','
  557.     && hexToInt(&ptr, &length)
  558.     && *ptr++ == ':') {
  559. if (hex2mem(ptr, (char *)addr, length)) {
  560. strcpy(remcomOutBuffer, "OK");
  561. } else {
  562. strcpy(remcomOutBuffer, "E03");
  563. }
  564. } else {
  565. strcpy(remcomOutBuffer, "E02");
  566. }
  567. break;
  568. case 'c':    /* cAA..AA    Continue at address AA..AA(optional) */
  569. /* try to read optional parameter, pc unchanged if no parm */
  570. ptr = &remcomInBuffer[1];
  571. if (hexToInt(&ptr, &addr)) {
  572. registers[PC] = addr;
  573. registers[NPC] = addr + 4;
  574. }
  575. /* Need to flush the instruction cache here, as we may have deposited a
  576.  * breakpoint, and the icache probably has no way of knowing that a data ref to
  577.  * some location may have changed something that is in the instruction cache.
  578.  */
  579. flush_cache_all();
  580. unlock_kernel();
  581. return;
  582. /* kill the program */
  583. case 'k' : /* do nothing */
  584. break;
  585. case 'r': /* Reset */
  586. asm ("call 0nt"
  587.      "nopnt");
  588. break;
  589. } /* switch */
  590. /* reply to the request */
  591. putpacket(remcomOutBuffer);
  592. } /* while(1) */
  593. }
  594. /* This function will generate a breakpoint exception.  It is used at the
  595.    beginning of a program to sync up with a debugger and can be used
  596.    otherwise as a quick means to stop program execution and "break" into
  597.    the debugger. */
  598. void
  599. breakpoint(void)
  600. {
  601. if (!initialized)
  602. return;
  603. /* Again, watch those c-prefixes for ELF kernels */
  604. #if defined(__svr4__) || defined(__ELF__)
  605. asm(".globl breakinstn"
  606.     "breakinst:nt"
  607.     "ta 1n");
  608. #else
  609. asm(".globl _breakinstn"
  610.     "_breakinst:nt"
  611.     "ta 1n");
  612. #endif
  613. }