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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [kernel/] [v2_0/] [src/] [debug/] [dbg-thread-demux.c] - Blame information for rev 757

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

Line No. Rev Author Line
1 27 unneback
/*==========================================================================
2
//
3
//      dbg-thread-demux.c
4
//
5
//      GDB Stub ROM system calls
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
//#####DESCRIPTIONBEGIN####
42
//
43
// Author(s):   nickg
44
// Contributors:
45
// Date:        1998-09-03
46
// Purpose:     GDB Stub ROM system calls
47
// Description:
48
//
49
//####DESCRIPTIONEND####
50
//
51
//========================================================================*/
52
 
53
#include <cyg/hal/hal_arch.h>
54
 
55
/* This file implements system calls out from the ROM debug stub into
56
   the operating environment.
57
   We assume they exist in the same address space.
58
   This file should be linked into your operating environment, your O.S.
59
   or whatever is managing multiple saved process contexts.
60
   Your O.S. needs to implement and provide
61
      dbg_thread_capabilities
62
      dbg_currthread
63
      dbg_threadlist
64
      dbg_threadinfo
65
      dbg_getthreadreg
66
      dbg_setthreadreg
67
 
68
   The debug stub will call this function by calling it indirectly
69
   vis a pre-assigned location possably somthing like a virtual vector table.
70
   Where this is exactly is platform specific.
71
 
72
   The O.S. should call patch_dbg_syscalls() and pass the address of the
73
   location to be patched with the dbg_thread_syscall_rmt function.
74
   Nothing really calls this by name.
75
 
76
   This scheme would also work if we wanted to use a real trapped system call.
77
   */
78
 
79
// -------------------------------------------------------------------------
80
 
81
#include <pkgconf/system.h>             // for CYGPKG... and STARTUP
82
 
83
#include <pkgconf/kernel.h>
84
 
85
#include <cyg/infra/cyg_type.h>
86
 
87
#include "cyg/hal/dbg-threads-api.h"
88
#include "cyg/hal/dbg-thread-syscall.h" 
89
 
90
// -------------------------------------------------------------------------
91
 
92
static int dbg_thread_syscall_rmt(
93
                       enum dbg_syscall_ids id,
94
                       union dbg_thread_syscall_parms * p
95
                       )
96
{
97
    int ret;
98
    CYGARC_HAL_SAVE_GP();
99
    switch (id)
100
    {
101
    case dbg_null_func :
102
        ret = 1 ;  /* test the syscall apparatus */
103
        break;
104
 
105
#ifdef CYGDBG_KERNEL_DEBUG_GDB_THREAD_SUPPORT
106
    case dbg_capabilities_func :
107
        ret = dbg_thread_capabilities(p->cap_parms.abilities) ;
108
        break ;
109
    case dbg_currthread_func :
110
        ret = dbg_currthread(p->currthread_parms.ref) ;
111
        break ;
112
    case dbg_threadlist_func :
113
        ret = dbg_threadlist(p->threadlist_parms.startflag,
114
                             p->threadlist_parms.lastid,
115
                             p->threadlist_parms.nextthreadid) ;
116
        break ;
117
    case dbg_threadinfo_func :
118
        ret = dbg_threadinfo(p->info_parms.ref,
119
                             p->info_parms.info ) ;
120
        break ;
121
    case dbg_getthreadreg_func :
122
        ret = dbg_getthreadreg(p->reg_parms.thread,
123
                               p->reg_parms.regcount,
124
                               p->reg_parms.registers) ;
125
        break ;
126
    case dbg_setthreadreg_func :
127
        ret = dbg_setthreadreg(p->reg_parms.thread,
128
                               p->reg_parms.regcount,
129
                               p->reg_parms.registers) ;
130
        break ;
131
    case dbg_scheduler_func :
132
        ret = dbg_scheduler(p->scheduler_parms.thread,
133
                            p->scheduler_parms.lock,
134
                            p->scheduler_parms.mode) ;
135
        break ;
136
#endif /* CYGDBG_KERNEL_DEBUG_GDB_THREAD_SUPPORT */      
137
    default :
138
        ret = 0 ;  /* failure due to non-implementation */
139
    }
140
    CYGARC_HAL_RESTORE_GP();
141
    return ret;
142
}
143
 
144
 
145
// Note: This constant is the same as the one defined in hal_if.h:
146
// #define CYGNUM_CALL_IF_DBG_SYSCALL                15
147
// But we don't have the hal_if on all the platforms we support this
148
// intercalling on. Maintaining backwards compatibility is so much fun!
149
 
150
#define DBG_SYSCALL_THREAD_VEC_NUM 15
151
 
152
#ifdef CYGDBG_KERNEL_DEBUG_GDB_THREAD_SUPPORT
153
 
154
#ifdef CYGPKG_HAL_SPARCLITE_SLEB
155
# include <cyg/hal/hal_cygm.h>
156
# ifdef CYG_HAL_USE_ROM_MONITOR_CYGMON
157
// then we support talking to CygMon...
158
#  undef DBG_SYSCALL_THREAD_VEC_NUM
159
#  define DBG_SYSCALL_THREAD_VEC_NUM BSP_VEC_MT_DEBUG
160
# endif
161
// otherwise this code is wrong for SPARClite but also not used.
162
#endif
163
 
164
#endif
165
 
166
void patch_dbg_syscalls(void * vector)
167
{
168
   dbg_syscall_func * f ;
169
   f = vector ;
170
 
171
#ifdef CYGDBG_KERNEL_DEBUG_GDB_THREAD_SUPPORT
172
 
173
   f[DBG_SYSCALL_THREAD_VEC_NUM] = dbg_thread_syscall_rmt ;
174
 
175
#endif
176
 
177
}
178
 
179
// -------------------------------------------------------------------------
180
// End of dbg-thread-demux.c

powered by: WebSVN 2.1.0

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