Virtual Address Space
The MIPS32 4 GB virtual address space is partitioned into five fixed-size segments with traditional names. Different things happen according to the virtual memory area an address lies in, as follows:
KUSEG: 0x00000000-0x7FFFFFFF (low 2 GB):
These are the addresses permitted in User mode (see Modes of Operation). In machines with a Memory Management Unit (MMU), these addresses will always be mapped. Do not attempt to use these addresses unless the MMU is set up. On PIC32MZ, this region is also cacheable.
KSEG0: 0x80000000-0x9FFFFFFF (512 MB) :
These addresses are translated directly into physical addresses by stripping off the MSB and mapping them contiguously into the low 512 MB of physical memory (0x00000000 - 0x1FFFFFFF). Since this is a "trivial" translation, these addresses are often called unmapped.
KSEG1: 0xA0000000-0xBFFFFFFF (512 MB) :
These addresses are mapped into physical addresses by stripping off the leading 3-bits, giving a duplicate mapping into the low 512 MB of physical memory (0x00000000 - 0x1FFFFFFF). This time, access will not use the cache.
KSEG1 is the only memory region that can be used at reset because the MMU and cache must be configured by the boot code before it can be used. Therefore, your boot code must be placed in KSEG1.
KSEG2: 0xC0000000-0xDFFFFFFF (512 MB) & KSEG3: 0xE0000000-0xFFFFFFFF (512 MB) :
These areas are only accessible in Kernel mode and are translated through the MMU. Do not access it before the MMU is set up. On PIC32MZ devices, KSEG2 is used to map access to external serial and parallel memory interfaces, while KSEG3 contains the Debug Segment (DSEG), used by a debugger or monitor.
