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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [m68k/] [arch/] [v2_0/] [src/] [m68k_stub.c] - Blame information for rev 27

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
//========================================================================
2
//
3
//      m68k_stub.c
4
//
5
//      Helper functions for stub
6
//
7
//========================================================================
8
//####ECOSGPLCOPYRIGHTBEGIN####
9
// -------------------------------------------
10
// This file is part of eCos, the Embedded Configurable Operating System.
11
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
12
//
13
// eCos is free software; you can redistribute it and/or modify it under
14
// the terms of the GNU General Public License as published by the Free
15
// Software Foundation; either version 2 or (at your option) any later version.
16
//
17
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
18
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
19
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
20
// for more details.
21
//
22
// You should have received a copy of the GNU General Public License along
23
// with eCos; if not, write to the Free Software Foundation, Inc.,
24
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
25
//
26
// As a special exception, if other files instantiate templates or use macros
27
// or inline functions from this file, or you compile this file and link it
28
// with other works to produce a work based on this file, this file does not
29
// by itself cause the resulting work to be covered by the GNU General Public
30
// License. However the source code for this file must still be made available
31
// in accordance with section (3) of the GNU General Public License.
32
//
33
// This exception does not invalidate any other reasons why a work based on
34
// this file might be covered by the GNU General Public License.
35
//
36
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
37
// at http://sources.redhat.com/ecos/ecos-license/
38
// -------------------------------------------
39
//####ECOSGPLCOPYRIGHTEND####
40
//========================================================================
41
 
42
#include <stddef.h>
43
 
44
#include <pkgconf/hal.h>
45
 
46
#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
47
#include <cyg/hal/hal_stub.h>
48
 
49
#include <cyg/hal/hal_stub.h>
50
#include <cyg/hal/hal_arch.h>
51
#include <cyg/hal/hal_intr.h>
52
 
53
#ifdef CYGDBG_HAL_DEBUG_GDB_THREAD_SUPPORT
54
#include <cyg/hal/dbg-threads-api.h>    // dbg_currthread_id
55
#endif
56
 
57
/* Given a trap value TRAP, return the corresponding signal. */
58
 
59
int __computeSignal (unsigned int trap_number)
60
{
61
    switch (trap_number)
62
    {
63
 
64
    case CYGNUM_HAL_VECTOR_BUSERR:
65
    case CYGNUM_HAL_VECTOR_ADDERR:
66
        return SIGBUS;
67
 
68
    case CYGNUM_HAL_VECTOR_ILLINST:
69
        return SIGILL;
70
 
71
    case CYGNUM_HAL_VECTOR_ZERODIV:
72
        /* This isn't quite accurate: this is integer division only. */
73
        return SIGFPE;
74
 
75
    case CYGNUM_HAL_VECTOR_CHKINST:
76
    case CYGNUM_HAL_VECTOR_TRAPVINST:
77
        return SIGTRAP;
78
 
79
    case CYGNUM_HAL_VECTOR_PRIVVIOLATION:
80
        return SIGILL;
81
    case CYGNUM_HAL_VECTOR_TRACE:
82
        /* Instruction trace */
83
        return SIGTRAP;
84
 
85
    case CYGNUM_HAL_VECTOR_L1010:
86
    case CYGNUM_HAL_VECTOR_L1111:
87
    case CYGNUM_HAL_VECTOR_UNINITINT:
88
    case CYGNUM_HAL_VECTOR_SPURINT:
89
        return SIGTRAP;
90
 
91
    case CYGNUM_HAL_VECTOR_TRAPFIRST ... CYGNUM_HAL_VECTOR_TRAPLAST:
92
        return SIGTRAP;
93
 
94
    case CYGNUM_HAL_VECTOR_AUTOVEC1 ... CYGNUM_HAL_VECTOR_AUTOVEC7:
95
    case CYGNUM_HAL_VECTOR_INTRFIRST ... CYGNUM_HAL_VECTOR_INTRLAST:
96
        /* External interrupt */
97
        return SIGINT;
98
 
99
    default:
100
        return SIGTERM;
101
    }
102
}
103
 
104
 
105
/* Return the trap number corresponding to the last-taken trap. */
106
 
107
int __get_trap_number (void)
108
{
109
        //extern int hal_m68k_trap_number;
110
 
111
    // The vector is not not part of the GDB register set so get it
112
    // directly from the save context.
113
    //return hal_m68k_trap_number;
114
 
115
    return 1;
116
}
117
 
118
/* Set the currently-saved pc register value to PC. This also updates NPC
119
   as needed. */
120
 
121
void set_pc (target_register_t pc)
122
{
123
    put_register (PC, pc);
124
}
125
 
126
 
127
/*----------------------------------------------------------------------
128
 * Single-step support
129
 */
130
 
131
/* Set things up so that the next user resume will execute one instruction.
132
   This may be done by setting breakpoints or setting a single step flag
133
   in the saved user registers, for example. */
134
 
135
#define SR_TRACE 0x8000
136
 
137
void __single_step (void)
138
{
139
    target_register_t sr = get_register (PS);
140
 
141
    // Set trace flag in the exception context.
142
    sr |= SR_TRACE;
143
 
144
    put_register (PS, sr);
145
}
146
 
147
/* Clear the single-step state. */
148
 
149
void __clear_single_step (void)
150
{
151
    target_register_t sr = get_register (PS);
152
 
153
    // Clear single-step flag in the exception context.
154
    sr &= ~SR_TRACE;
155
 
156
    put_register (PS, sr);
157
}
158
 
159
 
160
void __install_breakpoints (void)
161
{
162
    /* NOP since single-step HW exceptions are used instead of
163
       breakpoints. */
164
}
165
 
166
void __clear_breakpoints (void)
167
{
168
}
169
 
170
 
171
/* If the breakpoint we hit is in the breakpoint() instruction, return a
172
   non-zero value. */
173
 
174
int
175
__is_breakpoint_function ()
176
{
177
    return get_register (PC) == (target_register_t)&CYG_LABEL_NAME(breakinst);
178
}
179
 
180
 
181
/* Skip the current instruction.  Since this is only called by the
182
   stub when the PC points to a breakpoint or trap instruction,
183
   we can safely just skip 4. */
184
 
185
void __skipinst (void)
186
{
187
    put_register (PC, get_register (PC) + 4);
188
}
189
 
190
#endif // CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
191
 

powered by: WebSVN 2.1.0

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