|
<< Click to Display Table of Contents >> Navigation: ASA-EMulatR Reference Guide > Introduction > Architecture Overview > Chapter 15 – Memory System Implementation Details > 15.2 GuestMemory vs SafeMemory (Critical Separation) |
GuestMemory is the physical address (PA) router. It is the only component that knows physical address mappings. Its responsibilities are to receive load/store requests, classify each PA to a subsystem, apply routing rules, and return results or faults. GuestMemory does not store raw bytes directly; it delegates all storage to the appropriate subsystem via the routing table.
GuestMemory classifies each PA exactly once and routes to exactly one subsystem. Subsystems must not re-route or know their own PA mapping. All CPU, DMA, and device accesses go through GuestMemory. The AccessKind enumeration distinguishes InstructionFetch, DataRead, DataWrite, DMARead, and DMAWrite operations, enabling policy enforcement such as preventing instruction fetch from MMIO regions.
SafeMemory is the single source of truth for all writable RAM bytes. It implements a pure offset-based interface with no knowledge of physical addresses. It owns the raw RAM bytes through a SparseMemoryBacking instance, performs bounds-checked and alignment-checked reads and writes per Alpha architectural rules (SRM v6.0 Section 6.3.3), and returns MEM_STATUS codes for every operation.
SafeMemory is oblivious to CPU identity, SMP ordering, barriers, or reservations. It provides typed access methods (load8/16/32/64, store8/16/32/64), block operations (readBlock, writeBlock), and the preferred getSpan() method for safe buffer access across page boundaries.
Component |
Responsibility |
|---|---|
GuestMemory |
Semantics and policy: PA classification, routing, access kind enforcement, MMIO vs RAM dispatch |
SafeMemory |
Storage and safety: offset-based reads/writes, bounds checking, alignment validation, sparse page allocation |
Invariant: SafeMemory never enforces architecture rules. GuestMemory never stores raw bytes directly.
See Also: memoryLib/GuestMemory.h (~286 lines) – PA router class; memoryLib/SafeMemory.h (~253 lines) – Offset-based RAM interface; memoryLib/GuestMemory.cpp (~431 lines) – Routing implementation; memoryLib/SafeMemory.cpp (~424 lines) – Storage implementation.