Mercurial > ecos
comparison packages/kernel/current/src/debug/dbg-thread-demux.c @ 0:3111d98ba7b3 ecos-v1_1-release
Initial commit of eCos version 1.1
| author | jlarmour |
|---|---|
| date | Tue, 11 May 1999 11:16:07 +0000 |
| parents | |
| children | 443894e2e912 |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:3111d98ba7b3 |
|---|---|
| 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 | |
| 25 // by Cygnus are Copyright (C) 1998 Cygnus Solutions. All Rights Reserved. | |
| 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 | |
| 69 #include <pkgconf/kernel.h> | |
| 70 | |
| 71 #include "cyg/hal/dbg-threads-api.h" | |
| 72 #include "dbg-thread-syscall.h" | |
| 73 | |
| 74 // ------------------------------------------------------------------------- | |
| 75 | |
| 76 static int dbg_thread_syscall_rmt( | |
| 77 enum dbg_syscall_ids id, | |
| 78 union dbg_thread_syscall_parms * p | |
| 79 ) | |
| 80 { | |
| 81 switch (id) | |
| 82 { | |
| 83 case dbg_null_func : return 1 ; /* test the syscall apparatus */ | |
| 84 | |
| 85 #ifdef CYGDBG_KERNEL_DEBUG_GDB_THREAD_SUPPORT | |
| 86 case dbg_capabilities_func : | |
| 87 return dbg_thread_capabilities(p->cap_parms.abilities) ; | |
| 88 break ; | |
| 89 case dbg_currthread_func : | |
| 90 return dbg_currthread(p->currthread_parms.ref) ; | |
| 91 break ; | |
| 92 case dbg_threadlist_func : | |
| 93 return dbg_threadlist(p->threadlist_parms.startflag, | |
| 94 p->threadlist_parms.lastid, | |
| 95 p->threadlist_parms.nextthreadid) ; | |
| 96 break ; | |
| 97 case dbg_threadinfo_func : | |
| 98 return dbg_threadinfo(p->info_parms.ref, | |
| 99 p->info_parms.info | |
| 100 ) ; | |
| 101 break ; | |
| 102 case dbg_getthreadreg_func : | |
| 103 return dbg_getthreadreg(p->reg_parms.thread, | |
| 104 p->reg_parms.regcount, | |
| 105 p->reg_parms.registers) ; | |
| 106 break ; | |
| 107 case dbg_setthreadreg_func : | |
| 108 return dbg_setthreadreg(p->reg_parms.thread, | |
| 109 p->reg_parms.regcount, | |
| 110 p->reg_parms.registers) ; | |
| 111 break ; | |
| 112 #endif /* CYGDBG_KERNEL_DEBUG_GDB_THREAD_SUPPORT */ | |
| 113 default : | |
| 114 return 0 ; /* failure tue to non-implementation */ | |
| 115 } | |
| 116 } | |
| 117 | |
| 118 // ------------------------------------------------------------------------- | |
| 119 // When Cygmon calls us on the TX39 It has its own value in GP. We need to | |
| 120 // save that and set our own before proceeding. | |
| 121 | |
| 122 #ifdef CYG_HAL_TX39 | |
| 123 static int dbg_thread_syscall_rmt_1( | |
| 124 enum dbg_syscall_ids id, | |
| 125 union dbg_thread_syscall_parms * p | |
| 126 ) | |
| 127 { | |
| 128 | |
| 129 register long gp_save; | |
| 130 int r; | |
| 131 asm ( "move %0,$28;" | |
| 132 ".extern _gp;" | |
| 133 "la $gp,_gp;" | |
| 134 : "=r"(gp_save) | |
| 135 ); | |
| 136 | |
| 137 r = dbg_thread_syscall_rmt( id, p ); | |
| 138 | |
| 139 asm ( "move $gp,%0;" :: "r"(gp_save) ); | |
| 140 | |
| 141 return r; | |
| 142 | |
| 143 } | |
| 144 #endif | |
| 145 | |
| 146 // ------------------------------------------------------------------------- | |
| 147 | |
| 148 void patch_dbg_syscalls(void * vector) | |
| 149 { | |
| 150 dbg_syscall_func * f ; | |
| 151 f = vector ; | |
| 152 #ifdef CYG_HAL_TX39 | |
| 153 *f = dbg_thread_syscall_rmt_1 ; | |
| 154 #else | |
| 155 *f = dbg_thread_syscall_rmt ; | |
| 156 #endif | |
| 157 } | |
| 158 | |
| 159 // ------------------------------------------------------------------------- | |
| 160 // End of dbg-thread-demux.c |
