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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [cygmon/] [v2_0/] [misc/] [arm/] [arm-mon.c] - Blame information for rev 559

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

Line No. Rev Author Line
1 27 unneback
//==========================================================================
2
//
3
//      arm-mon.c
4
//
5
//      Support code to extend the generic monitor code to support
6
//      ARM(R) processors.
7
//
8
//==========================================================================
9
//####ECOSGPLCOPYRIGHTBEGIN####
10
// -------------------------------------------
11
// This file is part of eCos, the Embedded Configurable Operating System.
12
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
13
//
14
// eCos is free software; you can redistribute it and/or modify it under
15
// the terms of the GNU General Public License as published by the Free
16
// Software Foundation; either version 2 or (at your option) any later version.
17
//
18
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
19
// 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 along
24
// with eCos; if not, write to the Free Software Foundation, Inc.,
25
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
26
//
27
// As a special exception, if other files instantiate templates or use macros
28
// or inline functions from this file, or you compile this file and link it
29
// with other works to produce a work based on this file, this file does not
30
// by itself cause the resulting work to be covered by the GNU General Public
31
// License. However the source code for this file must still be made available
32
// in accordance with section (3) of the GNU General Public License.
33
//
34
// This exception does not invalidate any other reasons why a work based on
35
// this file might be covered by the GNU General Public License.
36
//
37
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
38
// at http://sources.redhat.com/ecos/ecos-license/
39
// -------------------------------------------
40
//####ECOSGPLCOPYRIGHTEND####
41
//==========================================================================
42
//#####DESCRIPTIONBEGIN####
43
//
44
// Author(s):    
45
// Contributors: gthomas
46
// Date:         1999-10-20
47
// Purpose:      Support code to extend the generic monitor code to support
48
//               ARM(R) processors.
49
// Description:  Further board specific support is in other files.
50
//               This file contains:
51
//                 register names lookup table
52
//
53
//               Empty Stubs:
54
//                 Interval timer - This should really belong to the application
55
//                 operating system.
56
//
57
//               Should not contain:
58
//                 low level uart getchar and putchar functions
59
//                 delay function to support uart
60
//
61
//               ARM is a Registered Trademark of Advanced RISC Machines
62
//               Limited.
63
//               Other Brands and Trademarks are the property of their
64
//               respective owners.               
65
//
66
//####DESCRIPTIONEND####
67
//
68
//=========================================================================
69
 
70
#include <setjmp.h>
71
#include <bsp/bsp.h>
72
#include <bsp/cpu.h>
73
#ifdef DISASSEMBLER
74
#include <dis-asm.h>
75
#endif
76
 
77
#include "cpu_info.h"
78
#include "monitor.h"
79
 
80
/* This module is required to provide many of the services defined
81
   in tservice.h */
82
 
83
static char *apcs_names[] = {
84
  "a1", "a2", "a3", "a4",
85
  "v1", "v2", "v3", "v4",
86
  "v5", "v6", "sl", "fp",
87
  "ip", "sp", "lr", "pc",
88
#if HAVE_FLOAT_REGS
89
  "f0", "f1", "f2", "f3",
90
  "f4", "f5", "f6", "f7",
91
  "fps",
92
#endif
93
  "ps"
94
};
95
 
96
static char *standard_names[] =
97
{
98
  "r0",  "r1",  "r2",  "r3",
99
  "r4",  "r5",  "r6",  "r7",
100
  "r8",  "r9",  "r10", "r11",
101
  "r12", "r13", "r14", "pc",
102
#if HAVE_FLOAT_REGS
103
  "f0",  "f1",  "f2",  "f3",
104
  "f4",  "f5",  "f6",  "f7",
105
  "fps",
106
#endif
107
  "ps",
108
};
109
 
110
 
111
void arm_othernames (void);
112
 
113
struct regstruct regtab[] =
114
{
115
  { 0, REG_R0,   REGTYPE_INT   },
116
  { 0, REG_R1,   REGTYPE_INT   },
117
  { 0, REG_R2,   REGTYPE_INT   },
118
  { 0, REG_R3,   REGTYPE_INT   },
119
  { 0, REG_R4,   REGTYPE_INT   },
120
  { 0, REG_R5,   REGTYPE_INT   },
121
  { 0, REG_R6,   REGTYPE_INT   },
122
  { 0, REG_R7,   REGTYPE_INT   },
123
  { 0, REG_R8,   REGTYPE_INT   },
124
  { 0, REG_R9,   REGTYPE_INT   },
125
  { 0, REG_R10,  REGTYPE_INT   },
126
  { 0, REG_R11,  REGTYPE_INT   },
127
  { 0, REG_R12,  REGTYPE_INT   },
128
  { 0, REG_SP,   REGTYPE_INT   },
129
  { 0, REG_LR,   REGTYPE_INT   },
130
  { 0, REG_PC,   REGTYPE_INT   },
131
#if HAVE_FLOAT_REGS
132
  { 0, REG_F0,   REGTYPE_FLOAT },
133
  { 0, REG_F1,   REGTYPE_FLOAT },
134
  { 0, REG_F2,   REGTYPE_FLOAT },
135
  { 0, REG_F3,   REGTYPE_FLOAT },
136
  { 0, REG_F4,   REGTYPE_FLOAT },
137
  { 0, REG_F5,   REGTYPE_FLOAT },
138
  { 0, REG_F6,   REGTYPE_FLOAT },
139
  { 0, REG_F6,   REGTYPE_FLOAT },
140
  { 0, REG_FPS,  REGTYPE_FLOAT },
141
#endif
142
  { 0, REG_CPSR, REGTYPE_INT   },
143
  { 0, 0,        0             } /* Terminating element must be last */
144
} ;
145
 
146
void
147
initialize_mon(void)
148
{
149
  /* FIXME: Convert ALL variable initializations to assignments
150
     in order to support ROMABLE CODE.
151
     This includes the register table
152
     */
153
 
154
  /*
155
   * Call arm_othernames to sync up Cygmon and the disassembler
156
   * and ensure they are using the same set of registernames
157
   */
158
  arm_othernames();
159
 
160
  /*
161
   * Call arm_othernames again to revert to the assembler
162
   * default names
163
   */
164
  arm_othernames();
165
 
166
} /* initialize_mon */
167
 
168
 
169
/*
170
  read_memory
171
  write_memory
172
       Defaults to generic_mem.c
173
       */
174
 
175
 
176
/* SET_BREAKPOINT -
177
   CLEAR_BREAKPOINT
178
   Defaults to generic_bp32.c
179
   */
180
 
181
 
182
#ifndef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
183
 
184
/* Return the currently-saved value corresponding to register "regnum". */
185
target_regval_t
186
get_register (int regnum)
187
{
188
    struct regstruct *p;
189
    target_regval_t reg;
190
    int   offset, len;
191
    char  *dest = (char*)0;
192
 
193
    for (p = regtab; p->registername && p->registernumber != regnum; ++p)
194
        ;
195
 
196
    if (p->registername) {
197
        len = bsp_regsize(p->registernumber);
198
        offset = bsp_regbyte(p->registernumber);
199
        switch (p->registertype) {
200
          case REGTYPE_INT:
201
            dest = (char*)&(reg.i);
202
            break;
203
#if HAVE_FLOAT_REGS
204
        case REGTYPE_FLOAT:
205
            dest = (char*)&(reg.f);
206
            break;
207
#endif
208
#if HAVE_DOUBLE_REGS
209
        case REGTYPE_DOUBLE:
210
            dest = (char*)&(reg.d);
211
            break;
212
#endif
213
        }
214
        if (dest)
215
            memcpy(dest, (char *)mon_saved_regs + offset, len);
216
    } else
217
        reg.i = 0;
218
 
219
    return reg;
220
}
221
 
222
 
223
 
224
/* Store VALUE in the register corresponding to REGNUM. */
225
void
226
put_register (int regnum, target_regval_t value)
227
{
228
    int   offset, len;
229
 
230
    len = bsp_regsize(regnum);
231
    offset = bsp_regbyte(regnum);
232
    memcpy((char *)mon_saved_regs + offset, &value, len);
233
}
234
 
235
#endif // !CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
236
 
237
/* Change to the alternate register set names */
238
void
239
arm_othernames (void)
240
{
241
    static int regset = 1;
242
    char **name;
243
    int  i;
244
 
245
#ifdef DISASSEMBLER
246
    /* Change the disassembler */
247
    regset = arm_toggle_regnames();
248
#else
249
    regset = (regset == 0) ? 1 : 0;
250
#endif
251
 
252
    /* Change cygmon */
253
    if (regset == 1)
254
        /* Disassembler is using apcs names. */
255
        name = apcs_names;
256
    else
257
        /* Disassembler is using standard names. */
258
        name = standard_names;
259
 
260
    for (i = 0; i < (sizeof(apcs_names)/sizeof(apcs_names[0])); i++)
261
        regtab[i].registername = name[i];
262
}
263
 
264
#ifdef __ECOS__
265
 
266
#include <pkgconf/hal.h>
267
#include <cyg/hal/hal_arch.h>
268
#include "bsp/common/bsp_if.h"
269
 
270
int
271
machine_syscall(HAL_SavedRegisters *regs)
272
{
273
    int res, err;
274
    err = _bsp_do_syscall(regs->d[0], // Function
275
                          regs->d[1], regs->d[2], regs->d[3], 0, // arguments,
276
                          &res);
277
    regs->d[0] = res;
278
    regs->pc += 4;  // Advance PC
279
    return err;
280
}
281
#endif

powered by: WebSVN 2.1.0

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