diff --git a/chipsec/chipset.py b/chipsec/chipset.py index d599c96a..a7cd900e 100644 --- a/chipsec/chipset.py +++ b/chipsec/chipset.py @@ -245,8 +245,8 @@ class Chipset: else: self.helper = helper - self.vid = 0 - self.did = 0 + self.vid = 0xFFFF + self.did = 0xFFFF self.code = CHIPSET_CODE_UNKNOWN self.longname = "Unrecognized Platform" self.id = CHIPSET_ID_UNKNOWN @@ -279,6 +279,16 @@ class Chipset: # Iitialization # ################################################################################## + def detect_platform( self ): + vid = 0xFFFF + did = 0xFFFF + try: + vid_did = self.pci.read_dword(0, 0, 0, 0) + vid = vid_did & 0xFFFF + did = (vid_did >> 16) & 0xFFFF + except: + if logger().DEBUG: logger().error("pci.read_dword couldn't read platform VID/DID") + return (vid, did) def init( self, platform_code, start_driver, driver_exists=False ): @@ -287,9 +297,7 @@ class Chipset: logger().log( '[CHIPSEC] API mode: %s' % ('using OS native API (not using CHIPSEC kernel module)' if self.use_native_api() else 'using CHIPSEC kernel module API') ) if platform_code is None: - vid_did = self.pci.read_dword( 0, 0, 0, 0 ) - self.vid = vid_did & 0xFFFF - self.did = (vid_did >> 16) & 0xFFFF + self.vid, self.did = self.detect_platform() if VID_INTEL != self.vid: _unknown_platform = True else: diff --git a/chipsec/helper/linux/helper.py b/chipsec/helper/linux/helper.py index 139fdf0e..b3d6a14b 100644 --- a/chipsec/helper/linux/helper.py +++ b/chipsec/helper/linux/helper.py @@ -371,8 +371,6 @@ class LinuxHelper(Helper): def read_pci_reg( self, bus, device, function, offset, size = 4 ): _PCI_DOM = 0 #Change PCI domain, if there is more than one. - #if not self.driver_loaded: - # return self.read_pci_reg_from_sys(bus, device, function, offset, size, domain=_PCI_DOM) d = struct.pack("5"+self._pack, ((_PCI_DOM << 16) | bus), ((device << 16) | function), offset, size, 0) try: ret = self.ioctl(IOCTL_RDPCI, d) diff --git a/chipsec/helper/rwe/rwehelper.py b/chipsec/helper/rwe/rwehelper.py index dc5adbb5..d3a126e4 100644 --- a/chipsec/helper/rwe/rwehelper.py +++ b/chipsec/helper/rwe/rwehelper.py @@ -668,9 +668,6 @@ class RweHelper(Helper): return def read_pci_reg( self, bus, device, function, address, size ): - #raise UnimplementedNativeAPIError( "read_pci_reg" ) - if not self.driver_loaded: - return 0xFFFF value = 0xFFFFFFFF bdf = PCI_BDF( bus&0xFFFF, device&0xFFFF, function&0xFFFF, address&0xFFFF ) cfg_addr = bdf.cfg_address() @@ -679,7 +676,6 @@ class RweHelper(Helper): return value def write_pci_reg( self, bus, device, function, address, value, size ): - #raise UnimplementedNativeAPIError( "write_pci_reg" ) bdf = PCI_BDF( bus&0xFFFF, device&0xFFFF, function&0xFFFF, address&0xFFFF ) cfg_addr = bdf.cfg_address() self.write_io_port( 0xCF8, cfg_addr, 4 ) diff --git a/chipsec/helper/win/win32helper.py b/chipsec/helper/win/win32helper.py index 294956fd..2bd9c47f 100644 --- a/chipsec/helper/win/win32helper.py +++ b/chipsec/helper/win/win32helper.py @@ -647,8 +647,6 @@ class Win32Helper(Helper): return def read_pci_reg( self, bus, device, function, address, size ): - if not self.driver_loaded: - return 0xFFFF value = 0xFFFFFFFF bdf = PCI_BDF( bus&0xFFFF, device&0xFFFF, function&0xFFFF, address&0xFFFF ) out_length = size