quick_dump: SWIG chipset interface

This isn't strictly necessary it would have been easy enough to simply
convert intel_chipset.h but this should be nice prep work for directly
doing MMIO. It also serves as a nice review point.

It's demonstrated with an autodetect function in the script. That
autodetect has a hardcoded path that shouldn't be there, but it will go
away in the next patch when we can properly link in libpciaccess.

Thanks to Matt for helping whip the automake stuff into shape.

v2: Switch to $(top_srcdir)

Reviewed-by: Matt Turner <mattst88@gmail.com>
Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
This commit is contained in:
Ben Widawsky
2013-02-01 14:54:31 -08:00
parent 508b5ce9a5
commit 6437eed930
5 changed files with 62 additions and 2 deletions
+15
View File
@@ -5,6 +5,7 @@ import os
import sys
import ast
import subprocess
import chipset
def parse_file(file):
for line in file:
@@ -18,6 +19,7 @@ def parse_file(file):
parser = argparse.ArgumentParser(description='Dumb register dumper.')
parser.add_argument('-b', '--baseless', action='store_true', default=False, help='baseless mode, ignore files starting with base_')
parser.add_argument('-a', '--autodetect', action='store_true', default=False, help='autodetect chipset')
parser.add_argument('profile', nargs='?', type=argparse.FileType('r'), default=None)
args = parser.parse_args()
@@ -29,6 +31,19 @@ if args.baseless == False:
file = open(name.rstrip(), 'r')
parse_file(file)
if args.autodetect:
sysfs_file = open('/sys/class/drm/card0/device/device', 'r')
devid_str = sysfs_file.read()
devid = int(devid_str, 16)
if chipset.is_sandybridge(devid):
args.profile = open('sandybridge', 'r')
elif chipset.is_ivybridge(devid):
args.profile = open('ivybridge', 'r')
elif chipset.is_valleyview(devid):
args.profile = open('valleyview', 'r')
else:
print("Autodetect of %x " + devid + " failed")
if args.profile == None:
sys.exit()