In my last post I have asked you for an opinion regarding AArch64 port of Emu68. Since most of you voted for it I have looked into the ARMv8 manuals and started to learn it. No, I had no previous work done with 64bit ARM but I just thought it could be interesting to give it a try.
In order to make a parallel port as easy as possible I have cleaned up the Emu68 code a little and I have wrote simple startups code in 64bit ARM assembly. The startup code prepares the stack, enters BigEndian mode and enters the supervisor (EL1) mode, eventually leaving the hypervisor (EL2) or secure monitor (EL3) by that occasion. Once correct mode is reached, the stack is prepared and C code starts. So far I have no MMU yet, but it will come as next step.
Since booting RasPi all the time would be pretty time-consuming, I've decided to give QEMU a try. It has nice AArch64 emulator partially supporting RasPi3 hardware. And guess what - it boots my code properly. What was not working for 32bit mode ARM works in this case perfectly. That made my day!
As you can see in the screenshot above, the first portions of Emu68 seem to work nicely. I can even query the screen, set its dimensions and draw Emu68 logo on it. Isn't it nice?
In next step I will add MMU setup for AArch64 and will make sure the build still works properly for the 32bit ARM. It should, but double checking is better than no check.
So, how will it look like? Once both versions of Emu68 are in sync, you will receive kernel.img and kernel8.img from me. The RasPi start.elf file will recognise the machine and ARM cpu features. If 64bit mode is available (this is the case on RPi3 and RPi4), it will pick the 64bit kernel8.img up, otherwise kernel.img (RasPi2) will be loaded. On M68k side there will be no change :) The same memory layout, the same access rights, the same RasPi peripheral base address.