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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [m68k/] [arch/] [current/] [src/] [m68k_stub.c] - Blame information for rev 838

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

Line No. Rev Author Line
1 786 skrzyp
//==========================================================================
2
//
3
//      m68k_stub.c
4
//
5
//      M68K gdb support
6
//
7
//==========================================================================
8
// ####ECOSGPLCOPYRIGHTBEGIN####                                            
9
// -------------------------------------------                              
10
// This file is part of eCos, the Embedded Configurable Operating System.   
11
// Copyright (C) 2003, 2008 Free Software Foundation, 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      
16
// version.                                                                 
17
//
18
// eCos is distributed in the hope that it will be useful, but WITHOUT      
19
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or    
20
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License    
21
// for more details.                                                        
22
//
23
// You should have received a copy of the GNU General Public License        
24
// along with eCos; if not, write to the Free Software Foundation, Inc.,    
25
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
26
//
27
// As a special exception, if other files instantiate templates or use      
28
// macros or inline functions from this file, or you compile this file      
29
// and link it with other works to produce a work based on this file,       
30
// this file does not by itself cause the resulting work to be covered by   
31
// the GNU General Public License. However the source code for this file    
32
// must still be made available in accordance with section (3) of the GNU   
33
// General Public License v2.                                               
34
//
35
// This exception does not invalidate any other reasons why a work based    
36
// on this file might be covered by the GNU General Public License.         
37
// -------------------------------------------                              
38
// ####ECOSGPLCOPYRIGHTEND####                                              
39
//==========================================================================
40
//###DESCRIPTIONBEGIN####
41
//
42
// Author(s):     bartv
43
// Date:          2003-06-04
44
//
45
//###DESCRIPTIONEND####
46
//========================================================================
47
 
48
#include <pkgconf/hal.h>
49
#include <pkgconf/hal_m68k.h>
50
 
51
#include <cyg/infra/cyg_type.h>
52
#include <cyg/infra/cyg_ass.h>
53
#include <cyg/infra/diag.h>
54
#include <cyg/hal/hal_arch.h>
55
#include <cyg/hal/hal_intr.h>
56
#include <cyg/hal/hal_if.h>
57
#include <cyg/hal/hal_stub.h>
58
 
59
// Translate between the eCos save state and what is expected by the gdb
60
// stubs. d0-d7/a0-a6 are in the right place already. SR/PS and the program
61
// counter need to come from variant-specific macros. The stack pointer
62
// can be determined from the saved context.
63
externC void
64
hal_get_gdb_registers(CYG_ADDRWORD* gdb_regs, HAL_SavedRegisters* ecos_regs)
65
{
66
    int     sr;
67
    int     pc;
68
    int     i;
69
    for (i = 0; i < 15; i++) {
70
        gdb_regs[i] = ecos_regs->da[i];
71
    }
72
    gdb_regs[15]    = (CYG_ADDRWORD) &(ecos_regs[1]);
73
    HAL_CONTEXT_PCSR_GET_SR(ecos_regs, sr);
74
    HAL_CONTEXT_PCSR_GET_PC(ecos_regs, pc);
75
    gdb_regs[16]    = sr;
76
    gdb_regs[17]    = pc;
77
}
78
 
79
externC void
80
hal_set_gdb_registers(HAL_SavedRegisters* ecos_regs, CYG_ADDRWORD* gdb_regs)
81
{
82
    int i;
83
    for (i = 0; i < 15; i++) {
84
        ecos_regs->da[i] = gdb_regs[i];
85
    }
86
    if (gdb_regs[15] != (CYG_ADDRWORD) &(ecos_regs[1])) {
87
        CYG_FAIL("gdb has requested a thread context switch - not supported,");
88
    }
89
    HAL_CONTEXT_PCSR_SET_SR(ecos_regs, gdb_regs[16]);
90
    HAL_CONTEXT_PCSR_SET_PC(ecos_regs, gdb_regs[17]);
91
}
92
 
93
#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
94
 
95
externC int
96
__computeSignal(unsigned int trap_number)
97
{
98
    switch(trap_number) {
99
      case CYGNUM_HAL_EXCEPTION_DATA_ACCESS:
100
        return SIGBUS;
101
      case CYGNUM_HAL_EXCEPTION_DATA_UNALIGNED_ACCESS:
102
      case CYGNUM_HAL_EXCEPTION_SYSTEM_ERROR:
103
        return SIGSEGV;
104
      case CYGNUM_HAL_EXCEPTION_ILLEGAL_INSTRUCTION:
105
        return SIGILL;
106
      case CYGNUM_HAL_EXCEPTION_DIV_BY_ZERO:
107
        return SIGFPE;
108
      case CYGNUM_HAL_EXCEPTION_TRACE:
109
      case CYGNUM_HAL_VECTOR_TRAP0 ... CYGNUM_HAL_VECTOR_TRAP15:
110
      default:
111
        return SIGTRAP;
112
    }
113
}
114
 
115
externC int
116
__get_trap_number(void)
117
{
118
    int result = CYGNUM_HAL_EXCEPTION_SYSTEM_ERROR;
119
    if ((HAL_SavedRegisters*)0 != _hal_registers) {
120
        HAL_CONTEXT_PCSR_GET_EXCEPTION(_hal_registers, result);
121
    }
122
    return result;
123
}
124
 
125
externC void
126
set_pc(target_register_t pc)
127
{
128
    _registers[PC]  = pc;
129
}
130
 
131
// Single-stepping just involves setting the trace bit in the status register
132
externC void
133
__single_step(void)
134
{
135
    _registers[PS]  |= HAL_M68K_SR_T;
136
}
137
 
138
externC void
139
__clear_single_step(void)
140
{
141
    _registers[PS]  &= ~HAL_M68K_SR_T;
142
}
143
 
144
// This breakpoint support is (probably) not needed because
145
// single-stepping is supported instead.
146
externC void
147
__install_breakpoints(void)
148
{
149
}
150
 
151
externC void
152
__clear_breakpoints(void)
153
{
154
}
155
 
156
externC int
157
__is_breakpoint_function(void)
158
{
159
    return _registers[PC]   == (target_register_t)&_breakinst;
160
}
161
 
162
// The 68K has variable length instructions so skipping an instruction
163
// is messy. However __skipinst() is only used for a breakpoint
164
// instruction or for a trap, and these are always 2 bytes.
165
externC void
166
__skipinst(void)
167
{
168
    _registers[PC] += 2;
169
}
170
 
171
#endif

powered by: WebSVN 2.1.0

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