OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [branches/] [newlib/] [newlib/] [libgloss/] [sparc/] [sparcl-stub.c] - Diff between revs 39 and 56

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 39 Rev 56
Line 86... Line 86...
 *
 *
 ****************************************************************************/
 ****************************************************************************/
 
 
#include <string.h>
#include <string.h>
#include <signal.h>
#include <signal.h>
 
#include "asm.h"
 
 
/************************************************************************
/************************************************************************
 *
 *
 * external low-level support routines
 * external low-level support routines
 */
 */
 
 
extern putDebugChar();   /* write a single character      */
extern putDebugChar();   /* write a single character      */
extern getDebugChar();   /* read and return a single char */
extern getDebugChar();   /* read and return a single char */
 
 
 
/* Pointer to hook for outbyte, set by stub's exception handler.  */
 
extern void (*__outbyte_hook)();
 
 
/************************************************************************/
/************************************************************************/
/* BUFMAX defines the maximum number of characters in inbound/outbound buffers*/
/* BUFMAX defines the maximum number of characters in inbound/outbound buffers*/
/* at least NUMREGBYTES*2 are needed for register packets */
/* at least NUMREGBYTES*2 are needed for register packets */
#define BUFMAX 2048
#define BUFMAX 2048
 
 
Line 147... Line 150...
! This function is called when any SPARC trap (except window overflow or
! This function is called when any SPARC trap (except window overflow or
! underflow) occurs.  It makes sure that the invalid register window is still
! underflow) occurs.  It makes sure that the invalid register window is still
! available before jumping into C code.  It will also restore the world if you
! available before jumping into C code.  It will also restore the world if you
! return from handle_exception.
! return from handle_exception.
 
 
        .globl _trap_low
        .globl " STRINGSYM(trap_low) "
_trap_low:
" STRINGSYM(trap_low) ":
        mov     %psr, %l0
        mov     %psr, %l0
        mov     %wim, %l3
        mov     %wim, %l3
 
 
        srl     %l3, %l0, %l4           ! wim >> cwp
        srl     %l3, %l0, %l4           ! wim >> cwp
        cmp     %l4, 1
        cmp     %l4, 1
Line 239... Line 242...
        or      %l0, 0xf20, %l4
        or      %l0, 0xf20, %l4
        mov     %l4, %psr               ! Turn on traps, disable interrupts
        mov     %l4, %psr               ! Turn on traps, disable interrupts
        nop
        nop
        nop
        nop
        nop
        nop
        call    _get_in_break_mode
        call    " STRINGSYM(get_in_break_mode) "
        nop
        nop
        nop
        nop
        nop
        nop
 
 
        sethi   %hi(0xff00), %l5
        sethi   %hi(0xff00), %l5
Line 277... Line 280...
        or      %l0, 0xf20, %l4
        or      %l0, 0xf20, %l4
        mov     %l4, %psr               ! Turn on traps, disable interrupts
        mov     %l4, %psr               ! Turn on traps, disable interrupts
        nop
        nop
        nop
        nop
        nop
        nop
        call    _handle_exception
        call    " STRINGSYM(handle_exception) "
        add     %sp, 24 * 4, %o0        ! Pass address of registers
        add     %sp, 24 * 4, %o0        ! Pass address of registers
 
 
! Reload all of the registers that aren't on the stack
! Reload all of the registers that aren't on the stack
 
 
        ld      [%sp + (24 + 1) * 4], %g1 ! registers[Gx]
        ld      [%sp + (24 + 1) * 4], %g1 ! registers[Gx]
Line 579... Line 582...
! past the faulting instruction after setting mem_err.
! past the faulting instruction after setting mem_err.
 
 
        .text
        .text
        .align 4
        .align 4
 
 
_fltr_set_mem_err:
" STRINGSYM(fltr_set_mem_err) ":
        sethi %hi(_mem_err), %l0
        sethi %hi(" STRINGSYM(mem_err) "), %l0
        st %l1, [%l0 + %lo(_mem_err)]
        st %l1, [%l0 + %lo(" STRINGSYM(mem_err) ")]
        jmpl %l2, %g0
        jmpl %l2, %g0
        rett %l2+4
        rett %l2+4
");
");
 
 
static void
static void
Line 603... Line 606...
 
 
asm ("
asm ("
        .text
        .text
        .align 4
        .align 4
 
 
_dummy_hw_breakpoint:
" STRINGSYM(dummy_hw_breakpoint) ":
        jmpl %l2, %g0
        jmpl %l2, %g0
        rett %l2+4
        rett %l2+4
        nop
        nop
        nop
        nop
");
");
Line 682... Line 685...
    }
    }
 
 
  return (numChars);
  return (numChars);
}
}
 
 
 
/* Replacement for outbyte that sends a packet to GDB containing
 
   the character to be output.  */
 
 
 
static void
 
outbyte_stub (int c)
 
{
 
  static char buf[4];
 
 
 
  buf[0] = 'O';
 
  buf[1] = hexchars[(c >> 4) & 0xf];
 
  buf[2] = hexchars[c % 16];
 
  buf[3] = 0;
 
  putpacket (buf);
 
}
 
 
 
 
/*
/*
 * This function does all command procesing for interfacing to gdb.  It
 * This function does all command procesing for interfacing to gdb.  It
 * returns 1 if you should skip the instruction at the trap address, 0
 * returns 1 if you should skip the instruction at the trap address, 0
 * otherwise.
 * otherwise.
 */
 */
Line 780... Line 799...
 
 
  *ptr++ = 0;
  *ptr++ = 0;
 
 
  putpacket(remcomOutBuffer);
  putpacket(remcomOutBuffer);
 
 
 
  __outbyte_hook = outbyte_stub;
 
 
  while (1)
  while (1)
    {
    {
      remcomOutBuffer[0] = 0;
      remcomOutBuffer[0] = 0;
 
 
      getpacket(remcomInBuffer);
      getpacket(remcomInBuffer);
Line 967... Line 988...
breakpoint()
breakpoint()
{
{
  if (!initialized)
  if (!initialized)
    return;
    return;
 
 
  asm(" .globl _breakinst
  asm(" .globl " STRINGSYM(breakinst) "
 
 
        _breakinst: ta 1
        " STRINGSYM(breakinst) ": ta 1
      ");
      ");
}
}
 
 
static void
static void
hw_breakpoint()
hw_breakpoint()

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.