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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [kernel/] [current/] [src/] [debug/] [dbg-thread-demux.c] - Blame information for rev 851

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

Line No. Rev Author Line
1 786 skrzyp
/*==========================================================================
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 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):   nickg
43
// Contributors:
44
// Date:        1998-09-03
45
// Purpose:     GDB Stub ROM system calls
46
// Description:
47
//
48
//####DESCRIPTIONEND####
49
//
50
//========================================================================*/
51
 
52
#include <cyg/hal/hal_arch.h>
53
 
54
/* This file implements system calls out from the ROM debug stub into
55
   the operating environment.
56
   We assume they exist in the same address space.
57
   This file should be linked into your operating environment, your O.S.
58
   or whatever is managing multiple saved process contexts.
59
   Your O.S. needs to implement and provide
60
      dbg_thread_capabilities
61
      dbg_currthread
62
      dbg_threadlist
63
      dbg_threadinfo
64
      dbg_getthreadreg
65
      dbg_setthreadreg
66
 
67
   The debug stub will call this function by calling it indirectly
68
   vis a pre-assigned location possably somthing like a virtual vector table.
69
   Where this is exactly is platform specific.
70
 
71
   The O.S. should call patch_dbg_syscalls() and pass the address of the
72
   location to be patched with the dbg_thread_syscall_rmt function.
73
   Nothing really calls this by name.
74
 
75
   This scheme would also work if we wanted to use a real trapped system call.
76
   */
77
 
78
// -------------------------------------------------------------------------
79
 
80
#include <pkgconf/system.h>             // for CYGPKG... and STARTUP
81
 
82
#include <pkgconf/kernel.h>
83
 
84
#include <cyg/infra/cyg_type.h>
85
 
86
#include "cyg/hal/dbg-threads-api.h"
87
#include "cyg/hal/dbg-thread-syscall.h" 
88
 
89
// -------------------------------------------------------------------------
90
 
91
#ifdef CYGDBG_KERNEL_DEBUG_GDB_THREAD_SUPPORT
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
#endif /* CYGDBG_KERNEL_DEBUG_GDB_THREAD_SUPPORT */
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.