class Region
Defined at line 47 of file ../../sdk/lib/driver/mock-mmio/cpp/region.h
Mocks a region of MMIO registers. Each register is backed by a Register instance.
Each Register class ExpectRead() and ExpectWrite() call adds to the Register instance's
list of expected transactions in FIFO order.
All ExpectRead() and ExpectWrite() calls must be made before the actual read or write
transactions. Each Read() or Write() call that the Register receives removes the next expected
transaction in the list and verifies that the transactions match.
The Region class's VerifyAll() should be called at the end of the test in which the functions
verifies that all of the Region's Register objects have no outstanding expected transactions.
Region instances are not thread-safe.
Example:
mock_mmio::Region mock_registers(register_size, number_of_registers);
fdf::MmioBuffer mmio_buffer(mock_registers.GetMmioBuffer());
SomeDriver dut(mmio_buffer);
mock_registers[0]
.ExpectRead()
.ExpectWrite(0xdeadbeef)
.ExpectRead(0xcafecafe)
.ExpectWrite()
.ExpectRead();
mock_registers[5]
.ExpectWrite(0)
.ExpectWrite(1024)
.ReadReturns(0);
EXPECT_OK(dut.SomeMethod());
mock_registers.VerifyAll();
Public Methods
void VerifyAll ()
Calls VerifyAndClear() on all MockMmioReg objects.
Defined at line 9 of file ../../sdk/lib/driver/mock-mmio/cpp/region.cc
fdf::MmioBuffer GetMmioBuffer ()
Defined at line 15 of file ../../sdk/lib/driver/mock-mmio/cpp/region.cc
void Region (size_t reg_size, size_t reg_count, size_t reg_offset)
Constructs a Region. reg_size is the size of each register in bytes, and reg_count
is the total number of registers. If all accesses will be to registers past a certain address,
reg_offset can be set to this value (in number of registers) to reduce the required reg_count.
Accesses to registers lower than this offset are not permitted.
Defined at line 53 of file ../../sdk/lib/driver/mock-mmio/cpp/region.h
const Register & operator[] (size_t offset)
Accesses the MockMmioReg at the given offset. Note that this is the byte offset of the region
of MMIO registers, not the index.
Defined at line 60 of file ../../sdk/lib/driver/mock-mmio/cpp/region.h
Register & operator[] (size_t offset)
Accesses the MockMmioReg at the given offset. Note that this is the byte offset of the region
of MMIO registers, not the index.
Defined at line 67 of file ../../sdk/lib/driver/mock-mmio/cpp/region.h