File: skyeye2gdb.c

package info (click to toggle)
skyeye 1.2.5-4
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 8,236 kB
  • ctags: 19,345
  • sloc: ansic: 90,379; sh: 5,188; python: 707; cpp: 417; makefile: 322; exp: 38
file content (159 lines) | stat: -rw-r--r-- 3,804 bytes parent folder | download | duplicates (4)
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
/*
        skyeye2gdb.c - 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>
 * */

#include "armdefs.h"

#include "skyeye_types.h"
#include "memory.h"
#include "armemu.h"
#include "skyeye2gdb.h"
#include "skyeye_defs.h"

#include <stdint.h>

extern struct ARMul_State * state;
extern struct _memory_core memory_core;
extern register_defs_t * current_reg_type;
extern generic_arch_t * arch_instance;
int bigendSig;
int
frommem (unsigned char *memory)
{
	bigendSig = current_reg_type->endian_flag;
	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);
	}
}


void
tomem (unsigned char *memory, int val)
{
	bigendSig = current_reg_type->endian_flag;
	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;
}

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);
        }
	else
		sim_resume(0);
}
void gdbserver_step(){
         if(!strcmp(skyeye_config.arch->arch_name,"arm")){
                //chy 2006004-12
                state->NextInstr = RESUME;
                state->Reg[15]=ARMul_DoInstr (state);
        }
	else
		sim_resume(1);
}