2
iomem.c - implementation of read/write function for blackfin simulation
3
Copyright (C) 2003 Skyeye Develop Group
4
for help please send mail to <skyeye-developer@lists.sf.linuxforum.net>
6
This program is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2 of the License, or
9
(at your option) any later version.
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
16
You should have received a copy of the GNU General Public License
17
along with this program; if not, write to the Free Software
18
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
* 12/16/2006 Michael.Kang <blackfin.kang@gmail.com>
2
25
#include "bfin-sim.h"
5
27
#include "mem_map.h"
29
#include <skyeye_config.h>
31
get_long (unsigned char *memory, bu32 addr);
8
32
//#define IO_ERR {printf("\n%s io error!addr=0x%x\n",__FUNCTION__,addr);exit(-1);}
10
#define IO_ERR {printf("\n%s io error!addr=0x%x,pc=0x%x,oldpc=0x%x,sp=0x%x\n",__FUNCTION__,addr,PCREG,OLDPCREG,SPREG);}
34
#define IO_ERR {printf("\n%s io error!addr=0x%x,pc=0x%x,oldpc=0x%x,sp=0x%x,insn@pc=0x%x\n",__FUNCTION__,addr,PCREG,OLDPCREG,SPREG,get_long(saved_state.memory,PCREG));exit(-1);}
13
38
isram_write_word (bu32 addr, bu16 v)
125
150
put_byte (unsigned char *memory, bu32 addr, bu8 v)
128
fprintf(PF,"KSDBG:addr=0xc0900,PC=0x%x\n",PCREG);
130
152
if ((addr >= IO_START) && (addr < IO_END)) {
131
saved_state.p_mach->io_write_byte (addr, v);
153
skyeye_config.mach->mach_io_write_byte (&saved_state, addr, v);
134
156
else if (addr >= ISRAM_START && addr < ISRAM_END) {
156
178
put_word (unsigned char *memory, bu32 addr, bu16 v)
159
fprintf(PF,"KSDBG:addr=0xc0900,PC=0x%x\n",PCREG);
161
180
if ((addr >= IO_START) && (addr < IO_END)) {
162
saved_state.p_mach->io_write_word (addr, v);
181
skyeye_config.mach->mach_io_write_halfword (&saved_state, addr, v);
164
183
else if (addr >= ISRAM_START && addr < ISRAM_END) {
183
202
put_long (unsigned char *memory, bu32 addr, bu32 v)
186
fprintf(PF,"KSDBG:addr=0xc0900,v=0x%x,PC=0x%x\n", v, PCREG);
188
204
if ((addr > IO_START) && (addr < IO_END)) {
189
saved_state.p_mach->io_write_long (addr, v);
205
skyeye_config.mach->mach_io_write_word (&saved_state, addr, v);
191
207
else if (addr >= SSRAM_START && addr < SSRAM_END) {
192
208
ssram_write_long (addr, v);
208
224
get_byte (unsigned char *memory, bu32 addr)
210
226
if ((addr >= IO_START) && (addr < IO_END)) {
211
return saved_state.p_mach->io_read_byte (addr);
227
return skyeye_config.mach->mach_io_read_byte (&saved_state, addr);
213
229
else if (addr >= ISRAM_START && addr < ISRAM_END) {
214
230
return isram_read_byte (addr);
230
246
get_word (unsigned char *memory, bu32 addr)
232
248
if ((addr >= IO_START) && (addr < IO_END)) {
233
return saved_state.p_mach->io_read_word (addr);
249
return skyeye_config.mach->mach_io_read_halfword (&saved_state, addr);
235
251
else if (addr >= ISRAM_START && addr < ISRAM_END) {
236
252
return isram_read_word (addr);
251
267
get_long (unsigned char *memory, bu32 addr)
253
269
if ((addr >= IO_START) && (addr < IO_END)) {
254
return saved_state.p_mach->io_read_long (addr);
270
return skyeye_config.mach->mach_io_read_word (&saved_state, addr);
256
272
else if (addr >= ISRAM_START && addr < ISRAM_END) {