Skip to content

Commit

Permalink
Fix --no_driver option on macOS (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
c7zero committed Mar 17, 2017
1 parent 504c251 commit 0ad817d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
18 changes: 13 additions & 5 deletions chipsec/chipset.py
Expand Up @@ -245,8 +245,8 @@ def __init__(self, helper=None):
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
Expand Down Expand Up @@ -279,6 +279,16 @@ def __init__(self, helper=None):
# 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 ):

Expand All @@ -287,9 +297,7 @@ def init( self, platform_code, start_driver, driver_exists=False ):
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:
Expand Down
2 changes: 0 additions & 2 deletions chipsec/helper/linux/helper.py
Expand Up @@ -371,8 +371,6 @@ def va2pa( self, va ):

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)
Expand Down
4 changes: 0 additions & 4 deletions chipsec/helper/rwe/rwehelper.py
Expand Up @@ -668,9 +668,6 @@ def write_msr( self, cpu_thread_id, msr_addr, eax, edx ):
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()
Expand All @@ -679,7 +676,6 @@ def read_pci_reg( self, bus, device, function, address, size ):
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 )
Expand Down
2 changes: 0 additions & 2 deletions chipsec/helper/win/win32helper.py
Expand Up @@ -647,8 +647,6 @@ def write_msr( self, cpu_thread_id, msr_addr, eax, edx ):
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
Expand Down

0 comments on commit 0ad817d

Please sign in to comment.