[NTLK] Einstein Xcode project cleanup

Paul Guyot pguyot at kallisys.net
Fri Dec 5 19:33:42 EST 2014


>> One other question I had about Einstein: It allocates 2 banks of 4 MB flash storage for a total of 8 MB.  As we know, a real MP2100 has 4 MB total flash storage.  Does Einstein have more just "because we can" or is there some other reason?  On a real MP2100, does it map out as a single 4 MB bank or 2 x 2MB banks or ...?
> 
> Einstein does not emulate the Flash RAM, but instead adds a Flash driver to the OS via a custom REx. In plain speak, Einstein uses the Flash access API to convert Flash RAM access into accessing a memory mapped Unix style disk file.

I was surprised by this statement so I checked my local copy of the source code.
It turns out flash memory is emulated like most hardware parts of the Newton: the simpler interactions with the hardware are emulated, and interactions going through a driver are bypassed with a custom shim driver. This approach proved successful except for networking where Matthias' NE2K emulator was easier to set up than bypassing networking at a higher level.

Flash read accesses on the Newton are done through regular reads at specific addresses (prepared through calls of the driver). Write accesses are only done through calling methods of the driver. This makes sense regarding what flash memory is.

Write accesses are bypassed through a ugly hack I'm not so proud of in TNativePrimitives::ExecuteFlashDriverNative( KUInt32 inInstruction ). This code is invoked through the custom driver using yet another mechanisms to invoke native code, and it actually peeks in the regular RAM to read out the virtual table of the driver or some other C++ object to find out more details on the call and especially if we are doing what I called a 32 bits write or a 16 bits write. I probably spent way too much time debugging this, and the three supported ROMs are hard-coded there (MP2x00 US, MP2100D and eMate).

Some driver functions are just void. For example, a comment reads:
"Erase is always complete with no error :D"
as TEinsteinFlashDriver::IsEraseComplete always returns 0.

To specifically answer your question Steven, I believe I realized we could have 8 MB of flash instead of the regular 4 MB we had, as a second 4MB bank was possible, so I enabled 8 MB.

This actually is (sparsely) commented in source code in TEinsteinFlashDriver::Identify:

// For 4MB, just return 1 for 0x34000000 only.

This should be understood as Einstein currently returns 1 for both chip addresses (0x34000000 and 0x34400000, cf another comment above) and probably my stock Newton only returned 1 for 0x34000000.
The structure written by this function could probably enable different flash sizes. We could also imagine a Newton only handling chip at 0x34400000 (what I called bank 2).

Likewise, I think Einstein could (does ?) emulate up to 4 PCMCIA cards…

Basically, the allocated 8MB definitely are internal storage.

Paul
-- 
Semiocast            http://semiocast.com/
+33.183627948 - 20 rue Lacaze, 75014 Paris




More information about the NewtonTalk mailing list