n64/docs/source/memory_map.rst
2021-04-26 08:56:46 -04:00

90 lines
9.4 KiB
ReStructuredText

Memory Map
==========
Virtual Memory Map
-------------------
**ALL** memory accesses made by the main CPU, both instruction fetches and through load/store instructions, use virtual addresses. These addresses are translated to physical addresses by the Memory Management Unit (MMU) before they are actually used to access hardware.
+--------------+------------+-------+--------------------------------------------+
| Address Range | Name | Description |
+==============+============+=======+============================================+
| 0x00000000 | 0x7FFFFFFF | KUSEG | User segment. TLB mapped |
+--------------+------------+-------+--------------------------------------------+
| 0x80000000 | 0x9FFFFFFF | KSEG0 | Kernel segment 0. Direct mapped, cached. |
+--------------+------------+-------+--------------------------------------------+
| 0xA0000000 | 0xBFFFFFFF | KSEG1 | Kernel segment 1. Direct mapped, no cache. |
+--------------+------------+-------+--------------------------------------------+
| 0xC0000000 | 0xDFFFFFFF | KSSEG | Kernel supervisor segment. TLB mapped. |
+--------------+------------+-------+--------------------------------------------+
| 0xE0000000 | 0xFFFFFFFF | KSEG3 | Kernel segment 3. TLB mapped. |
+--------------+------------+-------+--------------------------------------------+
Note that the cacheing mentioned above is not critical for emulation.
Virtual-to-Physical Address Translation
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
For the direct mapped segments (KSEG0 and KSEG1), the translation is easy. Simply subtract the start of the segment the address is in from the address itself.
For example, both virtual address 0x80001000 (in KSEG0) and virtual address 0xA0001000 (in KSEG1) would translate to the physical address 0x00001000.
For TLB-mapped segments, things are a bit more complicated. See the :ref:`TLB section<TLB>` for more details.
Physical Memory Map
-------------------
+---------------+------------+------------------------------+---------------------------------------------------------------------------+
| Address Range | Name | Description |
+===============+============+==============================+===========================================================================+
| 0x00000000 | 0x003FFFFF | RDRAM | RDRAM - built in |
+---------------+------------+------------------------------+---------------------------------------------------------------------------+
| 0x00400000 | 0x007FFFFF | RDRAM | RDRAM - expansion pak (available if inserted) |
+---------------+------------+------------------------------+---------------------------------------------------------------------------+
| 0x00800000 | 0x03EFFFFF | Unused | Unused |
+---------------+------------+------------------------------+---------------------------------------------------------------------------+
| 0x03F00000 | 0x03FFFFFF | RDRAM Registers | RDRAM MMIO, configures timings, etc. Irrelevant for emulation |
+---------------+------------+------------------------------+---------------------------------------------------------------------------+
| 0x04000000 | 0x04000FFF | SP DMEM | RSP Data Memory |
+---------------+------------+------------------------------+---------------------------------------------------------------------------+
| 0x04001000 | 0x04001FFF | SP IMEM | RSP Instruction Memory |
+---------------+------------+------------------------------+---------------------------------------------------------------------------+
| 0x04002000 | 0x0403FFFF | Unused | Unused |
+---------------+------------+------------------------------+---------------------------------------------------------------------------+
| 0x04040000 | 0x040FFFFF | SP Registers | Control RSP DMA engine, status, program counter |
+---------------+------------+------------------------------+---------------------------------------------------------------------------+
| 0x04100000 | 0x041FFFFF | DP Command Registers | Send commands to the RDP |
+---------------+------------+------------------------------+---------------------------------------------------------------------------+
| 0x04200000 | 0x042FFFFF | DP Span Registers | Unknown |
+---------------+------------+------------------------------+---------------------------------------------------------------------------+
| 0x04300000 | 0x043FFFFF | MIPS Interface (MI) | System information, interrupts. |
+---------------+------------+------------------------------+---------------------------------------------------------------------------+
| 0x04400000 | 0x044FFFFF | Video Interface (VI) | Screen resolution, framebuffer settings |
+---------------+------------+------------------------------+---------------------------------------------------------------------------+
| 0x04500000 | 0x045FFFFF | Audio Interface (AI) | Control the audio subsystem |
+---------------+------------+------------------------------+---------------------------------------------------------------------------+
| 0x04600000 | 0x046FFFFF | Peripheral Interface (PI) | Control the cartridge interface. Set up DMAs cart <==> RDRAM |
+---------------+------------+------------------------------+---------------------------------------------------------------------------+
| 0x04700000 | 0x047FFFFF | RDRAM Interface (RI) | Control RDRAM settings (timings?) Irrelevant for emulation. |
+---------------+------------+------------------------------+---------------------------------------------------------------------------+
| 0x04800000 | 0x048FFFFF | Serial Interface (SI) | Control PIF RAM <==> RDRAM DMA engine |
+---------------+------------+------------------------------+---------------------------------------------------------------------------+
| 0x04900000 | 0x04FFFFFF | Unused | Unused |
+---------------+------------+------------------------------+---------------------------------------------------------------------------+
| 0x05000000 | 0x05FFFFFF | Cartridge Domain 2 Address 1 | N64DD control registers - returns open bus (or all 0xFF) when not present |
+---------------+------------+------------------------------+---------------------------------------------------------------------------+
| 0x06000000 | 0x07FFFFFF | Cartridge Domain 1 Address 1 | N64DD IPL ROM - returns open bus (or all 0xFF) when not present |
+---------------+------------+------------------------------+---------------------------------------------------------------------------+
| 0x08000000 | 0x0FFFFFFF | Cartridge Domain 2 Address 2 | SRAM is mapped here |
+---------------+------------+------------------------------+---------------------------------------------------------------------------+
| 0x10000000 | 0x1FBFFFFF | Cartridge Domain 1 Address 2 | ROM is mapped here |
+---------------+------------+------------------------------+---------------------------------------------------------------------------+
| 0x1FC00000 | 0x1FC007BF | PIF Boot Rom | First code run on boot. Baked into hardware. |
+---------------+------------+------------------------------+---------------------------------------------------------------------------+
| 0x1FC007C0 | 0x1FC007FF | PIF RAM | Used to communicate with PIF chip (controllers, memory cards) |
+---------------+------------+------------------------------+---------------------------------------------------------------------------+
| 0x1FC00800 | 0x1FCFFFFF | Reserved | |
+---------------+------------+------------------------------+---------------------------------------------------------------------------+
| 0x1FD00000 | 0x7FFFFFFF | Cartridge Domain 1 Address 3 | |
+---------------+------------+------------------------------+---------------------------------------------------------------------------+
| 0x80000000 | 0xFFFFFFFF | Unknown | Unknown |
+---------------+------------+------------------------------+---------------------------------------------------------------------------+