comparison packages/hal/common/current/src/dbg-threads-syscall.c @ 6:d376b777e2ce ecos-sw-1999-05-14

Merge from eCos master repository on 1999-05-14-19:27:43-BST
author jlarmour
date Fri, 14 May 1999 12:20:00 +0000
parents
children e97d78785e2d
comparison
equal deleted inserted replaced
5:4e8259f41183 6:d376b777e2ce
1
2 /* pseudo system calls to bind system specific multithread debug support
3 with a ROM monitor, cygmon.
4 We call it Cygmon, but the feature lives in libstub.
5 */
6
7 /*
8 * Copyright (c) 1998, 1999 Cygnus Solutions
9 *
10 * The contents of this file are subject to the Cygnus eCos Public
11 * License Version 1.0 (the "License"); you may not use this file
12 * except in compliance with the License. You may obtain a copy of
13 * the License at http://sourceware.cygnus.com/ecos/
14 *
15 * Software distributed under the License is distributed on an
16 * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
17 * implied. See the License for the specific language governing rights
18 * and limitations under the License.
19 *
20 * The Original Code is eCos - Embedded Cygnus Operating System,
21 * released September 30, 1998. The Initial Developer of the Original
22 * Code is Cygnus. Portions created by Cygnus are Copyright (C) 1998
23 * Cygnus Solutions. All Rights Reserved.
24 */
25
26 #include <pkgconf/system.h>
27 #include <pkgconf/hal.h>
28
29 #if !defined(CYGPKG_KERNEL) && defined(CYGDBG_HAL_DEBUG_GDB_THREAD_SUPPORT)
30
31 /* Only include this code if we do not have a kernel. Otherwise the kernel
32 * supplies these functions for the app we are linked with.
33 */
34
35 #include <cyg/hal/dbg-threads-api.h>
36 #include <cyg/hal/dbg-thread-syscall.h>
37
38
39 static dbg_syscall_func * dbg_syscall_ptr ;
40
41 static union dbg_thread_syscall_parms tcall ;
42
43 /* ----- INIT_THREADS_SYSCALL --------------------------------------- */
44 /* Some external bing and configuration logic knows how to setup
45 the ststem calls. In the first implementation, we have used a vector
46 in the secondary vector table. This functions allows us to isolate that
47 sort of system specific detail. Similarly, we do not export the
48 specific detail of a dbg_syscall_func.
49 */
50
51
52 void init_threads_syscall(void * vector)
53 {
54 dbg_syscall_ptr = vector ; /* AH, the easy compatability of the
55 void pointer*/
56 } /* init_threads_syscall */
57
58 /* All forms of failure return 0 */
59 /* Whether non support, incomplete initialization, unknown thread */
60 static __inline__ int dbg_thread_syscall(
61 enum dbg_syscall_ids id)
62 {
63 dbg_syscall_func f ; /* double indirect via */
64 if (0 ==(f = *dbg_syscall_ptr)) return 0 ; /* no pointer to vector */
65 if (0 == *f) return 0 ; /* vector not initialized */
66 return (*f)(id,&tcall);
67 }
68
69
70
71
72 /* ------- INIT_THREAD_SYSCALL ------------------------------------------- */
73 /* Received the address of the entry in the secondary interrupt vector table */
74 /* This table is the interchange between the O.S. and Cygmon/libstub */
75 /* This could get more complex so, I am doing it with a function
76 rather than exposing the internals.
77 */
78 void init_thread_syscall(void * vector)
79 {
80 dbg_syscall_ptr = vector ;
81 }
82
83 int dbg_thread_capabilities(struct dbg_capabilities * cbp)
84 {
85 #if 0
86 tcall.cap_parms.abilities = cbp ;
87 return dbg_thread_syscall(dbg_capabilities_func) ;
88 #else
89 cbp->mask1 = has_thread_current |
90 has_thread_registers |
91 has_thread_reg_change |
92 has_thread_list |
93 has_thread_info ;
94 return 1 ;
95 #endif
96 }
97
98 int dbg_currthread(threadref * varparm)
99 {
100 tcall.currthread_parms.ref = varparm ;
101 return dbg_thread_syscall(dbg_currthread_func) ;
102 }
103
104
105 int dbg_threadlist(
106 int startflag,
107 threadref * lastthreadid,
108 threadref * next_thread
109 )
110 {
111 tcall.threadlist_parms.startflag = startflag ;
112 tcall.threadlist_parms.lastid = lastthreadid ;
113 tcall.threadlist_parms.nextthreadid = next_thread ;
114 return dbg_thread_syscall(dbg_threadlist_func) ;
115 }
116
117 int dbg_threadinfo(
118 threadref * threadid,
119 struct cygmon_thread_debug_info * info)
120 {
121 tcall.info_parms.ref = threadid ;
122 tcall.info_parms.info = info ;
123 return dbg_thread_syscall(dbg_threadinfo_func) ;
124 }
125
126 int dbg_getthreadreg(
127 threadref * osthreadid,
128 int regcount, /* count of registers in the array */
129 void * regval) /* fillin this array */
130 {
131 tcall.reg_parms.thread = osthreadid ;
132 tcall.reg_parms.regcount = regcount ;
133 tcall.reg_parms.registers = regval ;
134 return dbg_thread_syscall(dbg_getthreadreg_func) ;
135 }
136
137 int dbg_setthreadreg(
138 threadref * osthreadid,
139 int regcount , /* number of registers */
140 void * regval)
141 {
142 tcall.reg_parms.thread = osthreadid ;
143 tcall.reg_parms.regcount = regcount ;
144 tcall.reg_parms.registers = regval ;
145 return dbg_thread_syscall(dbg_setthreadreg_func) ;
146 } /* dbg_setthreadreg */
147
148 int dbg_scheduler(threadref *thread_id, int lock, int mode)
149 {
150 tcall.scheduler_parms.thread = thread_id;
151 tcall.scheduler_parms.lock = lock ;
152 tcall.scheduler_parms.mode = mode ;
153
154 return dbg_thread_syscall(dbg_scheduler_func) ;
155 }
156
157
158
159 #if (CYG_BYTEORDER == CYG_LSBFIRST)
160
161 unsigned long swap32(unsigned long x)
162 {
163 unsigned long r = 0;
164
165 r |= (x>>24)&0xFF;
166 r |= ((x>>16)&0xFF)<<8;
167 r |= ((x>>8)&0xFF)<<16;
168 r |= ((x)&0xFF)<<24;
169
170 return r;
171 }
172
173 #else
174
175 #define swap32(x) ((unsigned long)(x))
176
177 #endif
178
179 int dbg_currthread_id(void)
180 {
181 threadref ref;
182 dbg_currthread( &ref );
183
184 return (cyg_uint16)swap32(((unsigned long *)ref)[1]);
185 }
186
187 #endif