|
<< Click to Display Table of Contents >> Navigation: ASA-EMulatR Reference Guide > Introduction > Architecture Overview > Chapter 15 – Memory System Implementation Details > 15.3 GuestMemory Region Support and PA Routing |
GuestMemory maintains a QVector<PARouteEntry> routing table that maps contiguous physical address ranges to subsystems. Each PARouteEntry is an 8-byte-aligned structure containing the start PA, end PA (exclusive), a RouteTarget discriminator, and an offsetBase for PA-to-subsystem-offset translation. The entry provides contains(), containsRange(), overlaps(), and calculateOffset() inline methods.
The RouteTarget enumeration has three values: None (unmapped), SafeMemory (RAM), and MMIOManager (memory-mapped I/O devices). During initialization, initDefaultPARoutes() reads the memory map from EmulatorSettings and builds exactly two routes. Overlap validation runs at initialization and logs errors for any overlapping ranges.
Route |
PA Range |
Target |
Offset Mapping |
|---|---|---|---|
1 – RAM |
[0x0, ramBase + ramSize) |
SafeMemory |
Identity (PA = offset, offsetBase = 0x0) |
2 – MMIO |
[mmioBase, mmioBase + mmioSize) |
MMIOManager |
Direct PA passthrough to device handlers |
With default settings, Route 1 spans [0x0, 0x880000000) covering 34 GB (ramBase 0x0 + 32 GB + low memory), and Route 2 spans [0x1000000000, 0x2000000000) covering 64 GB of Typhoon PCI I/O space. The setRoutes() method allows custom routing tables for non-standard configurations.
Because Route 1 uses identity mapping (offsetBase = 0), the SafeMemory offset equals the physical address for all RAM accesses. The layout within SafeMemory is:
PA 0x000000 - 0x1FFFFF SRM firmware (decompressed by SrmRomLoader)
+-- 0x002000 HWRPB (Hardware Restart Parameter Block)
+-- 0x008000 PAL entry (PC = 0x8001, PAL mode bit set)
+-- 0x0xxxxx PAL vectors, SRM console code
PA 0x600000 PAL_BASE (dispatch table)
PA 0x900000 Decompressor staging area (temporary)
PA 0x80000000+ Main RAM (OS kernel, applications)
SRM firmware is decompressed into SafeMemory at PA 0x0 by SrmRomLoader during system initialization. There is no separate firmware region — after decompression, firmware is simply bytes in RAM.
The PlatformAddressMap structure in memory_core.h defines platform-specific physical address space layouts for different Alpha chipset families. Each map specifies RAM base, maximum and actual RAM size, MMIO base and size, and a vector of named Aperture structures for detailed per-hose MMIO sub-regions.
Platform |
Chipset |
Max RAM |
|---|---|---|
DS10 / DS20 |
Tsunami |
2 GB |
ES40 / ES45 |
Clipper |
64 GB |
GS80 / GS160 / GS320 |
Wildfire |
128–512 GB |
MEM_STATUS GuestMemory::readRouted(quint64 pa, quint8 width,
quint64& outValue,
AccessKind kind) const noexcept
{
const PARouteEntry* route = findRoute(pa);
if (!route) return MEM_STATUS::AccessViolation;
const quint64 offset = route->calculateOffset(pa);
switch (route->target) {
case RouteTarget::SafeMemory:
return m_safeMem->load(offset, width, outValue);
case RouteTarget::MMIOManager:
return m_mmio->handleRead(pa, width, outValue);
}
}
See Also: memoryLib/memory_core.h (~412 lines) – PlatformAddressMap, Aperture, MEM_STATUS, SystemType_EmulatR; memoryLib/SrmRomLoader.h (~161 lines) – SRM firmware decompression-via-execution; configLib/global_EmulatorSettings.h – Memory map configuration.