aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2021-02-09 19:43:30 +0300
committerEvgeny Zinoviev <me@ch1p.io>2021-02-09 19:43:30 +0300
commitf925326357adc920b370c0d47c76272bcdb8cec9 (patch)
treee9b9023ea7a3aa22354373dd1b25fe92f6c527ec
initial
-rwxr-xr-xget_mbp101_ramcfg50
1 files changed, 50 insertions, 0 deletions
diff --git a/get_mbp101_ramcfg b/get_mbp101_ramcfg
new file mode 100755
index 0000000..0eef4e5
--- /dev/null
+++ b/get_mbp101_ramcfg
@@ -0,0 +1,50 @@
+#!/usr/bin/env python3
+import sys
+
+
+ramconfigs = (
+ '4g_hynix_1600s',
+ '1g_samsung_1600',
+ '4g_samsung_1600s',
+ '1g_hynix_1600',
+ '4g_elpida_1600s',
+ '2g_samsung_1600',
+ '2g_samsung_1333',
+ '2g_hynix_1600',
+ '4g_samsung_1600',
+ '4g_hynix_1600',
+ '2g_elpida_1600s',
+ '2g_elpida_1600',
+ '4g_elpida_1600',
+ '2g_samsung_1600s',
+ '2g_hynix_1600s'
+)
+
+
+def main():
+ reg = None
+ for line in sys.stdin:
+ line = line.strip()
+ if not line.endswith('(GPIO_LVL3)'):
+ continue
+
+ reg = int(line.split(' ')[1], 16)
+ break
+
+ if reg is None:
+ raise Exceptions("failed to parse gpio registers")
+
+ # GPIO68..GPIO71
+ ramcfg = (reg >> 4) & 0xf
+
+ # reverse bit order
+ ramcfg = int('{:04b}'.format(ramcfg)[::-1], 2)
+
+ if ramcfg > len(ramconfigs):
+ print("unsupported memory configuration %d" % ramcfg)
+ else:
+ print(ramconfigs[ramcfg])
+
+
+if __name__ == '__main__':
+ main()