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 205 to Rev 206
    Reverse comparison

Rev 205 → Rev 206

/trunk/or1ksim/cpu/or32/execute.c
411,6 → 411,7
unsigned long t_pc = pcnext;
unsigned long t_pcnext = delay_insn ? pcdelay : pcnext+4;
extern int cpu_stalled; /* CZ from debug_interface */
extern int NewStyleExceptions; /* CZ 11/09/01 */
 
/* If an insn was injected, don't increment the PC value,
as it should not affect the existing instruction stream */
421,7 → 422,7
}
DIR_insn_injected = 0;
 
if(!cpu_stalled)
if(!cpu_stalled || NewStyleExceptions)
_execute_update_pc(t_pc,t_pcnext);
else
PrepareExceptionPC(t_pc,t_pcnext);
771,13 → 772,31
next_delay_insn = 1;
}
void l_rfe() {
/* I'm really confused...this is not following
the documentation at all. Guess I'll go with
the flow... */
#if 0
unsigned int esr = mfspr(SPR_ESR_BASE);
 
cur->func_unit = exception;
pcdelay = mfspr(SPR_EPCR_BASE);
mtspr(SPR_SR, mfspr(SPR_ESR_BASE));
if(!(esr & 0x2000))
pcdelay += 4; /* According to table 9-3 */
mtspr(SPR_SR, esr);
next_delay_insn = 1;
if (temp_disable_except == 0)
temp_disable_except = 1;
#endif
unsigned int esr = mfspr(SPR_ESR_BASE);
 
cur->func_unit = exception;
pcdelay = mfspr(SPR_EPCR_BASE);
mtspr(SPR_SR, esr);
next_delay_insn = 1;
if (temp_disable_except == 0)
temp_disable_except = 1;
}
 
void l_nop() {
cur->func_unit = nop;
if (nop_period > nop_maxperiod)
/trunk/or1ksim/cpu/common/abstract.c
40,8 → 40,92
#include "opcode/or32.h"
 
extern unsigned long reg[];
extern unsigned long pc_phy;
extern char *disassembled;
 
static char* build_format(int len,char* buffer,int offset,unsigned char* data)
{
int i;
char sTemp[256];
 
sprintf(buffer," %4x: ",offset);
 
for(i=0;i<16;i++)
{
if(i < len)
{
sprintf(sTemp,"%02x",data[i]);
strcat(buffer,sTemp);
}
else
strcat(buffer," ");
 
if(i & 0x01)
strcat(buffer," ");
}
 
strcat(buffer," %s\n");
}
 
static char* BytesToAscii(char* s,int len,char* buffer)
{
int i;
 
for(i=0;i<len;i++)
buffer[i] = isprint(s[i]) ? s[i] : '.';
buffer[i] = '\0';
 
return buffer;
}
 
static void DumpAsciiToDescriptor(int fd,char* buffer,int len)
{
int i;
char format_buf[256];
char ascii_buf[256];
char* format;
char sTemp[256];
 
sprintf(sTemp," 00 02 04 06 08 0A 0C 0E ASCII\n");
write(fd,sTemp,strlen(sTemp));
sprintf(sTemp," ----- ---- ---- ---- ---- ---- ---- ---- ---- ----------------\n");
write(fd,sTemp,strlen(sTemp));
for(i=0;i<len;i+=16,buffer+=16)
{
int max = len-i;
 
if(max > 16) max = 16;
format = build_format(max,format_buf,i,buffer);
sprintf(sTemp,format,BytesToAscii((char*)buffer,max,ascii_buf));
write(fd,sTemp,strlen(sTemp));
}
}
 
static void DebugDump()
{
char buffer[1024];
unsigned long startmem = reg[1];
int i;
 
printf(" r0 r1 r2 r3 r4 r5 r6 r7\n");
printf("-------- -------- -------- -------- -------- -------- -------- --------\n");
printf("%08x %08x %08x %08x %08x %08x %08x %08x\n\n",reg[0],reg[1],reg[2],
reg[3],reg[4],reg[5],reg[6],reg[7]);
printf(" r8 r9 r10 r11 r12 r13 r14 r15\n");
printf("-------- -------- -------- -------- -------- -------- -------- --------\n");
printf("%08x %08x %08x %08x %08x %08x %08x %08x\n\n",reg[8],reg[9],reg[10],
reg[11],reg[12],reg[13],reg[14],reg[15]);
 
for(i=0;i<sizeof(buffer);i++)
{
if(startmem+i >= MEMORY_START + MEMORY_LEN)
break;
buffer[i] = mem[startmem+i].data;
}
printf("Hex dump of stack memory:\n");
DumpAsciiToDescriptor(fileno(stdout),buffer,i);
}
 
/* This is an abstract+physical memory array rather than only physical
memory array */
struct mem_entry mem[MEMORY_LEN];
87,6 → 171,7
}
}
 
 
/* Searches mem array for a particular label and returns label's address.
If label does not exist, returns 0. */
261,7 → 346,8
} else if (dev = verify_memoryarea(memaddr)) {
temp = dev->readfunc(memaddr);
} else {
printf("EXCEPTION: read out of memory (32-bit access to %.8lx)\n", memaddr);
printf("EXCEPTION @ <0x%06x>: read out of memory (32-bit access to %.8lx)\n", pc_phy, memaddr);
DebugDump();
cont_run = 0;
temp = 0;
}
291,7 → 377,8
temp = ((unsigned short)(mem[memaddr].data << 8) & 0xff00);
temp += ((unsigned short)mem[memaddr + 1].data & 0x00ff);
} else {
printf("EXCEPTION: read out of memory (16-bit access to %.8lx)\n", memaddr);
printf("EXCEPTION @ <0x%06x>: read out of memory (16-bit access to %.8lx)\n", pc_phy,memaddr);
DebugDump();
cont_run = 0;
temp = 0;
}
320,7 → 407,8
if (memaddr < (MEMORY_START + MEMORY_LEN)) {
temp = (unsigned char)mem[memaddr].data;
} else {
printf("EXCEPTION: read out of memory (8-bit access to %.8lx)\n", memaddr);
printf("EXCEPTION @ <0x%06x>: read out of memory (8-bit access to %.8lx)\n", pc_phy,memaddr);
DebugDump();
cont_run = 0;
temp = 0;
}
357,7 → 445,8
} else if (dev = verify_memoryarea(memaddr)) {
dev->writefunc(memaddr, value);
} else {
printf("EXCEPTION: write out of memory (32-bit access to %.8lx)\n", memaddr);
printf("EXCEPTION @ <0x%06x>: write out of memory (32-bit access to %.8lx)\n", pc_phy, memaddr);
DebugDump();
cont_run = 0;
}
 
384,7 → 473,8
mem[memaddr].data = (value >> 8);
mem[memaddr + 1].data = (char)(value);
} else {
printf("EXCEPTION: write out of memory (16-bit access to %.8lx)\n", memaddr);
printf("EXCEPTION @ <0x%06x>: write out of memory (16-bit access to %.8lx)\n",pc_phy, memaddr);
DebugDump();
cont_run = 0;
}
 
410,7 → 500,8
if (memaddr < (MEMORY_START + MEMORY_LEN)) {
mem[memaddr].data = value;
} else {
printf("EXCEPTION: write out of memory (8-bit access to %.8lx)\n", memaddr);
printf("EXCEPTION @ <0x%06x>: write out of memory (8-bit access to %.8lx)\n", pc_phy,memaddr);
DebugDump();
cont_run = 0;
}
 
/trunk/or1ksim/peripheral/debug_unit.c
144,8 → 144,14
return 0;
 
/* If we're single stepping, always stop */
 
/* CZ 15/09/01 -- change this behavior. Stop, set the cpu
into a stalled state, but do NOT return an exception */
if(debug_unit.DMR1.ST && action == DebugInstructionFetch)
return 1;
{
cpu_stalled = 1;
debug_unit.DRR.SS = 1;
}
 
switch(action)
{
555,7 → 561,7
 
if(!address)
err = JTAG_PROXY_ACCESS_EXCEPTION;
else if(address < 32)
else if(address < 80)
{
/* Assume that a write to the PC implies
that the debugging software has recognized
567,11 → 573,14
ClearPendingException();
ClearPreparedPCState();
}
/* if(address == 0x20)*/ /* EPC */
/* printf("EPC set to 0x%08x\n",data); */
 
mtspr(address,data);
}
else if(address >= 0x0400 && address < 0x0420)
else if(address >= 0x0400 && address < 0x0450)
reg[address - 0x0400] = data;
else if(address < 0x0600 || address >= 0x0620)
else if(address < 0x0600 || address >= 0x0650)
err = JTAG_PROXY_INVALID_ADDRESS;
}
else
651,11 → 660,14
{
extern unsigned long reg[32];
 
if(address < 32)
if(address == SPR_PC)
PrepareException();
 
if(address < 80)
value = mfspr(address);
else if(address >= 0x0400 && address < 0x0420)
else if(address >= 0x0400 && address < 0x0450)
value = reg[address - 0x400];
else if(address >= 0x0600 && address < 0x0620)
else if(address >= 0x0600 && address < 0x0650)
value = 0;
else
err = JTAG_PROXY_INVALID_ADDRESS;
700,5 → 712,10
if(result)
SetCPUStallState(true);
 
return (debug_unit.DMR1.ST && exception == EXCEPT_BREAK);
/* CZ 15/09/01 --- change this behavior...never ignore a breakpoint.
Fix single step so it doesn't return breakpoint. Note, we could stop
for multiple reasons...single step AND breakpoint for example. */
/* return (debug_unit.DMR1.ST && exception == EXCEPT_BREAK); */
 
return 0;
}
/trunk/or1ksim/peripheral/debug_unit.h
138,7 → 138,8
unsigned int SCE:1;
unsigned int BE:1;
unsigned int TE:1;
unsigned int reserved:18;
unsigned int SS:1;
unsigned int reserved:17;
} DRRregister;
 
typedef struct {
/trunk/or1ksim/toplevel.c
77,6 → 77,10
void BlockJTAG(void);
 
#ifndef DEBUGMOD_OFF
int NewStyleExceptions = 1; /* Start off with the new style exception handlers */
/* This means GDB will expect the PC at 0xD00 when a
a breakpoint occurs, and will intercept AFTER the
exception vector is taken. */
int GlobalMode = 0; /* Start off in the orginal mode */
#else /* no DEBUGMOD_OFF */
#define GlobalMode 0
83,7 → 87,7
#endif /* no DEBUGMOD_OFF */
 
/* CVS revision number. */
const char rcsrev[] = "$Revision: 1.23 $";
const char rcsrev[] = "$Revision: 1.24 $";
 
/* Continuos run versus single step tracing switch. */
int cont_run;
234,11 → 238,13
unsigned long endaddr = 0xFFFFFFFF;
int first_prompt = 1;
int trace_fd = 0;
unsigned char trace_reg[32];
 
memset(trace_reg,'\0',sizeof(trace_reg));
srand(getpid());
init_defconfig();
if (parse_args(argc, argv)) {
printf("Usage: %s [options] <filename>\n", argv[0]);
printf("Usage: %s [options] <filename>\n", argv[0]);
printf("Options:\n");
printf(" -v: version and copyright note\n");
printf(" -i: enable interactive command prompt\n");
406,6 → 412,7
tick_reset();
pm_reset();
pic_reset();
mtspr(2,0x20); /* We are emulating a 32 bit processor/no FP */
reset();
if(!GlobalMode) /* Only in old mode */
set_reg32(3, endaddr);
625,12 → 632,16
} else
if (!strcmp(item1, "trace")) { /* Added by CZ 210801 */
char item2[256];
char item3[256];
char *s,*q;
 
strtoken(linestr, item2, 2);
strtoken(linestr, item3, 3);
if(trace_fd)
{
close(trace_fd);
trace_fd = 0;
memset(trace_reg,'\0',sizeof(trace_reg));
}
if(strcmp(item2,"off")) /* if we're not being turned off */
{
645,6 → 656,21
trace_fd = 0;
}
}
if(!trace_fd && strlen(item3))
printf("Syntax error on trace: \"%s\" unexpected\n",item3);
else
for(s = item3;s && *s; s = q)
{
if(q = strchr(s,','))
*q++ = '\0';
if(strlen(s) < 4 && (s[0] == 'r' || s[0] == 'R') &&
isdigit(s[1]) && (isdigit(s[2]) || !s[2]))
trace_reg[atoi(&s[1])] = 1;
else
printf("Syntax error in format: \"%s\" not a valid register\n",s);
}
} else
if (strcmp(item1, "stats") == 0) { /* stats */
char item2[20];
703,28 → 729,37
{
char sTemp[256];
char sTemp2[256];
char reg_value[16];
unsigned long value;
int first_register = 1;
int i;
extern char *disassembled;
extern unsigned long reg[];
 
/* The objects passed to the
trace command should not be
hardcoded like this...instead
what to dump should be passed
on the command line.
value = (mem[0x0c].data << 24) +
(mem[0x0d].data << 16) +
(mem[0x0e].data << 8)
+ mem[0x0f].data;
 
FIX THIS LATER...
*/
value = (mem[0x306bc].data << 24) +
(mem[0x306bd].data << 16) +
(mem[0x306be].data << 8)
+ mem[0x306bf].data;
 
#if 0
sprintf(sTemp,"0x%06x: %s",addr,disassembled);
memset(sTemp2,' ',sizeof(sTemp2));
memset(sTemp2,' ',80);
strncpy(sTemp2,sTemp,strlen(sTemp));
sprintf(&sTemp2[40],"<0x%08x,0x%08x> [0x%08x]\n",
reg[3],reg[4],value);
sTemp[0] = '\0';
sTemp2[78] = '\0';
for(i=0;i<32;i++)
if(trace_reg[i])
{
sprintf(reg_value,"%c0x%08x",first_register?'<':',',
reg[i]);
strcat(sTemp,reg_value);
first_register = 0;
}
if(!first_register)
sprintf(&sTemp2[40],"%s>\n",sTemp);
#endif
sprintf(sTemp2,"0x%06x: %s <0x%08x>\n",addr,disassembled,value);
write(trace_fd,sTemp2,strlen(sTemp2));
}
update_pc();

powered by: WebSVN 2.1.0

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