Skip to content

Commit

Permalink
'fix' buserror assert
Browse files Browse the repository at this point in the history
  • Loading branch information
Spritetm committed Jun 24, 2024
1 parent c21a658 commit 3ab042e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
14 changes: 7 additions & 7 deletions emu.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,11 @@ static int check_can_access(mem_range_t *m, unsigned int address) {
static unsigned int read_memory_32(unsigned int address) {
if (address==0) EMU_LOG_DEBUG("read addr 0\n");
mem_range_t *m=find_range_by_addr(address);
//HACK! If this is set, diags get more verbose
// if (address==0xC00644) return 1; //output 'expected' diag lines
// if (address==0xC006de) return 1; //output PC of next subtest
//HACK! If this is enabled, diags get more verbose
#if 0
if (address==0xC00644) return 1; //output 'expected' diag lines
if (address==0xC006de) return 1; //output PC of next subtest
#endif
if (!m) {
EMU_LOG_INFO("Read32 from unmapped addr %08X\n", address);
dump_cpu_state();
Expand Down Expand Up @@ -317,11 +319,9 @@ static int check_mem_access(unsigned int address, int flags) {
dump_callstack();
csr_set_access_error(csr, cur_cpu, access);

assert(recursive_error==0);
recursive_error=1;
//note THIS WILL NOT RETURN!
//(m68ki_exception_bus_error ends with a longjmp)
m68k_pulse_bus_error();
recursive_error=0;

return 0;
}
return 1;
Expand Down
12 changes: 7 additions & 5 deletions mapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ void mapper_set_mapid(mapper_t *m, uint8_t id) {
m->cur_id=id;
}

//returns fault indicator, or 0 if allowed
static int access_allowed_page(mapper_t *m, unsigned int page, int access_flags) {
assert(page<4096);
unsigned int ac=(m->desc[page].w1<<16)+m->desc[page].w0;
Expand All @@ -82,14 +83,15 @@ int mapper_access_allowed(mapper_t *m, unsigned int a, int access_flags) {
if (a>=0x800000) {
//Anything except RAM does not go through the mapper, but is only
//accessible in system mode.
return (access_flags&ACCESS_SYSTEM)?ACCESS_ERROR_OK:ACCESS_ERROR_A;
int ret=(access_flags&ACCESS_SYSTEM)?ACCESS_ERROR_OK:ACCESS_ERROR_A;
if (ret==ACCESS_ERROR_A) {
MAPPER_LOG_INFO("mapper_access_allowed: address %x not accessible in user mode\n", a);
}
return ret;
}
//Map virtual page to phyical page.
int p=a>>12; //4K pages
if (p>=2048) {
MAPPER_LOG_INFO("mapper_access_allowed: out of range addr %x\n", a);
exit(1);
}
assert(p<=2048 && "out of range addr");
if (access_flags&ACCESS_SYSTEM) p+=2048;
int r=access_allowed_page(m, p, access_flags);
if (r) {
Expand Down

0 comments on commit 3ab042e

Please sign in to comment.