I've observed that the Macintosh Plus's memory mapping has many fragmented free segments after the RAM, totaling over 7.8MB. If I were to use two of the larger-looking segments to create 4MB of RAM, creating a mapping structure of 4MB + ROM & IO + 1MB + IO + 3MB, would the additional 1+3MB of memory be usable by applications (System 6)?Or can it be achieved by adding INITs。<snip>
Throwing my weight of naivety and ignorance into the mix of this.
My understanding is that for some Macs, particularly in the ≥68030 eras, but also going up to the PPC era (e.g. PowerBook 1400), non-contiguous RAM was handled both by custom chips and the MMU. But let's start with the Mac Plus, Mac SE (and presumably the Mac Classic).
They all in fact have hardware to handle non-contiguous RAM. Shock! Horror! Who knew? Well, we all do. If you place 4x 256kB RAM chips in a Mac Plus you get 1MB of RAM, but obviously this can't be using the same addressing as sticking 4x 1MB RAM chips. Instead a crude system using solder jumpers and resistors makes the second bank of 512kB contiguous with the first bank. And this explains why the RAM options are what they are: 1MB, 2MB, 2.5MB 4MB: there's no 1.5MB or 3MB options on a Plus. The DRAM chips of the era multiplexed address lines, so a 256kbit DRAM chip had 9 address lines A0..A8 when the /CAS signal is low which were also used for A9..A17 (/RAS is low). So, the next step up would need to use one more address line, giving A0..A9, which when multiplexed also gives A10..A19 and therefore addresses 1Mbit instead of 256kbit. Hence only two SIMMs were allowed: 256kB and 1MB (though with 64kbit x 4bit chips you can create other options, we'll ignore that).
Hmmm. The 1MB mapping could have been:
An...: A21 A20 A19 A18 A17 A16 A15 A14 A13 A12 A11 A10 A09 A08 A07 A06 A05 A04 A03 A02 A01 A00
Bank0: ..........0 a8. a7. a6. a5. a4. a3. a2. a1. a0. a8. a7. a6. a5. a4. a3. a2. a1. a0
Bank1: ..........1 a8. a7. a6. a5. a4. a3. a2. a1. a0. a8. a7. a6. a5. a4. a3. a2. a1. a0
Where
a8.. a0 in bold are the /RAS=0 multiplexed lines And the 4MB mapping could have been:
An..: A21 A20 A19 A18 A17 A16 A15 A14 A13 A12 A11 A10 A09 A08 A07 A06 A05 A04 A03 A02 A01 A00
Bank0:..0 a9. a8. a7. a6. a5. a4. a3. a2. a1. a0. a9. a8. a7. a6. a5. a4. a3. a2. a1. a0
Bank1:..1 a9. a8. a7. a6. a5. a4. a3. a2. a1. a0. a9. a8. a7. a6. a5. a4. a3. a2. a1. a0
But this would have required a9.. a0 to be shifted. Instead it's easier just to map just a9 and
a9 to the higher address bits:
An..: A21 A20 A19 A18 A17 A16 A15 A14 A13 A12 A11 A10 A09 A08 A07 A06 A05 A04 A03 A02 A01 A00
Bank0:..0. a9. a9. a8. a7. a6. a5. a4. a3. a2. a1. a0. a8. a7. a6. a5. a4. a3. a2. a1. a0
Bank1:..1. a9. a9. a8. a7. a6. a5. a4. a3. a2. a1. a0. a8. a7. a6. a5. a4. a3. a2. a1. a0
Given the simplicity of the Mac Plus SIMM handling, this is almost certainly how it's done. But the conclusion is the same, RAM in these other Macs is physically, non-contiguous. That's also why you have to put the 256kB DRAMs in bank 1 if you have 2.5MB, because then Bank0 happily generates the addresses for the first 2MB of RAM, and Bank1 only needs to generate up to
a8 a8.
Onto later generation Macs. Even though an LCII has a 68030 with an MMU, its
Egret chip (I think, edit: wrong it's called V8) handles different sizes of SIMMs, because a similar engineering challenge occurs! Except this time, the bit mangling can be controlled in software. Here, the bottom 4MB of RAM is fixed and must be in the lowest part of physical RAM if no SIMMs are inserted, but if 8MB of RAM is added, the SIMMs must be in the lower part of Physical RAM. Therefore the 4MB of RAM must initially be allocated 8MB of address space anyway and there are a few configuration bits (maybe just 1) which juggles address lines in the same way as for the Mac Plus. The LCII and LC are both limited to 10MB of RAM so the top 2MB of the 4MB of soldered RAM is inaccessible if SIMMs contain 8MB.
The Egret bit juggling is excusable for the LCII, because it basically uses the same logic board as the 68020-based LC which had no MMU. However, 68030 Macs like the IIsi and others had similar, limited options for RAM expansion, and will handle the physical RAM organisation in similar ways: with bit juggling in hardware.
You could also argue that the IIsi needed the hardware bit juggling, because it was released in the System 6 era, which had no support for virtual memory (and couldn't support it, because of the use of high address bits as flags by the OS's memory manager), but in fact similar things happen for the PowerPC Macs like the PowerBook 1400 whose MMU I understand is always active (even if VM is off). Having said this, the MMU in a 68030
could have been used to get around the problem even in the system 6 era by duplicating page tables for every 16MB of address space. Then it doesn't matter what's in the upper 8-bits, it still all points to the same addresses; and it doesn't matter that VM isn't supported because the page tables wouldn't be modified once the OS was booted up. The 68030 supports 32kB page table entries so you need 512 entries for 16MB of RAM and 131072 entries for the entire address space. so, not very practical (perhaps taking up to 2MB of RAM)!
Here, the PB1400 can support multiple odd-ball RAM slots. It has 8MB of soldered RAM + a daughterboard of 4MB or 8MB + 2 User RAM expansions each of which can support up to 32MB. In theory, it could be fitted with 64+16=80MB of RAM, though in fact this is not possible! In a PB1400 there's a physical memory mapping chip which has 32 entries of 4-bits each (16 bytes of IO space, because each byte contains a pair of entries). Each entry represents 2MB of physical address space, sourcing each 2MB from one of up to 8 RAM slots (Logic board, system expansion, then 3x user expansions for both boards). In theory, and there's some discussion about this on the 68KMLA, software could reprogram these on the fly to bank-switch in the other 16MB of RAM that's not usually available. This would almost certainly lead to a crash!
Is there a meaningful difference between these two?
- two discontiguous blocks of memory, from A to B and C to D
- one contiguous block of memory from A to D, with a locked handle from B to C
There has been some discussion about this for the Mac Plus and other 4MB Macs. The major reason why you need a gap is because the Mac Plus (and SE and Classic) have ROM sitting at 4MB, even though its only 128kB, so you could (in theory) add nearly 4MB of RAM on top until you hit I/O.
I made some progress on it. I don't think it's practical to create a locked handle to exclude the ROM gap, because by the time the OS has booted, The OS has already limited RAM to below the ROM. What I have proved is that you can run an app which launches another application with a specific memory allocation that takes the bottom of it's memory allocation to just above the gap you want to create; then launch a third application whose size forces the bottom of it's memory to just below the gap you want (thus that app covers the gap), then quit all the other apps, leaving that app occupying a hole in the Mac's memory.
Then what you'd do is implement that in a early INIT: adjust System RAM so that it's 8MB not 4MB; create a fake application that covers the ROM area; then the INIT quits, leaving a gap for the system to work around. You wouldn't be able to allocate 6MB of contiguous space in an app (obviously), but you could have 2x applications using 3MB each or you could have an app which used its own 3MB of RAM and allocated system RAM (dangerous) for access to up to 3MB more, or so, of RAM.
Check out AppGap:
I'm afraid there are lots of places in the OS, especially in early boot, where it assumes the RAM is all contiguous. Once the memory manager is started, yes, you might be able to get away with permanent allocations, but getting it to the point where the memory manager is working will be more...
68kmla.org