Now that we can execute PPC code from the 68K side, the next step is to execute 68K code from the PPC side. In WarpOS, this is done with the Run68K() function.
In a standard WarpOS program, the PPC task is setup by a 68K task, as the OS is 68K. When the PPC code is called from the sonnet library, the 68K task enters the WaitPort() function so the Amiga OS can execute other tasks while the 68K tasks waits for the PPC. We can use this same port from the PPC side (and so this waiting 68K task) to execute 68K code by sending a message to this port containing the information needed (called PPStruct within WarpOS). Actually, this port, set up by the sonnet library, waits for two types of messages (at the present). A message signaling that 68K code needs to be executed, or a message stating that the PPC has finished its code.
It's actually a bit more complicated than this, but we'll save the real tech talk for another time.
At the moment, the sonnet library only supports synchronous executing, which means that the 68K task waits for its PPC mirror task to complete before continuing and the other way around. For multitasking on the PPC side, we need to have code in place that puts the PPC task in a wait state when this happens and schedule another 'ready' PPC task. This code is commonly known as a 'Scheduler'. All this is of course already implemented on the 68K side by the Amiga OS.
When the 68K is ready, it signals the PPC that it can continue its code. So the sonnet library scheduler sets the task again in a 'ready' state and decides to put it into running based on priority compared to other 'ready' tasks,
So after putting Run68K() and a simple task scheduler in place, the WarpOS program 'Tabletennis' now works on Sonnet:
Now the less fun work begins as with the more complex programs, the ugly beast of cache coherency and consistency in a dual CPU system rears it head. So next up is to write code which properly handles the flushing and invalidation of caches.
To share the things I do with my Amiga computers. From tinkering with the hardware to writing software!
Wednesday, April 29, 2015
Monday, April 13, 2015
Some first results!
Of course I wanted to get some results quickly, but how to achieve that? Looking at WarpOS there are 2 critical functions who could help me to get just that: Results!
RunPPC and Run68K are the two main functions which execute code, RunPPC is called from 68K code to execute PPC code and Run68K is the other way around.
Looking at some of the sources of the demo programs included with WarpOS, the most simple ones just used RunPPC. But after a few hours of coding and a working RunPPC there was nothing to show for. Of course: code got executed, but no meaningful PPC functions were there yet, let alone functions with any meaningful output. So GetInfo() was included in the first version of sonnet.library and various tag functions. This resulted in the very first WarpOS-like program to be run: GetInfo!
Here it is. The MPC750 showing itself for the first time. The GetInfo program reads (amongst other info) the PVR which is a special register of the PowerPC with the CPU info in it.
Looking at the sources of the other WarpOS demo programs, it seemed that CyberPI was an easy program to convert. As the PowerPC of the Sonnet can only access the memory on the Sonnet itself (and PCI memory). WarpOS programs need to be patched to be loaded into the Sonnet memory. Three simple patches later this was the result:
CyberPI with 100000 decimals is completed in 1 minute and 28 seconds. Compared to:
50 minutes on a 25 MHz 68030
30 minutes on a 25 MHz 68040
15 minutes on a 50 MHz 68060
9 minutes on a 150 MHz 603e
4,5 minutes on a 200 MHz 604e
Cybermand also looked like a program which could be patched easily. And it worked almost out of the box:
Next stop is to get the Run68K going followed by multitasking (scheduler) on the PPC.
RunPPC and Run68K are the two main functions which execute code, RunPPC is called from 68K code to execute PPC code and Run68K is the other way around.
Looking at some of the sources of the demo programs included with WarpOS, the most simple ones just used RunPPC. But after a few hours of coding and a working RunPPC there was nothing to show for. Of course: code got executed, but no meaningful PPC functions were there yet, let alone functions with any meaningful output. So GetInfo() was included in the first version of sonnet.library and various tag functions. This resulted in the very first WarpOS-like program to be run: GetInfo!
Here it is. The MPC750 showing itself for the first time. The GetInfo program reads (amongst other info) the PVR which is a special register of the PowerPC with the CPU info in it.
Looking at the sources of the other WarpOS demo programs, it seemed that CyberPI was an easy program to convert. As the PowerPC of the Sonnet can only access the memory on the Sonnet itself (and PCI memory). WarpOS programs need to be patched to be loaded into the Sonnet memory. Three simple patches later this was the result:
CyberPI with 100000 decimals is completed in 1 minute and 28 seconds. Compared to:
50 minutes on a 25 MHz 68030
30 minutes on a 25 MHz 68040
15 minutes on a 50 MHz 68060
9 minutes on a 150 MHz 603e
4,5 minutes on a 200 MHz 604e
Cybermand also looked like a program which could be patched easily. And it worked almost out of the box:
Next stop is to get the Run68K going followed by multitasking (scheduler) on the PPC.
Subscribe to:
Posts (Atom)