Accessing Memory Contents
Some devices may need to access memory content in memory models, this can be done using the MemoryIface interface. The interface provides functions to read and write byte blocks from emulated memory. The interface is implemented by memory spaces, but would typically also be provided by memory models, CPU models and IOMMU models.
By convention, a memory space handles physical address offsets, while a CPU model would handle virtual addresses in this interface. It is only allowed to do memory content access in one device at a time. That is if one attempts to read or write a block which will span multiple device mappings (e.g. end of ROM followed by start of RAM), then the memory access will fail.
Memory content is accessed using the
Note that the model should normally be connected to the memory space for this.
Although, some systems that contain an IOMMU would connect the device models directly to the IOMMU model instead.
Note that the read and write bytes functions will not trigger side effects. I.e. if the access is intended to be routed to a device model, the memory transaction interface should be used (but setting the initiator to NULL in the transaction object).
// Writing 128 bytes, data is given as an array of 32-bit words Dev->Mem.Iface->writeBytes(Dev->Mem.Obj, 0x40000000, 128, &Data, 2); // Reading data, out data will be an array of 32-bit words Dev->Mem.Iface->readBytes(Dev->Mem.Obj, &Data, 0x40000000, 128, 2);