• Updated 2023-07-12: Hello, Guest! Welcome back, and be sure to check out this follow-up post about our outage a week or so ago.

Macintosh Memory Map

Grackle

Member
I'm curious about how memory mapping works on the Macintosh. On reset, the 68k loads from $000000, so the ROM must be there in some way when the machine boots. Some magic happens afterwards, and then when the system is running, the ROM is present in the address range $400000 - $41FFFF. How does this address translation work? What device provides that functionality? Any details would be appreciated. I'm learning about computer architecture, and this topic has me somewhat perplexed.

 

dougg3

Well-known member
Hey there!

Guide to the Macintosh Family Hardware has this to say:

Each Macintosh computer uses two address maps: the ROM overlay address map and the normal address map. The ROM overlay address map, used when the machine is turned on or reset, maps addresses in the lowest address space to locations in ROM rather than to RAM.
It goes on to explain exactly what you said about the 68k looking at address 0 at startup being the reasoning for that behavior.

Now that's not the interesting part; the interesting part is on page 122 regarding the 128K, 512K, and Plus:

The ROM overlay address map, which is used when the machine is turned on or reset, maps addresses from $00 0000 to $01 FFFF to locations in ROM rather than to RAM. The startup or Reset handler software switches from the ROM overlay address map to the normal address map by setting low the Overlay signal from the VIA.
In particular, bit 4 of the VIA data register A is used to set this. It looks to me from this book that the VIA register controls a pin on the VIA chip, which is hooked up to an input on the PALs, which change their address decoding logic based on that input. As far as I can tell, the VIA is pretty much just a pair of GPIO ports, 2 timers, and a shift register. So what it comes down to is one of the GPIO port pins is used to control the PALs.

I can find more details in Guide to the Macintosh Family Hardware if you want...that's pretty much the gist of it from what I can tell!

Edit: bigmessowires knows a ton about this--he implemented a Mac Plus on an FPGA! I haven't seen him around lately on here, but he would definitely know the exact details...

 

Grackle

Member
Thanks, that explained it nicely! Some of the tricks built into these old systems are quite fascinating.

Anyway, the reason for my curiosity: I'm working on building my own computer on an FPGA, and I'm taking some inspiration from the older macintosh systems. I don't think I'll copy this bit of complexity though; instead I'll use the uppermost address byte to split my memory up into sections enabled by chip selects. ROM at the bottom, then RAM across a number of sections, and the remaining to be used for memory mapped peripherals.

 

trag

Well-known member
The original Mac was built before there were Microcontrollers as we know them today, and a lot of the I/O circuitry which has found its way onto system chips just wasn't put on a chip with the CPU back then.

If you're familiar with modern microcontrollers, then a good analogy is that the VIA (versatile interface A) is like an addressable microcontroller port. One accesses it at certain addresses in the address space, and it provides the kind of port services we've come to expect from microcontroller ports on a modern chip.

 

Charlieman

Well-known member
Thanks for the descriptions above, which essentially define the 4MB RAM limit for most 68000 Macs. Presumably the Portable and some others were able to map the ROM to a higher memory location (and that when this occurred, the system knew the upper RAM bounds). Which leads to the question whether any third party manufactured an add-on for the Plus or earlier that remapped memory for the ROM to permit more than 4MB system RAM. I'm familiar with accelerators with 8MB that allowed 4MB system RAM plus 4MB RAM disk, but not 8MB system RAM. If it had been easy, lots of people would have done it...

Similar limitations applied to boards based on the LC/LCII design but one of the third party accelerator manufacturers cracked this. It's in my notes somewhere but before I look it up I'd appreciate other thoughts.

 

dougg3

Well-known member
Anyway, the reason for my curiosity: I'm working on building my own computer on an FPGA...
Cool! I've always thought that would be an awesome project to do, but I have neither the patience nor the knowledge to get it done...count me in as impressed!

The original Mac was built before there were Microcontrollers as we know them today, and a lot of the I/O circuitry which has found its way onto system chips just wasn't put on a chip with the CPU back then.
Ah, that's a good explanation! Looking at the Wikipedia page for the 6522 pretty quickly made me think it was just like a microcontroller GPIO peripheral. I was wondering why they needed it...makes perfect sense.

Presumably the Portable and some others were able to map the ROM to a higher memory location (and that when this occurred, the system knew the upper RAM bounds).
Guide to the Macintosh Family Hardware says that in the Portable's address map, the ROM starts at $900000. So there is actually room in the address space below ROM for 9 MB of RAM. I don't think the ROM space gets dynamically moved around or anything like that. Some Googling confirms 9 MB of RAM can be used in the Portable, except for the backlit version which only works with 8. I'm too lazy to do any more research on the reason behind that though :) (As a side note, unlike how it works on the 128k/512k/Plus, ROM overlay mode is exited on the Portable automatically the first time an access is made to the normal ROM address range)

Which leads to the question whether any third party manufactured an add-on for the Plus or earlier that remapped memory for the ROM to permit more than 4MB system RAM.
I doubt it -- I think it would require totally replacing the PALs to change where the ROM is mapped, and then changing any software (OS, user applications) that assumes the ROM is mapped at its old location. I think the ROM is designed to be able to be moved to a new location (uses relative jumps and stuff like that that don't refer to an absolute address), but I just don't know if the hardware can allow it. I think newer processors with an MMU would have more flexibility in that regard...

Similar limitations applied to boards based on the LC/LCII design but one of the third party accelerator manufacturers cracked this. It's in my notes somewhere but before I look it up I'd appreciate other thoughts.
Unfortunately, Apple's dev notes are missing the original LC note, and the LC II note just talks about differences between the LC II and original LC, so I can't refer to Apple's documentation. If anyone knows where to find the original LC developer note, I would love to add it to my collection! I'm guessing that the upgrade cards also end up bringing an MMU into the picture (68030 and above) which probably allow all kinds of address remapping. Just a thought...I could be completely wrong too.

 

ClassicHasClass

Well-known member
a lot of the I/O circuitry which has found its way onto system chips just wasn't put on a chip with the CPU back then.
Minor pedantry: the 6510 in the Commodore 64 (and its successor designs, such as the 7501, 8500, 8501 and 8502) has an on-chip I/O port mapped to $0000 and $0001 which is used for banking signals, essentially what the VIA is doing here, so such designs definitely did exist and predated the Mac. I imagine the use of a bog-standard 68000 was to stick with relatively off-the-shelf components rather than fab one with an I/O port, which Commodore (as the owner of MOS Technology) could do fairly cheaply since they owned their own fab and designs. The 6522 VIA is a pretty adept device, so it always seemed like overkill in this usage to me.

 

techfury90

Well-known member
I'm curious about how memory mapping works on the Macintosh. On reset, the 68k loads from $000000, so the ROM must be there in some way when the machine boots. Some magic happens afterwards, and then when the system is running, the ROM is present in the address range $400000 - $41FFFF. How does this address translation work? What device provides that functionality? Any details would be appreciated. I'm learning about computer architecture, and this topic has me somewhat perplexed.
Just a heads up, the 68k does NOT start execution at $00000000. Instead, it loads the starting address at $00000000, then jumps to the address given there. The initial stack pointer is also given at $00000004 (also known as the A7 register).

 

zuiko21

Well-known member
Actually, the stack pointer is taken from $00000000, and the starting address from $00000004...

By the way, the starting address for some (most?) Mac ROMs is of the form $40800000 -- that way is both compatible with 32-bit addressing, as expected upon reset ($40x00000 is the start of the several ROM images); and with 24-bit addressing, which maps the ROM to $800000.

BTW2... the SE and others (but not the SE/30) do not use any VIA bit for toggling the ROM overlay mode -- the first access to the ROM within its usual address range switches it!

 

techfury90

Well-known member
Yeah, durr. I had that backwards. Been a while here. I've seen some systems where the ROM was at 0, but the RAM was higher up, as well... (Apollo DN3500 comes to mind)

 
Top