|
0
|
1 /*========================================================================== |
|
|
2 // |
|
|
3 // dbg-thread-demux.c |
|
|
4 // |
|
|
5 // GDB Stub ROM system calls |
|
|
6 // |
|
|
7 //========================================================================== |
|
|
8 //####COPYRIGHTBEGIN#### |
|
|
9 // |
|
|
10 // ------------------------------------------- |
|
|
11 // The contents of this file are subject to the Cygnus eCos Public License |
|
|
12 // Version 1.0 (the "License"); you may not use this file except in |
|
|
13 // compliance with the License. You may obtain a copy of the License at |
|
|
14 // http://sourceware.cygnus.com/ecos |
|
|
15 // |
|
|
16 // Software distributed under the License is distributed on an "AS IS" |
|
|
17 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the |
|
|
18 // License for the specific language governing rights and limitations under |
|
|
19 // the License. |
|
|
20 // |
|
|
21 // The Original Code is eCos - Embedded Cygnus Operating System, released |
|
|
22 // September 30, 1998. |
|
|
23 // |
|
|
24 // The Initial Developer of the Original Code is Cygnus. Portions created |
|
2
|
25 // by Cygnus are Copyright (C) 1998,1999 Cygnus Solutions. All Rights Reserved. |
|
0
|
26 // ------------------------------------------- |
|
|
27 // |
|
|
28 //####COPYRIGHTEND#### |
|
|
29 //========================================================================== |
|
|
30 //#####DESCRIPTIONBEGIN#### |
|
|
31 // |
|
|
32 // Author(s): nickg |
|
|
33 // Contributors: |
|
|
34 // Date: 1998-09-03 |
|
|
35 // Purpose: GDB Stub ROM system calls |
|
|
36 // Description: |
|
|
37 // |
|
|
38 //####DESCRIPTIONEND#### |
|
|
39 // |
|
|
40 //========================================================================*/ |
|
|
41 |
|
|
42 |
|
|
43 /* This file implements system calls out from the ROM debug stub into |
|
|
44 the operating environment. |
|
|
45 We assume they exist in the same address space. |
|
|
46 This file should be linked into your operating environment, your O.S. |
|
|
47 or whatever is managing multiple saved process contexts. |
|
|
48 Your O.S. needs to implement and provide |
|
|
49 dbg_thread_capabilities |
|
|
50 dbg_currthread |
|
|
51 dbg_threadlist |
|
|
52 dbg_threadinfo |
|
|
53 dbg_getthreadreg |
|
|
54 dbg_setthreadreg |
|
|
55 |
|
|
56 The debug stub will call this function by calling it indirectly |
|
|
57 vis a pre-assigned location possably somthing like a virtual vector table. |
|
|
58 Where this is exactly is platform specific. |
|
|
59 |
|
|
60 The O.S. should call patch_dbg_syscalls() and pass the address of the |
|
|
61 location to be patched with the dbg_thread_syscall_rmt function. |
|
|
62 Nothing really calls this by name. |
|
|
63 |
|
|
64 This scheme would also work if we wanted to use a real trapped system call. |
|
|
65 */ |
|
|
66 |
|
|
67 // ------------------------------------------------------------------------- |
|
|
68 |
|
2
|
69 #include <pkgconf/system.h> // for CYGPKG... and STARTUP |
|
|
70 |
|
0
|
71 #include <pkgconf/kernel.h> |
|
|
72 |
|
2
|
73 #include <cyg/infra/cyg_type.h> |
|
|
74 |
|
0
|
75 #include "cyg/hal/dbg-threads-api.h" |
|
|
76 #include "dbg-thread-syscall.h" |
|
|
77 |
|
|
78 // ------------------------------------------------------------------------- |
|
|
79 |
|
|
80 static int dbg_thread_syscall_rmt( |
|
2
|
81 enum dbg_syscall_ids id, |
|
|
82 union dbg_thread_syscall_parms * p |
|
|
83 ) |
|
0
|
84 { |
|
|
85 switch (id) |
|
|
86 { |
|
|
87 case dbg_null_func : return 1 ; /* test the syscall apparatus */ |
|
|
88 |
|
|
89 #ifdef CYGDBG_KERNEL_DEBUG_GDB_THREAD_SUPPORT |
|
|
90 case dbg_capabilities_func : |
|
|
91 return dbg_thread_capabilities(p->cap_parms.abilities) ; |
|
|
92 break ; |
|
|
93 case dbg_currthread_func : |
|
|
94 return dbg_currthread(p->currthread_parms.ref) ; |
|
|
95 break ; |
|
|
96 case dbg_threadlist_func : |
|
|
97 return dbg_threadlist(p->threadlist_parms.startflag, |
|
2
|
98 p->threadlist_parms.lastid, |
|
|
99 p->threadlist_parms.nextthreadid) ; |
|
0
|
100 break ; |
|
|
101 case dbg_threadinfo_func : |
|
|
102 return dbg_threadinfo(p->info_parms.ref, |
|
2
|
103 p->info_parms.info |
|
|
104 ) ; |
|
0
|
105 break ; |
|
|
106 case dbg_getthreadreg_func : |
|
|
107 return dbg_getthreadreg(p->reg_parms.thread, |
|
2
|
108 p->reg_parms.regcount, |
|
|
109 p->reg_parms.registers) ; |
|
0
|
110 break ; |
|
|
111 case dbg_setthreadreg_func : |
|
|
112 return dbg_setthreadreg(p->reg_parms.thread, |
|
2
|
113 p->reg_parms.regcount, |
|
|
114 p->reg_parms.registers) ; |
|
|
115 break ; |
|
|
116 case dbg_scheduler_func : |
|
|
117 return dbg_scheduler(p->scheduler_parms.thread, |
|
|
118 p->scheduler_parms.lock, |
|
|
119 p->scheduler_parms.mode) ; |
|
0
|
120 break ; |
|
|
121 #endif /* CYGDBG_KERNEL_DEBUG_GDB_THREAD_SUPPORT */ |
|
|
122 default : |
|
|
123 return 0 ; /* failure tue to non-implementation */ |
|
|
124 } |
|
|
125 } |
|
|
126 |
|
|
127 // ------------------------------------------------------------------------- |
|
|
128 // When Cygmon calls us on the TX39 It has its own value in GP. We need to |
|
|
129 // save that and set our own before proceeding. |
|
|
130 |
|
|
131 #ifdef CYG_HAL_TX39 |
|
|
132 static int dbg_thread_syscall_rmt_1( |
|
2
|
133 enum dbg_syscall_ids id, |
|
|
134 union dbg_thread_syscall_parms * p |
|
|
135 ) |
|
0
|
136 { |
|
|
137 |
|
|
138 register long gp_save; |
|
|
139 int r; |
|
|
140 asm ( "move %0,$28;" |
|
|
141 ".extern _gp;" |
|
|
142 "la $gp,_gp;" |
|
|
143 : "=r"(gp_save) |
|
|
144 ); |
|
|
145 |
|
|
146 r = dbg_thread_syscall_rmt( id, p ); |
|
|
147 |
|
|
148 asm ( "move $gp,%0;" :: "r"(gp_save) ); |
|
|
149 |
|
|
150 return r; |
|
|
151 |
|
|
152 } |
|
|
153 #endif |
|
|
154 |
|
|
155 // ------------------------------------------------------------------------- |
|
|
156 |
|
2
|
157 #define DBG_SYSCALL_THREAD_VEC_NUM 15 |
|
|
158 |
|
|
159 #ifdef CYGDBG_KERNEL_DEBUG_GDB_THREAD_SUPPORT |
|
|
160 |
|
|
161 #ifdef CYG_HAL_SPARCLITE_SLEB |
|
|
162 # include <cyg/hal/hal_cygm.h> |
|
|
163 # ifdef CYG_HAL_USE_ROM_MONITOR_CYGMON |
|
|
164 // then we support talking to CygMon... |
|
|
165 # undef DBG_SYSCALL_THREAD_VEC_NUM |
|
|
166 # define DBG_SYSCALL_THREAD_VEC_NUM BSP_VEC_MT_DEBUG |
|
|
167 # endif |
|
|
168 // otherwise this code is wrong for SPARClite but also not used. |
|
|
169 #endif |
|
|
170 |
|
|
171 #endif |
|
|
172 |
|
0
|
173 void patch_dbg_syscalls(void * vector) |
|
|
174 { |
|
|
175 dbg_syscall_func * f ; |
|
|
176 f = vector ; |
|
2
|
177 |
|
|
178 #ifdef CYGDBG_KERNEL_DEBUG_GDB_THREAD_SUPPORT |
|
|
179 |
|
0
|
180 #ifdef CYG_HAL_TX39 |
|
2
|
181 f[DBG_SYSCALL_THREAD_VEC_NUM] = dbg_thread_syscall_rmt_1 ; |
|
0
|
182 #else |
|
2
|
183 f[DBG_SYSCALL_THREAD_VEC_NUM] = dbg_thread_syscall_rmt ; |
|
|
184 #endif |
|
|
185 |
|
|
186 #endif |
|
|
187 |
|
0
|
188 } |
|
|
189 |
|
|
190 // ------------------------------------------------------------------------- |
|
|
191 // End of dbg-thread-demux.c |