Lets actually try Hybrid Emulation

NovaCoder
Posts: 23
Joined: Fri Aug 07, 2020 4:02 am
Has thanked: 4 times
Been thanked: 1 time

Re: Lets actually try Hybrid Emulation

Unread post by NovaCoder »

Best 040 library to use will probably be the one from the OS 3.9 CD-ROM.

Alternatively you could try MMU.library

http://aminet.net/package/util/libs/MMULib.lha

060 CPU was very different to the 68040 so best not to use that library unless you are emulating an 68060.

Also be mindful that most 68060 libraries are designed for a specific accelerator card. Even some 68040 libraries were bundled with accelerators so may possibly contain some proprietary code.

MMU libs are generic but can be tricky to setup in workbench.

You can obviously use winaue to test that you have a working workbench set-up before switching over to the MiSTer.
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

Unread post by foft »

So, the user mode vs system mode qemu thing is the case with other qemu machines. So nothing to do with my homebrew one!

time ./run_m68k ./main_68k_elf
real 1m38.438s
user 1m38.294s
sys 0m0.064s

vs

@debian:~/test_hybrid_freestanding# time ./main_68k_elf
real 4m43.590s
user 4m30.640s
sys 0m0.230s

This matches what I see when I write my own amiga 'rom' that just runs the same program in fast ram.
kolla
Posts: 188
Joined: Sat Jun 13, 2020 7:56 am
Has thanked: 17 times
Been thanked: 33 times

Re: Lets actually try Hybrid Emulation

Unread post by kolla »

Regarding the 68040 libraries, I think the problem with the mmulib ones are either the mmu, or perhaps that it tries to “fix” known issues with the real 68040s that aren’t necessarily there with a software emulated 68040…
bbond007
Top Contributor
Posts: 519
Joined: Tue May 26, 2020 5:06 am
Has thanked: 85 times
Been thanked: 198 times

Re: Lets actually try Hybrid Emulation

Unread post by bbond007 »

foft wrote: Tue May 04, 2021 10:43 am For anyone who wants to try the current state 'as-is'...

OK, here is a new core and kernel module.
http://www.64kib.com/minimig_irq_core.tar.gz

After booting up you can install it using:
./minimig_module/setup
Then you can check /proc/interrupts and dmesg to check it is happy.

Next you need a new qemu:
http://www.64kib.com/qemu_system_testv8.tar.xz

Clicking on icons is crashy but you can run stuff from the cli!
Thanks!

I was able to run a demo targeted for AGA/060+

Very cool that it ran at all but underwhelming framerate wise. SysInfo lies :)
OceanMachine.png
OceanMachine.png (2.17 MiB) Viewed 7328 times
http://www.pouet.net/prod.php?which=16337

Updated my script to load the kernel module:
68000.zip
(583.07 KiB) Downloaded 148 times
kolla
Posts: 188
Joined: Sat Jun 13, 2020 7:56 am
Has thanked: 17 times
Been thanked: 33 times

Re: Lets actually try Hybrid Emulation

Unread post by kolla »

Can’t expect too much when emulating full 040 with MMU and (hence) no JIT :)
NovaCoder
Posts: 23
Joined: Fri Aug 07, 2020 4:02 am
Has thanked: 4 times
Been thanked: 1 time

Re: Lets actually try Hybrid Emulation

Unread post by NovaCoder »

Cool to see such fast progress :D

If you want another thing to test with then you can try my port of ZDOOM which runs on all CPUs.

http://aminet.net/package/game/shoot/ZDOOM_AGA

http://aminet.net/package/game/shoot/ZDOOM_RTG
User avatar
LamerDeluxe
Top Contributor
Posts: 1160
Joined: Sun May 24, 2020 10:25 pm
Has thanked: 798 times
Been thanked: 257 times

Re: Lets actually try Hybrid Emulation

Unread post by LamerDeluxe »

My Candy Factory Pro software also has versions for all types of CPUs and shows the time it took to render an image.
It was commercial software but can now be downloaded for free here: https://www.amigafuture.de/app.php/dlex ... id=5116%3f
(you need to register at that site to be able to download it)
kolla
Posts: 188
Joined: Sat Jun 13, 2020 7:56 am
Has thanked: 17 times
Been thanked: 33 times

Re: Lets actually try Hybrid Emulation

Unread post by kolla »

There is no JIT option for qemu, I guess?
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

Unread post by foft »

qemu is jit, that is why it gets like 500000 dhrystones.

You can see the code translation if you run with -d in_asm,out_asm
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

Unread post by foft »

Something really weird...

Cold boot -> newcli -> software:benchmarks/sysinfo -> sys info. This gives 4000 dhrystones.
Cold boot -> gui -> software:benchmarks/sysinfo -> sys info. This gives 74000 dhrystones.
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

Unread post by foft »

A couple of icon clicking crashes...

chipROM::UNKNOWN tb at 0xb2a69200
INT 4369: Level 3 Interrupt(0x6c) pc=00f9693a sp=401a0a34 sr=0014:Trace 0: 0xb2a665c0 [00000000/00f81354/0x2000]
0x00f947ea: movew #64,%a0@(156)
0x00f947f0: movel %a1@(58),%d0
0x00f947f4: beqs 0xf947e8

0x00f947f6: btst #1,%a1@(169)
0x00f947fc: beqs 0xf947e8

0x00f947fe: moveal %a1,%fp
0x00f94800: moveal %d0,%a1
0x00f94802: tstb %a0@(2)
0x00f94806: btst #6,%a0@(2)
0x00f9480c: beqs 0xf94826

0x00f94826: tstb %a0@(2)
0x00f9482a: bclr #7,%fp@(169)
0x00f94830: bnes 0xf94858

0x00f94832: movew %a1@(12),%d0
0x00f94836: bpls 0xf9484e

0x00f9484e: moveal %a1@(4),%a5
0x00f94852: jsr %a5@ -> jsr to space...

chipROM:0x00001120: orib #0,%d0
0x00001124: orib #0,%d0
0x00001128: orib #0,%d0
---

chipROM::UNKNOWN tb at 0xb2b69200
INT 2079: Level 3 Interrupt(0x6c) pc=400083aa sp=401a0ad8 sr=0014:Trace 0: 0xb2b665c0 [00000000/00f81354/0x2000]
0x00f947ea: movew #64,%a0@(156)
0x00f947f0: movel %a1@(58),%d0
0x00f947f4: beqs 0xf947e8

0x00f947f6: btst #1,%a1@(169)
0x00f947fc: beqs 0xf947e8

0x00f947fe: moveal %a1,%fp
0x00f94800: moveal %d0,%a1
0x00f94802: tstb %a0@(2)
0x00f94806: btst #6,%a0@(2)
0x00f9480c: beqs 0xf94826

0x00f94826: tstb %a0@(2)
0x00f9482a: bclr #7,%fp@(169)
0x00f94830: bnes 0xf94858

0x00f94832: movew %a1@(12),%d0
0x00f94836: bpls 0xf9484e

0x00f9484e: moveal %a1@(4),%a5
0x00f94852: jsr %a5@ -> jsr to space...

chipROM:0x00000028: 0370
0x0000002a: bset %d5,%a2@(248)
0x0000002e: bset %d5,%a4@(248)
0x00000032: bset %d5,%fp@(248)
0x00000036: bset %d5,%a0@(fffffffffffffff8,%d0:w)
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

Unread post by foft »

Normally it goes here:
0x00f96a1c: moveb %a1@(22),%d0
kolla
Posts: 188
Joined: Sat Jun 13, 2020 7:56 am
Has thanked: 17 times
Been thanked: 33 times

Re: Lets actually try Hybrid Emulation

Unread post by kolla »

So JIT and MMU? In other 68k emulators those have been mutually exclusive - either super fast JIT or relatively slow “non JIT”, but with MMU.
kolla
Posts: 188
Joined: Sat Jun 13, 2020 7:56 am
Has thanked: 17 times
Been thanked: 33 times

Re: Lets actually try Hybrid Emulation

Unread post by kolla »

foft wrote: Tue May 04, 2021 10:43 am OK, here is a new core and kernel module.
http://www.64kib.com/minimig_irq_core.tar.gz
Where do I find the sources for this module?
As I wrote earlier, I build my own kernels, and hence the "magic version" is different than the "official" kernel :)

Code: Select all

/root# insmod /media/fat/Amiga/minimig_module/minimig-irq.ko
insmod: ERROR: could not insert module /media/fat/Amiga/minimig_module/minimig-irq.ko: Invalid module format
Dmesg output:

Code: Select all

[Wed May  5 22:42:32 2021] minimig_irq: version magic '4.19.0-socfpga-r1 SMP mod_unload ARMv7 p2v8 ' should be '4.19.0 SMP mod_unload ARMv7 p2v8 '
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

Unread post by foft »

Here is the kernel module source, please excuse the mess!
Attachments
minimigirq.tar.gz
(2.58 KiB) Downloaded 128 times
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

Unread post by foft »

kolla wrote: Wed May 05, 2021 9:45 pm So JIT and MMU? In other 68k emulators those have been mutually exclusive - either super fast JIT or relatively slow “non JIT”, but with MMU.
Yeah that is with the uae jit. I plan to try that too but haven't worked out how to plumb it in yet.
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

Unread post by Caldor »

I have been testing a bit with the newest updates. Still seems unstable. I tried using the 3.1.4 ROM from Hyperion and the Workbench that comes with it, but it still had the problem with clicking icons even though the install disk should have a 68040 library.

I will wait for it to be more stable I think. Unless there is something that needs testing maybe that I can help with.
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

Unread post by foft »

Caldor wrote: Thu May 06, 2021 11:35 am I have been testing a bit with the newest updates. Still seems unstable. I tried using the 3.1.4 ROM from Hyperion and the Workbench that comes with it, but it still had the problem with clicking icons even though the install disk should have a 68040 library.

I will wait for it to be more stable I think. Unless there is something that needs testing maybe that I can help with.
Yes its very unstable right now.

The kind of testing I'm keen on now is really people familiar with 68k machine code, 68k testing tools and amiga rom internals. I'm more familiar with the Atari 8-bit since I never developed on the Amiga.
kolla
Posts: 188
Joined: Sat Jun 13, 2020 7:56 am
Has thanked: 17 times
Been thanked: 33 times

Re: Lets actually try Hybrid Emulation

Unread post by kolla »

Caldor wrote: Thu May 06, 2021 11:35 am I tried using the 3.1.4 ROM from Hyperion and the Workbench that comes with it, but it still had the problem with clicking icons even though the install disk should have a 68040 library.
OS 3.1.4 does NOT come with 68040.library, you are supposed to install CPU libraries from CPU card provider - or the CPU libraries from ThoR (MMULib).

Running AmigaOS on 68040 or 68060, "real" or not, without having CPU library installed, is bound to cause various problems.
NovaCoder
Posts: 23
Joined: Fri Aug 07, 2020 4:02 am
Has thanked: 4 times
Been thanked: 1 time

Re: Lets actually try Hybrid Emulation

Unread post by NovaCoder »

Yes like I said before, the logical way to test this new 040 core is to first set up a working (verified) workbench installation under winuae (obviously emulating an 040). Once you have a validated workbench installation you can then switch to the MiSTer for a comparison.

I recommend using a base OS 3.9 installation with just boing bags 1 and 2 installed and no other 3rd party patches, this will give you a very clean and stable installation.

It seems that the people developing this core are not really Amiga workbench people, if you need some guidance please ask over on the English Amiga board and you will get lots of help setting up workbench.

http://eab.abime.net/index.php
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

Unread post by foft »

From my googling, a crash on doubling clicking icons on workbench can be CIA related.

So despite it just jumping to random memory, I wonder if the root cause is timing.
User avatar
toastboy
Posts: 69
Joined: Wed Sep 09, 2020 9:20 pm
Has thanked: 13 times
Been thanked: 19 times

Re: Lets actually try Hybrid Emulation

Unread post by toastboy »

kolla wrote: Sat May 08, 2021 4:43 pm OS 3.1.4 does NOT come with 68040.library, you are supposed to install CPU libraries from CPU card provider - or the CPU libraries from ThoR (MMULib).
Running AmigaOS on 68040 or 68060, "real" or not, without having CPU library installed, is bound to cause various problems.
I restored an A4000 last year with 68040 cpu card and 3.1.4 ROM.
When 3.1.4 workbench boots from a clean install, you get a prompt on boot about the lack of 68040 libs.
Then it crashes a lot, but at least it told you so.
kolla
Posts: 188
Joined: Sat Jun 13, 2020 7:56 am
Has thanked: 17 times
Been thanked: 33 times

Re: Lets actually try Hybrid Emulation

Unread post by kolla »

The cause for the crashes (8000 000B) are the mathlibs, which may try to use calls for the 68881/68882 that isn’t available. 68040.library traps those calls that aren’t available on 040 and perform them in software instead (essentially 68881/68882 emulation).

There are mathlibs that do not use FPU, and hence will not cause such problems - I wonder if perhaps the 3.9 ones are such, would need to look it up. (I have them for use with FEMU, the software FPU emulator, which uses the math libs for FPU emulation, and hence cannot rely on an FPU… which they emulate, catch 22)
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

Unread post by foft »

I'm not just getting 8000 000B, so I think this is more than 68040.library. In fact I seem to get a random exception each time and the address it jumps to seems somewhat random.

I put the library in from the link I posted before and no longer have the instability warning now.

I wonder if its a double click issue rather than anything workbench specific. I'll try that...
kolla
Posts: 188
Joined: Sat Jun 13, 2020 7:56 am
Has thanked: 17 times
Been thanked: 33 times

Re: Lets actually try Hybrid Emulation

Unread post by kolla »

@foft

What kind of crashes do you see? Freeze? System failure with red alert? If so, what error code? All kinds of icons?

I ask since I don't really see such crashes myself.

EdIt: ah, ok, I see... so it happens when double clicking, regardless of where the pointer is?
Only thing I see here is that the mouse pointer is somewhat jerky and lagging.
robinsonb5
Posts: 129
Joined: Fri Jun 19, 2020 8:54 pm
Has thanked: 13 times
Been thanked: 57 times

Re: Lets actually try Hybrid Emulation

Unread post by robinsonb5 »

foft wrote: Mon May 10, 2021 6:48 am I'm not just getting 8000 000B, so I think this is more than 68040.library. In fact I seem to get a random exception each time and the address it jumps to seems somewhat random.
It's certainly true that 8000 000B exception is caused a fault with FPU-related opcodes, but it's often the result of the program counter ending up somewhere it shouldn't, and the machine trying to executing data as if it were code. So it can indicate a math / cpu library problem but it can also indicate memory corruption or a cache issue.
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

Unread post by foft »

So seems I can trace memory accesses using:
memory_region_ops_read, memory_region_ops_write

There is also a handy patch that
https://patchew.org/QEMU/20210307074833 ... amsat.org/

So we can trace the entire instruction sequence executed, the memory accesses and the registers. It must be possible to figure this out with all this, though it feels like finding a needle in a haystack.

Actually I couldn't reproduce with the register dump on...

BTW if you switch on this tracing be aware that its glacial if it doesn't go to /tmp/. Also they can be switched on at runtime in the monitor, so we can enable them after the boot up before running a test.
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

Unread post by foft »

i.e. enable like this...
& in the go script use -D /tmp/qemu.log

/media/fat# ./qemu_system_test/go
Init interrupt polling thread (requires kernel module):0xb4c1e000
QEMU 5.2.93 monitor - type 'help' for more information
(qemu) log in_asm,out_asm,exec,nochain
(qemu) trace-event memory_region_ops_read on
(qemu) trace-event memory_region_ops_write on
(qemu) trace-event memory_region_ram_device_read on
(qemu) trace-event memory_region_ram_device_write on

Can also log 'cpu' to get all the registers and 'int' to get all interrupts. I didn't manage to reproduce with 'cpu' on!

edit: memory_region_ram_device* doesn't seem to work,. though memory_* is good...
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

Unread post by foft »

kolla wrote: Mon May 10, 2021 6:54 am @foft

What kind of crashes do you see? Freeze? System failure with red alert? If so, what error code? All kinds of icons?

I ask since I don't really see such crashes myself.

EdIt: ah, ok, I see... so it happens when double clicking, regardless of where the pointer is?
Only thing I see here is that the mouse pointer is somewhat jerky and lagging.
I see it double clicking on the drive icons (ram:, system: etc) on the workbench desktop mostly and sometimes in windows too. Miscellaneous guru.

I don't see a jerky mouse pointer though, except when I run at high trace levels.
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

Unread post by foft »

Turning on "trace-event memory_* on" or "log cpu" both make it work. Must be something timing related... Heisenbug!
Post Reply