|
<< Click to Display Table of Contents >> Navigation: ASA-EMulatR Reference Guide > Introduction > Architecture Overview > Chapter 4 - Functional Execution Domains ("Boxes) > 4.8 CBox - Cache / Coherency / Coordination Box |
CBox governs global ordering and visibility. It is responsible for serialization and global coordination. CBox controls when forward progress may resume, but never executes instruction semantics.
•Memory barriers — MB (full memory ordering) and WMB (store ordering only). executeMB() and executeWMB() set stall flags and initiate write buffer draining.
•Exception barriers — EXCB (exception serialization)
•Trap barriers — TRAPB (trap serialization)
•Write buffer management — drainWriteBuffers() flushes pending writes to GuestMemory via the WriteBufferManager callback interface. addWriteBufferEntry() enqueues writes.
•Branch prediction — owns the BranchPredictor instance; provides getBranchPredictor(), updatePrediction(pc, taken, target), clearBranchPredictor(), and flushBranchPredictorOnPipelineFlush()
•SMP coherency coordination — issueMemoryBarrier() forwards barrier requests to the global MemoryBarrierCoordinator for cross-CPU ordering
•LL/SC reservation invalidation coordination — works with ReservationManager via GuestMemory
•MMIO access routing — holds a reference to mmio_Manager for device-mapped memory regions
CBox operates in one of three states (CBoxState): RUNNING (normal execution), SERIALIZING (memory barrier in progress, pipeline frontend stalled), and HALTED (terminal state).
CBox is the only component allowed to stall the pipeline for ordering reasons. Barrier instructions set stall flags in the EX stage, prevent frontend fetch, and release only when architectural conditions are met (write buffer drained, pending faults delivered, etc.).
Implementation: CBoxBase.h, 1,345 lines, 29 execute/coordination methods. Dependencies: GuestMemory, WriteBufferManager, MemoryBarrierCoordinator, mmio_Manager, BranchPredictor.
Invariant: Ordering rules live in CBox — never in EBox or MBox.
See Also: Chapter 6 - Serialization and Stall Model; 3.12 Stalls and Serialization; CBoxLib/CBoxBase.h.