OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 142 to Rev 143
    Reverse comparison

Rev 142 → Rev 143

/trunk/insight/gdb/remote-or1k.c
49,6 → 49,8
extern ULONGEST jtag_read_reg PARAMS ((unsigned int regno));
extern void jtag_write_reg PARAMS ((unsigned int regno, ULONGEST data));
extern void jtag_done PARAMS ((void));
extern int jtag_read_block PARAMS ((unsigned int regno, void* block, int nRegisters));
extern int jtag_write_block PARAMS ((unsigned int regno, void* block, int nRegisters));
extern void jtag_set_chain PARAMS ((int chain));
struct target_ops or1k_jtag_ops;
static struct or1k_target_ops or1k_target_jtag =
58,6 → 60,8
jtag_done,
jtag_read_reg,
jtag_write_reg,
jtag_read_block,
jtag_write_block,
jtag_set_chain,
NULL,
&or1k_jtag_ops,
75,6 → 79,8
NULL,
NULL,
NULL,
NULL,
NULL,
&or1k_sim_ops,
OPS_MAGIC
};
90,6 → 96,8
NULL,
NULL,
NULL,
NULL,
NULL,
&or1k_dummy_ops,
OPS_MAGIC
};
313,6 → 321,7
or1k_unstall ()
{
unsigned int val;
 
or1k_set_chain (SC_REGISTER);
val = or1k_read_reg (JTAG_RISCOP);
or1k_write_reg (JTAG_RISCOP, val & ~1);
710,6 → 719,8
CORE_ADDR pc = read_pc ();
int breakpoint = 0;
int i;
unsigned long value; /* CZ */
 
for (i = 0; i < or1k_implementation.num_used_matchpoints; i++)
if (dvr[i] == pc && dcr[i].dp && dcr[i].cc == CC_EQUAL
&& !dcr[i].sc && dcr[i].ct == CT_FETCH)
718,6 → 729,12
break;
}
hit_watchpoint = !breakpoint;
 
/* Cause the trap/breakpoint exception to be ignored. This is
the behavior of the simulator when the PC value is changed
by a write command. All pending exceptions are cleared and
the simulator continues at the PC value specified. */
or1k_write_spr_reg(PC_SPRNUM,value);
}
else
hit_watchpoint = 0;
898,9 → 915,12
register int count = (((memaddr + len) - addr) + 3) / 4;
/* Allocate buffer of that many longwords. */
register char *buffer = alloca (count * 4);
 
int status;
 
int block_xfer_size = 256; /* CZ 21/06/01 ... number of 32 bit words */
int nBlocks = (count + block_xfer_size -1)/block_xfer_size;
int terminate = 0; /* Terminate the printing of '*'s... */
 
if (memaddr >= MEM_SPACE)
error("Invalid address");
 
907,7 → 927,7
/* (CZ 21/06/01 -- because upper layers which know nothing about
Or1k or JTAG call this function directly, it is always necessary
to set the chain to point to the Debug Unit. Otherwise, it may
be pointint to the Development Interface chain, in which case
be pointing to the Development Interface chain, in which case
we're going to get bupkiss... */
 
or1k_set_chain (SC_RISC_DEBUG);
932,14 → 952,28
/* Copy data to be written over corresponding part of buffer */
memcpy ((char *) buffer + (memaddr & 3), myaddr, len);
 
/* Write the entire buffer. */
for (i = 0; i < count; i++, addr += 4)
/* CZ: rewrote the block transfer routines to make the code
a little more efficient for implementations that can handle
variable sized scan chains. Might be useful in the future.
Certainly makes downloads to the simulator more efficient. */
for(i=0;i<nBlocks;i++,count-=block_xfer_size,addr += block_xfer_size*4)
{
status = or1k_store_word (addr,
(unsigned long)extract_unsigned_integer (&buffer[i * 4], 4));
/* Report each kilobyte (we download 32-bit words at a time) */
if (i % 256 == 255)
int j;
int n = count < block_xfer_size ? count : block_xfer_size;
unsigned long *__buf;
 
if(!(__buf = (unsigned long*)malloc(n*sizeof(unsigned long))))
{
errno = ERR_MEM;
return 0;
}
 
for(j=0;j<n;j++)
__buf[j] = (unsigned long)extract_unsigned_integer(&buffer[(i * block_xfer_size +j)*4], 4);
status = or1k_store_block(addr,__buf,n);
free(__buf);
if(n == block_xfer_size)
{
printf_unfiltered ("*");
gdb_flush (gdb_stdout);
}
950,18 → 984,29
}
/* FIXME: Do we want a QUIT here? */
}
if (count >= 256)
if (terminate)
printf_unfiltered ("\n");
}
else
{
/* Read all the longwords */
for (i = 0; i < count; i++, addr += 4)
for(i=0;i<nBlocks;i++,count-=block_xfer_size,addr += block_xfer_size*4)
{
store_unsigned_integer (&buffer[i * 4], 4, or1k_fetch_word (addr));
QUIT;
int j;
int n = count < block_xfer_size ? count : block_xfer_size;
unsigned long *__buf;
 
__buf = (unsigned long*)malloc(n*sizeof(unsigned long));
status = or1k_load_block(addr,__buf,n);
if (!status)
for(j=0;j<n;j++)
store_unsigned_integer (&buffer[(i * block_xfer_size +j)*4], 4, __buf[j]);
else
errno = status;
free(__buf);
 
if(status)
return 0;
}
 
/* Copy appropriate bytes out of the buffer. */
memcpy (myaddr, buffer + (memaddr & 3), len);
}
968,6 → 1013,28
return len;
}
 
int or1k_load_block(CORE_ADDR addr,void* buffer,int nRegisters)
{
int i=0;
unsigned int regno = (addr >> 2) + MEM_SPACE;
 
if (current_or1k_target != NULL && current_or1k_target->to_read_block != NULL)
return current_or1k_target->to_read_block (regno,buffer,nRegisters);
else
for(i=0;i<nRegisters;i++)
((unsigned long*)buffer)[i] = 0x1234;
return 0;
}
 
int or1k_store_block(CORE_ADDR addr,void* buffer,int nRegisters)
{
unsigned int regno = (addr >> 2) + MEM_SPACE;
 
if (current_or1k_target != NULL && current_or1k_target->to_write_block != NULL)
return current_or1k_target->to_write_block (regno,buffer,nRegisters);
return 0;
}
 
/* Flushes pipeline. May not be needed by all implementations, but
it doen't hurt to do it. This function should be called every time
or1k stops.
1256,7 → 1323,10
int
or1k_stopped_by_watchpoint (void)
{
return hit_watchpoint;
/* For now, no watchpoints */
return 0;
 
/* return hit_watchpoint; */
}
 
/* Insert a breakpoint. */
/trunk/gdb-5.0/gdb/remote-or1k.c
49,6 → 49,8
extern ULONGEST jtag_read_reg PARAMS ((unsigned int regno));
extern void jtag_write_reg PARAMS ((unsigned int regno, ULONGEST data));
extern void jtag_done PARAMS ((void));
extern int jtag_read_block PARAMS ((unsigned int regno, void* block, int nRegisters));
extern int jtag_write_block PARAMS ((unsigned int regno, void* block, int nRegisters));
extern void jtag_set_chain PARAMS ((int chain));
struct target_ops or1k_jtag_ops;
static struct or1k_target_ops or1k_target_jtag =
58,6 → 60,8
jtag_done,
jtag_read_reg,
jtag_write_reg,
jtag_read_block,
jtag_write_block,
jtag_set_chain,
NULL,
&or1k_jtag_ops,
75,6 → 79,8
NULL,
NULL,
NULL,
NULL,
NULL,
&or1k_sim_ops,
OPS_MAGIC
};
90,6 → 96,8
NULL,
NULL,
NULL,
NULL,
NULL,
&or1k_dummy_ops,
OPS_MAGIC
};
313,6 → 321,7
or1k_unstall ()
{
unsigned int val;
 
or1k_set_chain (SC_REGISTER);
val = or1k_read_reg (JTAG_RISCOP);
or1k_write_reg (JTAG_RISCOP, val & ~1);
710,6 → 719,8
CORE_ADDR pc = read_pc ();
int breakpoint = 0;
int i;
unsigned long value; /* CZ */
 
for (i = 0; i < or1k_implementation.num_used_matchpoints; i++)
if (dvr[i] == pc && dcr[i].dp && dcr[i].cc == CC_EQUAL
&& !dcr[i].sc && dcr[i].ct == CT_FETCH)
718,6 → 729,12
break;
}
hit_watchpoint = !breakpoint;
 
/* Cause the trap/breakpoint exception to be ignored. This is
the behavior of the simulator when the PC value is changed
by a write command. All pending exceptions are cleared and
the simulator continues at the PC value specified. */
or1k_write_spr_reg(PC_SPRNUM,value);
}
else
hit_watchpoint = 0;
898,9 → 915,12
register int count = (((memaddr + len) - addr) + 3) / 4;
/* Allocate buffer of that many longwords. */
register char *buffer = alloca (count * 4);
 
int status;
 
int block_xfer_size = 256; /* CZ 21/06/01 ... number of 32 bit words */
int nBlocks = (count + block_xfer_size -1)/block_xfer_size;
int terminate = 0; /* Terminate the printing of '*'s... */
 
if (memaddr >= MEM_SPACE)
error("Invalid address");
 
907,7 → 927,7
/* (CZ 21/06/01 -- because upper layers which know nothing about
Or1k or JTAG call this function directly, it is always necessary
to set the chain to point to the Debug Unit. Otherwise, it may
be pointint to the Development Interface chain, in which case
be pointing to the Development Interface chain, in which case
we're going to get bupkiss... */
 
or1k_set_chain (SC_RISC_DEBUG);
932,14 → 952,28
/* Copy data to be written over corresponding part of buffer */
memcpy ((char *) buffer + (memaddr & 3), myaddr, len);
 
/* Write the entire buffer. */
for (i = 0; i < count; i++, addr += 4)
/* CZ: rewrote the block transfer routines to make the code
a little more efficient for implementations that can handle
variable sized scan chains. Might be useful in the future.
Certainly makes downloads to the simulator more efficient. */
for(i=0;i<nBlocks;i++,count-=block_xfer_size,addr += block_xfer_size*4)
{
status = or1k_store_word (addr,
(unsigned long)extract_unsigned_integer (&buffer[i * 4], 4));
/* Report each kilobyte (we download 32-bit words at a time) */
if (i % 256 == 255)
int j;
int n = count < block_xfer_size ? count : block_xfer_size;
unsigned long *__buf;
 
if(!(__buf = (unsigned long*)malloc(n*sizeof(unsigned long))))
{
errno = ERR_MEM;
return 0;
}
 
for(j=0;j<n;j++)
__buf[j] = (unsigned long)extract_unsigned_integer(&buffer[(i * block_xfer_size +j)*4], 4);
status = or1k_store_block(addr,__buf,n);
free(__buf);
if(n == block_xfer_size)
{
printf_unfiltered ("*");
gdb_flush (gdb_stdout);
}
950,18 → 984,29
}
/* FIXME: Do we want a QUIT here? */
}
if (count >= 256)
if (terminate)
printf_unfiltered ("\n");
}
else
{
/* Read all the longwords */
for (i = 0; i < count; i++, addr += 4)
for(i=0;i<nBlocks;i++,count-=block_xfer_size,addr += block_xfer_size*4)
{
store_unsigned_integer (&buffer[i * 4], 4, or1k_fetch_word (addr));
QUIT;
int j;
int n = count < block_xfer_size ? count : block_xfer_size;
unsigned long *__buf;
 
__buf = (unsigned long*)malloc(n*sizeof(unsigned long));
status = or1k_load_block(addr,__buf,n);
if (!status)
for(j=0;j<n;j++)
store_unsigned_integer (&buffer[(i * block_xfer_size +j)*4], 4, __buf[j]);
else
errno = status;
free(__buf);
 
if(status)
return 0;
}
 
/* Copy appropriate bytes out of the buffer. */
memcpy (myaddr, buffer + (memaddr & 3), len);
}
968,6 → 1013,28
return len;
}
 
int or1k_load_block(CORE_ADDR addr,void* buffer,int nRegisters)
{
int i=0;
unsigned int regno = (addr >> 2) + MEM_SPACE;
 
if (current_or1k_target != NULL && current_or1k_target->to_read_block != NULL)
return current_or1k_target->to_read_block (regno,buffer,nRegisters);
else
for(i=0;i<nRegisters;i++)
((unsigned long*)buffer)[i] = 0x1234;
return 0;
}
 
int or1k_store_block(CORE_ADDR addr,void* buffer,int nRegisters)
{
unsigned int regno = (addr >> 2) + MEM_SPACE;
 
if (current_or1k_target != NULL && current_or1k_target->to_write_block != NULL)
return current_or1k_target->to_write_block (regno,buffer,nRegisters);
return 0;
}
 
/* Flushes pipeline. May not be needed by all implementations, but
it doen't hurt to do it. This function should be called every time
or1k stops.
1256,7 → 1323,10
int
or1k_stopped_by_watchpoint (void)
{
return hit_watchpoint;
/* For now, no watchpoints */
return 0;
 
/* return hit_watchpoint; */
}
 
/* Insert a breakpoint. */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.