1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
/*==========================================================================
//
// dbg-thread-demux.c
//
// GDB Stub ROM system calls
//
//==========================================================================
// ####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later
// version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License
// along with eCos; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// As a special exception, if other files instantiate templates or use
// macros or inline functions from this file, or you compile this file
// and link it with other works to produce a work based on this file,
// this file does not by itself cause the resulting work to be covered by
// the GNU General Public License. However the source code for this file
// must still be made available in accordance with section (3) of the GNU
// General Public License v2.
//
// This exception does not invalidate any other reasons why a work based
// on this file might be covered by the GNU General Public License.
// -------------------------------------------
// ####ECOSGPLCOPYRIGHTEND####
//==========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): nickg
// Contributors:
// Date: 1998-09-03
// Purpose: GDB Stub ROM system calls
// Description:
//
//####DESCRIPTIONEND####
//
//========================================================================*/
#include <cyg/hal/hal_arch.h>
/* This file implements system calls out from the ROM debug stub into
the operating environment.
We assume they exist in the same address space.
This file should be linked into your operating environment, your O.S.
or whatever is managing multiple saved process contexts.
Your O.S. needs to implement and provide
dbg_thread_capabilities
dbg_currthread
dbg_threadlist
dbg_threadinfo
dbg_getthreadreg
dbg_setthreadreg
The debug stub will call this function by calling it indirectly
vis a pre-assigned location possably somthing like a virtual vector table.
Where this is exactly is platform specific.
The O.S. should call patch_dbg_syscalls() and pass the address of the
location to be patched with the dbg_thread_syscall_rmt function.
Nothing really calls this by name.
This scheme would also work if we wanted to use a real trapped system call.
*/
// -------------------------------------------------------------------------
#include <pkgconf/system.h> // for CYGPKG... and STARTUP
#include <pkgconf/kernel.h>
#include <cyg/infra/cyg_type.h>
#include "cyg/hal/dbg-threads-api.h"
#include "cyg/hal/dbg-thread-syscall.h"
// -------------------------------------------------------------------------
#ifdef CYGDBG_KERNEL_DEBUG_GDB_THREAD_SUPPORT
static int dbg_thread_syscall_rmt(
enum dbg_syscall_ids id,
union dbg_thread_syscall_parms * p
)
{
int ret;
CYGARC_HAL_SAVE_GP();
switch (id)
{
case dbg_null_func :
ret = 1 ; /* test the syscall apparatus */
break;
#ifdef CYGDBG_KERNEL_DEBUG_GDB_THREAD_SUPPORT
case dbg_capabilities_func :
ret = dbg_thread_capabilities(p->cap_parms.abilities) ;
break ;
case dbg_currthread_func :
ret = dbg_currthread(p->currthread_parms.ref) ;
break ;
case dbg_threadlist_func :
ret = dbg_threadlist(p->threadlist_parms.startflag,
p->threadlist_parms.lastid,
p->threadlist_parms.nextthreadid) ;
break ;
case dbg_threadinfo_func :
ret = dbg_threadinfo(p->info_parms.ref,
p->info_parms.info ) ;
break ;
case dbg_getthreadreg_func :
ret = dbg_getthreadreg(p->reg_parms.thread,
p->reg_parms.regcount,
p->reg_parms.registers) ;
break ;
case dbg_setthreadreg_func :
ret = dbg_setthreadreg(p->reg_parms.thread,
p->reg_parms.regcount,
p->reg_parms.registers) ;
break ;
case dbg_scheduler_func :
ret = dbg_scheduler(p->scheduler_parms.thread,
p->scheduler_parms.lock,
p->scheduler_parms.mode) ;
break ;
#endif /* CYGDBG_KERNEL_DEBUG_GDB_THREAD_SUPPORT */
default :
ret = 0 ; /* failure due to non-implementation */
}
CYGARC_HAL_RESTORE_GP();
return ret;
}
#endif /* CYGDBG_KERNEL_DEBUG_GDB_THREAD_SUPPORT */
// Note: This constant is the same as the one defined in hal_if.h:
// #define CYGNUM_CALL_IF_DBG_SYSCALL 15
// But we don't have the hal_if on all the platforms we support this
// intercalling on. Maintaining backwards compatibility is so much fun!
#define DBG_SYSCALL_THREAD_VEC_NUM 15
#ifdef CYGDBG_KERNEL_DEBUG_GDB_THREAD_SUPPORT
#ifdef CYGPKG_HAL_SPARCLITE_SLEB
# include <cyg/hal/hal_cygm.h>
# ifdef CYG_HAL_USE_ROM_MONITOR_CYGMON
// then we support talking to CygMon...
# undef DBG_SYSCALL_THREAD_VEC_NUM
# define DBG_SYSCALL_THREAD_VEC_NUM BSP_VEC_MT_DEBUG
# endif
// otherwise this code is wrong for SPARClite but also not used.
#endif
#endif
void patch_dbg_syscalls(void * vector)
{
dbg_syscall_func * f ;
f = vector ;
#ifdef CYGDBG_KERNEL_DEBUG_GDB_THREAD_SUPPORT
f[DBG_SYSCALL_THREAD_VEC_NUM] = dbg_thread_syscall_rmt ;
#endif
}
// -------------------------------------------------------------------------
// End of dbg-thread-demux.c
|