Saturday, December 11, 2010

Stalled for months!

[Updated below; some progress!]
[Updated again, lots more progress!]

I've been struggling with the RPC emulator over the last few weeks.

The main problem is accessing a hard disc image.  Initially, I intercepted the calls from FileCore to ADFS in order to read (what I thought were) the appropriate areas of the disc image file, but what I returned wasn't accepted by FileCore.  Then I tried another track; I integrated the files ide.c, fdc.c and superio.c from RPCEmu to provide the emulation of the fdc37c665 component.  This is the result when using the hd4.hdf and cmos.ram from http://b-em.bbcmicro.com/arculator/hdboot.zip (the emulator now has a VNC based front-end that provides keyboard entry):


The output I get from the ide.c file (with the addition of the data read from the file) is as follows:
IDE: First check - spt 63 hpc 16
IDE: Write IDE 000003F6 00 039C0A2C 02107CF4
IDE: Read IDE 000003F6 039C2028 00000000
IDE: Write IDE 000001F6 A0 039C1FEC 02107CF4
IDE: Read IDE 000003F6 039C1FF8 00000000
Callback IDE = 200
IDE: Read IDE 000003F6 039C1B88 00000200
IDE: Write IDE 000001F6 A0 039C1BA0 02107CF4
IDE: Read IDE 000003F6 039C1BB4 00000200
IDE: Write IDE 000001F1 00 039C1BD0 02107CF4
IDE: Write IDE 000001F2 01 039C1BD8 02107CF4
IDE: Write IDE 000001F3 07 039C1BE0 02107CF4
IDE: Write IDE 000001F4 00 039C1BE8 02107CF4
IDE: Write IDE 000001F5 00 039C1BF0 02107CF4
IDE: Write IDE 000001F6 A0 039C1BF8 02107CF4
IDE: Write IDE 000001F7 20 039C1BFC 02107CF4
IDE: New IDE command - 20 0 0 039C1BFC
IDE: Read 1 sectors from sector 7 cylinder 0 head 0
IDE: Read 0 0 7 00000E00
IDE: Read sector callback 7 0 0 offset 00000E00 0 left 1
IDE: Read data:  00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00    ................
IDE: Read data:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
IDE: Read data:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
IDE: Read data:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
IDE: Read data:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
IDE: Read data:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
IDE: Read data:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
IDE: Read data:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
IDE: Read data:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
IDE: Read data:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
IDE: Read data:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
IDE: Read data:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
IDE: Read data:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
IDE: Read data:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
IDE: Read data:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
IDE: Read data:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
IDE: Read data:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
IDE: Read data:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
IDE: Read data:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
IDE: Read data:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
IDE: Read data:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
IDE: Read data:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
IDE: Read data:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
IDE: Read data:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
IDE: Read data:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
IDE: Read data:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
IDE: Read data:  00 00 00 00 00 00 00 00 00 00 00 00 ff ff ff ff    ................
IDE: Read data:  00 00 00 00 00 00 00 00 00 00 00 01 00 80 13 03    ................
IDE: Read data:  09 3f 10 00 0d 09 00 00 01 1a 68 00 35 02 00 00    .?........h.5...
IDE: Read data:  00 60 1b 03 00 00 00 00 00 00 00 00 00 00 00 00    .`..............
IDE: Read data:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
IDE: Read data:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5f    ..............._
IDE: Read IDE 000001F7 039C17B8 00000002
IDE: Over! packlen 0 512
IDE: Read IDE 000003F6 039C1B88 00000002
IDE: Write IDE 000001F6 AF 039C1BA0 02107CF4
IDE: Read IDE 000003F6 039C1BB4 00000002
IDE: Write IDE 000001F1 00 039C1BD0 02107CF4
IDE: Write IDE 000001F2 3F 039C1BD8 02107CF4
IDE: Write IDE 000001F3 07 039C1BE0 02107CF4
IDE: Write IDE 000001F4 00 039C1BE8 02107CF4
IDE: Write IDE 000001F5 00 039C1BF0 02107CF4
IDE: Write IDE 000001F6 AF 039C1BF8 02107CF4
IDE: Write IDE 000001F7 91 039C1BFC 02107CF4
IDE: New IDE command - 91 0 0 039C1BFC
IDE: Read IDE 000001F7 039C1F84 00000002
c2107f08 00000041 00000006 01c07a90 000001f4 021086ac Callback IDE = 200
IDE: -1338894612 sectors per track, -1338894596 heads per cylinder
IDE: Read IDE 000003F6 039C1B88 00000002
IDE: Write IDE 000001F6 AF 039C1BA0 02107CF4
IDE: Read IDE 000003F6 039C1BB4 00000002
IDE: Write IDE 000001F1 00 039C1BD0 02107CF4
IDE: Write IDE 000001F2 3F 039C1BD8 02107CF4
IDE: Write IDE 000001F3 07 039C1BE0 02107CF4
IDE: Write IDE 000001F4 00 039C1BE8 02107CF4
IDE: Write IDE 000001F5 00 039C1BF0 02107CF4
IDE: Write IDE 000001F6 AF 039C1BF8 02107CF4
IDE: Write IDE 000001F7 91 039C1BFC 02107CF4
IDE: New IDE command - 91 0 0 039C1BFC
IDE: Read IDE 000001F7 039C1F84 00000002
Callback IDE = 200
IDE: -1338894612 sectors per track, -1338894596 heads per cylinder

Some differences in my use of the RPCEmu code are:

  1. callbackide is called on the next tick event, ignoring the value of (non-zero) idecallback.
  2. No DMA implemented
Any bright ideas?

Update:

Thanks to Tom Walker pointing out (on stardot) that the error reported by RISC OS is a floppy disc error, not a hard disc one, I noticed that I wasn't making callbacks required by the fdc.c floppy disc emulation.  Now, I have a nice new error to worry about!


Update 2: Not so much to worry about, after all.  That one turns out to be because my emulation of post-increment LDR wasn't storing the calculated base+offset value into the base register.  That's the first bug I've found in the basic emulate-ARM-instructions part of the emulator for a long time, but at least it's just a two line fix.