Hi,
When in the emulator (both Interpreter or Recompiler) if you choose
"Shutdown" from the task manager's menu, then click on "Restart" on the
resulting dialogue box on RISC OS 5 this causes emulator 0.9.3 to fatally
exit with
Bad PC FC001000 FC001000
The reset code in the HAL does the usual trick of turning off the MMU and
jumping to the start of the ROM, where the turn off and jump are arranged to
fit in the CPU's pipeline so it doesn't matter that the image has been
remapped elsewhere - the instructions have already been fetched.
It's possible to workaround this fatal exit by noting how getpccache()
decodes the physical address. You end up in the 0x1f000000 case, so provided
there is 256MB of RAM configured it falls into the
ram1 != NULL
condition and manages to return a nonsense result, dodging the fatal exit.
However, the real cause appears to be a bug in the handling of writes to CP15
register 1 (control). For some reason there's a check for changes to
CP15_CTRL_MMU | CP15_CTRL_ROM | CP15_CTRL_SYSTEM
which calls cp15_tlb_flush_all(). That would be harmless since RISC OS does
the flush itself, except that that sets pccache = 0xffffffff as a side effect
so back in the top level decode loop that triggers an attempt to read from
the ROM we just mapped out.
I checked the ARM ARM DDI100 rev E, section 2.4, and there's no mention at
all under the control register of anything to do with the TLB, so I don't
understand what the motivation was to flush it.
Deleting that call fixes the problem, and doesn't affect any of the other OS
releases I have to hand (3.x0 4.0x) either.
Going back to 2006 in Mercurial there are vestiges of similar things, so
another approach would be to properly emulate the pipeline (ie. set pccache =
0xffffffff after <pipeline depth> cycles have elapsed) but if we assume RISC
OS is sensible and does TLB maintenance when it is truly required that would
end up calling cp15_tlb_flush_all() anyway, so CP15 register 1 can stick to
just doing control type things.
Patch below,
Sprow.
No comments:
Post a Comment