stephen_usher wrote: 14 Mar 2022 19:59
Anders, are you making assumptions about the use of TT-RAM?
HDDriver uses TT-RAM for itself and if you're not using the OS to allocate memory then VeryBadThings(tm) will happen. This would especially be true under MiNT or any other pre-emptive multitasking operating system.
I think we're way past the point of VeryBadThings(tm) :)
This thing is doing all kinds of things that isn't compatible with TOS.
It's keeping TOS on a pretty strict leash, alive but dormant. The main reason it's being kept around is to avoid having to write hard disk drivers from scratch. I'm sure we're going to find other uses for it but that's what we use it for now.
The emulator enters a somewhat TOS compatible context whenever it needs to call TOS for anything but for the most part it's a bit of its own thing.
Having both Tos and Mac around at the same time does complicate matters since they both lay claim to some of the same resources but the alternative is much worse.
MiNT's multitasking doesn't really stand a chance. I don't think it does it for supervisor programs, but even if it wanted to it really can't, it only has as much (temporary) control over the machine as we allow it to.
It doesn't even matter if it changes any vectors. Tos assumes, just the MacOS do, that the CPU VBR is at the default location 0.
We've moved it though. So the CPU jumps to our table and we decide if we want to dispatch to Tos or Mac's virtualised tables, or do something completely different, as we see fit.
It's memory protection is only active when we are in tos context, the rest of the time the MMU is reconfigured specifically for the emulator.
At its core the "emulator" is just a little bit of oddball setup code before it jumps into the Mac ROM and we lose control over the "main loop".
Past that point we're just a glorified exception and interrupt handler :)
It's not really an emulator as such. It's "free running" Apple code directly on the machine while we try to grab control where we can - mostly in exceptions and interrupts but also by patching the Macintosh ROM to call our code.
At the same time prevent MacOS and TOS from fighting since they both are laying claim to some of the same resources and logical memory regions.
...But the memory is actually completely normal :)
It's just a normal Mxalloc() TOS call with flag 3 (Allocate either, Alternative-RAM preferred)
I could change it to Malloc() to not specify a preferred pool and thus let it be completely up to the program flags.
stephen_usher wrote: 14 Mar 2022 20:21
The program must be doing something incredibly hacky.
Yes, that's an understatement of the year :)
The OS calls are normal Fread() so that's nothing weird..
How we get to the point from a Mac->Atari in order to do so and then back to to Mac is though..
We do tick the virtualised 200hz counter for TOS's and HDDrivers convenience though, since it's not being allowed to process it's own timer-C interrupt :)