Lets actually try Hybrid Emulation

Post Reply
foft
Posts: 334
Joined: Thu Dec 03, 2020 11:05 am
Has thanked: 29 times
Been thanked: 120 times

Re: Lets actually try Hybrid Emulation

Post by foft »

I was thinking about this timing issue.

I don't actually know this is what is causing the workbench screen not to show, so should confirm that. It actually acts like it is restarting the process many times on 3.1. Only 1.3 it hangs on a white screen.

The issue is likely not a problem in all the applications, just in the OS. Since the OS does task switching the system friendly programs themselves can't really rely on this kind of loop for timing.

I tried the realtime priority, locking to processor etc. Though I should note that there are TWO threads that seem busy in qemu. I need to look in gdb to see what they are...
foft
Posts: 334
Joined: Thu Dec 03, 2020 11:05 am
Has thanked: 29 times
Been thanked: 120 times

Re: Lets actually try Hybrid Emulation

Post by foft »

So if you run it with this, then you can capture a log file of what its running:
-d in_asm,out_asm,exec,nochain

This can be processed with the attached perl script to convert into an amiga assembler trace. The blank lines are the gaps between the qemu translation blocks. Here are a few processed boots.
http://www.64kib.com/boot31v1_amiga.log.gz (short)
http://www.64kib.com/boot31v2_amiga.log.gz (longer)

Any amiga and/or 68k experts want to have a look?
Attachments
toamiga.pl.gz
(391 Bytes) Downloaded 136 times
lordoftime79
Posts: 97
Joined: Sun Feb 14, 2021 6:29 pm
Has thanked: 1 time
Been thanked: 2 times

Re: Lets actually try Hybrid Emulation

Post by lordoftime79 »

is it worth asking the Buffee discord? or the PIStorm discord they seem like simular goals just for actual Amigas maybe they can help?
just in case here is the PIstorm link https://discord.gg/K4VB2BHV and here is the Buffee link https://discord.gg/KyWfT9XU
foft
Posts: 334
Joined: Thu Dec 03, 2020 11:05 am
Has thanked: 29 times
Been thanked: 120 times

Re: Lets actually try Hybrid Emulation

Post by foft »

Good thought. I think pistorm are using mushashi and the buffee team are writing their own (p)jit. The former we have working and the latter is, I believe, not ready for use yet. Still worth asking to be sure.

Here is a 1.3 os boot trace, left it a long time to be sure it got to this white screen it hangs on, then left it longer still!
http://www.64kib.com/boot13v1_amiga.log.gz
foft
Posts: 334
Joined: Thu Dec 03, 2020 11:05 am
Has thanked: 29 times
Been thanked: 120 times

Re: Lets actually try Hybrid Emulation

Post by foft »

Referring to this...
http://wandel.ca/homepage/execdis/exec_disassembly.txt

can trace through somewhat.
foft
Posts: 334
Joined: Thu Dec 03, 2020 11:05 am
Has thanked: 29 times
Been thanked: 120 times

Re: Lets actually try Hybrid Emulation

Post by foft »

Looks to be stuck in the guru to me...

FC30EC movem.l D2/D7/A2/A3/A6,-(SP)

FC30F0 moveq #$0A,D1 Delay for a while.
FC30F2 moveq #-1,D0
FC30F4 dbra D0,FC30F4(PC)
FC30F8 dbra D1,FC30F4(PC)

vs...
0x00fc3128: moveml %d2/%d7/%a2-%a3/%fp,%sp@-
0x00fc312c: moveq #10,%d1
0x00fc312e: moveq #-1,%d0
0x00fc3130: dbf %d0,0xfc3130

0x00fc3130: dbf %d0,0xfc3130

0x00fc3130: dbf %d0,0xfc3130
...


via here:
; System exception alert entry point
; ----------------------------------

; If an exception occurs or a TRAP instruction is executed while the
; CPU is in supervisor mode, we jump here, since we have no task to
; blame it on. If a task was running, we use its tc_TrapCode vector
; instead, but at powerup, the exec default for this vector is also
; initialized to point here. Later, it is stolen by some other
; part of the system so the "Software error - task held" window can
; be put up before the guru.


FC2FB4 movem.l D0-D7/A0-A7,$0180 Dump the registers.
foft
Posts: 334
Joined: Thu Dec 03, 2020 11:05 am
Has thanked: 29 times
Been thanked: 120 times

Re: Lets actually try Hybrid Emulation

Post by foft »

One thought...
the chip ram 'rom' disable switch, I wonder if the TBs need invalidating
foft
Posts: 334
Joined: Thu Dec 03, 2020 11:05 am
Has thanked: 29 times
Been thanked: 120 times

Re: Lets actually try Hybrid Emulation

Post by foft »

Added that invalidation but its not _the_ problem. Since its jumps to ROM right away and doesn't really compile anything in the chip area... Continuing to investigate!
foft
Posts: 334
Joined: Thu Dec 03, 2020 11:05 am
Has thanked: 29 times
Been thanked: 120 times

Re: Lets actually try Hybrid Emulation

Post by foft »

So its from here... which is then from ...

Handler for miscellaneous other errors.
; These can be caught by the task.

FC0850 sub.l #$FC07DA,(SP) Use the return address on the stack
FC0856 lsr 2(SP) to compute the exception number.
FC085A btst #5,4(SP) See if error occurred in supervisor mode.
FC0860 beq.s FC0894 If not, go to task's trap routine.
FC0862 bra FC2FB4 Guru time if in supervisor mode.
foft
Posts: 334
Joined: Thu Dec 03, 2020 11:05 am
Has thanked: 29 times
Been thanked: 120 times

Re: Lets actually try Hybrid Emulation

Post by foft »

Divide by zero?

0x00fe9158: divuw %fp@(34),%d0
0x00fe915c: swap %d0
0x00fe915e: movew %d0,%d1
0x00fe9160: muluw %fp@(36),%d1
0x00fe9164: addl %fp@(206),%d1
0x00fe9168: movel %d1,%sp@-
0x00fe916a: swap %d0
0x00fe916c: moveaw %d0,%a1
0x00fe916e: movel %a1,%sp@-
0x00fe9170: moveal %sp,%a1
0x00fe9172: bsrw 0xfe9516

0x00fc081e: bsrs 0xfc088c <- what is this exception vector?
foft
Posts: 334
Joined: Thu Dec 03, 2020 11:05 am
Has thanked: 29 times
Been thanked: 120 times

Re: Lets actually try Hybrid Emulation

Post by foft »

There are only 8 instances of swap in the 1.2 disassembly and I don't see any div. I'd better check that code...
foft
Posts: 334
Joined: Thu Dec 03, 2020 11:05 am
Has thanked: 29 times
Been thanked: 120 times

Re: Lets actually try Hybrid Emulation

Post by foft »

Err, its off the end of the rom. The rom is 0xf80000 to 0xfc0000 right?

No, its fc0000 - ffffff, doh.

so...
00029100 70 00 4e 75 2f 09 41 e9 00 20 61 00 00 08 22 5f |p.Nu/.A.. a..."_|
00029110 61 98 4e 75 22 78 00 04 33 fc 40 00 00 df f0 9a |a.Nu"x..3.@.....|
00029120 52 29 01 26 20 ae 00 c6 21 6e 00 ca 00 04 70 00 |R).& ...!n....p.|
00029130 43 f9 00 bf e0 01 10 29 0a 00 e1 88 10 29 09 00 |C......).....)..|
00029140 e1 88 10 29 08 00 22 78 00 04 53 29 01 26 6c 08 |...).."x..S).&l.|
00029150 33 fc c0 00 00 df f0 9a 80 ee 00 22 48 40 32 00 |3.........."H@2.|
00029160 c2 ee 00 24 d2 ae 00 ce 2f 01 48 40 32 40 2f 09 |...$..../.H@2@/.|
00029170 22 4f 61 00 03 a2 50 8f 70 01 d1 ae 00 ce 4e 75 |"Oa...P.p.....Nu|
00029180 20 78 00 04 33 fc 40 00 00 df f0 9a 52 28 01 26 | x..3.@.....R(.&|
00029190 2d 69 00 20 00 c6 2d 69 00 24 00 ca 61 18 20 78 |-i. ..-i.$..a. x|
000291a0 00 04 53 28 01 26 6c 08 33 fc c0 00 00 df f0 9a |..S(.&l.3.......|
000291b0 61 00 fe f8 4e 75 42 ae 00 ce 41 f9 00 bf e0 01 |a...NuB...A.....|
000291c0 70 00 11 40 0a 00 11 40 09 00 11 40 08 00 4e 75 |p..@...@...@..Nu|
000291d0 2f 0b 08 a9 00 00 00 1e 20 78 00 04 33 fc 40 00 |/....... x..3.@.|
000291e0 00 df f0 9a 52 28 01 26 26 69 00 18 b7 eb 00 08 |....R(.&&i......|
000291f0 66 18 20 13 26 89 48 d1 08 01 20 40 21 49 00 04 |f. .&.H... @!I..|
foft
Posts: 334
Joined: Thu Dec 03, 2020 11:05 am
Has thanked: 29 times
Been thanked: 120 times

Re: Lets actually try Hybrid Emulation

Post by foft »

OK, looks to be a real divide and real code... So what is fp(34)
foft
Posts: 334
Joined: Thu Dec 03, 2020 11:05 am
Has thanked: 29 times
Been thanked: 120 times

Re: Lets actually try Hybrid Emulation

Post by foft »

I turned off the fpu ... and it booted one time and ran sysinfo!

BTW they weren't divide by zero, they were privilege violation then illegal instruction (save).
Bas
Top Contributor
Posts: 567
Joined: Fri Jan 22, 2021 4:36 pm
Has thanked: 74 times
Been thanked: 273 times

Re: Lets actually try Hybrid Emulation

Post by Bas »

So how did it stack up that one Sysinfo run?
foft
Posts: 334
Joined: Thu Dec 03, 2020 11:05 am
Has thanked: 29 times
Been thanked: 120 times

Re: Lets actually try Hybrid Emulation

Post by foft »

Well, 12000 dhrystones. It should be 400000. Though I have some logging which I think is massively slowing it down, just when I turn it off it doesn't boot!
foft
Posts: 334
Joined: Thu Dec 03, 2020 11:05 am
Has thanked: 29 times
Been thanked: 120 times

Re: Lets actually try Hybrid Emulation

Post by foft »

OK, here is a binary to play with:
http://www.64kib.com/qemu-system-m68kv3.gz
(You need the libs/script from the earlier post)

& the qemu patch:
qemuv3.patch.gz
(3.77 KiB) Downloaded 109 times
Yes I get the error about the expansion cards on boot (don't know why yet).
Oh and I'm using 384MB fast, 2MB chip and AGA.

P.S. very crashy too!
foft
Posts: 334
Joined: Thu Dec 03, 2020 11:05 am
Has thanked: 29 times
Been thanked: 120 times

Re: Lets actually try Hybrid Emulation

Post by foft »

The maintainer of the 68k part of qemu told me that 68040 is most mature. I tried it and it doesn’t boot (yet).

He also mentioned that the floating point save is disabled on 68020 since the stack frame isn’t implemented. Probably I could have found this much quicker if I looked straight for an exception - learning curve! Anyway apparently it might work with 68040 fpu frames.

Anyway plenty to figure out still. I’m probably going to take a few weeks break from this - got another project that I promised to do.

I posted all the hdl and code except the musashi stuff, I’ll do that tomorrow.
lordoftime79
Posts: 97
Joined: Sun Feb 14, 2021 6:29 pm
Has thanked: 1 time
Been thanked: 2 times

Re: Lets actually try Hybrid Emulation

Post by lordoftime79 »

where do we put these files?
foft
Posts: 334
Joined: Thu Dec 03, 2020 11:05 am
Has thanked: 29 times
Been thanked: 120 times

Re: Lets actually try Hybrid Emulation

Post by foft »

Grab this, it has the whole thing:
http://www.64kib.com/qemu_system_testv3.tar.xz

Extract the archive to /media/fat

Run ./qemu_system_test/go
(can put this in that 68000.sh I guess, I didn't try).
User avatar
Caldor
Top Contributor
Posts: 930
Joined: Sat Jul 25, 2020 11:20 am
Has thanked: 112 times
Been thanked: 111 times

Re: Lets actually try Hybrid Emulation

Post by Caldor »

Does this mean Qemu can be made to only emulate the CPU itself and its then used as the CPU for the Minimig core?
foft
Posts: 334
Joined: Thu Dec 03, 2020 11:05 am
Has thanked: 29 times
Been thanked: 120 times

Re: Lets actually try Hybrid Emulation

Post by foft »

Yes, that is what we have here. Though it needs some improvement it does boot and run some games.
Neocaron
Posts: 352
Joined: Sun Sep 27, 2020 10:16 am
Has thanked: 194 times
Been thanked: 72 times

Re: Lets actually try Hybrid Emulation

Post by Neocaron »

Yeah congrats Foft, I hope you'll get it nice and shiny once you're done with your other project, so other devs can see the appeal and use this idea for other cores. (Like the a0486 or newer one that were not possible in the first place)

Any idea of what is the performance cost on the cpu side? What I mean by that is basically, how much juice can be used from its original frequency? I know optimisation can probably make this number vary quite a bit, but a rough estimate would be interesting to know. I'm sure you can't just translate the 800mhz into 800 usable mhz in the emulator frequency.
lordoftime79
Posts: 97
Joined: Sun Feb 14, 2021 6:29 pm
Has thanked: 1 time
Been thanked: 2 times

Re: Lets actually try Hybrid Emulation

Post by lordoftime79 »

how do I use this?
foft
Posts: 334
Joined: Thu Dec 03, 2020 11:05 am
Has thanked: 29 times
Been thanked: 120 times

Re: Lets actually try Hybrid Emulation

Post by foft »

Like the musashi one, except leave the core at 384MB fast.
i.e.
i) start core from menu
ii) ssh in
iii) cd /media/fat
iv) ./qemu_system_test/go
foft
Posts: 334
Joined: Thu Dec 03, 2020 11:05 am
Has thanked: 29 times
Been thanked: 120 times

Re: Lets actually try Hybrid Emulation

Post by foft »

Neocaron wrote: Thu Apr 22, 2021 7:29 pm Yeah congrats Foft, I hope you'll get it nice and shiny once you're done with your other project, so other devs can see the appeal and use this idea for other cores. (Like the a0486 or newer one that were not possible in the first place)

Any idea of what is the performance cost on the cpu side? What I mean by that is basically, how much juice can be used from its original frequency? I know optimisation can probably make this number vary quite a bit, but a rough estimate would be interesting to know. I'm sure you can't just translate the 800mhz into 800 usable mhz in the emulator frequency.
There are some dhrystones measurements earlier in the thread.
Native arm:
Dhrystone(1.1) time for 10000000 passes = 2.3
This machine benchmarks at 4442697 dhrystones/second
2529 DMIPS
68K qemu:
Dhrystone(1.1) time for 10000000 passes = 19.0
This machine benchmarks at 526624 dhrystones/second
300 DMIPS

i.e. ~12%
Ideally we'd expose the native arm too, for where more performance is needed.
lordoftime79
Posts: 97
Joined: Sun Feb 14, 2021 6:29 pm
Has thanked: 1 time
Been thanked: 2 times

Re: Lets actually try Hybrid Emulation

Post by lordoftime79 »

Is there away to do it without the ssh in part as i dont have a computer close to my mister - is there anyway i can get it to work without doing that like the old version?
foft
Posts: 334
Joined: Thu Dec 03, 2020 11:05 am
Has thanked: 29 times
Been thanked: 120 times

Re: Lets actually try Hybrid Emulation

Post by foft »

Yes, same as the old version.

I mean that works by run a script to start cpu, when core restarted in the menu, it stops the script and restarts it.
lordoftime79
Posts: 97
Joined: Sun Feb 14, 2021 6:29 pm
Has thanked: 1 time
Been thanked: 2 times

Re: Lets actually try Hybrid Emulation

Post by lordoftime79 »

I am struggling with this - the old one worked but this isnt working... how do I make it work without having to do the Shh
lordoftime79
Posts: 97
Joined: Sun Feb 14, 2021 6:29 pm
Has thanked: 1 time
Been thanked: 2 times

Re: Lets actually try Hybrid Emulation

Post by lordoftime79 »

lordoftime79 wrote: Fri Apr 23, 2021 12:02 pm I am struggling with this - the old one worked but this isnt working... how do I make it work without having to do the Shh - do i still need the 68000 and if so what do i put in it - go or qemu-system-m68k also where do the libs folder go?
Post Reply