Exemplo n.º 1
0
 def native_write_pci_reg(self,
                          bus,
                          device,
                          function,
                          offset,
                          value,
                          size=4,
                          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.write_pci_config(bus, device, function, offset,
                                          value)
             return False
     try:
         config = open(device_path, "wb")
     except IOError as err:
         raise OsHelperError("Unable to open {}".format(device_path),
                             err.errno)
     config.seek(offset)
     config.write(defines.pack1(value, size))
     config.close()
Exemplo n.º 2
0
 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