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 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
|
/*
debugger.h - necessary definition for skyeye debugger
Copyright (C) 2003 Skyeye Develop Group
for help please send mail to <skyeye-developer@lists.sf.linuxforum.net>
This program 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 of the License, or
(at your option) any later version.
This program 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 this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* 12/04/2005 ksh <blacfin.kang@gmail.com>
* */
//koodailar add for mingw 2005.12.18 ----------------------------------------
#ifdef __MINGW32__
#include "arch/arm/common/armdefs.h"
#else
#include "armdefs.h"
#endif
// end ----------------------------------------------------------------------
#include "skyeye_types.h"
#include "arm_regdefs.h"
#include "bfin_regdefs.h"
#include "memory.h"
#include "cf_regdefs.h"
#include "armemu.h"
#include "skyeye2gdb.h"
#include <stdint.h>
extern struct ARMul_State * state;
extern struct _memory_core memory_core;
extern generic_arch_t * arch_instance;
int bigendSig;
int get_regnum(){
if(!strcmp(skyeye_config.arch->arch_name, "arm"))
return ARM_REGNUM;
if(!strcmp(skyeye_config.arch->arch_name, "blackfin"))
return BFIN_NUM_REGS;
if(!strcmp(skyeye_config.arch->arch_name, "coldfire"))
return CF_REGNUM;
}
static int
frommem (unsigned char *memory)
{
if (bigendSig == HIGH) {
return (memory[0] << 24)
| (memory[1] << 16) | (memory[2] << 8) | (memory[3] <<
0);
}
else {
return (memory[3] << 24)
| (memory[2] << 16) | (memory[1] << 8) | (memory[0] <<
0);
}
}
static void
tomem (unsigned char *memory, int val)
{
if (bigendSig == HIGH) {
memory[0] = val >> 24;
memory[1] = val >> 16;
memory[2] = val >> 8;
memory[3] = val >> 0;
}
else {
memory[3] = val >> 24;
memory[2] = val >> 16;
memory[1] = val >> 8;
memory[0] = val >> 0;
}
}
#if 0
ARMword
ARMul_Debug (ARMul_State * state, ARMword pc ATTRIBUTE_UNUSED,
ARMword instr ATTRIBUTE_UNUSED)
{
state->Emulate = STOP;
stop_simulator = 1;
return 1;
}
#endif
//chy 2006-04-12
int sim_ice_breakpoint_insert(ARMword addr)
{
int i;
for(i = 0; i < skyeye_ice.num_bps; i++) {
if (skyeye_ice.bps[i] == addr)
return 1;
}
if (skyeye_ice.num_bps >= MAX_BREAKPOINTS)
return -1;
skyeye_ice.bps[skyeye_ice.num_bps++] = addr;
return 0;
}
int sim_ice_breakpoint_remove(ARMword addr)
{
int i;
for(i = 0; i < skyeye_ice.num_bps; i++) {
if (skyeye_ice.bps[i] == addr)
goto found;
}
return 0;
found:
skyeye_ice.num_bps--;
if (i < skyeye_ice.num_bps)
skyeye_ice.bps[i] = skyeye_ice.bps[skyeye_ice.num_bps];
return 1;
}
int
sim_write (ARMword addr, unsigned char *buffer, int size)
{
int i;
int fault=0;
for (i = 0; i < size; i++) {
fault=arch_instance->ICE_write_byte(addr + i, buffer[i]);
if(fault) return -1;
}
return size;
}
int
sim_read (ARMword addr, unsigned char *buffer, int size)
{
int i;
int fault=0;
unsigned char v;
for (i = 0; i < size; i++) {
fault=arch_instance->ICE_read_byte(addr + i, &v);
if(fault) return -1;
buffer[i]=v;
}
return size;
}
int
sim_store_register (int rn, unsigned char *memory)
{
if(!strcmp(skyeye_config.arch->arch_name, "arm")){
bigendSig = state->bigendSig;
ARMul_SetReg (state, state->Mode, rn, frommem (memory));
}
else if(!strcmp(skyeye_config.arch->arch_name, "blackfin")){}
else if(!strcmp(skyeye_config.arch->arch_name, "coldfire")){
WORD val = frommem(memory);
if(0 <= rn < 8){
memory_core.d[rn] = val ;
}
else if(8 <= rn < 16 ){
memory_core.a[rn-8] = val ;
}
else if(16 == rn){
memory_core.sr = val;
}
else if(17 == rn){
memory_core.pc = val;
}
}
return -1;
}
int
sim_fetch_register (int rn, unsigned char *memory)
{
WORD regval;
if(!strcmp(skyeye_config.arch->arch_name,"arm")){
bigendSig = state->bigendSig;
if (rn < 16)
regval = ARMul_GetReg (state, state->Mode, rn);
else if (rn == 25) /* FIXME: use PS_REGNUM from gdb/config/arm/tm-arm.h */
regval = ARMul_GetCPSR (state);
else
regval = 0; /* FIXME: should report an error */
}
else if(!strcmp(skyeye_config.arch->arch_name,"blackfin")){
}
/*
coldfire register definition
static char *register_names[] = {
"d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7",
"a0", "a1", "a2", "a3", "a4", "a5", "fp", "sp",
"ps", "pc",
"fp0", "fp1", "fp2", "fp3", "fp4", "fp5", "fp6", "fp7",
"fpcontrol", "fpstatus", "fpiaddr", "fpcode", "fpflags"
};
*/
else if (!strcmp(skyeye_config.arch->arch_name,"coldfire")){
if(0 <= rn < 8){
regval = memory_core.d[rn];
}
else if(8 <= rn < 16 ){
regval = memory_core.a[rn-8];
}
else if(16 == rn){
regval = memory_core.sr;
}
else if(17 == rn){
regval = memory_core.pc;
}
}
tomem (memory, regval);
return -1;
}
void gdbserver_cont(){
if(!strcmp(skyeye_config.arch->arch_name,"arm")){
//chy 2006-04-12
state->NextInstr = RESUME; /* treat as PC change */
state->Reg[15]=ARMul_DoProg (state);
}
}
void gdbserver_step(){
if(!strcmp(skyeye_config.arch->arch_name,"arm")){
//chy 2006004-12
state->Reg[15]=ARMul_DoInstr (state);
}
}
|