-
Notifications
You must be signed in to change notification settings - Fork 293
Basilisk II Core Emulation Analysis
"Emulation core" refers to the logic of translating M68k CPU guest instructions into non-M68k CPU host instructions (Intel X86, AMD64, ARM and PPC). Besides CPU core emulation, we have a separate page to describe 68k Macintosh peripheral hardware emulation such as timer, ethernet, audio and etc. The majority of emulation analysis is based on the study under AMD64 Linux host. But it should apply to different host architecture and host operating system.
The facts described below are purely based on:
If it is on the Internet it must be true.
Basilisk II CPU emulation was first started by Christian Bauer. From the initial source code, it has an original root from another M68k Amiga emulation project called UAE. By performing a diff between early commit set 2bebaceabc7646d in macemu git repo and UAE v0.8.10 source code, we find that the files build68k.c, cpuopti.c, gencpu.c and table68k are nearly identical to those in UAE. For further reading on UAE, you can view the UAE People Section in the WinUAE documentation.
Based on the commit history, Gwénolé Beauchesne is the key contributor to Basilisk II CPU emulation. He added JIT translation (a.k.a dynamic binary translation) to speed up emulation. TODO...
For non-M68k CPU emulation, the source code is under src/uae_cpu folder.'
TODO -- overview of Glue/Adapter, UAE CPU, FPU and JIT.
There are two different perspectives in terms of memory addressing in emulation.
The first one is from the host OS point of view. Emulation program such as Basilisk II runs as an application at ring 3 user space. Majority modern host CPU, such as Intel x86, AMD 64, PPC and ARM nowadays builds with MMU, which may provide segmentation and paging. Majority modern host OS such as Linux, Mac OS X and Windows uses virtual address, instead of physical address.
For 32 bit CPU, CPU in theory can access up to 2^32 byte (4GB) virtual memory. 64 bit CPU can access address space far more than you can imagine. However, it doesn’t mean application can use whatever virtual address. This usually depends on CPU architecture and host OS implementation. For example, 32 bit Linux by default put aside lower 3GB for user space and upper 1GB for kernel space [1].
The second perspective is from the guest Macintosh OS point of view. In theory, guest OS doesn’t know if it runs under a physical M68k CPU or an emulated CPU provided by BII. Therefore BII needs to provide memory address mapping between guest OS and BII user space memory in host OS when executing translated instruction.
According to wikipedia page on M68k series CPU[2], only 68030 or above M68k series CPU has built-in Paged MMU. In addition, Apple added virtual memory features to System 7.
TODO -- investigate if BII emulate PMMU. Try to enable virtual memory in memory manger under control panel.
This addressing is for native M68k CPU.
TODO
TODO
TODO
TODO