import gdb-1999-05-25 snapshot
[binutils-gdb.git] / gdb / sparc-stub.c
index 5de62a339e4e49fbe4233f301dd2d471ca59e535..7da65c21080f63ae9dcda45b31f7fbc7edee42b2 100644 (file)
@@ -92,8 +92,8 @@
  * external low-level support routines
  */
 
-extern putDebugChar();   /* write a single character      */
-extern getDebugChar();   /* read and return a single char */
+extern void putDebugChar();    /* write a single character      */
+extern int getDebugChar();     /* read and return a single char */
 
 /************************************************************************/
 /* BUFMAX defines the maximum number of characters in inbound/outbound buffers*/
@@ -157,9 +157,28 @@ _trap_low:
 
        mov     %g1, %l4                ! Save g1, we use it to hold the wim
        srl     %l3, 1, %g1             ! Rotate wim right
-       sll     %l3, 8-1, %l5
-       or      %l5, %g1, %g1
+       tst     %g1
+       bg      good_wim                ! Branch if new wim is non-zero
+       nop
+
+! At this point, we need to bring a 1 into the high order bit of the wim.
+! Since we don't want to make any assumptions about the number of register
+! windows, we figure it out dynamically so as to setup the wim correctly.
+
+       not     %g1                     ! Fill g1 with ones
+       mov     %g1, %wim               ! Fill the wim with ones
+       nop
+       nop
+       nop
+       mov     %wim, %g1               ! Read back the wim
+       inc     %g1                     ! Now g1 has 1 just to left of wim
+       srl     %g1, 1, %g1             ! Now put 1 at top of wim
+       mov     %g0, %wim               ! Clear wim so that subsequent save
+       nop                             !  won't trap
+       nop
+       nop
 
+good_wim:
        save    %g0, %g0, %g0           ! Slip into next window
        mov     %g1, %wim               ! Install the new wim
 
@@ -280,7 +299,7 @@ getpacket(buffer)
   do
     {
       /* wait around for the start character, ignore all other characters */
-      while ((ch = getDebugChar()) != '$') ;
+      while ((ch = (getDebugChar() & 0x7f)) != '$') ;
 
       checksum = 0;
       xmitcsum = -1;
@@ -290,7 +309,7 @@ getpacket(buffer)
       /* now, read until a # or end of buffer is found */
       while (count < BUFMAX)
        {
-         ch = getDebugChar();
+         ch = getDebugChar() & 0x7f;
          if (ch == '#')
            break;
          checksum = checksum + ch;
@@ -305,8 +324,8 @@ getpacket(buffer)
 
       if (ch == '#')
        {
-         xmitcsum = hex(getDebugChar()) << 4;
-         xmitcsum |= hex(getDebugChar());
+         xmitcsum = hex(getDebugChar() & 0x7f) << 4;
+         xmitcsum |= hex(getDebugChar() & 0x7f);
 #if 0
          /* Humans shouldn't have to figure out checksums to type to it. */
          putDebugChar ('+');
@@ -352,8 +371,7 @@ putpacket(buffer)
 
       while (ch = buffer[count])
        {
-         if (! putDebugChar(ch))
-           return;
+         putDebugChar(ch);
          checksum += ch;
          count += 1;
        }
@@ -363,7 +381,7 @@ putpacket(buffer)
       putDebugChar(hexchars[checksum & 0xf]);
 
     }
-  while (getDebugChar() != '+');
+  while ((getDebugChar() & 0x7f) != '+');
 }
 
 static char remcomInBuffer[BUFMAX];
@@ -758,7 +776,7 @@ handle_exception (registers)
          break;
 #if 0
        case 't':               /* Test feature */
-         asm (" std %f31,[%sp]");
+         asm (" std %f30,[%sp]");
          break;
 #endif
        case 'r':               /* Reset */