def native_read_pci_reg(self, bus, device, function, offset, size, domain=0): device_name = "{domain:04x}:{bus:02x}:{device:02x}.{function}".format( domain=domain, bus=bus, device=device, function=function) device_path = "/sys/bus/pci/devices/{}/config".format(device_name) if not os.path.exists(device_path): if offset < 256: from chipsec.helper.linux.legacy_pci import LEGACY_PCI pci = LEGACY_PCI() value = pci.read_pci_config(bus, device, function, offset) return value else: byte = b"\xff" return defines.unpack1(byte * size, size) try: config = open(device_path, "rb") except IOError as err: raise OsHelperError("Unable to open {}".format(device_path), err.errno) config.seek(offset) reg = config.read(size) config.close() reg = defines.unpack1(reg, size) return reg
def native_read_mmio_reg(self, phys_address, size): if self.devmem_available(): region = self.memory_mapping(phys_address, size) if not region: os.lseek(self.dev_mem, phys_address, os.SEEK_SET) reg = os.read(self.dev_mem, size) else: region.seek(phys_address - region.start) reg = region.read(size) return defines.unpack1(reg, size)
def native_read_mmio_reg(self, bar_base, bar_size, offset, size): if bar_size is None: bar_size = offset + size if self.devmem_available(): region = self.memory_mapping(bar_base, bar_size) if not region: self.native_map_io_space(bar_base, bar_size, 0) region = self.memory_mapping(bar_base, bar_size) if not region: logger().error("Unable to map region {:08x}".format(bar_base)) region.seek(bar_base + offset - region.start) reg = region.read(size) return defines.unpack1(reg, size)
def native_read_mmio_reg(self, bar_base, bar_size, offset, size): if bar_size is None: bar_size = offset + size if self.devmem_available(): region = self.memory_mapping(bar_base, bar_size) if not region: self.native_map_io_space(bar_base, bar_size) region = self.memory_mapping(bar_base, bar_size) if not region: logger().error("Unable to map region {:08x}".format(bar_base)) region.seek(bar_base + offset - region.start) reg = region.read(size) return defines.unpack1(reg, size)
def native_read_pci_reg(self, bus, device, function, offset, size, domain=0): device_name = "{domain:04x}:{bus:02x}:{device:02x}.{function}".format( domain=domain, bus=bus, device=device, function=function) device_path = "/sys/bus/pci/devices/{}/config".format(device_name) try: config = open(device_path, "rb") except IOError as err: raise OsHelperError("Unable to open {}".format(device_path), err.errno) config.seek(offset) reg = config.read(size) config.close() reg = defines.unpack1(reg, size) return reg
def read_mmio_reg(self, phys_address, size): in_buf = struct.pack( "2" +self._pack, phys_address, size) out_buf = self.ioctl(IOCTL_RDMMIO, in_buf) reg = out_buf[:size] return defines.unpack1(reg, size)
def read_mmio_reg(self, phys_address, size): in_buf = struct.pack( "2"+self._pack, phys_address, size) out_buf = self.ioctl(IOCTL_RDMMIO, in_buf) reg = out_buf[:size] return defines.unpack1(reg, size)