diff --git a/tb/pcie.py b/tb/pcie.py index 4fc90fd9a..857e1ea22 100644 --- a/tb/pcie.py +++ b/tb/pcie.py @@ -2894,6 +2894,9 @@ class TreeItem(object): self.capabilities = [] self.ext_capabilities = [] + self.msi_addr = None + self.msi_data = None + self.children = [] def find_dev(self, dev_id): @@ -3011,6 +3014,10 @@ class RootComplex(Switch): self.regions = [] self.io_regions = [] + self.msi_addr = None + self.msi_msg_limit = 0 + self.msi_signals = {} + self.register_rx_tlp_handler(TLP_IO_READ, self.handle_io_read_tlp) self.register_rx_tlp_handler(TLP_IO_WRITE, self.handle_io_write_tlp) self.register_rx_tlp_handler(TLP_MEM_READ, self.handle_mem_read_tlp) @@ -3593,7 +3600,73 @@ class RootComplex(Switch): n += byte_length addr += byte_length - def enumerate_segment(self, tree, bus, timeout=1000, enable_bus_mastering=False): + def msi_region_read(self, addr, length): + return b'\x00'*length + + def msi_region_write(self, addr, data): + assert addr == self.msi_addr + assert len(data) == 4 + number = struct.unpack('> 23 & 1 + msi_mmcap = msg_ctrl >> 17 & 7 + + # message address + yield self.capability_write(dev, MSI_CAP_ID, 4, struct.pack('> 32) & 0xffffffff)) + # message data + yield self.capability_write(dev, MSI_CAP_ID, 12, struct.pack('